Search in sources :

Example 1 with InterceptionHandlerFactory

use of alma.acs.monitoring.DynamicInterceptor.InterceptionHandlerFactory in project ACS by ACS-Community.

the class ContainerSealant method createContainerSealant.

/**
	 * Creates a ContainerSealant and uses it as the invocation handler for the returned dynamic proxy
	 * which implements <code>corbaInterface</code>.
	 * 
	 * @param corbaInterface  the interface that the created sealant will implement;
	 *                         this should be the component's or offshoot's xxxOperations interface.
	 * @param component  the component/offshoot implementation class, or any translator class
	 *                    in front of the component implementation.
	 *                    <code>componentImpl</code> must implement <code>corbaInterface</code>
	 *                    so that the sealant can forward calls to the component. <br>
	 *                    Note about usage of java generics: Ideally this would be declared "T" instead of "Object", 
	 *                    but did not get it to work with that...
	 * @param name  the component instance name (used for logging) 
	 * @param isOffShoot true if the <code>component</code> object is actually an offshoot of a component
	 * @param logger  logger to be used by this class 
	 * @param componentContextCL  classloader used for {@link Thread#setContextClassLoader(java.lang.ClassLoader setContextClassLoader)}
	 *        before component method gets invoked. (after the call, the old context CL will be restored.)
	 * @param methodNamesExcludedFromInvocationLogging  
	 * @return  an instance of <code>corbaInterface</code> that intercepts calls to
	 *           <code>componentImpl</code> and forwards them if restrictions allow this.
	 * @throws ContainerException if the given <code>component</code> Object does not implement the given <code>corbaInterface</code>. 
	 */
public static <T> T createContainerSealant(Class<T> corbaInterface, Object component, String name, boolean isOffShoot, Logger logger, ClassLoader componentContextCL, String[] methodNamesExcludedFromInvocationLogging) throws AcsJContainerEx {
    if (!corbaInterface.isInstance(component)) {
        AcsJContainerEx ex = new AcsJContainerEx();
        ex.setContextInfo("sealant factory: component " + component.getClass().getName() + " must implement the sealant interface " + corbaInterface.getClass().getName());
        throw ex;
    }
    InterceptionHandlerFactory interceptionHandlerFactory = new ComponentInterceptionHandlerFactory(name, isOffShoot, logger, methodNamesExcludedFromInvocationLogging);
    return DynamicInterceptor.createDynamicInterceptor(corbaInterface, component, logger, componentContextCL, interceptionHandlerFactory);
}
Also used : AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) InterceptionHandlerFactory(alma.acs.monitoring.DynamicInterceptor.InterceptionHandlerFactory)

Aggregations

AcsJContainerEx (alma.JavaContainerError.wrappers.AcsJContainerEx)1 InterceptionHandlerFactory (alma.acs.monitoring.DynamicInterceptor.InterceptionHandlerFactory)1