org.jboss.aop
Class ClassAdvisor

java.lang.Object
  extended byorg.jboss.aop.Advisor
      extended byorg.jboss.aop.ClassAdvisor

public class ClassAdvisor
extends Advisor

Advises a class and provides access to the class's aspect chain. Each advisable class has an associated Advisor instance. References methods using int IDs rather than the actual instances for optimal performance. Provides ability to invoke methods on an advised object without advice (see Advisor.invokeWithoutAdvisement()).

Version:
$Revision: 1.110.2.4 $ =======, $Revision: 1.110.2.4 $ >>>>>>> 1.111
Author:
Bill Burke <<<<<<< ClassAdvisor.java

Field Summary
protected  HashMap backrefConCalledByConstructorBindings
           
protected  HashMap backrefConCalledByMethodBindings
           
protected  HashMap backrefMethodCalledByConstructorBindings
           
protected  HashMap backrefMethodCalledByMethodBindings
           
protected  HashMap[] conCalledByConBindings
           
protected  HashMap[] conCalledByConInterceptors
           
protected  gnu.trove.TLongObjectHashMap conCalledByMethodBindings
           
protected  gnu.trove.TLongObjectHashMap conCalledByMethodInterceptors
           
protected  boolean initialized
           
protected  HashMap[] methodCalledByConBindings
           
protected  HashMap[] methodCalledByConInterceptors
           
protected  gnu.trove.TLongObjectHashMap methodCalledByMethodBindings
           
protected  gnu.trove.TLongObjectHashMap methodCalledByMethodInterceptors
           
static String NOT_TRANSFORMABLE_SUFFIX
          Suffix added to unadvised methods.
 
Fields inherited from class org.jboss.aop.Advisor
adviceBindings, adviceInterceptors, advisedMethods, annotations, aspects, classAnnotations, classMetaData, classMetaDataBindings, clazz, constructionInterceptors, constructorInterceptors, constructorMetaData, constructors, defaultMetaData, doesHaveAspects, fieldMetaData, interfaceIntroductions, manager, methodInterceptors, methodMetaData, name, perInstanceAspectDefinitions, perInstanceJoinpointAspectDefinitions
 
Constructor Summary
ClassAdvisor(String classname, AspectManager manager)
           
 
Method Summary
 void addClassMetaData(ClassMetaDataBinding data)
           
 void addConstructorCalledByConPointcut(int callingIndex, String calledClass, long calledConHash, AdviceBinding binding)
           
 void addConstructorCalledByMethodPointcut(long callingMethodHash, String calledClass, long calledMethodHash, AdviceBinding binding)
           
 void addConstructorCallerPointcut(int callingIndex, String calledClass, long calledMethodHash, AdviceBinding binding)
           
 void addMethodCalledByMethodPointcut(long callingMethodHash, String calledClass, long calledMethodHash, AdviceBinding binding)
           
 void attachClass(Class clazz)
          Constructs a new helper.
protected  void bindClassMetaData(ClassMetaDataBinding data)
           
protected  void createInterceptorChains()
           
protected  void finalizeFieldChain(ArrayList newFieldInterceptors)
           
 Field[] getAdvisedFields()
           
 gnu.trove.TLongObjectHashMap getAdvisedMethods()
           
 HashMap[] getConCalledByConInterceptors()
           
 gnu.trove.TLongObjectHashMap getConCalledByMethodInterceptors()
           
 int getConstructorIndex(Constructor constructor)
          Get a constructor's index in the class.
 Constructor[] getConstructors()
           
 Object getFieldAspect(FieldJoinpoint joinpoint, AspectDefinition def)
          This method is to support PER_JOINPOINT scoping of Aspects for static fields Fields are special in that a get and set do not create separate aspect instances.
 int getFieldIndex(Field field)
          Get a field's index in the class.
 Interceptor[][] getFieldReadInterceptors()
           
 Interceptor[][] getFieldWriteInterceptors()
           
 HashMap[] getMethodCalledByConInterceptors()
           
 gnu.trove.TLongObjectHashMap getMethodCalledByMethodBindings()
           
 gnu.trove.TLongObjectHashMap getMethodCalledByMethodInterceptors()
           
 gnu.trove.TLongObjectHashMap getMethodInterceptors()
           
 gnu.trove.TLongObjectHashMap getUnadvisedMethods()
           
