INDEX

■A after throwing advice code, 45 abstract aspect, AspectJ, 50 around advice code, 45 Chain of Responsibility pattern, 165–167 before advice code, 44 , 161–164 code of an advice code block, 43 , 157–161 joinpoint types, 38 , 168–170 advice code, AspectJ 5 acc (.acc) extension defining aspects with annotations, 55 aspect-configuration files, JAC, 75 advice code, JAC access modifiers, AspectJ see wrappers, JAC wildcard for access modifiers, 31 advice code, JBoss AOP ACCESSORS see interceptors, JBoss AOP method-type operators, JAC, 70, 71 advice code, Spring AOP Account EJB see interceptors, Spring AOP implementation of business object pattern, advice tag, jboss-aop.xml file, 102 233–239 adviceexecution joinpoint type, AspectJ, 38, 42 Account interface advised interface, Spring AOP, 132–133 sample application, 213 advises node AccountBean class, 234 number of joinpoints associated with AccountDetails class, 278 pointcut, 28 AccountPOJO class, 244 advisors, Spring AOP acs property, jac, 78 linking pointcut to interceptor, 120 AddDateItf interface, Order class, 48 after advice, AspectJ, 17 ADDERS advice code types, 44 method-type operators, JAC, 71 proceed method, 29 addItem method @After annotation, AspectJ 5, 56 Customer Class, AspectJ, 24 after keyword, AspectJ, 44 Order Class, AspectJ, 25 after returning advice, AspectJ, 45 TraceAspect class, JAC, 62, 67 after returning advice, Spring AOP, 128–129 Administration and Supervision functions, after throwing advice, AspectJ, 45 191–204 AfterReturningAdvice interface, Spring AOP, introduction, 171 128 Java Management Extensions, 191–194 agent layer, JMX, 192, 193 agent layer, 193 aliases, Spring AOP distributed services layer, 193 getAliases method, BeanFactory class, 117 using JMX with AOP, 194–202 all pointcut type, JBoss AOP, 97 advice binding, JBoss AOP anchoring protocol technique weaving pointcuts, 108 aspect injecting Transaction Management advice code, 17–19 code, 268 AOP summary, 21 AnnotatedMixIn aspect class, 107 comparing AOP tools, 142–143 annotation-introduction tag, jboss-aop.xml, 110 definition, 17 AnnotationIntroductionDef annotation, JBoss pointcuts and joinpoints, 28 AOP types of, 17 annotation parameter, 111 advice code execution joinpoint type introducing annotations with annotations, comparing AOP tools, 141 110 advice code, AspectJ, 43–47 annotations after advice code, 44 AspectJ 5, 54–57 after returning advice code, 45 JBoss AOP, 105–108, 110 311 312 ■INDEX

annotated aspects, 106 example, 66 annotated interceptors, 107 properties, 66, 78 annotated mix-in, 107 running JAC application, 67 annotated pointcut definitions, 106 applications Ant techniques to manage complexity of compiling JBoss AOP application, 93 applications, 171 running JBoss AOP application, 95 argument lists AOP (aspect-oriented programming) variable length argument lists, 58 advantages for business tier, 227 around advice code, 17 AOP as integration technique, 261–269 advice code types, AspectJ, 45 AOP or , 246 around advice code with parameters, 46 application administration and supervision, return type, 46 191–202 comparing AOP tools, 142 background/history, 23 eliminating business delegates, 280 benefits of, 5 proceed method, 17 business tier improvements using, 250–254 around advice, Spring AOP comparing language approaches, 137, 146 see interceptors, Spring AOP design patterns of web presentation tier, @Around annotation, AspectJ 5, 56 using in, 298–309 around keyword, AspectJ, 45 designing classes and aspects, 5 around wrappers, JAC, 63 distributed communications, 271–292 ASM, 14 generic AOP, 286 @Aspect annotation, AspectJ 5, 55 implementation of access design patterns, @Aspect annotation, JBoss AOP, 106, 109 280 aspect classes, JAC implementing contracts with, 174–179 cardinality of, 86 OOP and, 3 aspect classes, JBoss AOP origins of, 2 advice code blocks, 111 presentation of client tier, using for, 293–298 interceptors, 102 sample application design, 225 aspect components, JAC, 62 testing applications, 180–191 aspect composition, 19–20 using JMX with AOP, 194–202 consequences of transforming a class into a AOP Alliance API, 64 singleton, 157 JAC wrappers, 63 design, 19 Spring AOP, 113 weaving, 20 aop tag, jboss-aop.xml file Aspect factory classes, JBoss AOP defining JBoss AOP pointcuts, 95 instantiating an aspect, 109 JBoss AOP aspects, 92 aspect instantiation aop.j2ee.business package AspectJ 5, 58 EJBComponents project, 215 comparing AOP tools, 138, 144–145 aop.j2ee.client.java package JAC, 86 sample application, 218 JBoss AOP, 109 APIs aspect ordering dependency inversion, 11 AspectJ, 51–52 application controller pattern comparing AOP tools, 138, 145 J2EE design solutions, 223 JAC, 86–87 using AOP in web presentation tier, 302–304 Spring AOP, 132 ApplicationClient project, Eclipse IDE, 207 aspect oriented applications, 5 DataModel class, 218 aspect reuse Simple class, 218 comparing AOP tools, 145–146 ApplicationContext factory, Spring AOP, 120 aspect tag, jboss-aop.xml ApplicationController aspect, 302 instantiating an aspect, 109 application-descriptor files, JAC aspect weaving, 12–14 comments, 78 AspectJ, 29 compiling JAC application, 66 comparing AOP tools, 137–138 configuring JAC applications, 78 compile-time weaving, 13 creating JAC aspect, 66 ■INDEX 313

