org.codehaus.nanning
Class AspectInstance

java.lang.Object
  extended byorg.codehaus.nanning.AspectInstance
All Implemented Interfaces:
java.lang.reflect.InvocationHandler, java.io.Serializable

public final class AspectInstance
extends java.lang.Object
implements java.lang.reflect.InvocationHandler, java.io.Serializable

The central concept of the Nanning Core, contains mixins. Use like this:


 AspectInstance instance = new AspectInstance();
 Mixin mixin = new Mixin();
 mixin.setInterfaceClass(Intf.class);
 mixin.addInterceptor(new MockInterceptor());
 mixin.addInterceptor(new NullInterceptor());
 mixin.setTarget(new Impl());
 instance.addMixin(mixin);
 

Version:
$Revision: 1.2 $
Author:
$Author: lecando $
See Also:
Serialized Form

Nested Class Summary
 class AspectInstance.ConstructionInvocationImpl
           
 
Constructor Summary
AspectInstance()
           
AspectInstance(AspectFactory aspectFactory, java.lang.Class classIdentifier)
           
AspectInstance(java.lang.Class classIdentifier)
           
 
Method Summary
 void addConstructionInterceptor(ConstructionInterceptor constructionInterceptor)
          Adds a ConstructionInterceptor, the interceptor will be invoked when creating the proxy in getProxy().
 void addInterceptor(MethodInterceptor interceptor)
           
 void addMixin(Mixin mixin)
          Adds a mixin.
 java.util.Set getAllInterceptors()
          Returns all the interceptors referenced by this aspect instance.
 AspectFactory getAspectFactory()
          Returns the AspectFactory used to create and configure this AspectInstance (if set by the AspectFactory).
 java.lang.Class getClassIdentifier()
           
 java.util.List getInterceptorsForMethod(java.lang.reflect.Method method)
          Returns the interceptors of the specified method, searches in the mixin for the interface that the method has been declared on.
 Mixin getMixinForInterface(java.lang.Class interfaceClass)
          Returns the mixin with the specified interface.
 java.util.List getMixins()
          Returns all mixins defined on this AspectInstance.
 java.lang.Object getProxy()
           
 java.lang.Object[] getTargets()
           
 boolean hasMixinForInterface(java.lang.Class interfaceClass)
           
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
           
 void setMixins(java.util.List mixinsList)
           
 void setTarget(java.lang.Class interfaceClass, java.lang.Object target)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AspectInstance

public AspectInstance()

AspectInstance

public AspectInstance(AspectFactory aspectFactory,
                      java.lang.Class classIdentifier)

AspectInstance

public AspectInstance(java.lang.Class classIdentifier)
Method Detail

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Throws:
java.lang.Throwable

getMixinForInterface

public Mixin getMixinForInterface(java.lang.Class interfaceClass)
Returns the mixin with the specified interface.

Parameters:
interfaceClass -
Returns:

hasMixinForInterface

public boolean hasMixinForInterface(java.lang.Class interfaceClass)

setTarget

public void setTarget(java.lang.Class interfaceClass,
                      java.lang.Object target)

getTargets

public java.lang.Object[] getTargets()

getClassIdentifier

public java.lang.Class getClassIdentifier()

addMixin

public void addMixin(Mixin mixin)
Adds a mixin.

Parameters:
mixin -

setMixins

public void setMixins(java.util.List mixinsList)

getAllInterceptors

public java.util.Set getAllInterceptors()
Returns all the interceptors referenced by this aspect instance. That is all interceptors of all methods of all mixins, invluding the construction-interceptors.

Returns:

getInterceptorsForMethod

public java.util.List getInterceptorsForMethod(java.lang.reflect.Method method)
Returns the interceptors of the specified method, searches in the mixin for the interface that the method has been declared on.

Parameters:
method -
Returns:

getAspectFactory

public final AspectFactory getAspectFactory()
Returns the AspectFactory used to create and configure this AspectInstance (if set by the AspectFactory).

Returns:

getProxy

public java.lang.Object getProxy()

toString

public java.lang.String toString()

getMixins

public java.util.List getMixins()
Returns all mixins defined on this AspectInstance.

Returns:

addConstructionInterceptor

public void addConstructionInterceptor(ConstructionInterceptor constructionInterceptor)
Adds a ConstructionInterceptor, the interceptor will be invoked when creating the proxy in getProxy().


addInterceptor

public void addInterceptor(MethodInterceptor interceptor)


Copyright © Jon Tirsen. All Rights Reserved.