org.springframework.aop.support
Class DelegatePerTargetObjectIntroductionInterceptor

java.lang.Object
  extended by org.springframework.aop.support.IntroductionInfoSupport
      extended by org.springframework.aop.support.DelegatePerTargetObjectIntroductionInterceptor
All Implemented Interfaces:
java.io.Serializable, DynamicIntroductionAdvice, IntroductionInfo, IntroductionInterceptor

public class DelegatePerTargetObjectIntroductionInterceptor
extends IntroductionInfoSupport
implements IntroductionInterceptor

Convenient implementation of the IntroductionInterceptor interface.

This differs from DelegatingIntroductionInterceptor in that a single instance of this class can be used to advise multiple target objects, and each target object will have its own delegate (whereas DelegatingIntroductionInterceptor shares the same delegate, and hence the same state across all targets).

The suppressInterface method can be used to suppress interfaces implemented by the delegate class but which should not be introduced to the owning AOP proxy.

An instance of this class is serializable if the delegates are.

Note: There are some implementation similarities between this class and DelegatingIntroductionInterceptor that suggest a possible refactoring to extract a common ancestor class in the future.

Since:
2.0
Author:
Adrian Colyer, Juergen Hoeller
See Also:
IntroductionInfoSupport.suppressInterface(java.lang.Class), DelegatingIntroductionInterceptor, Serialized Form

Field Summary
private  java.lang.Class defaultImplType
           
private  java.util.Map<java.lang.Object,java.lang.Object> delegateMap
          Hold weak references to keys as we don't want to interfere with garbage collection..
private  java.lang.Class interfaceType
           
 
Fields inherited from class org.springframework.aop.support.IntroductionInfoSupport
publishedInterfaces
 
Constructor Summary
DelegatePerTargetObjectIntroductionInterceptor(java.lang.Class defaultImplType, java.lang.Class interfaceType)
           
 
Method Summary
private  java.lang.Object createNewDelegate()
           
protected  java.lang.Object doProceed(MethodInvocation mi)
          Proceed with the supplied org.aopalliance.intercept.MethodInterceptor.
private  java.lang.Object getIntroductionDelegateFor(java.lang.Object targetObject)
           
 java.lang.Object invoke(MethodInvocation mi)
          Subclasses may need to override this if they want to perform custom behaviour in around advice.
 
Methods inherited from class org.springframework.aop.support.IntroductionInfoSupport
getInterfaces, implementInterfacesOnObject, implementsInterface, isMethodOnIntroducedInterface, suppressInterface
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.aop.DynamicIntroductionAdvice
implementsInterface
 

Field Detail

delegateMap

private final java.util.Map<java.lang.Object,java.lang.Object> delegateMap
Hold weak references to keys as we don't want to interfere with garbage collection..


defaultImplType

private java.lang.Class defaultImplType

interfaceType

private java.lang.Class interfaceType
Constructor Detail

DelegatePerTargetObjectIntroductionInterceptor

public DelegatePerTargetObjectIntroductionInterceptor(java.lang.Class defaultImplType,
                                                      java.lang.Class interfaceType)
Method Detail

invoke

public java.lang.Object invoke(MethodInvocation mi)
                        throws java.lang.Throwable
Subclasses may need to override this if they want to perform custom behaviour in around advice. However, subclasses should invoke this method, which handles introduced interfaces and forwarding to the target.

Throws:
java.lang.Throwable

doProceed

protected java.lang.Object doProceed(MethodInvocation mi)
                              throws java.lang.Throwable
Proceed with the supplied org.aopalliance.intercept.MethodInterceptor. Subclasses can override this method to intercept method invocations on the target object which is useful when an introduction needs to monitor the object that it is introduced into. This method is never called for MethodInvocations on the introduced interfaces.

Throws:
java.lang.Throwable

getIntroductionDelegateFor

private java.lang.Object getIntroductionDelegateFor(java.lang.Object targetObject)

createNewDelegate

private java.lang.Object createNewDelegate()