definition, 12 Observer pattern, 157–160 JAC, 61 pointcuts, 27, 30–43 AspectComponent class, JAC pointcut parameterization, 41 brief summary, 88 pointcut wildcards, 30–33 AspectComponent class, JAC API, 62 privileged aspect, 52 aspect-configuration files, JAC Proxy pattern, 168–170 compiling JAC application, 66 , 154–155 configuring aspects, JAC, 75–78 trace aspect, 26 creating JAC aspect, 64–65 weaving, 29 example, 65 AspectJ 5, 53–58 grouping parameters in, 77–78 after advice code, 56 syntax, 65, 76 annotations, 54–57 using, 76 around advice code, 56 AspectJ, 23–53 aspect instantiation, 58 abstract aspect, 49 autoboxing, 58 advice code, 28, 43–47 before advice code, 55 after advice code, 44 declare statements, 57 after returning advice code, 45 aspectOf method, TraceAspect class, 51 after throwing advice code, 45 aspects around advice code, 45 aspect inheritance, 49–50 before advice code, 44 background of concept, 1 aspect inheritance, 49 business precondition aspect, 256–258 aspect instantiation, 50 business tier aspects, 258–261 aspect ordering, 51–52 business tier components, 270 background/history, 1, 23 checking arguments of transaction, 255 Chain of Responsibility pattern, 165–167 comparing AOP tools, 139 Command pattern, 161–164 consequences of transforming a class into a creating first application, 24–30 singleton, 157 advice code, 28 constituent parts of AOP application, 5 compiling, 29 creating manageable resource with, 197–202 pointcut descriptor, 27 extending manageable resource with, 202 trace aspect, 26 data transfer objects, 287 declaring warnings and errors, 52 definition of, 9 filtering operators, joinpoints, 38–40 dependence, 20 introduction mechanism, 47–49 dependency inversion, 11 JAC compared, 61 designing AOP classes and aspects, 5 joinpoint introspection, 33–35 frameworks, 12 joinpoints, defining, 36–40 FrontController aspect, 300 keywords HttpRequestContext aspect, 304 aspect, 27 inheritance, 27 call, 36 integration of crosscutting functionalities, declare error, 52 10 declare, 54 managing communication layer, 284 declare parents, 48 Retry aspect, 285 execution, 36 TransferOptimizer aspect, 291 extends, 49 transforming POJO into entity EJB, 240–242 percflowbelow, 50 transparently introducing persistence into pertarget, 50 account POJO, 242 pointcut, 27 aspects, AspectJ privileged, 52 abstract aspect, 49 proceed, 28, 45 aspect inheritance, 50 thisJoinPoint, 34 aspect instantiation, 51 throws, 46 aspect ordering, 51–52 withincode, 39 Chain of Responsibility design pattern, 165–167 load-time weaving, 53 Command design pattern, 161–164 314 ■INDEX

declaring warnings and errors, 52 contracts in Java, 174 load-time weaving, 53 assertions, 172 Observer design pattern, 157–161 attribute tag, jboss-aop.xml privileged aspect, 52 configuring aspect classes with parameters, Proxy pattern, 168–170 110 Singleton pattern, 154–157 authentication aspect, JAC, 81, 83 aspects, JAC AuthenticationAC aspect, JAC, 83 aspects property, 78 authorization filter authentication aspect, 83 using AOP in web presentation tier, 308 brief summary, 88 autoboxing, AspectJ 5, 58 broadcasting aspect, 84 autodetect value, autowire attribute cache aspect, 84 bean data element, Spring AOP, 119 compiling JAC application, 66 automatic integration solutions configuring aspects, 75–78 AOP advantages for business tier, 227 brief summary, 89 auto-proxy feature, Spring AOP, 133–135 confirmation aspect, 83 autowire attribute consistency aspect, 84 bean data element, Spring AOP, 119 creating JAC aspect, 61–66 ■ creating application-descriptor file, 66 B creating aspect-configuration file, 64–65 Bank interface creating pointcut, 62 sample application, 210 creating wrapper, 63–64 BankAdmin class defining behavior of, 63 ApplicationClient project, 218 deployment aspect, 84 BCEL (Byte Code Engineering Library), 14, 70 distributed transactions aspect, 83 bean data element, Spring AOP, 118 execution order of, 86 bean dependencies, Spring AOP, 113 GUI aspect, 82 BeanFactory class, Spring AOP hibernate aspect, 83 methods, 116 HTML/servlet GUI aspect, 81 beans factories, Spring AOP integrity aspect, 84 XmlBeanFactory, 114 JAC aspects library, 81–85 beans, Spring AOP load balancing aspect, 84 see also MBeans mature aspects, 81 accessing beans, 116–117 persistence aspect, 83 auto-wiring collaborators, 119 creating JAC aspect, 64 bean definition, 114–116 reusing, 64, 75 constructor based alternative definition, brief summary, 89 116 session management aspect, 83 containsBean method, BeanFactory class, 116 Swing GUI aspect, 81 creating and configuring, 119 synchronization aspect, 85 getBean method, BeanFactory class, 116 transaction aspect, 83 Beck, Ken, 149 transaction-demarcation aspect, 64 before advice, 17 user interface aspects, 81 AspectJ, 44 user profile aspect, 83 Spring AOP, 126–127 aspects, JBoss AOP @Before annotation, AspectJ 5, 55 annotations for writing aspects, 106–107 before code files defining aspect, 91 comparing AOP tools, 137 instantiating an aspect, 109 before keyword, AspectJ, 44 ready-to-use aspects, 112 BeforeAdvice interface, Spring AOP, 126 Singleton pattern, 151–154 beginTx method, 267 aspects, Spring AOP @Bind annotation, JBoss AOP programmatically configured aspects, 132–133 annotated interceptors, 107 simple trace aspect, 120 annotated pointcut definitions, 106 assert keyword bind tag, jboss-aop.xml file annotations in pointcut definitions, 105 ■INDEX 315

attaching interceptor to pointcut, 99 CalendarItf interface definition of pointcut expression, 98 mix-in mechanism, JBoss AOP, 104 JBoss AOP pointcuts, 92, 95 call joinpoint, AspectJ, 36, 42 black-box tests, 180 CallerInvocation class BMP (bean managed persistence) joinpoint introspection, JBoss AOP, 101 implementation of business object pattern, Catalog Class, AspectJ, 25 239 cflow operator Boolean operations, AspectJ, 38 comparing AOP tools, 141 broadcasting aspect, JAC, 84 cflow operator, AspectJ BroadcastingAC aspect, JAC, 84 control-flow filtering, joinpoints, 40, 43 build.xml file, Ant cflowbelow operator, AspectJ compiling JBoss AOP application, 93–94 control-flow filtering, joinpoints, 40, 43 Burke, Bill, 91 cflows, Spring AOP, 125 business concerns, 10 Chain of Responsibility design pattern business delegate pattern description, 165 aspect-oriented implementation, 280,–283 evaluating AOP implementation, 167 , 117 AspectJ implementation, 165–167 implementation for bank application, 273 checkAccountArgs method J2EE design solutions, 222 TxControllerBean class, 256 business object pattern checkAccountArgsAndResolve method AOP based implementation, 240–242 TxControllerBean class, 231, 248 modularization of business persistence, checkArgsAndResolve method 242–246 implementation of session , regular implementation, 233–240 232 business persistence CheckBusinessConditions aspect, 257 modularization of, 242 class expression business preconditions aspect pointcut expressions, JAC, 68 precondition factorization, 255 class inheritance business tier aspect inheritance compared, 49 AOP advantages for, 227 class invariant assertions business tier aspects, 258–261 contract inheritance, 174 business tier components and their aspects, definition, 173 270 implementing invariants, 179 improvements using AOP, 250–254 class tag, jboss-aop.xml file improving business tier design patterns mix-in mechanism, JBoss AOP, 103 business object pattern, 233–246 classes session facade pattern, 228–233 aspects compared, 9 J2EE business tier design patterns, 219–221 constituent parts of AOP application, 5 precondition factorization, 254 crosscutting functionalities, 4 resolving object references, 247–252 designing AOP classes and aspects, 5 sample application, 206, 209–215 JAC including selected instances of, organizing business tier code, 214 62factors influencing choice in OOP, 3 BusinessComponents project, Eclipse IDE, 207 single instance classes, 150 BusinessDelegates project, Eclipse IDE, 207 Singleton pattern, 150 BusinessUtils project, Eclipse IDE, 207 wildcard for subclasses, 32 byname value, autowire attribute ClassFilter interface, Spring AOP, 123 bean data element, Spring AOP, 119 ClassPathXmlApplicationContext factory, Byte Code Engineering Library (BCEL), 14, 70 Spring AOP, 114 byType value, autowire attribute client tier bean data element, Spring AOP, 119 J2EE client tier design patterns, 221–223 sample application, 206, 216–219 ■C Swing client, 216 cache aspect, JAC, 84 using AOP for presentation of, 293–298 CacheAC aspect, JAC, 84 ClientUtils project, Eclipse IDE, 207 Calendar class CMP (container managed persistence) mix-in mechanism, JBoss AOP, 104 316 ■INDEX

