Human Resources Example - Apply an Aspect
5.3. Applying An Aspect Now that you have a valid distribution containing everything you need, you can configure jboss-beans.xml to apply the audit aspect. It is in examples/User_Guide/gettingStarted/commandLineClient/target/client-aop.dir. ... Procedure 5.2. Explanation of the Code to Apply an Aspect Before you can apply your aspect to any classes, you need to create an instance of org.jboss.aop.AspectManager using a element. A factory method is used here instead of calling a conventional constructor, since only one instance of the AspectManager in the JVM is necessary at run-time. Next an instance of our aspect called AuditAspect is created, using the element. This looks similar to the element because it has name and class attributes that are used in the same way. However it also has method and pointcut attributes that you can use to apply or bind an advice within the aspect to constructors and methods within other classes. These attributes bind the audit advice to all public constructors and methods within the HRManager class. Only the audit method needs to be specified, since it has been overloaded within the AuditAspect class with different parameters. JBoss AOP knows at run-time which to select, depending on whether a constructor or method invocation is being made.