Search in sources :

Example 1 with SerializableContextualInstance

use of org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance in project wildfly by wildfly.

the class Jsr299BindingsCreateInterceptor method processInvocation.

@Override
public Object processInvocation(InterceptorContext interceptorContext) throws Exception {
    BeanManagerImpl beanManager = this.beanManager;
    if (beanManager == null) {
        // cache the BM lookup, as it is quite slow
        beanManager = this.beanManager = weldContainerSupplier.get().getBeanManager(beanArchiveId);
    }
    // this is not always called with the deployments TCCL set
    // which causes weld to blow up
    SessionBean<Object> bean = null;
    if (ejbName != null) {
        EjbDescriptor<Object> descriptor = beanManager.getEjbDescriptor(this.ejbName);
        if (descriptor != null) {
            bean = beanManager.getBean(descriptor);
        }
    }
    InterceptorBindings interceptorBindings = interceptorBindingsSupplier.get();
    final ComponentInstance componentInstance = interceptorContext.getPrivateData(ComponentInstance.class);
    InterceptorInstances existing = interceptorSupport.getInterceptorInstances(componentInstance);
    if (existing == null) {
        CreationalContext<Object> creationalContext = beanManager.createCreationalContext(bean);
        HashMap<String, SerializableContextualInstance<Interceptor<Object>, Object>> interceptorInstances = new HashMap<String, SerializableContextualInstance<Interceptor<Object>, Object>>();
        if (interceptorBindings != null) {
            for (Interceptor<?> interceptor : interceptorBindings.getAllInterceptors()) {
                addInterceptorInstance((Interceptor<Object>) interceptor, beanManager, interceptorInstances, creationalContext);
            }
        }
        interceptorSupport.setInterceptorInstances(componentInstance, new WeldInterceptorInstances(creationalContext, interceptorInstances));
    }
    return interceptorContext.proceed();
}
Also used : HashMap(java.util.HashMap) InterceptorInstances(org.jboss.as.weld.spi.InterceptorInstances) SerializableContextualInstance(org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance) BeanManagerImpl(org.jboss.weld.manager.BeanManagerImpl) InterceptorBindings(org.jboss.weld.ejb.spi.InterceptorBindings) ComponentInstance(org.jboss.as.ee.component.ComponentInstance) Interceptor(javax.enterprise.inject.spi.Interceptor)

Aggregations

HashMap (java.util.HashMap)1 Interceptor (javax.enterprise.inject.spi.Interceptor)1 ComponentInstance (org.jboss.as.ee.component.ComponentInstance)1 InterceptorInstances (org.jboss.as.weld.spi.InterceptorInstances)1 InterceptorBindings (org.jboss.weld.ejb.spi.InterceptorBindings)1 BeanManagerImpl (org.jboss.weld.manager.BeanManagerImpl)1 SerializableContextualInstance (org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance)1