org.jboss.aop
Class ClassAdvisor

java.lang.Object
  extended by org.jboss.aop.Advisor
      extended by org.jboss.aop.ClassAdvisor
Direct Known Subclasses:
GeneratedClassAdvisor

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: 60810 $
Author:
Bill Burke

Field Summary
protected  Field[] advisedFields
           
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.
protected  gnu.trove.TLongObjectHashMap unadvisedMethods
           
 
Fields inherited from class org.jboss.aop.Advisor
adviceBindings, adviceInterceptors, advisedMethods, annotations, aspects, classAnnotations, classMetaData, classMetaDataBindings, clazz, constructionInfos, constructionInterceptors, constructorInfos, constructorInterceptors, constructorMetaData, constructors, defaultMetaData, doesHaveAspects, fieldMetaData, interfaceIntroductions, manager, methodInterceptors, methodMetaData, name, perInstanceAspectDefinitions, perInstanceJoinpointAspectDefinitions
 
Constructor Summary
ClassAdvisor(Class clazz, AspectManager manager)
           
ClassAdvisor(String classname, AspectManager manager)
           
 
Method Summary
 void addClassMetaData(ClassMetaDataBinding data)
           
 void addConstructorCallerPointcut(int callingIndex, String calledClass, long calledMethodHash, AdviceBinding binding)
           
protected  void addDeclaredMethods(Class superclass)
           
 void attachClass(Class clazz)
          Constructs a new helper.
protected  void bindClassMetaData(ClassMetaDataBinding data)
           
protected  void finalizeConCalledByConInterceptorChain(ConByConInfo info)
           
protected  void finalizeConCalledByMethodInterceptorChain(ConByMethodInfo info)
           
protected  void finalizeFieldReadChain(ArrayList newFieldInfos)
           
protected  void finalizeFieldWriteChain(ArrayList newFieldInfos)
           
protected  void finalizeMethodCalledByConInterceptorChain(MethodByConInfo info)
           
protected  void finalizeMethodCalledByMethodInterceptorChain(MethodByMethodInfo info)
           
 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.
 FieldInfo[] getFieldReadInfos()
           
 Interceptor[][] getFieldReadInterceptors()
          Deprecated. use getFieldReadInfos instead
 FieldInfo[] getFieldWriteInfos()
           
 Interceptor[][] getFieldWriteInterceptors()
          Deprecated. use getFieldWriteInfos instead
protected  org.jboss.aop.InterceptorChainObserver getInterceptorChainObserver()
          Returns the interceptor chain observer associated with this advisor.
 HashMap[] getMethodCalledByConInterceptors()
           
 gnu.trove.TLongObjectHashMap getMethodCalledByMethodBindings()
           
 gnu.trove.TLongObjectHashMap getMethodCalledByMethodInterceptors()
           
 gnu.trove.TLongObjectHashMap getMethodInterceptors()
           
protected  gnu.trove.TLongObjectHashMap getUnadvisedMethods()
           
protected  ArrayList initializeFieldReadChain()
           
protected  ArrayList initializeFieldWriteChain()
           
protected  gnu.trove.TLongObjectHashMap initializeMethodChain()
           
 Object invoke(Invocation invocation)
          Invokes interceptor chain.
 Object invokeCaller(long callingMethodHash, Object target, Object[] args, CallerMethodInfo info, Object callingObject)
          Deprecated.  
 Object invokeCaller(MethodByMethodInfo info, Object callingObject, Object target, Object[] args)
           
 Object invokeConCalledByCon(ConByConInfo info, Object[] args)
          Deprecated. Prefer using the version with callingObject instead of this one, since this object is available for call invocations made inside constructors.
 Object invokeConCalledByCon(ConByConInfo info, Object callingObject, Object[] args)
           
 Object invokeConCalledByCon(int callingIndex, Object[] args, CallerConstructorInfo info)
          Deprecated.  
 Object invokeConCalledByCon(int callingIndex, Object callingObject, Object[] args, CallerConstructorInfo info)
          Deprecated.  
 Object invokeConCalledByMethod(ConByMethodInfo info, Object callingObject, Object[] args)
           
 Object invokeConCalledByMethod(long callingMethodHash, Object[] args, CallerConstructorInfo info, Object callingObject)
          Deprecated.  
 Object invokeConstructorCaller(int callingIndex, Object target, Object[] args, CallerMethodInfo info)
          Deprecated.  
 Object invokeConstructorCaller(int callingIndex, Object callingObject, Object target, Object[] args, CallerMethodInfo info)
          Deprecated.  
 Object invokeConstructorCaller(MethodByConInfo info, Object target, Object[] args)
          Deprecated. Prefer using the version with callingObject instead of this one, since this object is available for call invocations made inside constructors.
 Object invokeConstructorCaller(MethodByConInfo info, Object callingObject, Object target, Object[] args)
           
 Object invokeMethod(InstanceAdvisor instanceAdvisor, Object target, long methodHash, Object[] arguments)
           
 Object invokeMethod(InstanceAdvisor instanceAdvisor, Object target, long methodHash, Object[] arguments, MethodInfo info)
           
 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 isGeneratedClassAdvisor(Class clazz)
           
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 populateInterceptorsFromInfos()
          Deprecated. We should just be using xxxxInfos
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 removeClassMetaData(ClassMetaDataBinding data)
           
 ConByMethodInfo resolveCallerConstructorInfo(long callingMethodHash, String calledClass, long calledConHash)
           
 WeakReference resolveCallerConstructorInfoAsWeakReference(long callingMethodHash, String calledClass, long calledConHash)
           
 MethodByMethodInfo resolveCallerMethodInfo(long callingMethodHash, String calledClass, long calledMethodHash)
           
 WeakReference resolveCallerMethodInfoAsWeakReference(long callingMethodHash, String calledClass, long calledMethodHash)
           
 ConByConInfo resolveConstructorCallerConstructorInfo(int callingIndex, String calledClass, long calledConHash)
           
 WeakReference resolveConstructorCallerConstructorInfoAsWeakReference(int callingIndex, String calledClass, long calledConHash)
           
 MethodByConInfo resolveConstructorCallerMethodInfo(int callingIndex, String calledClass, long calledMethodHash)
           
 WeakReference resolveConstructorCallerMethodInfoAsWeakReference(int callingIndex, String calledClass, long calledMethodHash)
           
