org.jboss.aop
Class Advisor

java.lang.Object
  extended by org.jboss.aop.Advisor
Direct Known Subclasses:
ClassAdvisor, ClassContainer, MarshalledProxyAdvisor

public abstract class Advisor
extends Object

Manages the interceptor chains of an aspect context (usually, this context is composed by either all joinpoints of a class, or the joinponts of an instance).

Version:
$Revision: 78663 $
Author:
Bill Burke, adrian@jboss.org

Field Summary
protected  Set<AdviceBinding> adviceBindings
          The collection of bindings that are applied to one or more joinpoints in the advised context.
protected  HashMap<AspectDefinition,Map<String,Interceptor>> adviceInterceptors
          Contains all the interceptor instances applied to this context.
protected  gnu.trove.TLongObjectHashMap advisedMethods
          Maps all advised methods to their interceptor chains.
protected  AnnotationRepository annotations
          Repository that contains all annotations applied to the context of this advisor
protected  ConcurrentHashMap<String,Object> aspects
          Contains all the aspect instances applied to this context.
protected  SimpleMetaData classMetaData
          The target class meta data.
protected  ArrayList<ClassMetaDataBinding> classMetaDataBindings
          The collection of class metadata bindings that are applied to the advised context.
protected  Class<?> clazz
          Target class of the advised joinpoint.
protected  ConstructionInfo[] constructionInfos
           
protected  Interceptor[][] constructionInterceptors
          Deprecated. Use constructorInfos instead
protected  ConstructorInfo[] constructorInfos
           
protected  Interceptor[][] constructorInterceptors
          Deprecated. Use constructorInfos instead
protected  ConstructorMetaData constructorMetaData
          Constructor execution joinpoints meta data.
protected  Constructor<?>[] constructors
          Contains the constructors that belong to the advised context.
protected  SimpleMetaData defaultMetaData
          Meta data that apply to all advised joinpoints.
protected  boolean doesHaveAspects
          Indicates whether there is one or more aspects applied to this context.
protected  FieldMetaData fieldMetaData
          Field read/write joinpoints meta data.
protected  ArrayList<InterfaceIntroduction> interfaceIntroductions
          The collection of interface introductions that affect the advised context.
protected  Object lazyCollectionLock
          Read/Write lock to be used when lazy creating the collections
protected  WeakReference<ClassLoader> loader
          Target class loader of the advised joinpoint.
protected  AspectManager manager
          Domain to which this advisor belongs.
protected  MethodInterceptors methodInfos
          Collection of method execution joinpoints.
protected  gnu.trove.TLongObjectHashMap methodInterceptors
          Deprecated. use methodInfos instead. These remain here for compatibility with EJB 3 in JBoss 4.x. See JBAOP-517
protected  MethodMetaData methodMetaData
          Method execution joinpoints meta data.
protected  String name
          Name that identifies this advisor.
protected static Object NULL_ASPECT
          Indicates that a call to factory create has already been made, but the factory returned null.
protected  CopyOnWriteArraySet<AspectDefinition> perInstanceAspectDefinitions
          Contains all definitions of PER_INSTANCE aspects applied to this context.
protected  ConcurrentHashMap<AspectDefinition,Set<Joinpoint>> perInstanceJoinpointAspectDefinitions
          Contains all definitions of PER_JOINPOINT scoped aspects applied to this sccontext
 
Constructor Summary
Advisor(String name, AspectManager manager)
          Constructor.
 
Method Summary
 void addAdviceInterceptor(AspectDefinition def, String adviceName, Interceptor interceptor, Joinpoint joinpoint)
           
abstract  void addClassMetaData(ClassMetaDataBinding data)
           
 void addInterfaceIntroduction(InterfaceIntroduction pointcut)
           
 void addPerClassAspect(AspectDefinition def)
           
 void addPerInstanceAspect(AspectDefinition def)
           
 void addPerInstanceJoinpointAspect(Joinpoint joinpoint, AspectDefinition def)
           
protected  void adjustInfoForAddedBinding(JoinPointInfo info)
          If the info was updated in response to a rebuildInterceptorsForAddedBinding call it will have the original interceptors in the interceptors array, and the appended interceptors in the interceptorChain List.
 boolean chainOverridingForInheritedMethods()
          Whether the type of advisor supports matching on pointcut expression, where the method is defined in a superclass only, while the pointcut expression class matches the subclass.
 void cleanup()
           