protected  CallerMethodInfo initializeCallerInterceptorsMap(long callingMethodHash, String calledClass, long calledMethodHash, Method calledMethod)
           
 void initializeConCalledByConEmptyChain(int callingIndex, String calledClass, long calledConHash)
           
protected  CallerConstructorInfo initializeConCalledByConInterceptorsMap(int callingIndex, String calledClass, long calledConHash, Constructor calledCon)
           
 void initializeConCalledByMethodEmptyChain(long callingMethodHash, String calledClass, long calledConHash)
           
protected  CallerConstructorInfo initializeConCalledByMethodInterceptorsMap(long callingMethodHash, String calledClass, long calledConHash, Constructor calledCon)
           
protected  CallerMethodInfo initializeConstructorCallerInterceptorsMap(int callingIndex, String calledClass, long calledMethodHash, Method calledMethod)
           
 void initializeEmptyCallerChain(long callingMethodHash, String calledClass, long calledMethodHash)
           
 void initializeEmptyConstructorCallerChain(int callingIndex, String calledClass, long calledMethodHash)
           
protected  ArrayList initializeFieldChain()
           
protected  gnu.trove.TLongObjectHashMap initializeMethodChain()
           
 Object invoke(Invocation invocation)
          Helper method This is the end of the chain
 Object invokeCaller(long callingMethodHash, Object target, Object[] args, CallerMethodInfo info, Object callingObject)
           
 Object invokeConCalledByCon(int callingIndex, Object[] args, CallerConstructorInfo info)
           
 Object invokeConCalledByMethod(long callingMethodHash, Object[] args, CallerConstructorInfo info, Object callingObject)
           
 Object invokeConstructorCaller(int callingIndex, Object target, Object[] args, CallerMethodInfo info)
           
 Object invokeMethod(ClassInstanceAdvisor instanceAdvisor, Object target, long methodHash, Object[] arguments, MethodInfo info)
           
 Object invokeMethod(InstanceAdvisor instanceAdvisor, Object target, long methodHash, Object[] arguments)
           
 Object invokeMethod(long methodHash, Object[] arguments)
           
 Object invokeMethod(Object target, long methodHash, Object[] arguments)
           
 Object invokeNew(Object[] args, int idx)
           
 Object invokeNewWithoutAdvisement(Object[] arguments, Constructor constructor)
           
 Object invokeRead(Object target, int index)
          Invokes interceptor chain.
 Object invokeWithoutAdvisement(Object target, long methodHash, Object[] arguments)
          Invokes target object without applying interceptors.
 Object invokeWrite(Object target, int index, Object value)
          Invokes interceptor chain.
static boolean isAdvisable(Field field)
          Is the field advisable?
static boolean isAdvisable(Method method)
          Is the method advisable?
static boolean isWithoutAdvisement(String name)
          Is this the name of a private, unadvised thing?
static String notAdvisedMethodName(String className, String methodName)
          Generates internal, unadvised version of a method name.
protected  void populateMixinMethods()
          Put mixin methods from mixin class into unadvisedMethods map so that they can be correctly invoked upon.
protected  void rebindClassMetaData()
           
protected  void rebuildCallerInterceptors()
           
protected  void rebuildInterceptors()
           
 void removeAdviceBinding(AdviceBinding binding)
           
 void removeAdviceBindings(ArrayList bindings)
           
 void removeCallerPointcut(AdviceBinding binding)
           
 void removeClassMetaData(ClassMetaDataBinding data)
           
 CallerConstructorInfo resolveCallerConstructorInfo(long callingMethodHash, String calledClass, long calledConHash)
           
 CallerMethodInfo resolveCallerMethodInfo(long callingMethodHash, String calledClass, long calledMethodHash)
           
 CallerConstructorInfo resolveConstructorCallerConstructorInfo(int callingIndex, String calledClass, long calledConHash)
           
 CallerMethodInfo resolveConstructorCallerMethodInfo(int callingIndex, String calledClass, long calledMethodHash)
           
