ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.   AddThis Social
Bookmark Button  Aspect-Oriented Annotations Pages: 1, 2, 3
Dependency Injection   First, we must again define our
annotation.   package org.jboss.aspects;  import
java.lang.annotation.ElementType; import
java.lang.annotation.Target;  public @interface Inject {}
package org.jboss.aspects;  import org.jboss.aop.joinpoint.*;
import java.lang.reflect.Field; import
javax.transaction.TransactionManager; import
org.jboss.tm.TxManager;  public InjectTMAspect    private
TransactionManager tm = TxManager.getInstance();     public
Object access(FieldReadInvocation invocation)        throws
Throwable        return tm;     public Object
access(FieldWriteInvocation invocation)        throws Throwable
throw new RuntimeException(           "Setting an @Injected
variable is illegal");     <aspect
class="org.jboss.aspects.InjectTMAspect"/>       <advice
name="access"   import javax.transaction.Trans