implementation of business object pattern, joinpoint introspection, JAC, 73 239 constructors code scattering, 8 bean class definition, Spring AOP, 116 limitations of OOP, 5 creating wrappers, JAC, 73 collaborators, Spring AOP evaluation of Singleton pattern, 156–157 auto-wiring collaborators, 119 introduction mechanism, AspectJ, 47 Command design pattern, 161–165 joinpoint types, AspectJ, 37 description, 161 container managed solutions, 224 evaluating AOP implementation, 164 AOP as integration technique, 261 AspectJ implementation, 161–164 containsBean method, BeanFactory class interfaces to be used with, 162 Spring AOP, 116 command objects, 298 context object pattern comments using AOP in web presentation tier, 304–306 application-descriptor files, JAC, 78 context objects, 299 Commons project, Eclipse IDE, 207 contracts service locator pattern, 221 see also Design by Contract communications AOP implementing, 174–179 distributed communications, 271, 291 conflict handling, 173 comparator contracting parties, 172 coverage analysis, 181 control-flow filtering component containers joinpoints, AspectJ, 40 AOP or component containers, 227 CounterMonitor monitor type composition transparency MBeanServer component, 193 Chain of Responsibility pattern, 167 coverage analysis, 181–185 design patterns in AOP, 150 introduction, 171 Observer pattern, 161 recorder, 181 computeAmount method, Order Class, AspectJ, create method 25 resolving object references, 247 concerns, 10 crosscutting concerns AOP as integration technique, 261 manual control of transactions with JTA, 263 component containers, 227 resolving object references, 248 manual control of transactions with JTA, 264 service locator pattern, 277 nonfunctional concerns, 10 crosscutting functionalities configured aspects, Spring AOP AOP summary, 20 Advised interface, 132–133 aspects and classes compared, 9 programmatically configured aspects, 132 integration of, 10 configuring aspects, JAC, 75–78 data-persistence functionality, 10 configuring JAC applications, 78 limitations of OOP, 4 confirmation aspect, JAC, 81, 83 crosscutting structure ConfirmationAC aspect, JAC, 83 definition of aspect, 8 consistency aspect, JAC, 84 Cunningham, Ward, 149 ConsistencyAC aspect, JAC, 84 Customer Class, AspectJ, 24 construct method, JAC CustomerAndAccountInfos class creating JAC wrapper, 64 data transfer objects, 288 creating wrappers, 73 construction tag, jboss-aop.xml file ■D mix-in mechanism, JBoss AOP, 103 D language, 23 constructor execution joinpoint type data elements, XML comparing AOP tools, 140 Spring AOP, 117 constructor value, autowire attribute data tier bean data element, Spring AOP, 119 sample application, 206, 208–209 constructor-execution pointcuts, JBoss AOP, 97 pattern ConstructorInvocation class aspect-oriented implementation, 287 joinpoint introspection, JBoss AOP, 102 transfer object aspect (client side), 290 ConstructorInvocation parameter debugging applications ■INDEX 317

benefits of implementing contracts, 172 pattern, 223 declarative management solutions, 224 intercepting filter pattern, 223 declare precedence keywords, AspectJ, 51–52 service locator pattern, 221 declare soft keywords, AspectJ, 49 Observer pattern, 157–161 declare statements, AspectJ 5 Proxy pattern, 168–170 defining aspects with annotations, 57 service locator pattern, 277 declare warning keywords, AspectJ, 52 session facade pattern, 228–233 DefaultAdvisorAutoProxyCreator, Spring AOP, Singleton pattern, 151–157 134 using AOP in web presentation tier, 298–309 DelegatingIntroductionInterceptor, Spring AOP, view helper pattern, 309 130–131 DisTransAC aspect, JAC, 83 deleteRow method, AccountBean class, 237 distributed aspects Dependency Injection, Spring AOP, 113 distributed applications, 83 constructor-based dependency injection, pointcuts, JAC, 84 117 distributed communications description, 135 using AOP for, 271–292 setter-based dependency injection, 117 distributed services layer, JMX, 192, 193 dependency inversion, 12 distributed transactions, 262–264 deployment aspect, JAC, 84 distributed transactions aspect, JAC, 83 deployment descriptor file documentation sample application, 215 benefits of implementing contracts, 172 DeploymentAC aspect, JAC, 84 Duke’s Bank application deploySunONE.bat file sample application architecture, 205–219 deploying sample application, 208 sample application design, 219–225 design dynamic AOP, JBoss AOP, 108 aspect composition, 20 dynamic shadow selection, AOP, 123 sample application, 225 dynaop, AOP Alliance framework, 64 Design by Contract, 171–180 contracts in Java, 174 ■E foundations of, 172–174 Eclipse IDE implementing contracts with AOP, 174–179 compiling JBoss AOP application, 93 implementing invariants, 179 running aspect-oriented programs, 24 implementing postconditions, 177–179 ejbActivate method implementing preconditions, 174–177 AccountBean class, 236 introduction, 171 EntityBeanProtocol interface, 241 design patterns, 149 EJBComponents project, Eclipse IDE, 207, 214 application controller pattern, 302–304 ejbCreate method business delegate pattern, 272–277 AccountBean class, 235 business layer access, 272 AccountPOJO class, 243 business object pattern, 233–246 SessionBeanProtocol, 252 Chain of Responsibility pattern, 165–168 TxControllerBean class, 231, 248 Command pattern, 161–164 ejbFindByCustomerId method context object pattern, 304–306 AccountBean class, 236 crosscutting, 150 AccountPOJO class, 243 data transfer object pattern, 278–280 ejbFindByPrimaryKey method evaluating benefit of AOP implementation, AccountBean class, 235 170 EntityBeanProtocol interface, 241 filter object pattern, 308 EJBGetter class, TxControllerBean class, 248 front controller pattern, 298–302 ejbLoad method implementation with AOP, 150 AccountBean class, 236 improving business tier patterns, 228–246 EntityBeanProtocol interface, 241 interception filter, 306–308 ejbPassivate method J2EE client tier patterns, 223 AccountBean class, 237 J2EE design solutions, 219–225 EntityBeanProtocol interface, 241 business object pattern, 220 ejbRemove method context object pattern, 223 318 ■INDEX

