@Override public CloseableCoreSession createCoreSession(String repositoryName, NuxeoPrincipal principal) { LocalSession session = new LocalSession(repositoryName, principal); sessions.put(session.getSessionId(), new CoreSessionRegistrationInfo(session)); return session; }
@Override public void afterCompletion(int status) { if (status == Status.STATUS_ROLLEDBACK) { // insure the connection is closed on roll-back also closeInThisThread(); } }
public LocalSession(String repositoryName, NuxeoPrincipal principal) { if (TransactionHelper.isTransactionMarkedRollback()) { throw new NuxeoException("Cannot create a CoreSession when transaction is marked rollback-only"); } if (!TransactionHelper.isTransactionActive()) { throw new NuxeoException("Cannot create a CoreSession outside a transaction"); } this.repositoryName = repositoryName; this.principal = principal; createMetrics(); // needs repo name sessionId = newSessionId(repositoryName, principal); if (log.isDebugEnabled()) { log.debug("Creating CoreSession: " + sessionId); } createSession(); // create first session for current thread }
@Override public Session getSession() { if (!TransactionHelper.isTransactionActiveOrMarkedRollback()) { throw new NuxeoException("Cannot use a CoreSession outside a transaction"); } TransactionHelper.checkTransactionTimeout(); SessionInfo si = sessionHolder.get(); if (si == null || !si.session.isLive()) { // close old one, previously completed closeInThisThread(); if (log.isDebugEnabled()) { log.debug("Reconnecting CoreSession: " + sessionId); } if (TransactionHelper.isTransactionMarkedRollback()) { throw new NuxeoException("Cannot reconnect a CoreSession when transaction is marked rollback-only"); } si = createSession(); } return si.session; }
sessionId = ((LocalSession) arg).getSessionId(); break;
@Override public void beforeCompletion() { // insure the connection is closed before commit closeInThisThread(); }
@Override public void destroy() { if (log.isDebugEnabled()) { log.debug("Destroying CoreSession: " + sessionId); } closeInThisThread(); }