文档介绍:Aspect-Oriented Programming with AspectJ?Julie Waterhouse and Mik /ASCON '042outline?I AOP and AspectJ overview –problems, basic concepts, context?II AspectJ tutorial –first example–language mechanisms–using aspects?III examples and demo?IV conclusion CASCON '043good modularity?XML parsing .–red shows relevant lines of code–nicely fits in one boxXML parsingCASCON '044good modularity?URL pattern matching .–red shows relevant lines of code–nicely fits in two boxes (using inheritance)URL pattern matchingCASCON '045problems like…?where is logging .–red shows lines of code that handle logging –not in just one place–not even in a small number of placeslogging is not modularizedCASCON '047problems like…HTTPRequestHTTPResponseServletgetCookies()getRequestURI()(doc)getSession()getRequestedSessionId()...getRequest()setContentType(contentType)getOutptutStream()setSessionId(id)...SessionInterceptorrequestMap(request)beforeBody(req, resp)...SessiongetAttribute(name)setAttribute(name, val)invalidate()...session tracking is not modularizedCASCON '048the problem of crosscutting concerns?critical aspects of large systems don’t fit in traditional modules–logging, error handling–synchronization–security–power management–memory management–performance optimizations?tangled code has a cost–difficult to understand–difficult to change–increases with size of system–maintenance costs are huge?good programmers work hard to get rid of tangled code–the last 10% of the tangled code causes 90% of the development and maintenance headacheslogging, security, optimizationsCASCON '049the AOP idea?crosscutting is inherent plex systems?crosscutting concerns–have a clear purpose–have a natural structure?defined set of methods, module boundary crossings, points of resource utilization, lines of dataflow…?so, let’s capture the structure of crosscutting concerns explicitly...–in a modular way–with linguistic and tool support?aspects are–well-modularized crosscutting co