/** * {@inheritDoc} */ public void start(Xid xid, int flags) throws XAException { try { cl.getManagedConnection().getLocalTransaction().begin(); } catch (ResourceException re) { throw new LocalXAException("start", XAException.XAER_RMERR, re); } }
public void tidyup() throws ResourceException { // We have a hanging transaction if (localTransaction.get()) { LocalTransaction local = null; ManagedConnection mc = getManagedConnection(); try { local = mc.getLocalTransaction(); } catch (Throwable t) { JBossResourceException.rethrowAsResourceException("Unfinished local transaction - error getting local transaction from " + this, t); } if (local == null) throw new ResourceException("Unfinished local transaction but managed connection does not provide a local transaction. " + this); else { local.rollback(); log.debug("Unfinished local transaction was rolled back." + this); } } }
public void rollback(Xid xid) throws XAException { if (xid.equals(currentXid) == false) throw new JBossLocalXAException("wrong xid in rollback: expected: " + currentXid + ", got: " + xid, XAException.XAER_PROTO); currentXid = null; try { cl.getManagedConnection().getLocalTransaction().rollback(); } catch (ResourceException re) { returnManagedConnection(cl, true); if (trace) log.trace("rollback problem: ", re); throw new JBossLocalXAException("could not rollback local tx", XAException.XAER_RMERR, re); } }
public void commit(Xid xid, boolean onePhase) throws XAException { if (xid.equals(currentXid) == false) throw new JBossLocalXAException("wrong xid in commit: expected: " + currentXid + ", got: " + xid, XAException.XAER_PROTO); currentXid = null; try { cl.getManagedConnection().getLocalTransaction().commit(); } catch (ResourceException re) { returnManagedConnection(cl, true); if (trace) log.trace("commit problem: ", re); throw new JBossLocalXAException("could not commit local tx", XAException.XA_RBROLLBACK, re); } }
/** * {@inheritDoc} */ public void rollback(Xid xid) throws XAException { try { cl.getManagedConnection().getLocalTransaction().rollback(); } catch (ResourceException re) { connectionManager.returnManagedConnection(cl, true); throw new LocalXAException("rollback", XAException.XAER_RMERR, re); } }
/** * {@inheritDoc} */ public void commit(Xid xid, boolean onePhase) throws XAException { try { cl.getManagedConnection().getLocalTransaction().commit(); } catch (ResourceException re) { connectionManager.returnManagedConnection(cl, true); throw new LocalXAException("commit", XAException.XA_RBROLLBACK, re); } }
public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { next.getConnection(connectionInfo); ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); mci.setXAResource( new LocalXAResource(mci.getManagedConnection().getLocalTransaction(), name)); }
public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { next.getConnection(connectionInfo); ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); mci.setXAResource( new LogXAResource( mci.getManagedConnection().getLocalTransaction(), name)); }
public void rollback(Xid xid) throws XAException { try { ResourceHandle handle = getResourceHandle(); ManagedConnection mc = (ManagedConnection) handle.getResource(); mc.getLocalTransaction().rollback(); } catch (Exception ex) { handleResourceException(ex); }finally{ resetAssociation(); resetAssociatedTransaction(); } }
public void commit(Xid xid, boolean onePhase) throws XAException { try { ResourceHandle handle = getResourceHandle(); ManagedConnection mc = (ManagedConnection) handle.getResource(); mc.getLocalTransaction().commit(); } catch (Exception ex) { handleResourceException(ex); }finally{ resetAssociation(); resetAssociatedTransaction(); } }
public void start(Xid xid, int flags) throws XAException { if (trace) log.trace("start, xid: " + xid + ", flags: " + flags); if (currentXid != null && flags == XAResource.TMNOFLAGS) throw new JBossLocalXAException("Trying to start a new tx when old is not complete! old: " + currentXid + ", new " + xid + ", flags " + flags, XAException.XAER_PROTO); if (currentXid == null && flags != XAResource.TMNOFLAGS) throw new JBossLocalXAException("Trying to start a new tx with wrong flags! new " + xid + ", flags " + flags, XAException.XAER_PROTO); if (currentXid == null) { try { cl.getManagedConnection().getLocalTransaction().begin(); } catch (ResourceException re) { throw new JBossLocalXAException("Error trying to start local tx: ", XAException.XAER_RMERR, re); } catch (Throwable t) { throw new JBossLocalXAException("Throwable trying to start local transaction!", XAException.XAER_RMERR, t); } currentXid = xid; } }
_localTransaction = conn.getLocalTransaction(); } catch (NotSupportedException e) { _cm.setLocalTransaction(false);
private ResourceHandle getResourceHandle() throws PoolingException { try { ResourceHandle h = null; JavaEETransaction j2eetran = getCurrentTransaction(); if (j2eetran == null) { //Only if some thing is wrong with tx manager. h = localHandle_; //Just return the local handle. } else { h = (ResourceHandle)j2eetran.getNonXAResource(); //make sure that if local-tx resource is set as 'unshareable', only one resource //can be acquired. If the resource in question is not the one in transaction, fail if(!localHandle_.isShareable()){ if(h != localHandle_){ throw new ResourceAllocationException("Cannot use more than one local-tx resource in unshareable scope"); } } } if (h.getResourceState().isUnenlisted()) { ManagedConnection mc = (ManagedConnection) h.getResource(); // begin the local transaction if first time // this ManagedConnection is used in this JTA transaction mc.getLocalTransaction().begin(); } return h; } catch (Exception ex) { _logger.log(Level.SEVERE, "poolmgr.system_exception", ex); throw new PoolingException(ex.toString(), ex); } }
/** * {@inheritDoc} */ @Override public void tidyup() throws ResourceException { // We have a hanging transaction if (localTransaction.get()) { LocalTransaction local = null; ManagedConnection mc = getManagedConnection(); try { local = mc.getLocalTransaction(); } catch (Throwable t) { throw new ResourceException(bundle.unfinishedLocalTransaction(this), t); } if (local == null) throw new ResourceException(bundle.unfinishedLocalTransactionNotProvideLocalTransaction(this)); else { local.rollback(); log.debugf("Unfinished local transaction was rolled back.%s", this); } } }
/** * {@inheritDoc} */ public void commit(Xid xid, boolean onePhase) throws XAException { if (!xid.equals(currentXid)) { throw new LocalXAException(bundle.wrongXidInCommit(currentXid, xid), XAException.XAER_PROTO); } currentXid = null; try { cl.getManagedConnection().getLocalTransaction().commit(); } catch (LocalResourceException lre) { connectionManager.returnManagedConnection(cl, true); throw new LocalXAException(bundle.couldNotCommitLocalTx(), XAException.XAER_RMFAIL, lre); } catch (ResourceException re) { connectionManager.returnManagedConnection(cl, true); throw new LocalXAException(bundle.couldNotCommitLocalTx(), XAException.XA_RBROLLBACK, re); } }
/** * {@inheritDoc} */ public void rollback(Xid xid) throws XAException { if (!xid.equals(currentXid)) { throw new LocalXAException(bundle.wrongXidInRollback(currentXid, xid), XAException.XAER_PROTO); } currentXid = null; try { cl.getManagedConnection().getLocalTransaction().rollback(); } catch (LocalResourceException lre) { connectionManager.returnManagedConnection(cl, true); throw new LocalXAException(bundle.couldNotRollbackLocalTx(), XAException.XAER_RMFAIL, lre); } catch (ResourceException re) { connectionManager.returnManagedConnection(cl, true); throw new LocalXAException(bundle.couldNotRollbackLocalTx(), XAException.XAER_RMERR, re); } }
@Override protected void associateTx(final Transaction tx, final ManagedConnectionPool<Object> pool, final ConnectionManagementContext context) throws ResourceException { try { final Object lch = context.getLogicalConnectionHandle(); if (lch == null) { context.allocateLogicalConnectionHandle(); } final LocalTransaction localTx = context.getManagedConnection().getLocalTransaction(); tx.enlistResource(new LocalTransactionXAResource(localTx)); if (pool.size() == 0) { registerContext(tx); } return; } catch (final RollbackException e) { throw new SResourceException("EJCA0000", e); } catch (final SystemException e) { throw new SResourceException("EJCA0000", e); } }
cl.getManagedConnection().getLocalTransaction().begin();