protected  void createInterceptorChain(InterceptorFactory[] factories, ArrayList<Interceptor> newinterceptors, Joinpoint joinpoint)
           
 void deployAnnotationOverride(AnnotationIntroduction introduction)
          Deploys introduction to the advised context, overriding current annotions with the same name, in case they are present.
 void deployAnnotationOverrides()
          Deploys to the advised context all AnnotationIntroduction that should override current annotions, in case they are present.
protected  void deployMethodAnnotationOverrides(Class<?> theClass, AnnotationIntroduction introduction)
          Recursively deploys all method annotation introductions, overriding annotations with the same name.
 void doDeployAnnotationOverride(AnnotationIntroduction introduction)
          Deploys introduction to the advised context, overriding current annotions with the same name, in case they are present.
 InvocationResponse dynamicInvoke(Object target, Invocation invocation)
           
protected  void finalizeChain(JoinPointInfo[] infos)
           
protected  void finalizeMethodChain()
           
 Interceptor getAdviceInterceptor(AspectDefinition def, String adviceName, Joinpoint joinpoint)
           
 Method[] getAllMethods()
          Deprecated. Need a better mechanism to override the methods seen by pointcuts, e.g. those provided by a "proxy advisor"
 AnnotationRepository getAnnotations()
          Returns the annotation repository used by this advisor to keep all annotations that are applied to the advised joinpoints.
 ClassLoader getClassLoader()
          Returns the class loader associated with this advisor.
 SimpleMetaData getClassMetaData()
          Returns the target class meta data.
 List<ClassMetaDataBinding> getClassMetadataBindings()
          Returns the collection of class meta data bindings that are applied to the advised context.
 Class getClazz()
          EJB3 counts on this being unchecked
 ConstructionInfo[] getConstructionInfos()
          Returns the list of advised construction joinpoints.
 Interceptor[][] getConstructionInterceptors()
          Deprecated. Use getConstructionInfos instead
 ConstructorInfo[] getConstructorInfos()
          Returns the list of advised constructor execution joinpoints.
 Interceptor[][] getConstructorInterceptors()
          Deprecated. Use getConstructorInfos instead
 ConstructorMetaData getConstructorMetaData()
          Returns the constructor joinpoints meta data
 Constructor<?>[] getConstructors()
          Returns the list of constructors that belong to the advised context.
 SimpleMetaData getDefaultMetaData()
          Returns the meta data that is applied to all joinpoints and to the target class.
 FieldMetaData getFieldMetaData()
          Returns the field joinpoints meta data
 ArrayList<InterfaceIntroduction> getInterfaceIntroductions()
           
 AspectManager getManager()
          Returns the aspect manager that represents the domain to which this Advisor belongs.
 org.jboss.metadata.spi.MetaData getMetadata()
          Get the metadata
 MethodInfo getMethodInfo(long hash)
          Returns the MethodInfo that represents the execution of the method identified by hash.
 MethodMetaData getMethodMetaData()
          Returns the method joinpoints meta data
 String getName()
           
 Object getPerClassAspect(AspectDefinition def)
           
 Object getPerClassAspect(String def)
           
 Set<AspectDefinition> getPerInstanceAspectDefinitions()
           
 Map<AspectDefinition,Set<Joinpoint>> getPerInstanceJoinpointAspectDefinitions()
           
 Object getPerVMAspect(AspectDefinition def)
           
static String getSimpleName(Class<?> clazz)
          Deprecated. Use Class.getSimpleName() instead
 boolean hasAnnotation(Class<?> tgt, Class<? extends Annotation> annotation)
          Indicates whether tgt has an annotation/meta data whose type is annotation.
 boolean hasAnnotation(Class<?> tgt, String annotation)
          Indicates whether tgt has an annotation/meta data whose name is annotation.
 boolean hasAnnotation(Constructor<?> m, String annotation)
           
 boolean hasAnnotation(javassist.CtClass clazz, String annotation)
           
 boolean hasAnnotation(javassist.CtConstructor member, String annotation)
           
 boolean hasAnnotation(javassist.CtField member, String annotation)
           
 boolean hasAnnotation(javassist.CtMethod member, String annotation)
           
 boolean hasAnnotation(Field m, Class<? extends Annotation> annotation)
           
 boolean hasAnnotation(Field m, String annotation)
           
 boolean hasAnnotation(Method m, Class<? extends Annotation> annotation)
           
 boolean hasAnnotation(Method m, String annotation)
           
 boolean hasAnnotation(String annotation)
          Indicates whether the advised class has an annotation/meta data whose name is annotation.
 boolean hasAspects()
           
 boolean hasSameConstructorAspectLength(Advisor other)
           
 boolean hasSameMethodAspectLength(Advisor other)
           