AccountBean class, 236 OOP (object-oriented programming), 3 EntityBeanProtocol interface, 241 extensions EJBResolver aspect acc (.acc) extension, 75 business tier improvements using AOP, 251 jac (.jac) extension, 78 description, 258 EJBs ■F Account EJB, 233–239 factory class, JBoss AOP AOP advantages for business tier, 227 instantiating an aspect, 109 entity EJBs, 213–214 Factory design pattern implementation of session facade pattern, aspects and, 170 232 field pointcuts, JBoss AOP, 97 POJO implementation, 215 field read/write joinpoint types sample application business tier overview, comparing AOP tools, 141 206 FieldInvocation class ejbStore method joinpoint introspection, JBoss AOP, 102 AccountBean class, 236 FileSaver class EntityBeanProtocol interface, 241 implementing Command pattern with empty methods, 246 AspectJ, 163 endTx method, 268 filter object pattern entity EJBs using AOP in web presentation tier, 308 J2EE design patterns, 233 filtering EntityBean interface declarative configuration of filters, 306 implementing business object pattern, 239, joinpoints, AspectJ, 39 240 filtering operators EntityBeanProtocol interface, 240 joinpoints, AspectJ, 38–40 error handling findByCustomerId method benefits of implementing contracts, 172 resolving object references, 247 EventHandle class findByPrimaryKey method ApplicationClient project, 218 resolving object references, 247 exception handler Fleury, Marc, 91 creating pointcuts, JAC, 68 framework approach exception handlers comparing AOP tools, 137, 146 application internationalization, 293 frameworks chaining, 81 Spring Framework, 113–120 introduction feature, JAC, 80–81 front controller pattern exception joinpoint type using AOP in web presentation tier, 298–302 comparing AOP tools, 141 FrontController class, 299 exceptions aspectized implementation of, 301 advice code, AspectJ, 46 function coverage analysis, 181 introduction mechanism, AspectJ, 48 functional requirements joinpoint types, 15 business concerns, 10 executedTx method functional tests, 180 resolving object references, 250 TxControllerBean class, 230 ■G execution joinpoint Gang of Four, 149 joinpoint types, AspectJ, 36, 42 GaugeMonitor monitor type execution keyword, JBoss AOP MBeanServer component, 193 JBoss pointcuts, 92 get joinpoint type, AspectJ, 36, 42 method- and constructor-execution getAliases method, BeanFactory class pointcuts, 97 Spring AOP, 117 explicit ordering getArgs method, JoinPoint interface aspect ordering, AspectJ, 51 org.aspectj.lang, 34 expr parameter getDate method, Calendar class AnnotationIntroductionDef annotation, mix-in mechanism, JBoss AOP, 104 JBoss APO, 111 getDetails method, AccountBean class, 234 extendability ■INDEX 319

getDetails method, AccountPOJO class, 245 hashCode method getEntityId method, AccountPOJO class, 244 regression analyzer, 188 getInstance method Hibernate Singleton pattern, 151 entity EJBs, 233 getInterceptors method, InvocationBase class integration of crosscutting functionalities, joinpoint introspection, JBoss AOP, 101 10 getInterfaces method hibernate aspect, JAC, 83 InterceptionIntroductionAdvisor interface, HibernateAC aspect, JAC, 83 Spring AOP, 130 Home interface getKind method, JoinPoint interface business object pattern, 240 org.aspectj.lang, 34 resolving object references, 247–248 getName method, Interceptor interface session facade pattern, 232 implementing preconditions, 176 host expression JBoss AOP interceptors, 92, 100 distributed applications, 84 getNextTxId method HTML/servlet GUI aspect, JAC, 81–82 resolving object references, 250 getNextTxId method, DBUtil class, 252 ■I getPrice method, Catalog Class, AspectJ, 25 I18n aspect, 294, 296 getServiceFacade method idref data element, Spring AOP, 118 business delegate implementation for bank if keyword application, 273 joinpoints, AspectJ, 43 getSignature method, JoinPoint interface implicit protocol technique org.aspectj.lang, 34 anchoring protocol technique, 267 getSourceLocation method, JoinPoint interface brief description, 250 org.aspectj.lang, 34 business tier improvements using AOP, 253 getTarget method, JoinPoint interface importXml method call and execution joinpoint types, AspectJ, coverage analysis, 183 36 incompatibility org.aspectj.lang, 34 aspects, 19 getTargetObject method, InvocationBase class increment method joinpoint introspection, JBoss AOP, 101 coverage analysis, 185 GETTERS implementing postconditions, 178 method-type operators, JAC, 70, 71 regression testing example, 191 getThis method, JoinPoint interface information parameter, Jac class, 88 org.aspectj.lang, 34 inheritance global shared variables aspect inheritance, AspectJ, 49–50 transforming a class into a singleton, 157 aspects, 27 GNU regexp library, 69 contract inheritance, 173 see also regular expressions introduction mechanism, AspectJ, 48 goto instruction OOP (object-oriented programming), 3 demise of, 2 inherited constructor execution joinpoint type granularity comparing AOP tools, 141 creating manageable resource with an initialization joinpoint types, AspectJ, 37, 42 aspect, 202 Injector class grouping parameters using JMX with AOP, 196 aspect-configuration files, JAC, 77–78 input constraints verification GUI aspect, JAC, 81–82 using AOP for UI concerns, 293–297 GUI parameter, Jac class, 88 insertRow method, AccountBean class, 237 GuiAC aspect, JAC, 82 instanceof keyword ■H pointcut expressions, JBoss AOP, 96 instantiation handler joinpoint type see aspect instantiation joinpoint types, AspectJ, 42 instrumentation layer, JMX, 192, 193 Hannemann, Jan, 150 integration, Spring AOP, 119 has keyword, JBoss AOP, 98 integrity aspect, JAC, 81, 84 hasfield keyword, JBoss AOP, 98 320 ■INDEX