protected  void resolveFieldPointcut(ArrayList newFieldInterceptors, AdviceBinding binding, boolean write)
           
 
Methods inherited from class org.jboss.aop.Advisor
addAdviceInterceptor, addInterfaceIntroduction, addPerClassAspect, addPerInstanceAspect, addPerInstanceJoinpointAspect, applyPrecedence, createInterceptorChain, deployAnnotationOverrides, deployMethodAnnotationOverrides, dynamicInvoke, finalizeConstructionChain, finalizeConstructorChain, finalizeMethodChain, getAdviceInterceptor, getAnnotations, getClassMetaData, getClassMetadataBindings, getClazz, getConstructionInterceptors, getConstructorInterceptors, getConstructorMetaData, getDefaultMetaData, getFieldMetaData, getInterfaceIntroductions, getManager, getMethodInfo, getMethodMetaData, getName, getPerClassAspect, getPerClassAspect, getPerInstanceAspectDefinitions, getPerInstanceJoinpointAspectDefinitions, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAspects, initializeConstructionChain, initializeConstructorChain, newBindingAdded, removeInterfaceIntroduction, removePerClassAspect, removePerInstanceAspect, removePerInstanceJoinpointAspect, resolveAnnotation, resolveAnnotation, resolveAnnotation, resolveAnnotation, resolveAnnotation, resolveConstructionPointcut, resolveConstructorPointcut, resolveMethodPointcut
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_TRANSFORMABLE_SUFFIX

public static final String NOT_TRANSFORMABLE_SUFFIX
Suffix added to unadvised methods.

See Also:
Constant Field Values

methodCalledByMethodBindings

protected gnu.trove.TLongObjectHashMap methodCalledByMethodBindings

backrefMethodCalledByMethodBindings

protected HashMap backrefMethodCalledByMethodBindings

methodCalledByMethodInterceptors

protected gnu.trove.TLongObjectHashMap methodCalledByMethodInterceptors

conCalledByMethodBindings

protected gnu.trove.TLongObjectHashMap conCalledByMethodBindings

backrefConCalledByMethodBindings

protected HashMap backrefConCalledByMethodBindings

conCalledByMethodInterceptors

protected gnu.trove.TLongObjectHashMap conCalledByMethodInterceptors

methodCalledByConBindings

protected HashMap[] methodCalledByConBindings

methodCalledByConInterceptors

protected HashMap[] methodCalledByConInterceptors

backrefMethodCalledByConstructorBindings

protected HashMap backrefMethodCalledByConstructorBindings

conCalledByConBindings

protected HashMap[] conCalledByConBindings

conCalledByConInterceptors

protected HashMap[] conCalledByConInterceptors

backrefConCalledByConstructorBindings

protected HashMap backrefConCalledByConstructorBindings

initialized

protected boolean initialized
Constructor Detail

ClassAdvisor

public ClassAdvisor(String classname,
                    AspectManager manager)
Method Detail

getFieldAspect

public Object getFieldAspect(FieldJoinpoint joinpoint,
                             AspectDefinition def)
This method is to support PER_JOINPOINT scoping of Aspects for static fields Fields are special in that a get and set do not create separate aspect instances.

Parameters:
joinpoint -
def -
Returns:

getAdvisedFields

public Field[] getAdvisedFields()

getAdvisedMethods

public gnu.trove.TLongObjectHashMap getAdvisedMethods()

getUnadvisedMethods

public gnu.trove.TLongObjectHashMap getUnadvisedMethods()

getConstructors

public Constructor[] getConstructors()
Overrides:
getConstructors in class Advisor

getMethodCalledByMethodInterceptors

public gnu.trove.TLongObjectHashMap getMethodCalledByMethodInterceptors()

getMethodCalledByConInterceptors

public HashMap[] getMethodCalledByConInterceptors()

getConCalledByConInterceptors

public HashMap[] getConCalledByConInterceptors()

getConCalledByMethodInterceptors

public gnu.trove.TLongObjectHashMap getConCalledByMethodInterceptors()

getMethodCalledByMethodBindings

public gnu.trove.TLongObjectHashMap getMethodCalledByMethodBindings()

getFieldReadInterceptors

public Interceptor[][] getFieldReadInterceptors()

getFieldWriteInterceptors

public Interceptor[][] getFieldWriteInterceptors()

getMethodInterceptors

public gnu.trove.TLongObjectHashMap getMethodInterceptors()

attachClass

public void attachClass(Class clazz)
Constructs a new helper.


getConstructorIndex

public int getConstructorIndex(Constructor constructor)
Get a constructor's index in the class. Returns -1 if not there


