Top Description Fields Constructors Methods
org.springframework.aop.support

public Class DelegatePerTargetObjectIntroductionInterceptor

extends IntroductionInfoSupport
implements IntroductionInterceptor
Class Inheritance
All Implemented Interfaces
org.springframework.aop.IntroductionInterceptor, org.springframework.aop.DynamicIntroductionAdvice, org.aopalliance.aop.Advice, org.aopalliance.intercept.MethodInterceptor, org.aopalliance.intercept.Interceptor
Annotations
@SuppressWarnings:serial
Imports
java.util.Map, .WeakHashMap, org.aopalliance.intercept.MethodInvocation, org.springframework.aop.DynamicIntroductionAdvice, .IntroductionInterceptor, .ProxyMethodInvocation, org.springframework.lang.Nullable, org.springframework.util.ReflectionUtils

Convenient implementation of the org.springframework.aop.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.

Authors
Adrian Colyer, Juergen Hoeller
Since
2.0
See Also
suppressInterface, DelegatingIntroductionInterceptor

Field Summary

Modifier and TypeField and Description
private final Class<?>
private final Map<Object, Object>
delegateMap

Hold weak references to keys as we don't want to interfere with garbage collection..

private final Class<?>
Inherited from org.springframework.aop.support.IntroductionInfoSupport:
publishedInterfaces

Constructor Summary

AccessConstructor and Description
public
DelegatePerTargetObjectIntroductionInterceptor(Class<?> defaultImplType, Class<?> interfaceType)

Method Summary

Modifier and TypeMethod and Description
private Object
protected Object
private Object
public Object
invoke(MethodInvocation
the method invocation joinpoint
mi
)

Implements org.aopalliance.intercept.MethodInterceptor.invoke.

Subclasses may need to override this if they want to perform custom behaviour in around advice.
Inherited from org.springframework.aop.support.IntroductionInfoSupport:
getInterfacesimplementInterfacesOnObjectimplementsInterfaceisMethodOnIntroducedInterfacesuppressInterface

Field Detail

defaultImplTypeback to summary
private final Class<?> defaultImplType
delegateMapback to summary
private final Map<Object, Object> delegateMap

Hold weak references to keys as we don't want to interfere with garbage collection..

interfaceTypeback to summary
private final Class<?> interfaceType

Constructor Detail

DelegatePerTargetObjectIntroductionInterceptorback to summary
public DelegatePerTargetObjectIntroductionInterceptor(Class<?> defaultImplType, Class<?> interfaceType)

Method Detail

createNewDelegateback to summary
private Object createNewDelegate()
doProceedback to summary
protected Object doProceed(MethodInvocation mi) throws 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.

Annotations
@Nullable
getIntroductionDelegateForback to summary
private Object getIntroductionDelegateFor(Object targetObject)
invokeback to summary
public Object invoke(MethodInvocation mi) throws Throwable

Implements org.aopalliance.intercept.MethodInterceptor.invoke.

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.

Parameters
mi:MethodInvocation

Doc from org.aopalliance.intercept.MethodInterceptor.invoke.

the method invocation joinpoint

Returns:Object

Doc from org.aopalliance.intercept.MethodInterceptor.invoke.

the result of the call to Joinpoint#proceed(); might be intercepted by the interceptor

Annotations
@Override
@Nullable
Exceptions
Throwable:

Doc from org.aopalliance.intercept.MethodInterceptor.invoke.

if the interceptors or the target object throws an exception