Tomcat: URL Pattern matchingStill nice fit using inheritence
Tomcat: LoggingLogging all over the code!aspect• Lets make it into a module– an aspect of logging
Language elementsjoin point”kodpunkt” The possible ”wheres”. Well defined points in the execution of a program.pointcut”punktsnitt” A filter picking out interesting join points.advice”direktiv” Code to be run at join points.= aspect
Join PointWell defined point during execution A call to a method Method invocation Class initialization Object instantiationUsed as ”hooks” foraspectsNameBean bean = new NameBean();bean.foo();InvocationCallObject instantiationClass initialization
PointcutCollection of joinpoints that defines where theadvice should be appliedexecution(* foo(..)) or execution(* bar(int))
AdviceAdditional code executed at a specific joinpointVarious types that defines when the adviceshould be executed Before After Around Throws ...Example Log a method call
ProsPowerful new paradigm improving modularityEasier system evolutionLate binding in design decisionsMore code reuseExtension of Java, therefore it runs on existing systems andtoolsIt integrates well with different toolsUsed in good frameworks such as Spring
ConsMore to learn?Yes. Use small doses, get experience.Requires new design strategies?Yes.Extension to Java?!Use AspectWerkzBreaks encapsulation?Yes, but OOP breaks the technical concerns instead.Start with small and focused aspects.Use available tools.