Search in sources :

Example 1 with EjbOptionalIntfGenerator

use of com.sun.ejb.codegen.EjbOptionalIntfGenerator in project Payara by payara.

the class JavaEEInterceptorBuilderFactoryImpl method createBuilder.

@Override
public JavaEEInterceptorBuilder createBuilder(InterceptorInfo info) throws Exception {
    Class targetObjectClass = info.getTargetClass();
    // Create an interface with all public methods of the target class
    // in order to create a dynamic proxy
    String targetObjectClassName = targetObjectClass.getName();
    String subClassIntfName = EJBUtils.getGeneratedOptionalInterfaceName(targetObjectClassName);
    EjbOptionalIntfGenerator gen = new EjbOptionalIntfGenerator(targetObjectClass.getClassLoader());
    Class subClassIntf = gen.loadClass(targetObjectClassName, subClassIntfName, () -> gen.generateOptionalLocalInterface(targetObjectClass, subClassIntfName));
    String beanSubClassName = subClassIntfName + "__Bean__";
    // Generate a sub-class of the application's class.  Use an instance of this subclass
    // as the actual object passed back to the application.  The sub-class instance
    // delegates all public methods to the dyanamic proxy, which calls the
    // InvocationHandler.
    Class subClass = gen.loadClass(targetObjectClassName, beanSubClassName, () -> gen.generateOptionalLocalInterfaceSubClass(targetObjectClass, beanSubClassName, subClassIntf));
    // TODO do interceptor builder once per managed bean
    InterceptorManager interceptorManager = new InterceptorManager(_logger, targetObjectClass.getClassLoader(), targetObjectClass.getName(), info);
    JavaEEInterceptorBuilderImpl builderImpl = new JavaEEInterceptorBuilderImpl(info, interceptorManager, gen, subClassIntf, subClass);
    return builderImpl;
}
Also used : EjbOptionalIntfGenerator(com.sun.ejb.codegen.EjbOptionalIntfGenerator)

Aggregations

EjbOptionalIntfGenerator (com.sun.ejb.codegen.EjbOptionalIntfGenerator)1