protected  void initAdvisedMethodsMap()
           
protected  void initClassMetaDataBindingsList()
           
protected  void initializeConstructionChain()
           
protected  void initializeConstructorChain()
           
protected  void initializeInterfaceIntroductions(Class<?> theClass)
          Deploys to the advised context all InterfaceIntroduction whose pointcut matches one or more advised joinpoints.
protected  void initInterfaceIntroductionsList()
           
protected  void initPerInstanceAspectDefinitionsSet()
           
protected  void initPerInstanceJoinpointAspectDefinitionsMap()
           
protected  void lockWriteChain(JoinPointInfo[] infos)
           
protected  void lockWriteChain(MethodInterceptors methodInterceptors)
           
 void newBindingAdded()
          a new binding has been added to the AspectManager, recalculate interceptors
 void newBindingAdded(AdviceBinding binding)
           
protected  void pointcutResolved(JoinPointInfo info, AdviceBinding binding, Joinpoint joinpoint)
          Default implementation adds interceptorChain directly to the info.
protected  void populateInterceptorsFromInfos()
          Deprecated. We should just be using xxxxInfos
protected abstract  void rebuildInterceptors()
           
protected abstract  void rebuildInterceptorsForAddedBinding(AdviceBinding binding)
           
protected abstract  void rebuildInterceptorsForRemovedBinding(AdviceBinding removedBinding)
           
 void removeAdviceBinding(AdviceBinding binding)
           
 void removeAdviceBindings(ArrayList<AdviceBinding> bindings)
           
abstract  void removeClassMetaData(ClassMetaDataBinding data)
           
 void removeInterfaceIntroduction(InterfaceIntroduction pointcut)
           
 void removePerClassAspect(AspectDefinition def)
           
 void removePerInstanceAspect(AspectDefinition def)
           
 void removePerInstanceJoinpointAspect(AspectDefinition def)
           
protected  void resetChain(JoinPointInfo[] infos)
           
protected  void resetChain(MethodInterceptors methodInterceptors)
           
protected  void resetChainKeepInterceptors(JoinPointInfo[] infos)
           
protected  void resetChainKeepInterceptors(MethodInterceptors methodInterceptors)
           
 Object resolveAnnotation(Class<? extends Annotation> annotation)
          Returns an object representing the meta data of type annotation, if present.
 Object resolveAnnotation(Constructor<?> c, Class<? extends Annotation> annotation)
           
 Object resolveAnnotation(Field f, Class<? extends Annotation> annotation)
           
 Object resolveAnnotation(long hash, Method m, Class<? extends Annotation> annotation)
          Returns an object representing the method m annotation of type annotation, if m has such annotation.
 Object resolveAnnotation(Method m, Class<?>[] annotationChoices)
          Returns an object representing the method m annotation whose type is one of the elements in annotationChoices, if m has such annotation.
 Object resolveAnnotation(Method m, Class<? extends Annotation> annotation)
          Returns an object representing the method m annotation of type annotation, if m has such annotation.
protected  void resolveConstructionPointcut(AdviceBinding binding)
           
protected  void resolveConstructorPointcut(AdviceBinding binding)
           
protected  void resolveMethodPointcut(AdviceBinding binding)
           
<T extends Annotation>
T
resolveTypedAnnotation(Class<T> annotation)
          Returns an object representing the meta data of type annotation, if present.
<T extends Annotation>
T
resolveTypedAnnotation(Constructor<?> c, Class<T> annotation)
           
<T extends Annotation>
T
resolveTypedAnnotation(Field f, Class<T> annotation)
           
<T extends Annotation>
T
resolveTypedAnnotation(long hash, Method m, Class<T> annotation)
          Returns an object representing the method m annotation of type annotation, if m has such annotation.
<T extends Annotation>
T
resolveTypedAnnotation(Method m, Class<T> annotation)
          Returns an object representing the method m annotation of type annotation, if m has such annotation.
<T extends Annotation>
T
resolveTypedAnnotation(Method m, Class<T>[] annotationChoices)
          Returns an object representing the method m annotation whose type is one of the elements in annotationChoices, if m has such annotation.
protected  void setChainOverridingForInheritedMethods(boolean overriding)
           