protected  void setInterceptorChainObserver(org.jboss.aop.InterceptorChainObserver observer)
          Defines the interceptor chain observer associated with this advisor.
 
Methods inherited from class org.jboss.aop.Advisor
addAdviceInterceptor, addInterfaceIntroduction, addPerClassAspect, addPerInstanceAspect, addPerInstanceJoinpointAspect, chainOverridingForInheritedMethods, cleanup, createInterceptorChain, deployAnnotationOverride, deployAnnotationOverrides, deployMethodAnnotationOverrides, dynamicInvoke, finalizeConstructionChain, finalizeConstructorChain, finalizeMethodChain, getAdviceInterceptor, getAllMethods, getAnnotations, getClassMetaData, getClassMetadataBindings, getClazz, getConstructionInfos, getConstructionInterceptors, getConstructorInfos, getConstructorInterceptors, getConstructorMetaData, getDefaultMetaData, getFieldMetaData, getInterfaceIntroductions, getManager, getMethodInfo, getMethodMetaData, getName, getPerClassAspect, getPerClassAspect, getPerInstanceAspectDefinitions, getPerInstanceJoinpointAspectDefinitions, getSimpleName, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, hasAspects, initializeConstructionChain, initializeConstructorChain, initializeInterfaceIntroductions, newBindingAdded, pointcutResolved, removeInterfaceIntroduction, removePerClassAspect, removePerInstanceAspect, removePerInstanceJoinpointAspect, resolveAnnotation, resolveAnnotation, resolveAnnotation, resolveAnnotation, resolveAnnotation, resolveConstructionPointcut, resolveConstructorPointcut, resolveMethodPointcut, setChainOverridingForInheritedMethods, setManager
 
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

unadvisedMethods

protected gnu.trove.TLongObjectHashMap unadvisedMethods

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

advisedFields

protected Field[] advisedFields

initialized

protected boolean initialized
Constructor Detail

ClassAdvisor

public ClassAdvisor(String classname,
                    AspectManager manager)

ClassAdvisor