getFieldIndex

public int getFieldIndex(Field field)
Get a field's index in the class. Returns -1 if not there


populateMixinMethods

protected void populateMixinMethods()
                             throws Exception
Put mixin methods from mixin class into unadvisedMethods map so that they can be correctly invoked upon.

Throws:
Exception

removeAdviceBinding

public void removeAdviceBinding(AdviceBinding binding)
Overrides:
removeAdviceBinding in class Advisor

removeAdviceBindings

public void removeAdviceBindings(ArrayList bindings)
Overrides:
removeAdviceBindings in class Advisor

resolveFieldPointcut

protected void resolveFieldPointcut(ArrayList newFieldInterceptors,
                                    AdviceBinding binding,
                                    boolean write)

initializeMethodChain

protected gnu.trove.TLongObjectHashMap initializeMethodChain()

initializeFieldChain

protected ArrayList initializeFieldChain()

finalizeFieldChain

protected void finalizeFieldChain(ArrayList newFieldInterceptors)

createInterceptorChains

protected void createInterceptorChains()
                                throws Exception
Throws:
Exception

initializeCallerInterceptorsMap

protected CallerMethodInfo initializeCallerInterceptorsMap(long callingMethodHash,
                                                           String calledClass,
                                                           long calledMethodHash,
                                                           Method calledMethod)
                                                    throws Exception
Throws:
Exception

initializeConCalledByMethodInterceptorsMap

protected CallerConstructorInfo initializeConCalledByMethodInterceptorsMap(long callingMethodHash,
                                                                           String calledClass,
                                                                           long calledConHash,
                                                                           Constructor calledCon)
                                                                    throws Exception
Throws:
Exception

initializeConstructorCallerInterceptorsMap

protected CallerMethodInfo initializeConstructorCallerInterceptorsMap(int callingIndex,
                                                                      String calledClass,
                                                                      long calledMethodHash,
                                                                      Method calledMethod)
                                                               throws Exception
Throws:
Exception

initializeConCalledByConInterceptorsMap

protected CallerConstructorInfo initializeConCalledByConInterceptorsMap(int callingIndex,
                                                                        String calledClass,
                                                                        long calledConHash,
                                                                        Constructor calledCon)
                                                                 throws Exception
Throws:
Exception

rebuildCallerInterceptors

protected void rebuildCallerInterceptors()
                                  throws Exception
Throws:
Exception

rebuildInterceptors

protected void rebuildInterceptors()
Specified by:
rebuildInterceptors in class Advisor

bindClassMetaData

protected void bindClassMetaData(ClassMetaDataBinding data)

rebindClassMetaData

protected void rebindClassMetaData()

addClassMetaData

public void addClassMetaData(ClassMetaDataBinding data)
Specified by:
addClassMetaData in class Advisor

removeClassMetaData

public void removeClassMetaData(ClassMetaDataBinding data)
Specified by:
removeClassMetaData in class Advisor

initializeEmptyCallerChain

public void initializeEmptyCallerChain(long callingMethodHash,
                                       String calledClass,
                                       long calledMethodHash)
                                throws Exception
Throws:
Exception

initializeConCalledByMethodEmptyChain

public void initializeConCalledByMethodEmptyChain(long callingMethodHash,
                                                  String calledClass,
                                                  long calledConHash)
                                           throws Exception
Throws:
Exception

initializeEmptyConstructorCallerChain

public void initializeEmptyConstructorCallerChain(int callingIndex,
                                                  String calledClass,
                                                  long calledMethodHash)
                                           throws Exception
Throws:
Exception

initializeConCalledByConEmptyChain

public void initializeConCalledByConEmptyChain(int callingIndex,
                                               String calledClass,
                                               long calledConHash)
                                        throws Exception
Throws:
Exception

addMethodCalledByMethodPointcut

public void addMethodCalledByMethodPointcut(long callingMethodHash,
                                            String calledClass,
                                            long calledMethodHash,
                                            AdviceBinding binding)
                                     throws Exception
Throws:
Exception

addConstructorCalledByMethodPointcut

public void addConstructorCalledByMethodPointcut(long callingMethodHash,
                                                 String calledClass,
                                                 long calledMethodHash,
                                                 AdviceBinding binding)
                                          throws Exception
Throws:
Exception

addConstructorCallerPointcut

