org.equilibriums.aop.utils.interceptor.delegate
Class DelegateInterceptor

java.lang.Object
  extended by org.equilibriums.aop.utils.interceptor.delegate.DelegateInterceptor
All Implemented Interfaces:
org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor

public class DelegateInterceptor
extends Object
implements org.aopalliance.intercept.MethodInterceptor

Will delegate method calls this interceptor is configured for to specified delegates.

You can optionally override delegate's method to be called by specifying delegateMethodMap.

Return value from delegate calls are handled by first DelegateReturnValueHandler that will return true from its DelegateReturnValueHandler.supports(java.lang.Class, java.util.List) method. If no DelegateReturnValueHandler are specified will return null.

Here are some Design Pattern use cases that can be achieved by this interceptor without declaring any new type.

Delegate Pattern:

Composite Pattern:

For more on how to use this interceptor see Overview section of this Javadoc.

Author:
Tsolak Petrosian

Constructor Summary
DelegateInterceptor()
           
 
Method Summary
 Map<Object,Method> getDelegateMethodMap()
          Map where key is delegate and value is the method to be called by this interceptor instead of using invocation.getMethod() method.
 List<DelegateReturnValueHandler> getDelegateReturnValueHandlers()
           
 List<Object> getDelegates()
           
 Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
           
 void setDelegateMethodMap(Map<Object,Method> delegateMethodMap)
           
 void setDelegateReturnValueHandlers(List<DelegateReturnValueHandler> delegateReturnValueHandlers)
           
 void setDelegates(List<Object> delegates)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegateInterceptor

public DelegateInterceptor()
Method Detail

getDelegates

public List<Object> getDelegates()

setDelegates

public void setDelegates(List<Object> delegates)

getDelegateMethodMap

public Map<Object,Method> getDelegateMethodMap()
Map where key is delegate and value is the method to be called by this interceptor instead of using invocation.getMethod() method.

Returns:

setDelegateMethodMap

public void setDelegateMethodMap(Map<Object,Method> delegateMethodMap)

getDelegateReturnValueHandlers

public List<DelegateReturnValueHandler> getDelegateReturnValueHandlers()

setDelegateReturnValueHandlers

public void setDelegateReturnValueHandlers(List<DelegateReturnValueHandler> delegateReturnValueHandlers)

invoke

public Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
              throws Throwable
Specified by:
invoke in interface org.aopalliance.intercept.MethodInterceptor
Throws:
Throwable


Copyright © 2011. All Rights Reserved.