public ResourceHolder getResource() { TransactionState txState = transactionManager.getTransactionState(); ResourceHolder resource = txState.getNeoStoreTransaction(); if (resource == null) { txState.setNeoStoreTransaction(resource = createResource(getCurrentTransaction())); } return resource; }
private ResourceHolder createResource(Transaction tx) { try { XaConnection xaConnection = persistenceSource.getXaDataSource().getXaConnection(); NeoStoreTransaction resource = persistenceSource.createTransaction(xaConnection); ResourceHolder result = new ResourceHolder(tx, xaConnection, resource); TransactionState state = transactionManager.getTransactionState(); tx.registerSynchronization(new ResourceCleanupHook(tx, state, result)); return result; } catch (RollbackException | SystemException e) { throw new ResourceAcquisitionFailedException(e); } }
TransactionState getTransactionState() { return transactionManager.getTransactionState(); }