use of org.jboss.as.ee.component.ComponentInstance 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 = this.weldContainer.getValue().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 = this.interceptorBindings.getValue();
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();
}
use of org.jboss.as.ee.component.ComponentInstance in project wildfly by wildfly.
the class SFSBCreateInterceptor method processInvocation.
@Override
public Object processInvocation(InterceptorContext interceptorContext) throws Exception {
ComponentInstance componentInstance = interceptorContext.getPrivateData(ComponentInstance.class);
Map<String, ExtendedEntityManager> entityManagers = null;
if (componentInstance.getInstanceData(SFSBInvocationInterceptor.CONTEXT_KEY) == null) {
// Get all of the extended persistence contexts in use by the bean (some of which may of been inherited from
// other beans).
entityManagers = new HashMap<String, ExtendedEntityManager>();
componentInstance.setInstanceData(SFSBInvocationInterceptor.CONTEXT_KEY, new ImmediateManagedReference(entityManagers));
} else {
ManagedReference entityManagerRef = (ManagedReference) componentInstance.getInstanceData(SFSBInvocationInterceptor.CONTEXT_KEY);
entityManagers = (Map<String, ExtendedEntityManager>) entityManagerRef.getInstance();
}
final ExtendedEntityManager[] ems = CreatedEntityManagers.getDeferredEntityManagers();
for (ExtendedEntityManager e : ems) {
entityManagers.put(e.getScopedPuName(), e);
}
return interceptorContext.proceed();
}
use of org.jboss.as.ee.component.ComponentInstance in project wildfly by wildfly.
the class SFSBInvocationInterceptor method processInvocation.
@Override
public Object processInvocation(InterceptorContext context) throws Exception {
final ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class);
ManagedReference entityManagerRef = (ManagedReference) componentInstance.getInstanceData(SFSBInvocationInterceptor.CONTEXT_KEY);
if (entityManagerRef != null) {
Map<String, ExtendedEntityManager> entityManagers = (Map<String, ExtendedEntityManager>) entityManagerRef.getInstance();
SFSBCallStack.pushCall(entityManagers);
}
try {
// call the next interceptor or target
return context.proceed();
} finally {
if (entityManagerRef != null) {
SFSBCallStack.popCall();
}
}
}
use of org.jboss.as.ee.component.ComponentInstance in project wildfly by wildfly.
the class CurrentInvocationContext method getEjbContext.
public static EJBContextImpl getEjbContext() {
final InterceptorContext context = get();
if (context == null) {
throw EjbLogger.ROOT_LOGGER.noEjbContextAvailable();
}
final ComponentInstance component = context.getPrivateData(ComponentInstance.class);
if (!(component instanceof EjbComponentInstance)) {
throw EjbLogger.ROOT_LOGGER.currentComponentNotAEjb(component);
}
return ((EjbComponentInstance) component).getEjbContext();
}
use of org.jboss.as.ee.component.ComponentInstance in project wildfly by wildfly.
the class MessageDrivenBeanSetMessageDrivenContextInterceptor method processInvocation.
@Override
public Object processInvocation(InterceptorContext context) throws Exception {
final MessageDrivenComponentInstance componentInstance = (MessageDrivenComponentInstance) context.getPrivateData(ComponentInstance.class);
final MessageDrivenContext messageDrivenContext = (MessageDrivenContext) componentInstance.getEjbContext();
((MessageDrivenBean) context.getTarget()).setMessageDrivenContext(messageDrivenContext);
return context.proceed();
}
Aggregations