YAAFI supports Dynamic Proxies (introduced with JDK 1.3) and Interceptors which was inspired by HiveMind. The intention for implementing these features is to provide better debugging and diagnostic support such as method invocation tracing, error logs or performance monitoring.
A dynamic proxy is a dynamically created class implementing a list of interfaces and using an invocation handler. For the caller there is no difference between the real objext and the proxy object but invoking an interface method allows the invocation handler to delegate the method invocation to the real object. A dynamic proxy only intercepts methods defined in an interface but not abstract methods defined in a base class. This limitation is not relevant since you are accessing your services only by their interface, aren't you?!
To make interceptors really useful some more infrastructure is needed
|AvalonInterceptorInvocationHandler||Delegates the invocation of the dynamic proxy to the service instance and doing most of the work such as creating an AvalonInterceptorContext and invoking the registered interceptors in the correct order|
|AvalonInterceptorContext||For each intercepted service invocation a new AvalonInterceptorContext is created which is passed to all registered interceptors. The AvalonInterceptorContext contains information about the service and method being invoked and allows access to a request context, a thread context using thread local storage and a transaction id.|
|BaseInterceptorServiceImpl||Is the base class of all existing interceptors to factor out common functionality.|
A few things to keep in mind when working with interceptors