org.codehaus.nanning
Class Mixin

java.lang.Object
  extended byorg.codehaus.nanning.Mixin
All Implemented Interfaces:
java.io.Serializable

public class Mixin
extends java.lang.Object
implements java.io.Serializable

A mixin consists of an interface, a target and a number of interceptors intercepting calls to methods, a mixin can also be a concrete class (no interface/implementation-separation) but at most one mixins with conrete classes per AspectInstance is supported. Create a mixin with interface and target:


new MixinInstance(Interface.class, new Target());
Create a mixin with a concrete class:

new MixinInstance(Target.class);
Add interceptor to method:

Method method = Target.class.getMethod("method", null);
MixinInstance mixin = new MixinInstance(Target.class);
mixin.addInterceptor(method, new MethodInterceptor() {
    public Object invoke(Invocation invocation) {
        return invocation.invokeNext();
    }
}

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

Nested Class Summary
protected  class Mixin.InvocationImpl
           
 
Constructor Summary
Mixin()
           
Mixin(java.lang.Class interfaceClass, java.lang.Object target)
           
 
Method Summary
 void addInterceptor(MethodInterceptor interceptor)
          Add interceptor to all methods of the mixin.
 void addInterceptor(java.lang.reflect.Method method, MethodInterceptor interceptor)
          Add interceptor to specified method.
 boolean equals(java.lang.Object o)
           
 java.util.Set getAllInterceptors()
           
 java.lang.reflect.Method[] getAllMethods()
           
 java.util.List getInterceptorsForMethod(java.lang.reflect.Method method)
           
 java.lang.Class getInterfaceClass()
           
 java.lang.Class getMainClass()
           
 java.lang.Object getTarget()
           
 int hashCode()
           
 java.lang.Object invokeMethod(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
           
 boolean isMainMixin()
           
 void setInterfaceClass(java.lang.Class interfaceClass)
           
 void setTarget(java.lang.Object target)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Mixin

public Mixin()

Mixin

public Mixin(java.lang.Class interfaceClass,
             java.lang.Object target)
Method Detail

setInterfaceClass

public void setInterfaceClass(java.lang.Class interfaceClass)

setTarget

public void setTarget(java.lang.Object target)

getInterfaceClass

public java.lang.Class getInterfaceClass()

getAllInterceptors

public java.util.Set getAllInterceptors()

getTarget

public java.lang.Object getTarget()

getInterceptorsForMethod

public java.util.List getInterceptorsForMethod(java.lang.reflect.Method method)

getMainClass

public java.lang.Class getMainClass()

invokeMethod

public java.lang.Object invokeMethod(java.lang.Object proxy,
                                     java.lang.reflect.Method method,
                                     java.lang.Object[] args)
                              throws java.lang.Throwable
Throws:
java.lang.Throwable

isMainMixin

public boolean isMainMixin()

addInterceptor

public void addInterceptor(MethodInterceptor interceptor)
Add interceptor to all methods of the mixin.

Parameters:
interceptor -

equals

public boolean equals(java.lang.Object o)

hashCode

public int hashCode()

addInterceptor

public void addInterceptor(java.lang.reflect.Method method,
                           MethodInterceptor interceptor)
Add interceptor to specified method.

Parameters:
method -
interceptor -

getAllMethods

public java.lang.reflect.Method[] getAllMethods()

toString

public java.lang.String toString()


Copyright © Jon Tirsen. All Rights Reserved.