protected  void setManager(AspectManager manager)
          For use by generated advisors.
 void setMetadata(org.jboss.metadata.spi.MetaData metadata)
          Set the metadata
protected  void unlockWriteChain(JoinPointInfo[] infos)
           
protected  void unlockWriteChain(MethodInterceptors methodInterceptors)
           
protected  void updateConstructionPointcutAfterRemove(AdviceBinding binding)
           
protected  void updateConstructorPointcutAfterRemove(AdviceBinding binding)
           
protected  void updateFieldPointcutAfterRemove(FieldInfo[] fieldInfos, AdviceBinding binding, boolean write)
           
protected  void updateFieldPointcutAfterRemove(FieldInfo fieldInfo, int i, boolean write)
           
protected  void updateMethodPointcutAfterRemove(AdviceBinding binding)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lazyCollectionLock

protected Object lazyCollectionLock
Read/Write lock to be used when lazy creating the collections


adviceBindings

protected Set<AdviceBinding> adviceBindings
The collection of bindings that are applied to one or more joinpoints in the advised context.


interfaceIntroductions

protected volatile ArrayList<InterfaceIntroduction> interfaceIntroductions
The collection of interface introductions that affect the advised context.


classMetaDataBindings

protected volatile ArrayList<ClassMetaDataBinding> classMetaDataBindings
The collection of class metadata bindings that are applied to the advised context.


defaultMetaData

protected SimpleMetaData defaultMetaData
Meta data that apply to all advised joinpoints.


methodMetaData

protected MethodMetaData methodMetaData
Method execution joinpoints meta data.


fieldMetaData

protected FieldMetaData fieldMetaData
Field read/write joinpoints meta data.


classMetaData

protected SimpleMetaData classMetaData
The target class meta data.


constructorMetaData

protected ConstructorMetaData constructorMetaData
Constructor execution joinpoints meta data.


annotations

protected AnnotationRepository annotations
Repository that contains all annotations applied to the context of this advisor


doesHaveAspects

protected boolean doesHaveAspects
Indicates whether there is one or more aspects applied to this context.


name

protected String name
Name that identifies this advisor.


aspects

protected ConcurrentHashMap<String,Object> aspects
Contains all the aspect instances applied to this context.


adviceInterceptors

protected HashMap<AspectDefinition,Map<String,Interceptor>> adviceInterceptors
Contains all the interceptor instances applied to this context.


perInstanceAspectDefinitions

protected volatile CopyOnWriteArraySet<AspectDefinition> perInstanceAspectDefinitions
Contains all definitions of PER_INSTANCE aspects applied to this context.


perInstanceJoinpointAspectDefinitions

protected volatile ConcurrentHashMap<AspectDefinition,Set<Joinpoint>> perInstanceJoinpointAspectDefinitions
Contains all definitions of PER_JOINPOINT scoped aspects applied to this sccontext


advisedMethods

protected volatile gnu.trove.TLongObjectHashMap advisedMethods
Maps all advised methods to their interceptor chains.


methodInterceptors

protected gnu.trove.TLongObjectHashMap methodInterceptors
Deprecated. use methodInfos instead. These remain here for compatibility with EJB 3 in JBoss 4.x. See JBAOP-517
See Also:
AspectManager.maintainAdvisorMethodInterceptors

methodInfos

protected MethodInterceptors methodInfos
Collection of method execution joinpoints.


manager

protected AspectManager manager
Domain to which this advisor belongs.


clazz

protected Class<?> clazz
Target class of the advised joinpoint.


loader

protected WeakReference<ClassLoader> loader
Target class loader of the advised joinpoint.


constructors

protected Constructor<?>[] constructors
Contains the constructors that belong to the advised context.


constructorInterceptors

protected Interceptor[][] constructorInterceptors
Deprecated. Use constructorInfos instead

constructorInfos

protected ConstructorInfo[] constructorInfos

constructionInterceptors

protected Interceptor[][] constructionInterceptors
Deprecated. Use constructorInfos instead

constructionInfos

protected ConstructionInfo[] constructionInfos

NULL_ASPECT

protected static Object NULL_ASPECT
Indicates that a call to factory create has already been made, but the factory returned null.

Constructor Detail

Advisor

public Advisor(String name,
               AspectManager manager)
Constructor.

Do not use this method to create Advisor instances. Instead, use the create methods of .

Parameters:
name - identifies the advisor to be created.
manager - the domain to which this advisor belongs.
Method Detail

getMethodInfo

public MethodInfo getMethodInfo(long hash)
Returns the MethodInfo that represents the execution of the method identified by hash.

Parameters:
hash - a hash code that identifies uniquely a method inside the context.
Returns:
a MethodInfo representing the queried method execution joinpoint.

getConstructors

public Constructor<?>[] getConstructors()
Returns the list of constructors that belong to the advised context.

Returns:
an array of constructors

getConstructorInterceptors

public Interceptor[][] getConstructorInterceptors()
Deprecated. Use getConstructorInfos instead


getConstructorInfos

public ConstructorInfo[] getConstructorInfos()
Returns the list of advised constructor execution joinpoints.

Returns:
an array of ConstructorInfo objects

getConstructionInterceptors

public Interceptor[][] getConstructionInterceptors()
Deprecated. Use getConstructionInfos instead


getConstructionInfos

public ConstructionInfo[] getConstructionInfos()
Returns the list of advised construction joinpoints.

Returns:
an array of ConstructionInfo objects

getAllMethods

public Method[] getAllMethods()
Deprecated. Need a better mechanism to override the methods seen by pointcuts, e.g. those provided by a "proxy advisor"


getManager

public AspectManager getManager()
Returns the aspect manager that represents the domain to which this Advisor belongs.

Returns:
an AspectManager instance.

setManager

protected void setManager(AspectManager manager)
For use by generated advisors. They will explicitly set the manager.

Parameters:
manager - the domain to which this Advisor belongs.

getClassMetadataBindings

public List<ClassMetaDataBinding> getClassMetadataBindings()
Returns the collection of class meta data bindings that are applied to the advised context.

Returns:
a list of ClassMetaDataBinding. This list is not a copy, and, hence, must not be edited.

getClassMetaData

public SimpleMetaData getClassMetaData()
Returns the target class meta data.

Returns:
the target class meta data. This object is not a copy, and, hence, must not be edited.

getDefaultMetaData

public SimpleMetaData getDefaultMetaData()
Returns the meta data that is applied to all joinpoints and to the target class.

Returns:
the meta data that apply to all joinpoints and to the target class. This object is not a copy, and, hence, must not be edited.

getMethodMetaData

public MethodMetaData getMethodMetaData()
Returns the method joinpoints meta data

Returns:
the method joinpoints meta data. This object is not a copy, and, hence, must not be edited.

getFieldMetaData

public FieldMetaData getFieldMetaData()
Returns the field joinpoints meta data

Returns:
the field joinpoints meta data. This object is not a copy, and, hence, must not be edited.

getConstructorMetaData

public ConstructorMetaData getConstructorMetaData()
Returns the constructor joinpoints meta data

Returns:
the constructor joinpoints meta data. This object is not a copy, and, hence, must not be edited.

deployAnnotationOverrides

public void deployAnnotationOverrides()
Deploys to the advised context all AnnotationIntroduction that should override current annotions, in case they are present.
The annotation introductions to be deployed are extracted from this advisor domain (AspectManager.getAnnotationOverrides()).


deployAnnotationOverride

public void deployAnnotationOverride(AnnotationIntroduction introduction)
Deploys introduction to the advised context, overriding current annotions with the same name, in case they are present.

Parameters:
introduction - an annotation introduction that must be applied to the advised context.

doDeployAnnotationOverride

public void doDeployAnnotationOverride(AnnotationIntroduction introduction)
Deploys introduction to the advised context, overriding current annotions with the same name, in case they are present.
This method must not be called externally, since it will perform deployment from outside a privileged environment. Use deployAnnotationOverride(AnnotationIntroduction) instead.

Parameters:
introduction - an annotation introduction that must be applied to the advised context.
introduction -

initializeInterfaceIntroductions

protected void initializeInterfaceIntroductions(Class<?> theClass)
Deploys to the advised context all InterfaceIntroduction whose pointcut matches one or more advised joinpoints.
The interface introductions to be deployed are extracted from this advisor domain (AspectManager.getInterfaceIntroductions()).


deployMethodAnnotationOverrides

protected void deployMethodAnnotationOverrides(Class<?> theClass,
                                               AnnotationIntroduction introduction)
Recursively deploys all method annotation introductions, overriding annotations with the same name.

For internal use only.

Parameters:
theClass - the class that contains the affected methods. Must be equal to getClazz() or to one of its super classes.
introduction - the introduction to be deployed.