public ClassAdvisor(Class clazz,
                    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. Also used to support PER_CLASS_JOINPOINT, since that behaves similarly to static fields

Parameters:
joinpoint -
def -
Returns:

getAdvisedFields

public Field[] getAdvisedFields()

getAdvisedMethods

public gnu.trove.TLongObjectHashMap getAdvisedMethods()

getUnadvisedMethods

protected 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()
Deprecated. use getFieldReadInfos instead


getFieldReadInfos

public FieldInfo[] getFieldReadInfos()

getFieldWriteInterceptors

public Interceptor[][] getFieldWriteInterceptors()
Deprecated. use getFieldWriteInfos instead


getFieldWriteInfos

public FieldInfo[] getFieldWriteInfos()

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

initializeMethodChain

protected gnu.trove.TLongObjectHashMap initializeMethodChain()

initializeFieldReadChain

protected ArrayList initializeFieldReadChain()

initializeFieldWriteChain

protected ArrayList initializeFieldWriteChain()

finalizeFieldReadChain

protected void finalizeFieldReadChain(ArrayList newFieldInfos)

finalizeFieldWriteChain

protected void finalizeFieldWriteChain(ArrayList newFieldInfos)

rebuildCallerInterceptors

protected void rebuildCallerInterceptors()
                                  throws Exception
Throws:
Exception

finalizeMethodCalledByMethodInterceptorChain

protected void finalizeMethodCalledByMethodInterceptorChain(MethodByMethodInfo info)

finalizeConCalledByMethodInterceptorChain

protected void finalizeConCalledByMethodInterceptorChain(ConByMethodInfo info)

finalizeConCalledByConInterceptorChain

protected void finalizeConCalledByConInterceptorChain(ConByConInfo info)

finalizeMethodCalledByConInterceptorChain

protected void finalizeMethodCalledByConInterceptorChain(MethodByConInfo info)

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

addConstructorCallerPointcut

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

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?


addDeclaredMethods

protected void addDeclaredMethods(Class superclass)
                           throws Exception
Throws:
Exception

resolveCallerMethodInfo

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

resolveCallerMethodInfoAsWeakReference

public WeakReference resolveCallerMethodInfoAsWeakReference(long callingMethodHash,
                                                            String calledClass,
                                                            long calledMethodHash)

resolveCallerConstructorInfo

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

resolveCallerConstructorInfoAsWeakReference

public WeakReference resolveCallerConstructorInfoAsWeakReference(long callingMethodHash,
                                                                 String calledClass,
                                                                 long calledConHash)

resolveConstructorCallerMethodInfo

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

resolveConstructorCallerMethodInfoAsWeakReference

public WeakReference resolveConstructorCallerMethodInfoAsWeakReference(int callingIndex,
                                                                       String calledClass,
                                                                       long calledMethodHash)

resolveConstructorCallerConstructorInfo

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

resolveConstructorCallerConstructorInfoAsWeakReference

public WeakReference resolveConstructorCallerConstructorInfoAsWeakReference(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(InstanceAdvisor 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
Deprecated. 

Throws:
Throwable

invokeCaller

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

invokeConCalledByMethod

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

Throws:
Throwable

invokeConCalledByMethod

public Object invokeConCalledByMethod(ConByMethodInfo info,
                                      Object callingObject,
                                      Object[] args)
                               throws Throwable
Throws:
Throwable

invokeConstructorCaller

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

Throws:
Throwable

invokeConstructorCaller

public Object invokeConstructorCaller(int callingIndex,
                                      Object callingObject,
                                      Object target,
                                      Object[] args,
                                      CallerMethodInfo info)
                               throws Throwable
Deprecated. 

Throws:
Throwable

invokeConstructorCaller

public Object invokeConstructorCaller(MethodByConInfo info,
                                      Object target,
                                      Object[] args)
                               throws Throwable
Deprecated. Prefer using the version with callingObject instead of this one, since this object is available for call invocations made inside constructors.

Throws:
Throwable
See Also:
invokeConstructorCaller(MethodByConInfo, Object, Object, Object[])

invokeConstructorCaller

public Object invokeConstructorCaller(MethodByConInfo info,
                                      Object callingObject,
                                      Object target,
                                      Object[] args)
                               throws Throwable
Throws:
Throwable

invokeConCalledByCon

public Object invokeConCalledByCon(int callingIndex,
                                   Object[] args,
                                   CallerConstructorInfo info)
                            throws Throwable
Deprecated. 

Throws:
Throwable

invokeConCalledByCon

public Object invokeConCalledByCon(int callingIndex,
                                   Object callingObject,
                                   Object[] args,
                                   CallerConstructorInfo info)
                            throws Throwable
Deprecated. 

Throws:
Throwable

invokeConCalledByCon

public Object invokeConCalledByCon(ConByConInfo info,
                                   Object[] args)
                            throws Throwable
Deprecated. Prefer using the version with callingObject instead of this one, since this object is available for call invocations made inside constructors.

Throws:
Throwable
See Also:
invokeConCalledByCon(ConByConInfo, Object, Object[])

invokeConCalledByCon

public Object invokeConCalledByCon(ConByConInfo info,
                                   Object callingObject,
                                   Object[] args)
                            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
Invokes interceptor chain. This is the beginning

Throws:
Throwable

getInterceptorChainObserver

protected org.jboss.aop.InterceptorChainObserver getInterceptorChainObserver()
Returns the interceptor chain observer associated with this advisor.


setInterceptorChainObserver

protected void setInterceptorChainObserver(org.jboss.aop.InterceptorChainObserver observer)
Defines the interceptor chain observer associated with this advisor.

Parameters:
observer - the interceptor chain observer.

populateInterceptorsFromInfos

protected void populateInterceptorsFromInfos()
Deprecated. We should just be using xxxxInfos

Overrides:
populateInterceptorsFromInfos in class Advisor

isGeneratedClassAdvisor

public static boolean isGeneratedClassAdvisor(Class clazz)


Copyright © 2004 JBoss Inc. All Rights Reserved.