com.interface21.aop.framework
Class DefaultProxyConfig

java.lang.Object
  |
  +--com.interface21.aop.framework.DefaultProxyConfig
All Implemented Interfaces:
InitializingBean, ProxyConfig
Direct Known Subclasses:
ProxyFactory, ProxyFactoryBean

public class DefaultProxyConfig
extends java.lang.Object
implements ProxyConfig, InitializingBean

Superclass for AOP Proxy configuration objects. Subclasses are normally factories from which AOP proxy instances are obtained directly. Implements InitializingBean interface. If using outside a BeanFactory (which will call this lifecycle method automatically) check subclass documentation as to whether it's necessary to call a method such as afterPropertiesSet() to complete initialization after all JavaBean properties has been set.
This class frees subclasses of the housekeeping of interceptors and pointcuts, but doesn't actually create AOP proxies.

Version:
$Id: DefaultProxyConfig.java,v 1.7 2003/05/28 16:39:11 jhoeller Exp $
Author:
Rod Johnson

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
DefaultProxyConfig()
          No arg constructor to allow use as a Java bean
DefaultProxyConfig(java.lang.Class[] intfs, boolean exposeInvocation, org.aopalliance.AttributeRegistry attributeRegistry)
           
 
Method Summary
 void addInterceptor(org.aopalliance.Interceptor interceptor)
          Add to tail
 void addInterceptor(int pos, org.aopalliance.Interceptor interceptor)
          New interfaces will only be available when a new proxy is obtained through getObject().
protected  void addInterface(java.lang.Class newInterface)
          Add a new proxied interface.
 void addMethodPointcut(int pos, MethodPointcut pc)
          Add a pointcut
 void addMethodPointcut(MethodPointcut pc)
          Add a pointcut
 void afterPropertiesSet()
          Lifecycle method.
 int countInterceptorsOfType(java.lang.Class interceptorClass)
          Count interceptors of the given class
 org.aopalliance.AttributeRegistry getAttributeRegistry()
           
 boolean getExposeInvocation()
          Gets the exposeInvocation.
 java.util.List getMethodPointcuts()
          List of interceptor and pointcut
 java.lang.Class[] getProxiedInterfaces()
           
 java.lang.Object getTarget()
          Can return null if now target.
 boolean interceptorIncluded(org.aopalliance.MethodInterceptor mi)
          Is this interceptor included in any pointcut?
 boolean removeInterceptor(org.aopalliance.Interceptor interceptor)
          Remove the given interceptor
protected  boolean removeInterface(java.lang.Class intf)
          Remove a proxied interface.
 boolean replaceMethodPointcut(MethodPointcut pc1, MethodPointcut pc2)
          Replace the given pointcut
 void setAttributeRegistry(org.aopalliance.AttributeRegistry attributeRegistry)
          Sets the attributeRegistry.
 void setExposeInvocation(boolean exposeInvocation)
          Sets the exposeInvocation property, governing whether the AopContext class will be usable by target objects.
protected  void setInterfaces(java.lang.Class[] interfaces)
          Sets the interfaces to be proxied.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

DefaultProxyConfig

public DefaultProxyConfig()
No arg constructor to allow use as a Java bean

DefaultProxyConfig

public DefaultProxyConfig(java.lang.Class[] intfs,
                          boolean exposeInvocation,
                          org.aopalliance.AttributeRegistry attributeRegistry)
Method Detail

getExposeInvocation

public boolean getExposeInvocation()
Gets the exposeInvocation.
Specified by:
getExposeInvocation in interface ProxyConfig
Returns:
Returns a boolean

setExposeInvocation

public final void setExposeInvocation(boolean exposeInvocation)
Sets the exposeInvocation property, governing whether the AopContext class will be usable by target objects.
Parameters:
exposeInvocation - The exposeInvocation to set

addInterceptor

public void addInterceptor(org.aopalliance.Interceptor interceptor)
Description copied from interface: ProxyConfig
Add to tail
Specified by:
addInterceptor in interface ProxyConfig
See Also:
ProxyConfig.addInterceptor(org.aopalliance.Interceptor)

addInterceptor

