接口 MethodInterceptor
- 所有超级接口:
Advice
,Interceptor
- 所有已知子接口:
IntroductionInterceptor
- 所有已知实现类:
AbstractMonitoringInterceptor
,AbstractRemoteSlsbInvokerInterceptor
,AbstractSlsbInvokerInterceptor
,AbstractTraceInterceptor
,AfterReturningAdviceInterceptor
,AnnotationAsyncExecutionInterceptor
,AspectJAfterAdvice
,AspectJAfterThrowingAdvice
,AspectJAroundAdvice
,AsyncExecutionInterceptor
,CacheInterceptor
,ConcurrencyThrottleInterceptor
,CustomizableTraceInterceptor
,DebugInterceptor
,DelegatePerTargetObjectIntroductionInterceptor
,DelegatingIntroductionInterceptor
,EventPublicationInterceptor
,ExposeInvocationInterceptor
,HessianClientInterceptor
,HessianProxyFactoryBean
,HttpInvokerClientInterceptor
,HttpInvokerProxyFactoryBean
,JamonPerformanceMonitorInterceptor
,JaxWsPortClientInterceptor
,JaxWsPortProxyFactoryBean
,JCacheInterceptor
,JmsInvokerClientInterceptor
,JmsInvokerProxyFactoryBean
,JndiRmiClientInterceptor
,JndiRmiProxyFactoryBean
,LocalSlsbInvokerInterceptor
,LocalStatelessSessionProxyFactoryBean
,MBeanClientInterceptor
,MBeanProxyFactoryBean
,MethodBeforeAdviceInterceptor
,MethodValidationInterceptor
,OpenSessionInterceptor
,PerformanceMonitorInterceptor
,PersistenceExceptionTranslationInterceptor
,RemoteInvocationTraceInterceptor
,RmiClientInterceptor
,RmiProxyFactoryBean
,SimpleRemoteSlsbInvokerInterceptor
,SimpleRemoteStatelessSessionProxyFactoryBean
,SimpleTraceInterceptor
,ThrowsAdviceInterceptor
,TransactionInterceptor
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
@FunctionalInterface public interface MethodInterceptor extends Interceptor
Intercepts calls on an interface on its way to the target. These are nested "on top" of the target.The user should implement the
invoke(MethodInvocation)
method to modify the original behavior. E.g. the following class implements a tracing interceptor (traces all the calls on the intercepted method(s)):class TracingInterceptor implements MethodInterceptor { Object invoke(MethodInvocation i) throws Throwable { System.out.println("method "+i.getMethod()+" is called on "+ i.getThis()+" with args "+i.getArguments()); Object ret=i.proceed(); System.out.println("method "+i.getMethod()+" returns "+ret); return ret; } }
- 作者:
- Rod Johnson
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 Object
invoke(MethodInvocation invocation)
Implement this method to perform extra treatments before and after the invocation.
方法详细资料
invoke
Object invoke(MethodInvocation invocation) throws Throwable
Implement this method to perform extra treatments before and after the invocation. Polite implementations would certainly like to invokeJoinpoint.proceed()
.- 参数:
invocation
- the method invocation joinpoint- 返回:
- the result of the call to
Joinpoint.proceed()
; might be intercepted by the interceptor - 抛出:
Throwable
- if the interceptors or the target object throws an exception