IntegrityAC aspect, JAC, 84 IntroductionInterceptor interface, Spring AOP, intercepted object execution 129 comparing AOP tools, 137 introspection interception filter joinpoint introspection, AspectJ, 33–35 using AOP in web presentation tier, 306–308 thisJoinPoint keyword, 34 InterceptionIntroductionAdvisor interface, joinpoint introspection, JAC, 73 Spring AOP, 129 invariants, 179 Interceptor interface, JBoss AOP, 100 (IoC) interceptor tag, jboss-aop.xml file see Dependency Injection, Spring AOP attaching interceptor to pointcut, 99 invisible parameter JBoss AOP pointcuts, 92, 95 AnnotationIntroductionDef annotation, @InterceptorDef annotation, JBoss AOP, 107 JBoss APO, 111 interceptor-ref tag, jboss-aop.xml file Invocation interface defining interceptor stacks, 99 joinpoint introspection, JAC, 74 interceptors, JBoss AOP, 100–103 joinpoint introspection, JBoss AOP, 101 advice code blocks, 111 InvocationBase class associating interceptor with pointcut, 98–99 invoke method, Interceptor interfacejoinpoint coverage analysis, 181 introspection, JBoss AOP, 101 creating manageable resource with an coverage analysis, 183 aspect, 198 JBoss AOP interceptors, 92–93, 100, 102 declaring interceptors, 99 Spring AOP interceptors, 121 deployment of regression interceptor, 189 invoke method, JAC grouping interceptors, 99 creating wrappers, 64, 72 implementing, 100 invokeNext method, Interceptor interface implementing postconditions, 179 JBoss AOP interceptors, 93, 100 implementing preconditions, 175–176 invokeNext method, InvocationBase class instantiating an aspect, 109 joinpoint introspection, JBoss AOP, 101 interceptor stacks, 99 regression analyzer, 188 introduction, 92–93 invokeRoleMethod method, JAC, 79 joinpoint introspection, 101 Ioc (Inversion of Control) interceptors, Spring AOP, 126 see Dependency Injection, Spring AOP associating with pointcuts, 125 isFrozen method comparing AOP tools, 142 Advised interface, Spring AOP, 133 trace aspect, 120 isPerInstance method interfaces tag, jboss-aop.xml file Advisor interface, Spring AOP, 125 mix-in mechanism, JBoss AOP, 103, 105 isRuntime method internal invariant assertions MethodMatcher interface, Spring AOP, 123 contract inheritance, 174 isSingleton method, BeanFactory class definition, 173 Spring AOP, 117 Interpreter design pattern ■ aspects and, 170 J intertype declaration J2EE design solutions see introduction mechanism, AspectJ AOP advantages for business tier, 227 introduction advice, Spring AOP, 129 automatic integration solutions, 223–224 introduction feature, JAC, 78–81 business tier design patterns, 219–221 exception handlers, 80–81 improving, 228–246 role methods, 79–80 client tier design patterns, 221–223 introduction mechanism, 19 presentation tier design patterns, 223 AOP summary, 21 J2EE environments comparing AOP tools, 138, 143–144 Spring AOP, 113 introduction mechanism, AspectJ, 47–49 j2eeclient.properties file introduction tag, jboss-aop.xml file deploying sample application, 208 creating manageable resource with an jac (.jac) extension aspect, 198 application-descriptor files, 78 mix-in mechanism, JBoss AOP, 103 JAC (Java Aspect Components), 61–89 aspects ■INDEX 321

aspect components, 62 DisTransAC aspect, 83 aspect configuration, 75–78 GuiAC aspect, 82 aspect creation, 61–66 HibernateAC aspect, 83 aspect instantiation, 86 IntegrityAC aspect, 84 aspect ordering, 86–87 LoadBalancingAC aspect, 84 configuring, 75–77 PersistenceAC aspect, 83 creating aspect, 62 SessionAC aspect, 83 creating aspect configuration file, 65 SynchronizationAC aspect, 85 creating aspect descriptor file, 66 TransactionAC aspect, 83 distribution aspects, 83 UserAC aspect, 83 JAC aspects library, 81–85 Jac class, 88 persistence aspects, 83 JAC Naming Repository timing of aspect weaving, 61 object naming, 87 transaction aspects, 83 JAC, AOP Alliance framework, 64 user interface aspects, 81–83 jac.acs property, 78 AspectJ compared, 61 jac.comp.wrappingOrder property, 78 background/history, 23 jac.topology property, 78 compiling JAC application, 66–67 Java Aspect Components configuring JAC applications, 78 see JAC creating JAC application, 61–67 Java class definition, Spring AOP, 114 exception handlers, 80 Java contracts, 174 GNU regexp, using with JAC, 69 java files (.java files) GUI aspects, 82 compiling JAC application, 66 implementing contracts with AOP, 174 Java Management Extensions introduction feature, 78–81 see JMX JAC operators, 69 Javassist (Java Programming Assistant), 14 joinpoint introspection, 73 JBoss AOP, 91–112 keywords, 88 advice code blocks, 111 licensing, 61 annotations, 105–108, 110–111 method type operators, 70 aspect-oriented application using, 91–94 object naming, 87 aspects output from JAC application, 67 aspect instantiation, 109 pointcuts, 62, 68–72 introduction to, 91 associating wrapper with, 71 compiling JBoss AOP application, 93–94 operators, 69 configuring aspect classes with parameters, pointcut expressions, 68 109–110 regular expressions, 69 dynamic AOP, 108 programming in UMLAF, 85–86 implementing contracts with AOP, 174 research team, 61 implementing Singleton pattern, 151–154 role methods, 79 interceptors, 92, 100–103 run options, 88 licensing, 91 running JAC application, 67 mix-in mechanism, 103–105, 110–111 run-time type identification (RTTI), 87 pointcuts, 92, 95–99 summary, 88 running JBoss AOP application, 95 wrappers, 71, 72–75 summary, 111 constructors, 73 web site, 91 methods, 72 jboss-aop.xml file wrapper chains, 74 aspect classes, JBoss AOP interceptors, 102 JAC aspects library, 81–85 compiling JBoss AOP application, 93 AuthenticationAC aspect, 83 configuring aspect classes with parameters, BroadcastingAC aspect, 84 110 CacheAC aspect, 84 defining JBoss AOP pointcuts, 95 ConfirmationAC aspect, 83 files defining JBoss AOP aspect, 91 ConsistencyAC aspect, 84 general structure of, 95 DeploymentAC aspect, 84 introducing annotations into application, 110 322 ■INDEX

