Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions

alma.acs.monitoring.DynamicInterceptor Class Reference

Inherits java::lang::reflect::InvocationHandler.

List of all members.

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)

Detailed Description

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.

Author:
hsommer
Since:
ACS 9.0

Constructor & Destructor Documentation

alma.acs.monitoring.DynamicInterceptor.DynamicInterceptor ( Object  delegate,
Logger  logger,
ClassLoader  contextCL,
InterceptionHandlerFactory  interceptionHandlerFactory 
) [protected]

Member Function Documentation

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.

Parameters:
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()).

See also:
java.lang.reflect.InvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties