org.jboss.aop
Class GeneratedInstanceAdvisorMixin

java.lang.Object
  extended by org.jboss.aop.GeneratedInstanceAdvisorMixin
All Implemented Interfaces:
Serializable, InstanceAdvisor

public class GeneratedInstanceAdvisorMixin
extends Object
implements InstanceAdvisor, Serializable

Adapts the old instance advisor api to the new generated advisor stuff. Old API calls on generated instance advisors will delegate to this class

Version:
$Revision$
Author:
Kabir Khan
See Also:
Serialized Form

Nested Class Summary
 class GeneratedInstanceAdvisorMixin.InstanceInterceptorFactory
           
 
Field Summary
protected  ArrayList<Interceptor> appendedInterceptors
           
 boolean hasInstanceAspects
           
protected  ArrayList<Interceptor> insertedInterceptors
           
protected  WeakReference<Object> instanceRef
           
 
Constructor Summary
GeneratedInstanceAdvisorMixin()
           
GeneratedInstanceAdvisorMixin(Object instance, GeneratedClassAdvisor genadvisor)
           
 
Method Summary
 void appendInterceptor(Interceptor interceptor)
          Appends an interceptor to the end of the instance's interceptor chain.
 void appendInterceptor(int index, Interceptor interceptor)
          Appends an interceptor at position index of the appended instance's interceptor chain.
 void appendInterceptorStack(String stackName)
          Appends an interceptor chain to the end of the instance's interceptor chain.
protected  void finalize()
          Added to notify interceptor chain observer of interceptor chain garbage collection.
 Domain getDomain()
          Returns the domain where this advisor belongs.
 Object getInstance()
          Returns the advised instance managed by this advisor.
 Interceptor[] getInterceptors()
          Returns the interceptor chain of the advised instance.
 Interceptor[] getInterceptors(Interceptor[] advisorChain)
          Called by the advisor
 SimpleMetaData getMetaData()
          Returns the metadata bound to the advised instance.
 Object getPerInstanceAspect(AspectDefinition def)
          Returns a per instance aspect object defined by def.
 Object getPerInstanceAspect(String def)
          Returns a per instance aspect object identified by aspectName.
 Object getPerInstanceJoinpointAspect(Joinpoint joinpoint, AspectDefinition def)
          Returns the per instance joinpoint aspect object defined by def to be applied at joipoint.
 GeneratedAdvisorInterceptor[] getWrappers()
           
 Interceptor[] getWrappers(Interceptor[] advisorChain)
          Called by the advisor
 boolean hasAspects()
          Indicates whether there are instance aspects bound to the instance advised.
 boolean hasInterceptors()
          Indicates if the advised instance interceptor chain is not empty.
 void insertInterceptor(Interceptor interceptor)
          Inserts an interceptor at the beginning of the instance's interceptor chain.
 void insertInterceptor(int index, Interceptor interceptor)
          Inserts an interceptor at position index of the inserted instance's interceptor chain.
 void insertInterceptorStack(String stackName)
          Inserts an interceptor stack to the beginning of the instance's interceptor chain.
 void removeInterceptor(String name)
          This will not remove interceptor pointcuts! You will have to do this through AspectManager
 void removeInterceptorStack(String stackName)
          Removes an interceptor stack from the instance's interceptor chain.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

insertedInterceptors

protected ArrayList<Interceptor> insertedInterceptors

appendedInterceptors

protected ArrayList<Interceptor> appendedInterceptors

instanceRef

protected WeakReference<Object> instanceRef

hasInstanceAspects

public boolean hasInstanceAspects
Constructor Detail

GeneratedInstanceAdvisorMixin

public GeneratedInstanceAdvisorMixin()

GeneratedInstanceAdvisorMixin

public GeneratedInstanceAdvisorMixin(Object instance,
                                     GeneratedClassAdvisor genadvisor)
Method Detail

hasInterceptors

public boolean hasInterceptors()
Description copied from interface: InstanceAdvisor
Indicates if the advised instance interceptor chain is not empty.

Specified by:
hasInterceptors in interface InstanceAdvisor
Returns:
true if the advised instance interceptor chain contains one or more elements.

getPerInstanceAspect

public Object getPerInstanceAspect(String def)
Description copied from interface: InstanceAdvisor
Returns a per instance aspect object identified by aspectName.
Notice that the aspect objects are created by JBoss AOP, either by using an aspect factory or by using the constructor of an aspect class.

For internal use only.

Specified by:
getPerInstanceAspect in interface InstanceAdvisor
Parameters:
def - name of the queried aspect
Returns:
the per instance aspect named aspectName

getPerInstanceAspect

public Object getPerInstanceAspect(AspectDefinition def)
Description copied from interface: InstanceAdvisor
Returns a per instance aspect object defined by def.
Notice that the aspect objects are created by JBoss AOP, either by using an aspect factory or by using the constructor of an aspect class.

For internal use only.

Specified by:
getPerInstanceAspect in interface InstanceAdvisor
Parameters:
def - definition of the queried aspect
Returns:
the per instance aspect defined by def

getPerInstanceJoinpointAspect

public Object getPerInstanceJoinpointAspect(Joinpoint joinpoint,
                                            AspectDefinition def)
Description copied from interface: InstanceAdvisor
Returns the per instance joinpoint aspect object defined by def to be applied at joipoint.
Notice that the aspect objects are created by JBoss AOP, either by using an aspect factory or by using the constructor of an aspect class.

For internal use only.

Specified by:
getPerInstanceJoinpointAspect in interface InstanceAdvisor
Parameters:
joinpoint - the joinpoint to which the aspect object will be applied.
def - definition of the queried aspect
Returns:
the per instance joinpoint aspect defined by def to be applied at joinpoint

getMetaData

public SimpleMetaData getMetaData()
Description copied from interface: InstanceAdvisor
Returns the metadata bound to the advised instance.

Specified by:
getMetaData in interface InstanceAdvisor
Returns:
the metadata bound to the advised instance.

getInterceptors

public Interceptor[] getInterceptors()
Description copied from interface: InstanceAdvisor
Returns the interceptor chain of the advised instance.

For internal use only.

Specified by:
getInterceptors in interface InstanceAdvisor
Returns:
the interceptor chain of the advised instance.

getInterceptors

public Interceptor[] getInterceptors(Interceptor[] advisorChain)
Called by the advisor

Specified by:
getInterceptors in interface InstanceAdvisor
Parameters:
advisorChain - the chain to be joined with the advised instance's chain.
Returns:
a new interception chain as a result of the merge of baseChain with the instance's chain. May return baseChain if the last one is empty.

getWrappers

public GeneratedAdvisorInterceptor[] getWrappers()

getWrappers

public Interceptor[] getWrappers(Interceptor[] advisorChain)
Called by the advisor

Parameters:
An - array of GeneratedAdvisorInterceptor from the advisor's intereceptor chain for the joinpoint
Returns:
The advisor's original array along with extra GeneratedAdvisorInterceptors appended/prepended to this instance

insertInterceptor

public void insertInterceptor(int index,
                              Interceptor interceptor)
Description copied from interface: InstanceAdvisor
Inserts an interceptor at position index of the inserted instance's interceptor chain.

Specified by:
insertInterceptor in interface InstanceAdvisor
Parameters:
index - the position where to insert interceptor. This value must not be greater than or equal to the number of inserted interceptors in the chain.
interceptor - the interceptor to be added to the instance's chain.

insertInterceptor

public void insertInterceptor(Interceptor interceptor)
Description copied from interface: InstanceAdvisor
Inserts an interceptor at the beginning of the instance's interceptor chain.

Specified by:
insertInterceptor in interface InstanceAdvisor
Parameters:
interceptor - the interceptor to be added to the instance's chain.

appendInterceptor

public void appendInterceptor(Interceptor interceptor)
Description copied from interface: InstanceAdvisor
Appends an interceptor to the end of the instance's interceptor chain.

Specified by:
appendInterceptor in interface InstanceAdvisor
Parameters:
interceptor - the interceptor to be appended to the instance's chain

appendInterceptor

public void appendInterceptor(int index,
                              Interceptor interceptor)
Description copied from interface: InstanceAdvisor
Appends an interceptor at position index of the appended instance's interceptor chain.

Specified by:
appendInterceptor in interface InstanceAdvisor
Parameters:
index - the position where to insert interceptor. This value must not be greater than or equal to the number of appended interceptors in the chain.
interceptor - the interceptor to be added to the instance's chain.

removeInterceptor

public void removeInterceptor(String name)
This will not remove interceptor pointcuts! You will have to do this through AspectManager

Specified by:
removeInterceptor in interface InstanceAdvisor
Parameters:
name - name of the interceptor to be removed from the chain.
See Also:
Interceptor.getName()

hasAspects

public final boolean hasAspects()
Description copied from interface: InstanceAdvisor
Indicates whether there are instance aspects bound to the instance advised. In other words, this method returns the same as InstanceAdvisor.hasInterceptors().

Specified by:
hasAspects in interface InstanceAdvisor
Returns:
true if there is one or more aspects bound to this advised instance.

insertInterceptorStack

public void insertInterceptorStack(String stackName)
Description copied from interface: InstanceAdvisor
Inserts an interceptor stack to the beginning of the instance's interceptor chain.

Specified by:
insertInterceptorStack in interface InstanceAdvisor
Parameters:
stackName - the name that identifies the interceptor stack to be inserted

appendInterceptorStack

public void appendInterceptorStack(String stackName)
Description copied from interface: InstanceAdvisor
Appends an interceptor chain to the end of the instance's interceptor chain.

Specified by:
appendInterceptorStack in interface InstanceAdvisor
Parameters:
stackName - the name that identifies the interceptor stack to be appended

removeInterceptorStack

public void removeInterceptorStack(String stackName)
Description copied from interface: InstanceAdvisor
Removes an interceptor stack from the instance's interceptor chain.

Specified by:
removeInterceptorStack in interface InstanceAdvisor
Parameters:
stackName - the name that identifies the interceptor stack to be removed

getDomain

public Domain getDomain()
Description copied from interface: InstanceAdvisor
Returns the domain where this advisor belongs. The domain contains all the configured AOP features (like bindings, aspects, and introductions) that should be applied to the advised instance.

Specified by:
getDomain in interface InstanceAdvisor
Returns:
the domain bound to this advisor

finalize

protected void finalize()
Added to notify interceptor chain observer of interceptor chain garbage collection.

Overrides:
finalize in class Object

getInstance

public Object getInstance()
Description copied from interface: InstanceAdvisor
Returns the advised instance managed by this advisor.

Specified by:
getInstance in interface InstanceAdvisor
Returns:
the advised instance


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