mix-in mechanism, JBoss AOP, 103 all pointcut type, 98 JDBC abstraction layer, Spring AOP, 119 joinpoint introspection, 101–102 JMX (Java Management Extensions), 192–202 method-call pointcuts, 98 agent layer 192, 193 wildcards in pointcut expressions, 97 architecture layers, 192 JOTM (Java Open Transaction Monitor), 83 distributed services layer, 192, 193 JoyAop, AOP Alliance framework, 64 instrumentation layer, 192, 193 JTA (Java Transaction API) using JMX with AOP, 194–202 manual control of transactions with JTA, creating manageable resource with an 262–264 aspect, 197–202 extending manageable resource with an ■K aspect, 202 Kiczales, Gregor, 1–2, 6, 150 Johnson, Rod, 113 AOP description, 9 JoinPoint interface AspectJ, 23 joinpoint introspection, JAC, 74 JoinPoint interface, org.aspectj.lang ■L methods, 34 libraries joinpoint introspection JAC aspects library, 81–85 AspectJ, 33–35 list data element, Spring AOP, 118 comparing AOP tools, 143 load balancing aspect, JAC, 84 JAC, 73 load-time weaving, AspectJ, 53 JBoss AOP, 101–102 loadAccount method, AccountBean class, 238 joinpoint shadow, 15 LoadBalancingAC aspect, JAC, 84 joinpoints, 14–15 loadCustomerIds method, AccountBean class, AOP summary, 21 239 comparing AOP tools, 140 locality definition, 14 Chain of Responsibility pattern, 165–167 granularity, 15 Command pattern, 161–164 types of, 15 design patterns in AOP, 150 joinpoints, AspectJ Observer pattern, 158–161 call joinpoint, 27 session facade pattern, 233 defining joinpoints, 36–40 Locator aspect filtering operators, 38–40 business delegate pattern, 280 control-flow filtering, 40 client/server communication, 292 joinpoint introspection, 33–35 Lockable interface, Spring AOP, 130 program listing, 35 logical operations thisJoinPoint keyword, 34 joinpoints, AspectJ, 38 joinpoint types, 36–38 LoginController class adviceexecution type, 38 aspectized login controller, 303 exceptions, 37 Lopez, Christina, 23 fields, 36 ■ handler type, 37 M initialization type, 37 Maes, Patricia, 23 preinitialization type, 37 main parameter, Jac class, 88 static code blocks, 37 makeConnection method, TxControllerBean staticinitialization type, 38 class, 231 joinpoints, JAC map data element, Spring AOP, 118 creating JAC wrapper, 64 marker interface exception handler, 68 business object pattern, 240 execution order of aspects, 86 Martelli, Laurent, 61 joinpoint introspection, 73 matches method pointcut expressions, 68 ClassFilter interface, Spring AOP, 123 wrapper chains, 74 MBeans (Manageable Beans) Wrapper class, 68 description, 192 joinpoints, JBoss AOP instrumentation layer, JMX, 192 MBean interface, role of, 192 ■INDEX 323

StatsMBean interface, 197 session facade pattern, 233 types, 192 monitor types using JMX with AOP, 194 MBeanServer component, 193 MBeanServer component monitors creating manageable resource with an creating manageable resource with an aspect, 200 aspect, 200 MembershipFilter class, 307 multiple constructors metadata evaluation of Singleton pattern, 156–157 see annotations MVC web application framework method call pointcuts, JBoss AOP, 98 Spring AOP, 120 method call/execution joinpoint types MX4J, 193 comparing AOP tools, 140 creating manageable resource with an method expression aspect, 197 pointcut expressions, JAC, 69 MySingleton class method signatures single instance classes, 151 pointcut expressions, JAC, 69 ■ MethodBeforeAdvice interface, Spring AOP, 126 N MethodCalledByMethodInvocation class naming conventions joinpoint introspection, JBoss AOP, 102 object naming, JAC, 87 MethodInterceptor class networks Spring AOP interceptors, 121 distributed aspects, 83 MethodInvocation class new keyword, AspectJ, 47 joinpoint introspection, JBoss AOP, 102 new operator MethodInvocation parameter single instance classes, 151 joinpoint introspection, JAC, 73 nonfunctional concerns, 10 MethodMatcher interface, Spring AOP, 123 nonfunctional services methods aspects and, 10–11 code scattering, 5 nonregression tests, 185–190 creating wrappers, JAC, 72 null data element, Spring AOP, 118 joinpoint types, 15 ■ AspectJ, 36 O wildcards for method names/parameters, 31 object expression method-type operators pointcut expressions, JAC, 68 pointcut expressions, JAC, 70–71 object life-cycle management, Spring AOP, 119 ACCESSORS, 70 object naming, JAC, 87 ADDERS, 71 ObjectWeb community, 61 GETTERS, 70 Observer design pattern, 157–161 MODIFIERS, 70 AspectJ implementation, 158–160 REMOVERS, 71 evaluating AOP implementation, 161 SETTERS, 70 OOP (object-oriented programming), 2 run-time type identification (RTTI), 87 AOP and, 3 Meyer, Bertrand, 171 code scattering, 5 @Mixin annotation, JBoss AOP, 107 crosscutting functionalities, 4 mix-in mechanism, JBoss AOP, 103–105 extendability, 3 basic code for defining, 103 factors influencing choice of classes, 3 example, 104 inheritance, 3 extending manageable resource with an limitations of, 4 aspect, 202 modularity, 3 introducing annotations, 110–111 reliability, 3 mixin tag, jboss-aop.xml file, 103 reusability, 3 mix-ins, Spring AOP, 129 operators MODIFIERS GNU regexp library, 69 method-type operators, JAC, 70, 71 JAC operators, 69 modularity, 8–12 method-type operators, JAC, 70–71 OOP, 3 Order Class mix-in mechanism, JBoss AOP, 104 324 ■INDEX

