use of org.jboss.as.jpa.container.ExtendedEntityManager 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.jpa.container.ExtendedEntityManager 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();
}
}
}
Aggregations