public void addConstructorCallerPointcut(int callingIndex,
                                         String calledClass,
                                         long calledMethodHash,
                                         AdviceBinding binding)
                                  throws Exception
Throws:
Exception

addConstructorCalledByConPointcut

public void addConstructorCalledByConPointcut(int callingIndex,
                                              String calledClass,
                                              long calledConHash,
                                              AdviceBinding binding)
                                       throws Exception
Throws:
Exception

removeCallerPointcut

public void removeCallerPointcut(AdviceBinding binding)

notAdvisedMethodName

public static String notAdvisedMethodName(String className,
                                          String methodName)
Generates internal, unadvised version of a method name.


isWithoutAdvisement

public static boolean isWithoutAdvisement(String name)
Is this the name of a private, unadvised thing?


isAdvisable

public static boolean isAdvisable(Field field)
Is the field advisable?


isAdvisable

public static boolean isAdvisable(Method method)
Is the method advisable?


resolveCallerMethodInfo

public CallerMethodInfo resolveCallerMethodInfo(long callingMethodHash,
                                                String calledClass,
                                                long calledMethodHash)

resolveCallerConstructorInfo

public CallerConstructorInfo resolveCallerConstructorInfo(long callingMethodHash,
                                                          String calledClass,
                                                          long calledConHash)

resolveConstructorCallerMethodInfo

public CallerMethodInfo resolveConstructorCallerMethodInfo(int callingIndex,
                                                           String calledClass,
                                                           long calledMethodHash)

resolveConstructorCallerConstructorInfo

public CallerConstructorInfo resolveConstructorCallerConstructorInfo(int callingIndex,
                                                                     String calledClass,
                                                                     long calledConHash)

invokeWithoutAdvisement

public Object invokeWithoutAdvisement(Object target,
                                      long methodHash,
                                      Object[] arguments)
                               throws Throwable
Invokes target object without applying interceptors.

Throws:
Throwable

invokeNewWithoutAdvisement

public Object invokeNewWithoutAdvisement(Object[] arguments,
                                         Constructor constructor)
                                  throws Throwable
Throws:
Throwable

invokeMethod

public Object invokeMethod(long methodHash,
                           Object[] arguments)
                    throws Throwable
Throws:
Throwable

invokeMethod

public Object invokeMethod(Object target,
                           long methodHash,
                           Object[] arguments)
                    throws Throwable
Throws:
Throwable

invokeMethod

public Object invokeMethod(InstanceAdvisor instanceAdvisor,
                           Object target,
                           long methodHash,
                           Object[] arguments)
                    throws Throwable
Throws:
Throwable

invokeMethod

public Object invokeMethod(ClassInstanceAdvisor instanceAdvisor,
                           Object target,
                           long methodHash,
                           Object[] arguments,
                           MethodInfo info)
                    throws Throwable
Throws:
Throwable

invokeCaller

public Object invokeCaller(long callingMethodHash,
                           Object target,
                           Object[] args,
                           CallerMethodInfo info,
                           Object callingObject)
                    throws Throwable
Throws:
Throwable

invokeConCalledByMethod

public Object invokeConCalledByMethod(long callingMethodHash,
                                      Object[] args,
                                      CallerConstructorInfo info,
                                      Object callingObject)
                               throws Throwable
Throws:
Throwable

invokeConstructorCaller

public Object invokeConstructorCaller(int callingIndex,
                                      Object target,
                                      Object[] args,
                                      CallerMethodInfo info)
                               throws Throwable
Throws:
Throwable

invokeConCalledByCon

public Object invokeConCalledByCon(int callingIndex,
                                   Object[] args,
                                   CallerConstructorInfo info)
                            throws Throwable
Throws:
Throwable

invokeNew

public Object invokeNew(Object[] args,
                        int idx)
                 throws Throwable
Throws:
Throwable

invokeRead

public Object invokeRead(Object target,
                         int index)
                  throws Throwable
Invokes interceptor chain. This is the beginning

Throws:
Throwable

invokeWrite

public Object invokeWrite(Object target,
                          int index,
                          Object value)
                   throws Throwable
Invokes interceptor chain. This is the beginning

Throws:
Throwable

invoke

public Object invoke(Invocation invocation)
              throws Throwable
Helper method This is the end of the chain

Throws:
Throwable


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.