org.jboss.aop
Class Advisor

java.lang.Object
  extended byorg.jboss.aop.Advisor
Direct Known Subclasses:
ClassAdvisor, ClassContainer

public abstract class Advisor
extends Object

Version:
$Revision: 1.87 $
Author:
Bill Burke

Field Summary
protected  HashSet adviceBindings
           
protected  HashMap adviceInterceptors
           
protected  gnu.trove.TLongObjectHashMap advisedMethods
           
protected  AnnotationRepository annotations
           
protected  EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap aspects
           
protected  HashMap classAnnotations
           
protected  SimpleMetaData classMetaData
           
protected  ArrayList classMetaDataBindings
           
protected  Class clazz
           
protected  ConstructionInfo[] constructionInfos
           
protected  Interceptor[][] constructionInterceptors
          Deprecated. Use constructorInfos instead
protected  ConstructorInfo[] constructorInfos
           
protected  Interceptor[][] constructorInterceptors
          Deprecated. Use constructorInfos instead
protected  ConstructorMetaData constructorMetaData
           
protected  Constructor[] constructors
           
protected  SimpleMetaData defaultMetaData
           
protected  boolean doesHaveAspects
           
protected  FieldMetaData fieldMetaData
           
protected  ArrayList interfaceIntroductions
           
protected  AspectManager manager
           
protected  gnu.trove.TLongObjectHashMap methodInterceptors
           
protected  MethodMetaData methodMetaData
           
protected  String name
           
protected  EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArraySet perInstanceAspectDefinitions
           
protected  EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap perInstanceJoinpointAspectDefinitions
           
 
Constructor Summary
Advisor(String name, AspectManager manager)
           
 
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  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.
protected  void createInterceptorChain(InterceptorFactory[] factories, ArrayList newinterceptors, Joinpoint joinpoint)
           
 void deployAnnotationOverride(AnnotationIntroduction introduction)
           
 void deployAnnotationOverrides()
           
protected  void deployMethodAnnotationOverrides(Class theClass, AnnotationIntroduction introduction)
           
 InvocationResponse dynamicInvoke(Object target, Invocation invocation)
           
protected  void finalizeConstructionChain(ArrayList newConstructionInfos)
           
protected  void finalizeConstructorChain(ArrayList newConstructorInfos)
           
protected  void finalizeMethodChain(gnu.trove.TLongObjectHashMap newMethodInterceptors)
           
 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()
           
 SimpleMetaData getClassMetaData()
           
 List getClassMetadataBindings()
           
 Class getClazz()
           
 ConstructionInfo[] getConstructionInfos()
           
 Interceptor[][] getConstructionInterceptors()
          Deprecated. Use getConstructionInfos instead
 ConstructorInfo[] getConstructorInfos()
           
 Interceptor[][] getConstructorInterceptors()
          Deprecated. Use getConstructorInfos instead
 ConstructorMetaData getConstructorMetaData()
           
 Constructor[] getConstructors()
           
 SimpleMetaData getDefaultMetaData()
           
 FieldMetaData getFieldMetaData()
           
 ArrayList getInterfaceIntroductions()
           
 AspectManager getManager()
           
 org.jboss.repository.spi.MetaDataContext getMetadataContext()
           
 MethodInfo getMethodInfo(long hash)
           
 MethodMetaData getMethodMetaData()
           
 String getName()
           
 Object getPerClassAspect(AspectDefinition def)
           
 Object getPerClassAspect(String def)
           
 Set getPerInstanceAspectDefinitions()
           
 Map getPerInstanceJoinpointAspectDefinitions()
           
static String getSimpleName(Class clazz)
           
 boolean hasAnnotation(Class tgt, String 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, String annotation)
           
 boolean hasAnnotation(Method m, String annotation)
           
 boolean hasAnnotation(String annotation)
           
 boolean hasAspects()
           
protected  ArrayList initializeConstructionChain()
           
