Commons Intercept provides a simple, flexible, interception API.

See:
          Description

Packages
org.skife.intercept The InterceptionBroker provides the entry point to most of the functionality for this library.
org.skife.intercept.interceptors Commonly used and sample Interceptor implementations
org.skife.intercept.interceptors.security The security package provides facilities for invocation-level ACL's.
org.skife.intercept.interceptors.tx The TransactionInterceptor can be used to implement container managed transactions in any environment that uses transactions.
org.skife.intercept.mock  
org.skife.intercept.signatures Commonly used and sample Signature implementations.
org.skife.mixin  

 

Commons Intercept provides a simple, flexible, interception API.

The InterceptionBroker provides the entry point to most of the functionality for this library. Use it to register Interceptor instances or classes via the addInterceptor(...) calls. Use it, also, to enhance objects so that their method calls will be intercepted.

The Signature interface defines the equivalent of a join point in AOP speak (which I have avoided as this isn't AOP, it is just interception). It should be pretty easy to implement anonymous Sigantures, or use common ones. The library will bundle a few commonly used types of signatures for your convenience in the signatures package.

The Interceptor interface defines the equivalent of around advice (but again, we are talking interception here, not aspects). Several common cases are provided in the interceptors package. All of the ones included with the library are atomic -- their ordering doesn't matter, and they don't depend on each other.

The broker is optimized for execution and wrapping objects, not for adding new interceptors. Registering a new interceptor is in fact very slow, so I suggest doing it at startup rather than whenever is convenient. It caches interceptors on a per-class bases based on the intercepted object's getClass() value. Once you have wrapped one type wrapping additional instances of the same type should be very fast. The first time you wrap a new type it is a bit slow as it must do some bytecode generation.

This library makes extensive use of the cglib library. Thank you cglib developers!