public final void addInterceptor(int pos,
                                 org.aopalliance.Interceptor interceptor)
New interfaces will only be available when a new proxy is obtained through getObject(). The same goes for removing interfaces.
Specified by:
addInterceptor in interface ProxyConfig
See Also:
ProxyConfig.addInterceptor(int, org.aopalliance.Interceptor)

removeInterceptor

public final boolean removeInterceptor(org.aopalliance.Interceptor interceptor)
Remove the given interceptor
Specified by:
removeInterceptor in interface ProxyConfig
See Also:
ProxyConfig.removeInterceptor(org.aopalliance.Interceptor)

addInterface

protected final void addInterface(java.lang.Class newInterface)
Add a new proxied interface.
Parameters:
newInterface - additional interface to proxy.

removeInterface

protected final boolean removeInterface(java.lang.Class intf)
Remove a proxied interface. Does nothing if it isn't proxied.
Parameters:
intf -  
Returns:
boolean

getProxiedInterfaces

public final java.lang.Class[] getProxiedInterfaces()
Specified by:
getProxiedInterfaces in interface ProxyConfig
See Also:
ProxyConfig.getProxiedInterfaces()

getAttributeRegistry

public org.aopalliance.AttributeRegistry getAttributeRegistry()
Specified by:
getAttributeRegistry in interface ProxyConfig
See Also:
ProxyConfig.getAttributeRegistry()

setAttributeRegistry

public void setAttributeRegistry(org.aopalliance.AttributeRegistry attributeRegistry)
Sets the attributeRegistry.
Parameters:
attributeRegistry - The attributeRegistry to set

setInterfaces

protected void setInterfaces(java.lang.Class[] interfaces)
Sets the interfaces to be proxied.
Parameters:
interfaces - The interfaces to set

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Lifecycle method. This implementation merely checks that configuration is complete: it doesn't do anything.
Specified by:
afterPropertiesSet in interface InitializingBean
See Also:
InitializingBean.afterPropertiesSet()

getTarget

public java.lang.Object getTarget()
Description copied from interface: ProxyConfig
Can return null if now target. Returns true if we have a target interceptor. A target interceptor must be the last interceptor. Implementations should be efficient, as this will be invoked on each invocation.
Specified by:
getTarget in interface ProxyConfig
See Also:
ProxyConfig.getTarget()

addMethodPointcut

public void addMethodPointcut(int pos,
                              MethodPointcut pc)
Description copied from interface: ProxyConfig
Add a pointcut
Specified by:
addMethodPointcut in interface ProxyConfig
See Also:
ProxyConfig.addMethodPointcut(int, com.interface21.aop.framework.MethodPointcut)

addMethodPointcut

public void addMethodPointcut(MethodPointcut pc)
Description copied from interface: ProxyConfig
Add a pointcut
Specified by:
addMethodPointcut in interface ProxyConfig
See Also:
ProxyConfig.addMethodPointcut(com.interface21.aop.framework.MethodPointcut)

getMethodPointcuts

public java.util.List getMethodPointcuts()
Description copied from interface: ProxyConfig
List of interceptor and pointcut
Specified by:
getMethodPointcuts in interface ProxyConfig
See Also:
ProxyConfig.getMethodPointcuts()

replaceMethodPointcut

public final boolean replaceMethodPointcut(MethodPointcut pc1,
                                           MethodPointcut pc2)
Replace the given pointcut
Parameters:
pc1 - pointcut to replace
pc2 - pointcut to replace it with
Returns:
boolean whether it was replaced. If the pointcut wasn't found in the list of pointcuts, this method returns false and does nothing.

interceptorIncluded

public final boolean interceptorIncluded(org.aopalliance.MethodInterceptor mi)
Is this interceptor included in any pointcut?
Parameters:
mi - interceptor to check inclusion of
Returns:
boolean whether this interceptor instance could be run in an invocation.

countInterceptorsOfType

public final int countInterceptorsOfType(java.lang.Class interceptorClass)
Count interceptors of the given class
Parameters:
interceptorClass - class of the interceptor to check
Returns:
int the count of the interceptors of this class or subclasses


Rod Johnson and Spring contributors 2001-2003.