public CoreSession getDocumentManager(RepositoryLocation serverLocation) { if (serverLocation == null) { /* * currentServerLocation (factory in ServerContextBean) is set through navigationContext, which itself * injects documentManager, so it will be null the first time. */ return null; } CloseableCoreSession session = sessions.get(serverLocation); if (session == null) { if (Lifecycle.isDestroying()) { /* * During Seam component destroy phases, we don't want to recreate a core session just for injection. * This happens during logout when the session context is destroyed; we don't want to cause EJB calls in * this case as the authentication wouldn't work. */ return null; } String serverName = serverLocation.getName(); session = CoreInstance.openCoreSession(serverName); log.debug("Opened session for repository " + serverName); sessions.put(serverLocation, session); } return session; }
@Unwrap public EntityManager getEntityManager() throws NamingException, SystemException { if (entityManager==null) initEntityManager(); if ( !synchronizationRegistered && !Lifecycle.isDestroying() ) { joinTransaction(); } return entityManager; }
@Unwrap public Session getSession() throws Exception { if (session==null) initSession(); if ( !synchronizationRegistered && !Lifecycle.isDestroying() ) { joinTransaction(); } return session; }
private void joinTransaction() throws SystemException { UserTransaction transaction = Transaction.instance(); if ( !transaction.isActiveOrMarkedRollback() ) { throw new IllegalStateException("JbpmContext may only be used inside a transaction"); } if ( !synchronizationRegistered && !Lifecycle.isDestroying() && transaction.isActive() ) { jbpmContext.getSession().isOpen(); try //TODO: what we really want here is if (!cmt) { transaction.registerSynchronization(this); } catch (UnsupportedOperationException uoe) { jbpmContext.getSession().getTransaction().registerSynchronization(this); } synchronizationRegistered = true; } }
boolean allowAutocreation = !org.jboss.seam.contexts.Lifecycle.isDestroying(); boolean create = in.create() && allowAutocreation; result = getInstanceInAllNamespaces(name, create, allowAutocreation);