spring-framework / org.aopalliance.intercept

Package org.aopalliance.intercept

Types

ConstructorInterceptor

interface ConstructorInterceptor : Interceptor

Intercepts the construction of a new object.

The user should implement the method to modify the original behavior. E.g. the following class implements a singleton interceptor (allows only one unique instance for the intercepted class):

 class DebuggingInterceptor implements ConstructorInterceptor { Object instance=null; Object construct(ConstructorInvocation i) throws Throwable { if(instance==null) { return instance=i.proceed(); } else { throw new Exception("singleton does not allow multiple instance"); } } } 

Invocation

interface Invocation : Joinpoint

This interface represents an invocation in the program.

An invocation is a joinpoint and can be intercepted by an interceptor.

MethodInterceptor

interface MethodInterceptor : 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; } } 

MethodInvocation

interface MethodInvocation : Invocation

Description of an invocation to a method, given to an interceptor upon method-call.

A method invocation is a joinpoint and can be intercepted by a method interceptor.