Inherits java::lang::reflect::InvocationHandler.
Classes | |
interface | InterceptionHandler |
interface | InterceptionHandlerFactory |
Public Member Functions | |
Object | invoke (Object proxy, Method method, Object[] args) throws Throwable |
Static Public Member Functions | |
static< T > T | createDynamicInterceptor (Class< T > dynInterface, Object delegate, Logger logger, ClassLoader contextCL, InterceptionHandlerFactory interceptionHandlerFactory) |
Protected Member Functions | |
DynamicInterceptor (Object delegate, Logger logger, ClassLoader contextCL, InterceptionHandlerFactory interceptionHandlerFactory) |
Dynamic interceptor, to be used for example to log or modify calls to a corba object like the CDB or a Java component.
This class has been extracted and generalized from alma.acs.container.ContainerSealant
in module jcont, to allow reusing the code for intercepting other calls as well.
alma.acs.monitoring.DynamicInterceptor.DynamicInterceptor | ( | Object | delegate, | |
Logger | logger, | |||
ClassLoader | contextCL, | |||
InterceptionHandlerFactory | interceptionHandlerFactory | |||
) | [protected] |
To be called only from the proxy factory method createDynamicInterceptor(Class, Object, Logger, ClassLoader, InterceptionHandlerFactory)
Referenced by alma.acs.monitoring.DynamicInterceptor.createDynamicInterceptor().
static <T> T alma.acs.monitoring.DynamicInterceptor.createDynamicInterceptor | ( | Class< T > | dynInterface, | |
Object | delegate, | |||
Logger | logger, | |||
ClassLoader | contextCL, | |||
InterceptionHandlerFactory | interceptionHandlerFactory | |||
) | [static] |
Creates a DynamicInterceptor
instance and uses it as the invocation handler for the returned dynamic proxy which implements dynInterface
.
Note that if we want to allow a chain of handlers for each call, e.g. to more cleanly separate logging from permission checks, then we should change this method to accept a List<InterceptionHandlerFactory>
, to create many InterceptionHandler
objects for each call. These handlers must then be chained together in a way that the call aborts after the first handler's callReceived
has returned false
, and the return value of the first handler's callFinished
is fed to the second handler as the retVal
argument.
dynInterface | ||
delegate | The delegation object. Note about usage of java generics: Ideally this delegate would be declared "T" instead of "Object", but did not get it to work with that... | |
logger | The Logger to be used by this class. | |
contextCL | The class loader to be associated with the current thread during the forwarding of the call to the delegate object, or null if the interceptor should not swap the classloader. | |
interceptionHandlerFactory | Will be used to create the callback object (one per invocation). |
References alma.acs.monitoring.DynamicInterceptor.DynamicInterceptor().
Object alma.acs.monitoring.DynamicInterceptor.invoke | ( | Object | proxy, | |
Method | method, | |||
Object[] | args | |||
) | throws Throwable |
Receives the intercepted calls, and forwards them to the handler and delegate object. Also sets the class loader passed to createDynamicInterceptor(Class, Object, Logger, ClassLoader, InterceptionHandlerFactory) as the current thread's context class loader (see Thread.currentThread().getContextClassLoader()
).