getAnnotations

public AnnotationRepository getAnnotations()
Returns the annotation repository used by this advisor to keep all annotations that are applied to the advised joinpoints.

For internal use only.

Returns:
the annotation repository.

resolveAnnotation

public Object resolveAnnotation(Class<? extends Annotation> annotation)
Returns an object representing the meta data of type annotation, if present.

Parameters:
annotation - the type of meta data/annotation queried
Returns:
the meta data/annotation of type annotation

resolveTypedAnnotation

public <T extends Annotation> T resolveTypedAnnotation(Class<T> annotation)
Returns an object representing the meta data of type annotation, if present.

Parameters:
annotation - the type of meta data/annotation queried
Returns:
the meta data/annotation of type annotation

hasAnnotation

public boolean hasAnnotation(String annotation)
Indicates whether the advised class has an annotation/meta data whose name is annotation.

Parameters:
annotation - the name of an annotation
Returns:
true if there is an annotation/meta data whose name is annotation

hasAnnotation

public boolean hasAnnotation(Class<?> tgt,
                             String annotation)
Indicates whether tgt has an annotation/meta data whose name is annotation.

Parameters:
tgt - the target class whose annotations/meta data will be examined.
annotation - the name of an annotation
Returns:
true if there is an annotation/meta data whose name is annotation

hasAnnotation

public boolean hasAnnotation(Class<?> tgt,
                             Class<? extends Annotation> annotation)
Indicates whether tgt has an annotation/meta data whose type is annotation.

Parameters:
tgt - the target class whose annotations/meta data will be examined.
annotation - the type of an annotation
Returns:
true if tgt has an annotation/meta data whose type is annotation

resolveAnnotation

public Object resolveAnnotation(Method m,
                                Class<? extends Annotation> annotation)
Returns an object representing the method m annotation of type annotation, if m has such annotation.

Parameters:
m - the method whose annotation is being queried
annotation - the type of the queried annotation
Returns:
the meta data/annotation of type annotation that apply to m

resolveTypedAnnotation

public <T extends Annotation> T resolveTypedAnnotation(Method m,
                                                       Class<T> annotation)
Returns an object representing the method m annotation of type annotation, if m has such annotation.

Parameters:
m - the method whose annotation is being queried
annotation - the type of the queried annotation
Returns:
the meta data/annotation of type annotation that apply to m

resolveAnnotation

public Object resolveAnnotation(long hash,
                                Method m,
                                Class<? extends Annotation> annotation)
Returns an object representing the method m annotation of type annotation, if m has such annotation.

Parameters:
hash - the hashcode of m
m - the method whose annotation is being queried
annotation - the type of the queried annotation
Returns:
the meta data/annotation of type annotation that apply to m

resolveTypedAnnotation

public <T extends Annotation> T resolveTypedAnnotation(long hash,
                                                       Method m,
                                                       Class<T> annotation)
Returns an object representing the method m annotation of type annotation, if m has such annotation.

Parameters:
hash - the hashcode of m
m - the method whose annotation is being queried
annotation - the type of the queried annotation
Returns:
the meta data/annotation of type annotation that apply to m

resolveAnnotation

public Object resolveAnnotation(Method m,
                                Class<?>[] annotationChoices)
Returns an object representing the method m annotation whose type is one of the elements in annotationChoices, if m has such annotation.

Parameters:
m - the method whose annotation is being queried
annotationChoices - the queried annotation must have one of the types contained in this array
Returns:
the meta data/annotation that apply to m whose type is in annotationChoices

resolveTypedAnnotation

public <T extends Annotation> T resolveTypedAnnotation(Method m,
                                                       Class<T>[] annotationChoices)
Returns an object representing the method m annotation whose type is one of the elements in annotationChoices, if m has such annotation.

Parameters:
m - the method whose annotation is being queried
annotationChoices - the queried annotation must have one of the types contained in this array
Returns:
the meta data/annotation that apply to m whose type is in annotationChoices

resolveAnnotation

public Object resolveAnnotation(Field f,
                                Class<? extends Annotation> annotation)

resolveTypedAnnotation

public <T extends Annotation> T resolveTypedAnnotation(Field f,
                                                       Class<T> annotation)

resolveAnnotation

public Object resolveAnnotation(Constructor<?> c,
                                Class<? extends Annotation> annotation)

resolveTypedAnnotation

public <T extends Annotation> T resolveTypedAnnotation(Constructor<?> c,
                                                       Class<T> annotation)

