use of org.jboss.weld.ejb.spi.EjbDescriptor in project core by weld.
the class SubclassedComponentDescriptorTest method prepareContainer.
@BeforeClass
public void prepareContainer() {
final EjbDescriptor<Foo> fooDescriptor = new EjbDescriptorImpl<Foo>(Foo.class, Foo.class, EnhancedFoo.class, SessionBeanType.STATEFUL);
final EjbDescriptor<Bar> barDescriptor = new EjbDescriptorImpl<Bar>(Bar.class, BarLocal.class, EnhancedBar.class, SessionBeanType.STATEFUL);
final EjbDescriptor<Baz> bazDescriptor = new EjbDescriptorImpl<Baz>(Baz.class, Baz.class, EnhancedBaz.class, null);
final BeanDeploymentArchive bda = new BeanDeploymentArchiveImpl("1", Foo.class, Bar.class, BarLocal.class, BarDecorator.class, BarInterceptor.class, BarInterceptorBinding.class, Baz.class) {
@Override
public Collection<EjbDescriptor<?>> getEjbs() {
return ImmutableSet.<EjbDescriptor<?>>of(fooDescriptor, barDescriptor, bazDescriptor);
}
};
final Deployment deployment = new FlatDeployment(bda) {
@Override
public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass) {
return bda;
}
@Override
protected void configureServices(Environment environment) {
super.configureServices(environment);
getServices().add(EjbServices.class, new MockEjbServices());
}
};
container = new TestContainer(deployment).startContainer();
manager = (BeanManagerImpl) container.getBeanManager(bda);
}
use of org.jboss.weld.ejb.spi.EjbDescriptor in project Payara by payara.
the class EjbServicesImpl method registerInterceptors.
@Override
public void registerInterceptors(EjbDescriptor<?> ejbDesc, InterceptorBindings interceptorBindings) {
com.sun.enterprise.deployment.EjbDescriptor glassfishEjbDesc = (com.sun.enterprise.deployment.EjbDescriptor) ((EjbDescriptorImpl<?>) ejbDesc).getEjbDescriptor();
// First create master list of EjbInterceptor descriptors
for (Interceptor<?> next : interceptorBindings.getAllInterceptors()) {
if (logger.isLoggable(FINE)) {
logger.log(FINE, TRYING_TO_REGISTER_INTERCEPTOR, new Object[] { next });
}
// Add interceptor to list all interceptors in ejb descriptor
if (!(glassfishEjbDesc.hasInterceptorClass(next.getBeanClass().getName()))) {
if (logger.isLoggable(FINE)) {
logger.log(FINE, ADDING_INTERCEPTOR_FOR_EJB, new Object[] { next.getBeanClass().getName(), glassfishEjbDesc.getEjbClassName() });
}
EjbInterceptor ejbInt = makeEjbInterceptor(next, glassfishEjbDesc.getEjbBundleDescriptor());
ejbInt.setInterceptorClass(next.getBeanClass());
glassfishEjbDesc.addInterceptorClass(ejbInt);
}
}
// Create ordered list of EjbInterceptor for each lifecycle interception type and append to
// EjbDescriptor.
// JSR 299 (CDI) interceptors are always added after any interceptors defined via
// EJB-defined metadata, so the ordering will be correct since all the ejb interceptors
// have already been processed.
glassfishEjbDesc.appendToInterceptorChain(makeInterceptorChain(AROUND_CONSTRUCT, interceptorBindings.getLifecycleInterceptors(AROUND_CONSTRUCT), glassfishEjbDesc));
glassfishEjbDesc.appendToInterceptorChain(makeInterceptorChain(POST_CONSTRUCT, interceptorBindings.getLifecycleInterceptors(POST_CONSTRUCT), glassfishEjbDesc));
glassfishEjbDesc.appendToInterceptorChain(makeInterceptorChain(PRE_DESTROY, interceptorBindings.getLifecycleInterceptors(PRE_DESTROY), glassfishEjbDesc));
glassfishEjbDesc.appendToInterceptorChain(makeInterceptorChain(PRE_PASSIVATE, interceptorBindings.getLifecycleInterceptors(PRE_PASSIVATE), glassfishEjbDesc));
glassfishEjbDesc.appendToInterceptorChain(makeInterceptorChain(POST_ACTIVATE, interceptorBindings.getLifecycleInterceptors(POST_ACTIVATE), glassfishEjbDesc));
// JSR 299-provided list is organized as per-method. Append each method chain to EjbDescriptor.
Class<?> ejbBeanClass = null;
try {
ClassLoader cl = glassfishEjbDesc.getEjbBundleDescriptor().getClassLoader();
ejbBeanClass = cl.loadClass(glassfishEjbDesc.getEjbClassName());
} catch (ClassNotFoundException cnfe) {
throw new IllegalStateException("Cannot load bean class " + glassfishEjbDesc.getEjbClassName(), cnfe);
}
Class<?> ejbBeanSuperClass = ejbBeanClass;
while (!ejbBeanSuperClass.equals(java.lang.Object.class)) {
for (Method m : ejbBeanSuperClass.getDeclaredMethods()) {
if (!methodOverridden(ejbBeanClass, m)) {
List<EjbInterceptor> aroundInvokeChain = makeInterceptorChain(InterceptionType.AROUND_INVOKE, interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_INVOKE, m), glassfishEjbDesc);
glassfishEjbDesc.addMethodLevelChain(aroundInvokeChain, m, true);
List<EjbInterceptor> aroundTimeoutChain = makeInterceptorChain(InterceptionType.AROUND_TIMEOUT, interceptorBindings.getMethodInterceptors(InterceptionType.AROUND_TIMEOUT, m), glassfishEjbDesc);
glassfishEjbDesc.addMethodLevelChain(aroundTimeoutChain, m, false);
}
}
ejbBeanSuperClass = ejbBeanSuperClass.getSuperclass();
}
}
Aggregations