dynaop
Class DispatchInterceptor

java.lang.Object
  extended by dynaop.DispatchInterceptor
All Implemented Interfaces:
Interceptor, java.io.Serializable

public abstract class DispatchInterceptor
extends java.lang.Object
implements Interceptor, java.io.Serializable

Dispatches to method in interceptor with the same signature as the intercepted method. If none exists, simply proceeds with invocation. The dispatch methods may throw Throwable even when the intercepted method does not. For example:

 public class SetIdInterceptor extends DispatchInterceptor {
 
   public void setId(long id) throws Throwable {
     proceed();
     Log.log("ID changed to " + id + ".");
   }
 }
 

Author:
Bob Lee (crazybob@crazybob.org)
See Also:
Serialized Form

Constructor Summary
DispatchInterceptor()
           
 
Method Summary
 boolean equals(java.lang.Object o)
           
protected  Invocation getInvocation()
          Gets the invocation object.
 int hashCode()
           
 java.lang.Object intercept(Invocation invocation)
          Intercepts a method invocation.
static MethodPointcut methodPointcut(java.lang.Class interceptorClass)
          Creates a method pointcut for the given DispatchInterceptor class.
protected  java.lang.Object proceed()
          Proceeds with invocation.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DispatchInterceptor

public DispatchInterceptor()
Method Detail

getInvocation

protected Invocation getInvocation()
Gets the invocation object.


proceed

protected java.lang.Object proceed()
                            throws java.lang.Throwable
Proceeds with invocation.

Throws:
java.lang.Throwable

intercept

public final java.lang.Object intercept(Invocation invocation)
                                 throws java.lang.Throwable
Description copied from interface: Interceptor
Intercepts a method invocation.

Specified by:
intercept in interface Interceptor
Throws:
java.lang.Throwable

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

methodPointcut

public static MethodPointcut methodPointcut(java.lang.Class interceptorClass)
Creates a method pointcut for the given DispatchInterceptor class. The pointcut picks methods implemented by the interceptor.