protected  ArrayList initializeConstructorChain()
           
protected  void initializeInterfaceIntroductions(Class theClass)
           
 void newBindingAdded()
          a new binding has been added to the AspectManager, recalculate interceptors
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()
           
 void removeAdviceBinding(AdviceBinding binding)
           
 void removeAdviceBindings(ArrayList bindings)
           
abstract  void removeClassMetaData(ClassMetaDataBinding data)
           
 void removeInterfaceIntroduction(InterfaceIntroduction pointcut)
           
 void removePerClassAspect(AspectDefinition def)
           
 void removePerInstanceAspect(AspectDefinition def)
           
 void removePerInstanceJoinpointAspect(AspectDefinition def)
           
 Object resolveAnnotation(Class annotation)
           
 Object resolveAnnotation(Constructor c, Class annotation)
           
 Object resolveAnnotation(Field f, Class annotation)
           
 Object resolveAnnotation(Method m, Class annotation)
           
 Object resolveAnnotation(Method m, Class[] annotationChoices)
           
protected  void resolveConstructionPointcut(ArrayList newConstructionInfos, AdviceBinding binding)
           
protected  void resolveConstructorPointcut(ArrayList newConstructorInfos, AdviceBinding binding)
           
protected  void resolveMethodPointcut(gnu.trove.TLongObjectHashMap newMethodInterceptors, AdviceBinding binding)
           
