Scope and XML Definitions
You can specify the scope of an aspect's instance. By Scope, I mean whether the aspect is allocated once per JVM, once per Class it is tied to, or once per Instance. You must declare an aspect definition in XML. The Scope is optional and defaults to once per JVM. Open up jboss-aop.xml to see declarations of aspects. There are three aspect classes. They all count field, method and constructor accesses from within themselves. You bind specific advices by referencing the method names within advice bindings. jboss-aop.xml again gives examples of this The above binding states that whenever a POJO or POJO2's constructor get's invoked call the method constructorAdvice on the AspectPerVM class and the method constructorAdvice on the AspectPerClass object. Remember, because of the scope defined, AspectPerVM will be allocated once for the entire VM. Any bindings that reference advices within that aspect class will share the same AspectPerVM instance. There is one AspectPerClass instance per class it is bound to. So there is an AspectPerClass instance for POJO and POJO2. The final two bindings intercept field and method access of POJO and POJO2.