org.apache.commons.proxy.interceptor
Class InterceptorChain

java.lang.Object
  extended by org.apache.commons.proxy.interceptor.InterceptorChain

public class InterceptorChain
extends Object

An InterceptorChain assists with creating proxies which go through a series of interceptors.

   MyServiceInterface serviceImpl = ...;
   ProxyFactory factory = ...;
   Interceptor[] interceptors = ...;
   InterceptorChain chain = new InterceptorChain(interceptors);
   ObjectProvider provider = chain.createProxyProvider(factory, serviceImpl);
   MyServiceInterface serviceProxy = ( MyServiceInterface )provider.getObject();
   serviceProxy.someServiceMethod(...); // This will go through the interceptors! 
 

Since:
1.0
Author:
James Carman

Constructor Summary
InterceptorChain(Interceptor[] interceptors)
           
 
Method Summary
 ObjectProvider createProxyProvider(ProxyFactory proxyFactory, ClassLoader classLoader, Object terminus, Class[] proxyClasses)
          Creates an ObjectProvider which will return a proxy that sends method invocations through this chain of interceptors and ultimately arrive at the supplied terminus object.
 ObjectProvider createProxyProvider(ProxyFactory proxyFactory, Object terminus)
          Creates an ObjectProvider which will return a proxy that sends method invocations through this chain of interceptors and ultimately arrive at the supplied terminus object.
 ObjectProvider createProxyProvider(ProxyFactory proxyFactory, Object terminus, Class[] proxyClasses)
          Creates an ObjectProvider which will return a proxy that sends method invocations through this chain of interceptors and ultimately arrive at the supplied terminus object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InterceptorChain

public InterceptorChain(Interceptor[] interceptors)
Method Detail

createProxyProvider

public ObjectProvider createProxyProvider(ProxyFactory proxyFactory,
                                          Object terminus)
Creates an ObjectProvider which will return a proxy that sends method invocations through this chain of interceptors and ultimately arrive at the supplied terminus object. The proxy will support all interfaces implemented by the terminus object. The thread context classloader will be used to generate the proxy class.

Parameters:
proxyFactory - the ProxyFactory to use to create the proxy
terminus - the terminus
Returns:
an ObjectProvider which will return a proxy that sends method invocations through this chain of interceptors and ultimately arrive at the supplied terminus object

createProxyProvider

public ObjectProvider createProxyProvider(ProxyFactory proxyFactory,
                                          Object terminus,
                                          Class[] proxyClasses)
Creates an ObjectProvider which will return a proxy that sends method invocations through this chain of interceptors and ultimately arrive at the supplied terminus object. The proxy will support only the specified interfaces/classes. The thread context classloader will be used to generate the proxy class.

Parameters:
proxyFactory - the ProxyFactory to use to create the proxy
terminus - the terminus
proxyClasses - the interfaces to support
Returns:
an ObjectProvider which will return a proxy that sends method invocations through this chain of interceptors and ultimately arrive at the supplied terminus object

createProxyProvider

public ObjectProvider createProxyProvider(ProxyFactory proxyFactory,
                                          ClassLoader classLoader,
                                          Object terminus,
                                          Class[] proxyClasses)
Creates an ObjectProvider which will return a proxy that sends method invocations through this chain of interceptors and ultimately arrive at the supplied terminus object. The proxy will support only the specified interfaces/classes. The specified classloader will be used to generate the proxy class.

Parameters:
proxyFactory - the ProxyFactory to use to create the proxy
classLoader - the classloader to be used to generate the proxy class
terminus - the terminus
proxyClasses - the interfaces to support
Returns:
an ObjectProvider which will return a proxy that sends method invocations through this chain of interceptors and ultimately arrive at the supplied terminus object


Copyright © 2005-2008 The Apache Software Foundation. All Rights Reserved.