protected  void setManager(AspectManager manager)
          For use by generated advisors.
 void setMetadataContext(org.jboss.repository.spi.MetaDataContext metadataContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

adviceBindings

protected HashSet adviceBindings

interfaceIntroductions

protected ArrayList interfaceIntroductions

classMetaDataBindings

protected ArrayList classMetaDataBindings

defaultMetaData

protected SimpleMetaData defaultMetaData

methodMetaData

protected MethodMetaData methodMetaData

fieldMetaData

protected FieldMetaData fieldMetaData

classMetaData

protected SimpleMetaData classMetaData

constructorMetaData

protected ConstructorMetaData constructorMetaData

classAnnotations

protected HashMap classAnnotations

annotations

protected AnnotationRepository annotations

doesHaveAspects

protected boolean doesHaveAspects

name

protected String name

aspects

protected EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap aspects

adviceInterceptors

protected HashMap adviceInterceptors

perInstanceAspectDefinitions

protected EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArraySet perInstanceAspectDefinitions

perInstanceJoinpointAspectDefinitions

protected EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap perInstanceJoinpointAspectDefinitions

advisedMethods

protected gnu.trove.TLongObjectHashMap advisedMethods

methodInterceptors

protected gnu.trove.TLongObjectHashMap methodInterceptors

manager

protected AspectManager manager

clazz

protected Class clazz

constructors

protected Constructor[] constructors

constructorInterceptors

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


constructorInfos

protected ConstructorInfo[] constructorInfos

constructionInterceptors

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


constructionInfos

protected ConstructionInfo[] constructionInfos
Constructor Detail

Advisor

public Advisor(String name,
               AspectManager manager)
Method Detail

getMethodInfo

public MethodInfo getMethodInfo(long hash)

getConstructors

public Constructor[] getConstructors()

getConstructorInterceptors

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


getConstructorInfos

public ConstructorInfo[] getConstructorInfos()

getConstructionInterceptors

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


getConstructionInfos

public ConstructionInfo[] getConstructionInfos()

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()

setManager

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


getClassMetadataBindings

public List getClassMetadataBindings()

getClassMetaData

public SimpleMetaData getClassMetaData()

getDefaultMetaData

public SimpleMetaData getDefaultMetaData()

getMethodMetaData

public MethodMetaData getMethodMetaData()

getFieldMetaData

public FieldMetaData getFieldMetaData()

getConstructorMetaData

public ConstructorMetaData getConstructorMetaData()

deployAnnotationOverrides

public void deployAnnotationOverrides()

deployAnnotationOverride

public void deployAnnotationOverride(AnnotationIntroduction introduction)

initializeInterfaceIntroductions

protected void initializeInterfaceIntroductions(Class theClass)

deployMethodAnnotationOverrides

protected void deployMethodAnnotationOverrides(Class theClass,
                                               AnnotationIntroduction introduction)

getAnnotations

public AnnotationRepository getAnnotations()

resolveAnnotation

public Object resolveAnnotation(Class annotation)

hasAnnotation

public boolean hasAnnotation(String annotation)

hasAnnotation

public boolean hasAnnotation(Class tgt,
                             String annotation)

resolveAnnotation

public Object resolveAnnotation(Method m,
                                Class annotation)

resolveAnnotation

public Object resolveAnnotation(Method m,
                                Class[] annotationChoices)

resolveAnnotation

public Object resolveAnnotation(Field f,
                                Class annotation)

resolveAnnotation

public Object resolveAnnotation(Constructor c,
                                Class annotation)

hasAnnotation

public boolean hasAnnotation(Method m,
                             String 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)

getMetadataContext

public org.jboss.repository.spi.MetaDataContext getMetadataContext()

setMetadataContext

public void setMetadataContext(org.jboss.repository.spi.MetaDataContext metadataContext)

getName

public String getName()

hasAspects

public final boolean hasAspects()

removeAdviceBinding

public void removeAdviceBinding(AdviceBinding binding)

removeAdviceBindings

public void removeAdviceBindings(ArrayList bindings)

newBindingAdded

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


getInterfaceIntroductions

public ArrayList getInterfaceIntroductions()

addInterfaceIntroduction

public void addInterfaceIntroduction(InterfaceIntroduction pointcut)

removeInterfaceIntroduction

public void removeInterfaceIntroduction(InterfaceIntroduction pointcut)

rebuildInterceptors

protected abstract void rebuildInterceptors()

addClassMetaData

public abstract void addClassMetaData(ClassMetaDataBinding data)

removeClassMetaData

public abstract void removeClassMetaData(ClassMetaDataBinding data)

addPerInstanceAspect

public void addPerInstanceAspect(AspectDefinition def)

removePerInstanceAspect

public void removePerInstanceAspect(AspectDefinition def)

getPerInstanceAspectDefinitions

public Set getPerInstanceAspectDefinitions()

addPerInstanceJoinpointAspect

public void addPerInstanceJoinpointAspect(Joinpoint joinpoint,
                                          AspectDefinition def)

removePerInstanceJoinpointAspect

public void removePerInstanceJoinpointAspect(AspectDefinition def)

getPerInstanceJoinpointAspectDefinitions

public Map 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 newinterceptors,
                                      Joinpoint joinpoint)

resolveMethodPointcut

protected void resolveMethodPointcut(gnu.trove.TLongObjectHashMap newMethodInterceptors,
                                     AdviceBinding binding)

finalizeMethodChain

protected void finalizeMethodChain(gnu.trove.TLongObjectHashMap newMethodInterceptors)

dynamicInvoke

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

getClazz

public Class getClazz()

getSimpleName

public static String getSimpleName(Class clazz)

initializeConstructorChain

protected ArrayList initializeConstructorChain()

initializeConstructionChain

protected ArrayList initializeConstructionChain()

finalizeConstructorChain

protected void finalizeConstructorChain(ArrayList newConstructorInfos)

finalizeConstructionChain

protected void finalizeConstructionChain(ArrayList newConstructionInfos)

resolveConstructorPointcut

protected void resolveConstructorPointcut(ArrayList newConstructorInfos,
                                          AdviceBinding binding)

resolveConstructionPointcut

protected void resolveConstructionPointcut(ArrayList newConstructionInfos,
                                           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

protected 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



Copyright © 2004 JBoss Inc. All Rights Reserved.