hasAnnotation

public boolean hasAnnotation(Method m,
                             String annotation)

hasAnnotation

public boolean hasAnnotation(Method m,
                             Class<? extends Annotation> annotation)

hasAnnotation

public boolean hasAnnotation(Field m,
                             Class<? extends Annotation> annotation)

hasAnnotation

public boolean hasAnnotation(Field m,
                             String annotation)

hasAnnotation

public boolean hasAnnotation(Constructor<?> m,
                             String annotation)

hasAnnotation

public boolean hasAnnotation(javassist.CtClass clazz,
                             String annotation)

hasAnnotation

public boolean hasAnnotation(javassist.CtMethod member,
                             String annotation)

hasAnnotation

public boolean hasAnnotation(javassist.CtField member,
                             String annotation)

hasAnnotation

public boolean hasAnnotation(javassist.CtConstructor member,
                             String annotation)

getMetadata

public org.jboss.metadata.spi.MetaData getMetadata()
Get the metadata

Returns:
the metadata

setMetadata

public void setMetadata(org.jboss.metadata.spi.MetaData metadata)
Set the metadata

Parameters:
metadata - the metadata

getName

public String getName()

hasAspects

public final boolean hasAspects()

removeAdviceBinding

public void removeAdviceBinding(AdviceBinding binding)

removeAdviceBindings

public void removeAdviceBindings(ArrayList<AdviceBinding> bindings)

newBindingAdded

public void newBindingAdded()
a new binding has been added to the AspectManager, recalculate interceptors


newBindingAdded

public void newBindingAdded(AdviceBinding binding)

getInterfaceIntroductions

public ArrayList<InterfaceIntroduction> getInterfaceIntroductions()

addInterfaceIntroduction

public void addInterfaceIntroduction(InterfaceIntroduction pointcut)

removeInterfaceIntroduction

public void removeInterfaceIntroduction(InterfaceIntroduction pointcut)

rebuildInterceptors

protected abstract void rebuildInterceptors()

rebuildInterceptorsForAddedBinding

protected abstract void rebuildInterceptorsForAddedBinding(AdviceBinding binding)

rebuildInterceptorsForRemovedBinding

protected abstract void rebuildInterceptorsForRemovedBinding(AdviceBinding removedBinding)

adjustInfoForAddedBinding

protected final void adjustInfoForAddedBinding(JoinPointInfo info)
If the info was updated in response to a rebuildInterceptorsForAddedBinding call it will have the original interceptors in the interceptors array, and the appended interceptors in the interceptorChain List. We need to merge the two so that all the interceptors appear in the interceptorChain List before finalizing the chain


addClassMetaData

public abstract void addClassMetaData(ClassMetaDataBinding data)

removeClassMetaData

public abstract void removeClassMetaData(ClassMetaDataBinding data)

getPerVMAspect

public Object getPerVMAspect(AspectDefinition def)

addPerInstanceAspect

public void addPerInstanceAspect(AspectDefinition def)

removePerInstanceAspect

public void removePerInstanceAspect(AspectDefinition def)

getPerInstanceAspectDefinitions

public Set<AspectDefinition> getPerInstanceAspectDefinitions()

addPerInstanceJoinpointAspect

public void addPerInstanceJoinpointAspect(Joinpoint joinpoint,
                                          AspectDefinition def)

removePerInstanceJoinpointAspect

public void removePerInstanceJoinpointAspect(AspectDefinition def)

getPerInstanceJoinpointAspectDefinitions

public Map<AspectDefinition,Set<Joinpoint>> getPerInstanceJoinpointAspectDefinitions()

getPerClassAspect

public Object getPerClassAspect(AspectDefinition def)

getPerClassAspect

public Object getPerClassAspect(String def)

addPerClassAspect

public void addPerClassAspect(AspectDefinition def)

removePerClassAspect

public void removePerClassAspect(AspectDefinition def)

getAdviceInterceptor

public Interceptor getAdviceInterceptor(AspectDefinition def,
                                        String adviceName,
                                        Joinpoint joinpoint)

addAdviceInterceptor

public void addAdviceInterceptor(AspectDefinition def,
                                 String adviceName,
                                 Interceptor interceptor,
                                 Joinpoint joinpoint)

createInterceptorChain

protected void createInterceptorChain(InterceptorFactory[] factories,
                                      ArrayList<Interceptor> newinterceptors,
                                      Joinpoint joinpoint)

