use of org.neo4j.kernel.impl.transaction.xaframework.XaConnection in project neo4j-mobile-android by neo4j-contrib.
the class PersistenceManager method getResource.
private NeoStoreTransaction getResource(boolean registerEventHooks) {
NeoStoreTransaction con = null;
Transaction tx = this.getCurrentTransaction();
if (tx == null) {
throw new NotInTransactionException();
}
con = txConnectionMap.get(tx);
if (con == null) {
try {
XaConnection xaConnection = persistenceSource.getXaDataSource().getXaConnection();
XAResource xaResource = xaConnection.getXaResource();
if (!tx.enlistResource(xaResource)) {
throw new ResourceAcquisitionFailedException("Unable to enlist '" + xaResource + "' in " + "transaction");
}
con = persistenceSource.createTransaction(xaConnection);
tx.registerSynchronization(new TxCommitHook(tx));
if (registerEventHooks)
registerTransactionEventHookIfNeeded();
txConnectionMap.put(tx, con);
} catch (javax.transaction.RollbackException re) {
String msg = "The transaction is marked for rollback only.";
throw new ResourceAcquisitionFailedException(msg, re);
} catch (javax.transaction.SystemException se) {
String msg = "TM encountered an unexpected error condition.";
throw new ResourceAcquisitionFailedException(msg, se);
}
}
return con;
}
Aggregations