/** * Pops the current SFSB invocation off the invocation call stack * * @return the entity manager map */ public static Map<String, ExtendedEntityManager> popCall() { ArrayList<Map<String, ExtendedEntityManager>> stack = currentSFSBCallStack(); Map<String, ExtendedEntityManager> result = stack.remove(stack.size() - 1); stack.trimToSize(); return result; }
/** * gets the current SFSB invocation off the invocation call stack * * @return the entity manager map */ static Map<String, ExtendedEntityManager> getCurrentCall() { ArrayList<Map<String, ExtendedEntityManager>> stack = currentSFSBCallStack(); Map<String, ExtendedEntityManager> result = null; if (stack != null) { result = stack.get(stack.size() - 1); } return result; }
/** * gets the current SFSB invocation off the invocation call stack * * @return the entity manager map */ static Map<String, ExtendedEntityManager> getCurrentCall() { ArrayList<Map<String, ExtendedEntityManager>> stack = currentSFSBCallStack(); Map<String, ExtendedEntityManager> result = null; if (stack != null) { result = stack.get(stack.size() - 1); } return result; }
/** * Pops the current SFSB invocation off the invocation call stack * * @return the entity manager map */ public static Map<String, ExtendedEntityManager> popCall() { ArrayList<Map<String, ExtendedEntityManager>> stack = currentSFSBCallStack(); Map<String, ExtendedEntityManager> result = stack.remove(stack.size() - 1); stack.trimToSize(); return result; }
/** * Push the passed SFSB context handle onto the invocation call stack * * @param entityManagers the entity manager map */ public static void pushCall(Map<String, ExtendedEntityManager> entityManagers) { currentSFSBCallStack().add(entityManagers); if (entityManagers != null) { /** * JPA 2.0 spec section 7.9.1 Container Responsibilities: * "When a business method of the stateful session bean is invoked, * if the stateful session bean uses container managed transaction demarcation, * and the entity manager is not already associated with the current JTA transaction, * the container associates the entity manager with the current JTA transaction and * calls EntityManager.joinTransaction. * " */ for(ExtendedEntityManager extendedEntityManager: entityManagers.values()) { extendedEntityManager.internalAssociateWithJtaTx(); } } }
/** * Push the passed SFSB context handle onto the invocation call stack * * @param entityManagers the entity manager map */ public static void pushCall(Map<String, ExtendedEntityManager> entityManagers) { currentSFSBCallStack().add(entityManagers); if (entityManagers != null) { /** * JPA 2.0 spec section 7.9.1 Container Responsibilities: * "When a business method of the stateful session bean is invoked, * if the stateful session bean uses container managed transaction demarcation, * and the entity manager is not already associated with the current JTA transaction, * the container associates the entity manager with the current JTA transaction and * calls EntityManager.joinTransaction. * " */ for(ExtendedEntityManager extendedEntityManager: entityManagers.values()) { extendedEntityManager.internalAssociateWithJtaTx(); } } }
@Override public ExtendedEntityManager findExtendedPersistenceContext(String puScopedName) { ExtendedEntityManager result; SFSBInjectedXPCs currentInjectedXPCs = SFSBCallStack.getSFSBCreationTimeInjectedXPCs(puScopedName); // will look directly at the top level bean being created (registerExtendedPersistenceContext() registers xpc there). result = currentInjectedXPCs.findExtendedPersistenceContextDeepInheritance(puScopedName); if (result == null) { // walk up the BEAN call stack (this also covers the case of a bean method JNDI searching for another bean) for (Map<String, ExtendedEntityManager> handle : SFSBCallStack.currentSFSBCallStack()) { result = handle.get(puScopedName); if(result != null) { return result; } } } return result; } }
@Override public ExtendedEntityManager findExtendedPersistenceContext(String puScopedName) { ExtendedEntityManager result; SFSBInjectedXPCs currentInjectedXPCs = SFSBCallStack.getSFSBCreationTimeInjectedXPCs(puScopedName); // will look directly at the top level bean being created (registerExtendedPersistenceContext() registers xpc there). result = currentInjectedXPCs.findExtendedPersistenceContextDeepInheritance(puScopedName); if (result == null) { // walk up the BEAN call stack (this also covers the case of a bean method JNDI searching for another bean) for (Map<String, ExtendedEntityManager> handle : SFSBCallStack.currentSFSBCallStack()) { result = handle.get(puScopedName); if(result != null) { return result; } } } return result; } }