Ordered interface, Spring AOP, 132 pointcuts, AspectJ 5 order-management application, AspectJ, 24–30 defining aspects with annotations, 55 @Pointcut annotation, 55 ■P pointcuts, JAC packages aspect configuration, 65 wildcard for package names, 32 associating wrapper with, 71–72 paradigms in programming, 1 brief summary, 88 parameter precondition aspects creating, 68–72 precondition factorization, 255–256 associating wrapper with pointcut, 71–72 parameters pointcut expressions, 68–71 creating pointcuts, JAC, 68 creating JAC aspect, 62 grouping, aspect-configuration files, JAC, distributed aspects, 84 77–78 pointcut expressions Jac class, 88 class expression, 68 pointcut parameterization, AspectJ, 41 creating pointcuts, 68–72 wildcard for method parameters, 31 method expression, 69 Pawlak, Renaud, 61 method-type operators, 70–71 PER_CLASS mode, JBoss AOP, 109 object expression, 68 PER_INSTANCE mode, JBoss AOP, 109 regular expressions, 69 PER_JOINPOINT mode, JBoss AOP, 109 subexpressions, 68 PER_VM mode, JBoss AOP, 109 pointcut method parameters, 62 percflow keyword, AspectJ, 50 pointcut method, AspectComponent class, persistence aspect, JAC, 64, 81, 83 62 persistence management creating pointcuts, 68 implementation of business object pattern, pointcuts, JBoss AOP, 95–99 239 annotations in pointcut definitions, 105 using aspects with entity EJBs, 242 associating interceptor with pointcut, 98–99 PersistenceAC aspect, JAC, 83 extending manageable resource with an pertarget keyword, AspectJ, 155 aspect, 203 perthis keyword, AspectJ, 50 filtering joinpoints, 98 PERTYPEWITHIN mode, AspectJ 5, 58 implementing preconditions, 177 pluggability introduction, 92 design patterns in AOP, 150 pointcut tag, pointcut-naming, 97 Chain of Responsibility pattern, 168 @PointcutDef annotation, 106 Observer pattern, 161 types of JBoss AOP pointcuts, 96 pointcuts, 16–17 weaving, dynamic AOP, 108 AOP summary, 21 XML definition of pointcut, 92 comparing AOP tools, 139–142 pointcuts, Spring AOP, 120, 122–126 data-modification pointcut, 16 definition of, 122 definition, 16 linking to interceptor, 121 joinpoints, 16 Pointcut interface, 122 method-calls pointcut, 17 pointcut property, 126 method-executions pointcut, 17 PointcutAdvisor interface, 125 number of joinpoints associated with, 27 programmatically defined pointcuts, redefining in subaspect, 49 123–124 types of, 16 regexp pointcuts, 124 pointcuts, AspectJ, 30–43 POJO (Plain Old Java Objects) joinpoint introspection, 33–35 AccountPOJO class, 245 joinpoints, defining, 36–40 implementing EJBs, 228 order-management application, 28 POJOEntity aspect, 240, 242, 258 pointcut descriptors, 27, 41 POJOSession aspect, 232–233, 242 defining parameterized pointcuts, 44 business tier improvements using AOP, 250, joinpoints, 38 252 pointcut parameterization, 41 description, 258 wildcards, 31–33 postcondition assertions, 177–179 precondition assertions, 173, 174–177 ■INDEX 325

precondition factorization, 254 recorder AOP based implementation, 255 coverage analysis, 183–185 parameter precondition aspect, 255 recordMethodCall method, 183 regular implementation, 254–255 redundancy in aspects, 20 preinitialization joinpoint types, AspectJ, 42 ref data element, Spring AOP, 118 @Prepare annotation, JBoss AOP, 108 reference record prepare tag, jboss-aop.xml, 108 regression tests, 186 presentation tier references see also web presentation tier implementation of business object pattern, J2EE design patterns, 223 239 sample application, 206 resolving object references, 250 web presentation tier, 219 referential integrity constraints PresentationAC aspect, JAC, 76 integrity aspect, JAC, 84 priceList hash map, Catalog Class, AspectJ, 26 reflection privileged aspect, AspectJ, 52 description, 23 procedural programming, 2 run-time type identification (RTTI), 87 proceed keyword, AspectJ, 45 regexp library operators, 69 proceed method see also regular expressions execution of program with around advice regexp pointcuts, Spring AOP, 124 code, 28–29 regression analyzer, 186 FrontController class, 300 regression interceptor, 189 implementing empty methods within regression testing aspects, 246 nonregression tests, 185–190 JAC, 64, 73 regular expressions JBoss AOP, 111 host expression, 84 Spring AOP, 121, 126 using GNU regexp with JAC, 69 program control flow @Release annotation, JBoss AOP, 110 joinpoints, 14 releaseConnection method, TxControllerBean programming paradigms, 1 class, 232 OOP, 2 reliability procedural programming, 2 OOP, 3 properties REMOVERS application-descriptor files, JAC, 66, 78 method-type operators, JAC, 71 initialization of properties, Spring AOP, 115 research team, JAC, 61 props data element, Spring AOP, 118 residues, 179 protocols resolving object references, 247–252 implicit protocol technique, 246 Retry aspect, 284–285 proxies client/server communication, 292 auto-proxy feature, Spring AOP, 133–134 retry policy Proxy design pattern, 168–170 business delegate pattern, 276 ProxyFactory class, Spring AOP, 133 return types advice code types, AspectJ, 46 ■Q wildcard for return types, 31 Quality of Service reusability Design by Contract, 171–180coverage Chain of Responsibility pattern, 167 analysis, 181–185 Command pattern, 164 Java Management Extensions (JMX), design patterns in AOP, 150 191–202 elements of reusable software, 149 nonregression tests, 185–190 example with exception handlers, 80 testing applications, 180–190 Observer pattern, 161 ■R OOP, 3 session facade pattern, 233 RAD (rapid application development) role methods environment introduction feature, JAC, 79–80 programming in UMLAF, 85 RTTI (run-time type identification), 87 real-world behavior, 10 326 ■INDEX

run options, JAC, 88 setEntityContext method run-time weaving, 13 AccountBean class, 236 hooks, 14 EntityBeanProtocol interface, 241 setEntityId method, AccountPOJO class, 244 ■S setExtraContext method, AccountPOJO class, sample application 243 client for, 272 setGanularityPeriod method, 202 Customer interface, 213 setPattern/setPatterns methods, Spring AOP, table creation script, 208 124 transfer object for, 278 setRollbackOnly method, 265 sample application architecture, 205–219 setSessionContext method, TxControllerBean business tier, 209–215 class, 231 entity EJBs, 213–214 SETTERS session facades, 209–212 method-type operators, JAC, 70, 71 client tier signatures web client, 216 method signatures, 69 data tier, 208–209 Simple class deploying application, 207 ApplicationClient project, 218 organizing and packaging code, 207 client for bank application, 272 overview, 205–208 eliminating business delegates, 282 tiers, 205–206 Singleton design pattern, 150–157 using Eclipse IDE, 206 classes, 150 web presentation tier, 219 description, 150–151 sample application design, 219–225 evaluating AOP implementations, 155 using AOP, 225 evaluation of implementations using J2EE design solutions multiple constructors, 156–157 automatic integration solutions, 223 implementation using Java, 151 business tier design patterns, 219–221 AspectJ implementation, 154–155, 156 client tier design patterns, 221–223 binding to Stats class, 155 presentation tier design patterns, 223 JBoss AOP implementation, 151–154 Seinturier, Lionel, 61 binding to Stats class, 153 selectByCustomerId method, AccountBean sample class to test, 152 class, 238 testing with JBoss AOP, 153 selectByPrimaryKey method, AccountBean singletons class, 238 aspect instantiation, AspectJ, 50 , 287 isSingleton method, Spring AOP, 117 service locator pattern Smith, Brian, 23 design patterns for business layer access, source-code weaving, 13 277 Spring AOP, 113–135 eliminating business delegates, 280 abstraction layers, 119 session facade pattern advantages, 135 AOP based implementation, 232 advice types, 126–132 J2EE design solutions, 220 advised interface, 132–133 regular implementation, 228–232 advisors, 121 session facades after returning advice, 128–129 Bank facade, 209–212 AOP Alliance API, 113 business delegate methods retrieving, 276 architecture overview, 113–120 session management aspect, JAC, 83 aspects SessionAC aspect, JAC, 83 aspect ordering, 132 SessionBean interface trace aspect, 120 business object pattern, 240 auto-proxy feature, 133–135 session facade pattern, 228, 232 auto-wiring collaborators, 119 set data element, Spring AOP, 118 bean configuration, 114–119 set joinpoint type, AspectJ, 36, 42 before advice, 126–127 setBalance method, 265 ClassPathXmlApplicationContext factory, setDate method, Order Class, AspectJ, 47 114 ■INDEX 327

