private void begin() { lock.lock(); try { if (isActive()) throw new IllegalStateException("Transaction is already active!"); lockIfWrite(); persistenceManager = persistenceManagerFactory.getPersistenceManager(); jdoTransaction = persistenceManager.currentTransaction(); jdoTransaction.begin(); listenerRegistry.onBegin(); } finally { lock.unlock(); } }
@Override public void commit() { lock.lock(); try { if (!isActive()) throw new IllegalStateException("Transaction is not active!"); listenerRegistry.onCommit(); daoClass2Dao.clear(); jdoTransaction.commit(); persistenceManager.close(); jdoTransaction = null; persistenceManager = null; localRevision = -1; unlockIfWrite(); } finally { lock.unlock(); } }