The original and most general callback type is the {@link MethodInterceptor}, which in AOP terms enables "around advice"--that is, you can invoke custom code both before and after the invocation of the "super" method. In addition you can modify the arguments before calling the super method, or not call it at all.
Although MethodInterceptor
is generic enough to meet any interception need, it is often overkill. For simplicity and performance, additional specialized callback types, such as {@link LazyLoader} are also available.Often a single callback will be used per enhanced class, but you can control which callback is used on a per-method basis with a {@link CallbackFilter}.
The most common uses of this class are embodied in the static helper methods. For advanced needs, such as customizing the ClassLoader
to use, you should create a new instance of Enhancer
. Other classes within CGLIB follow a similar pattern.
All enhanced objects implement the {@link Factory} interface, unless {@link #setUseFactory} isused to explicitly disable this feature. The Factory
interface provides an API to change the callbacks of an existing object, as well as a faster and easier way to create new instances of the same type.
For an almost drop-in replacement for java.lang.reflect.Proxy
, see the {@link Proxy} class.
|
|
|
|
|
|