comparing AspectJ/JAC/JBoss AOP, 137 ■T constructor interception, 126 target keyword, AspectJ creating and configuring beans, 114–117 joinpoint filtering, 40 Dependency Injection, 113, 117 joinpoints, 43 description, 113, 135 pointcut parameterization, 41 disadvantages, 135 testing applications, 180–191 improving in the future, 135 this keyword, AspectJ, 43 interceptors, 121, 125, 126 thisJoinPoint keyword, AspectJ, 34 introduction advice, 129 threads introduction to Spring AOP, 120–122 using JMX with AOP, 196 Inversion of Control (IoC), 113 throws advice, Spring AOP, 127–128 mix ins, 129 ThrowsAdvice interface, Spring AOP, 127 pointcuts, 120, 122–126 tiers proxy factory, 133 sample application architecture, 205–206 singletons, 116, 117 toBeTraced pointcut descriptor, AspectJ, 27 throws advice, 127–128 topology property, jac, 78 XML elements for data, 118–119 trace aspect, AspectJ, 24 Spring, AOP Alliance framework, 64 trace aspects, JAC, 61 SQLAccount aspect, 242, 246 trace aspects, Spring AOP, 120 sqrt method trace method, JAC, 65 implementing preconditions, 174 TraceAspect aspect, AspectJ, 27, 28 stack tag, jboss-aop.xml, 99 TraceAspect class, JAC, 62 stack-ref tag, jboss-aop.xml file, 99 TraceInterceptor class, Spring AOP, 121 state invariant, 179 TraceInterceptor.java static block execution joinpoint type files defining JBoss AOP aspect, 91 comparing AOP tools, 141 TraceWrapper class, JAC staticinitialization joinpoint type, AspectJ, 42 creating aspect, 62 Stats class creating wrapper, 63 Chain of Responsibility pattern, AspectJ, Transaction aspect, 266 166–167 anchoring protocol technique, 268 Command pattern, AspectJ, 163–164 transaction aspect, JAC, 83 creating manageable resource with an Transaction Controller interface, 212 aspect, 197 transaction management Observer pattern, AspectJ, 159–160 modular integration of transactions, Proxy pattern, AspectJ, 169 266–268 Singleton pattern, AspectJ, 155 parameter precondition aspect, 255 Singleton pattern, JBoss AOP, 152–153 Spring AOP, 119 using JMX with AOP, 194, 196 TransactionAC aspect, JAC, 83 StatsMBean interface, 202 TransactionAttributeSourceAdvisor, Spring storeAccount method, AccountBean class, 239 AOP, 134 StringMonitor monitor type, MBeanServer, 193 transaction-demarcation aspect, JAC, 64 structural tests, 180 transactions Subject interface declarative mechanism in J2EE, 265 Observer pattern, 158 EJBs for automatic integration of, 264–266 SunONE.properties file manual control with JTA, 262 deploying sample application, 208 transfer object aspect (client side), 290 Supervision functions transfer object aspect (server side), 289 see Administration and Supervision transfer object pattern functions J2EE design solutions, 221 Swing client transferFunds method organizing Java Swing client code, 217–218 TxControllerBean class, 230, 262, 264 sample application, 216 TxControllerPOJO class, 260 Swing GUI aspect, JAC, 81–82 TransferOptimizer aspect synchronization aspect, JAC, 85 client/server communication, 292 SynchronizationAC aspect, JAC, 85 transparency system-level concerns, 10 328 ■INDEX

see also composition transparency see also presentation tier Singleton pattern, 151 using AOP in design patterns of, 298–309 Tx interface white-box tests, 180 sample application, 214 wildcards, AspectJ TX_BEAN_MANAGED attribute, 264–265 method names, 31 TX_MANDATORY attribute, 264 method signatures, 31 TX_NOT_SUPPORTED attribute, 264 package names, 32 TX_REQUIRED attribute, 264 wildcards, JBoss AOP, 96 TX_REQUIRES_NEW attribute, 264 withdraw method TX_SUPPORTS attribute, 264 resolving object references, 249 TxCheckArgs aspect, 255 withdraw method TxController facade, 212 TxControllerBean class, 229 business tier aspects, 258 TxControllerPOJO class precondition factorization, 254 business tier aspects, 259 resolving object references, 248 precondition factorization, 254 session facade pattern, 228, 232 within keyword, joinpoints TxControllerBean class, 229 AspectJ, 40, 43 anchoring protocol, transferFunds method, JBoss AOP, 98 267 withincode keyword, joinpoints manual control of transactions, JTA, 262 AspectJ, 43 withdraw method, 258 JBoss AOP, 98 TxControllerPOJO class wrappers, JAC business tier aspects, 259 AOP Alliance API, 63 business tier improvements, 250 around wrappers, 63 withdraw method, 253 associating with pointcut, 71–72 ■ brief summary, 88 U cardinality of wrapper classes, 86 UI concerns, using AOP for, 293, 297 code execution time, 63 UML (Unified Modeling Language), 85 compiling application, 66 UMLAF (UML Aspectual Factory), 85–86, 89 creating, 72–75 unpluggability creating aspect, 62, 63–64 see pluggability creating pointcuts, 68 user profile aspect, JAC, 83 creating wrappers, 72 UserAC aspect, JAC, 83 defining wrappers, 63 user-profile aspect, JAC, 81 execution order of aspects, 86 ■ reusing, 63 V role methods, 79 value data element, Spring AOP, 118 wrapper chains, 74 view helper pattern wrappingOrder property, jac.comp, 78 J2EE design solutions, 223 web presentation tier, 309 ■X ■ XML configuration W bean definition, Spring AOP, 114, 116 weaving XML elements for data, Spring AOP, 117–119 see also aspect weaving XmlBeanFactory bean factory source-code weaving, 13 Spring AOP, 114 web presentation tier, 219