resolveMethodPointcut

protected void resolveMethodPointcut(AdviceBinding binding)

updateMethodPointcutAfterRemove

protected void updateMethodPointcutAfterRemove(AdviceBinding binding)

updateFieldPointcutAfterRemove

protected void updateFieldPointcutAfterRemove(FieldInfo[] fieldInfos,
                                              AdviceBinding binding,
                                              boolean write)

updateFieldPointcutAfterRemove

protected void updateFieldPointcutAfterRemove(FieldInfo fieldInfo,
                                              int i,
                                              boolean write)

updateConstructorPointcutAfterRemove

protected void updateConstructorPointcutAfterRemove(AdviceBinding binding)

updateConstructionPointcutAfterRemove

protected void updateConstructionPointcutAfterRemove(AdviceBinding binding)

lockWriteChain

protected void lockWriteChain(MethodInterceptors methodInterceptors)

unlockWriteChain

protected void unlockWriteChain(MethodInterceptors methodInterceptors)

resetChain

protected void resetChain(MethodInterceptors methodInterceptors)

resetChainKeepInterceptors

protected void resetChainKeepInterceptors(MethodInterceptors methodInterceptors)

finalizeMethodChain

protected void finalizeMethodChain()

dynamicInvoke

public InvocationResponse dynamicInvoke(Object target,
                                        Invocation invocation)
                                 throws Throwable
Throws:
Throwable

getClazz

public Class getClazz()
EJB3 counts on this being unchecked


getClassLoader

public ClassLoader getClassLoader()
Returns the class loader associated with this advisor.

Returns:
the class loader that loaded all joinpoints contained in the advised context.

getSimpleName

public static String getSimpleName(Class<?> clazz)
Deprecated. Use Class.getSimpleName() instead


initializeConstructorChain

protected void initializeConstructorChain()

initializeConstructionChain

protected void initializeConstructionChain()

finalizeChain

protected void finalizeChain(JoinPointInfo[] infos)

lockWriteChain

protected void lockWriteChain(JoinPointInfo[] infos)

unlockWriteChain

protected void unlockWriteChain(JoinPointInfo[] infos)

resetChain

protected void resetChain(JoinPointInfo[] infos)

resetChainKeepInterceptors

protected void resetChainKeepInterceptors(JoinPointInfo[] infos)

resolveConstructorPointcut

protected void resolveConstructorPointcut(AdviceBinding binding)

resolveConstructionPointcut

protected void resolveConstructionPointcut(AdviceBinding binding)

populateInterceptorsFromInfos

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


pointcutResolved

protected void pointcutResolved(JoinPointInfo info,
                                AdviceBinding binding,
                                Joinpoint joinpoint)
Default implementation adds interceptorChain directly to the info. GeneratedClassAdvisor overrides this


chainOverridingForInheritedMethods

public boolean chainOverridingForInheritedMethods()
Whether the type of advisor supports matching on pointcut expression, where the method is defined in a superclass only, while the pointcut expression class matches the subclass. This is currently only supported for generated advisors, due to the new weaving model. So (with generated advisors) if we have

public class Super {
  void method(){}
}

public class Sub etxends Super {
}
and
<bind pointcut="execution(* Super->method())">
  <interceptor class="A"/>
</bind>
<bind pointcut="execution(* sub->method())">
  <interceptor class="B"/>
</bind>

Super.method() will be intercepted by A only
Sub.method() will be intercepted by A and B


setChainOverridingForInheritedMethods

protected void setChainOverridingForInheritedMethods(boolean overriding)
Parameters:
overriding - the new value of chainOverridingForInheritedMethods
See Also:
chainOverridingForInheritedMethods()

cleanup

public void cleanup()

initInterfaceIntroductionsList

protected void initInterfaceIntroductionsList()

initClassMetaDataBindingsList

protected void initClassMetaDataBindingsList()

initPerInstanceAspectDefinitionsSet

protected void initPerInstanceAspectDefinitionsSet()

initPerInstanceJoinpointAspectDefinitionsMap

protected void initPerInstanceJoinpointAspectDefinitionsMap()

initAdvisedMethodsMap

protected void initAdvisedMethodsMap()

hasSameMethodAspectLength

public boolean hasSameMethodAspectLength(Advisor other)

hasSameConstructorAspectLength

public boolean hasSameConstructorAspectLength(Advisor other)


Copyright © 2008 JBoss, a division of Red Hat, Inc.. All Rights Reserved.