Creating an interceptor
Tie interceptors are built using the AOP Alliance interfaces. Other frameworks (such as Spring and Guice) also use these interfaces, so your interceptors should be interchangeable between frameworks.
This is a basic interceptor that logs method entry/exit via a java.util.logging.Logger.
public class LoggingInterceptor implements MethodInterceptor { private static final Logger LOG = Logger.getLogger( LoggingInterceptor.class.getPackage().getName() + ".trace"); public Object invoke(MethodInvocation invocation) throws Throwable { String className = invocation.getThis().getClass().getName(); String methodName = invocation.getMethod().getName(); LOG.entering(className, methodName, invocation.getArguments()); Object result = invocation.proceed(); LOG.exiting(className, methodName, result); return result; } }(You can see this code in full in the sample code)
The instructions listed above do not require the "ext" jar to be on the classpath.