List of usage examples for javax.transaction.xa XAException XAException
public XAException(int errcode)
From source file:org.nuxeo.ecm.core.blob.storage.impl.XASession.java
public void start(Xid xid, int flags) throws XAException { if (isAssociated()) { log.error("Resource already associated with a transaction."); throw new XAException(XAException.XAER_PROTO); }//from w w w. j a v a2 s . c om TransactionContext tx = (TransactionContext) transactions.get(xid); if (flags == TMNOFLAGS) { if (tx != null) { throw new XAException(XAException.XAER_DUPID); } tx = createTransaction(xid); } else if (flags == TMJOIN) { if (tx == null) { throw new XAException(XAException.XAER_NOTA); } } else if (flags == TMRESUME) { if (tx == null) { throw new XAException(XAException.XAER_NOTA); } if (!tx.isSuspended()) { log.error("Unable to resume: transaction not suspended."); throw new XAException(XAException.XAER_PROTO); } tx.setSuspended(false); } else { throw new XAException(XAException.XAER_INVAL); } associate(tx); }
From source file:org.nuxeo.ecm.core.blob.storage.impl.XASession.java
public void end(Xid xid, int flags) throws XAException { TransactionContext tx = (TransactionContext) transactions.get(xid); if (tx == null) { throw new XAException(XAException.XAER_NOTA); }//from ww w . j a va2 s. c om if (flags == TMSUSPEND) { if (!isAssociated()) { log.error("Resource not associated with a transaction."); throw new XAException(XAException.XAER_PROTO); } associate(null); tx.setSuspended(true); } else if (flags == TMFAIL || flags == TMSUCCESS) { if (!tx.isSuspended()) { if (!isAssociated()) { log.error("Resource not associated with a transaction."); throw new XAException(XAException.XAER_PROTO); } associate(null); } else { tx.setSuspended(false); } } else { throw new XAException(XAException.XAER_INVAL); } }
From source file:org.nuxeo.ecm.core.blob.storage.impl.XASession.java
public void commit(Xid xid, boolean onePhase) throws XAException { TransactionContext tx = (TransactionContext) transactions.get(xid); if (tx == null) { throw new XAException(XAException.XAER_NOTA); }/*from www . j a va2 s. c om*/ try { if (onePhase) { tx.prepare(); } tx.commit(); } catch (ResourceException e) { XAException ee = new XAException(XAException.XAER_RMERR); ee.initCause(e); throw ee; } transactions.remove(xid); }
From source file:org.nuxeo.ecm.core.blob.storage.impl.XASession.java
public int prepare(Xid xid) throws XAException { TransactionContext tx = (TransactionContext) transactions.get(xid); if (tx == null) { throw new XAException(XAException.XAER_NOTA); }//from ww w . j a v a 2s . com try { tx.prepare(); } catch (ResourceException e) { XAException ee = new XAException(XAException.XAER_RMERR); ee.initCause(e); throw ee; } return XA_OK; }
From source file:org.nuxeo.ecm.core.blob.storage.impl.XASession.java
public void rollback(Xid xid) throws XAException { TransactionContext tx = (TransactionContext) transactions.get(xid); if (tx == null) { throw new XAException(XAException.XAER_NOTA); }/*from ww w . j a v a2 s. c o m*/ try { tx.rollback(); } catch (ResourceException e) { XAException ee = new XAException(XAException.XAER_RMERR); ee.initCause(e); throw ee; } transactions.remove(xid); }
From source file:org.nuxeo.ecm.core.jca.ManagedXAResource.java
private void checkState() throws XAException { if (xar == null) { throw new XAException("the session was not initialized"); }//from w w w . ja v a 2 s. c om }
From source file:org.nuxeo.ecm.core.storage.sql.jdbc.JDBCMapper.java
@Override public void start(Xid xid, int flags) throws XAException { try {/*from w w w . j a v a2 s . com*/ checkConnectionValid(); xaresource.start(xid, flags); if (logger.isLogEnabled()) { logger.log("XA start on " + systemToString(xid)); } } catch (StorageException e) { throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e); } catch (XAException e) { checkConnectionReset(e); logger.error("XA start error on " + systemToString(xid), e); throw e; } }
From source file:org.nuxeo.ecm.core.storage.sql.jdbc.JDBCMapper.java
@Override public void end(Xid xid, int flags) throws XAException { try {/*www .j a va2 s .c o m*/ xaresource.end(xid, flags); if (logger.isLogEnabled()) { logger.log("XA end on " + systemToString(xid)); } } catch (NullPointerException e) { // H2 when no active transaction logger.error("XA end error on " + systemToString(xid), e); throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e); } catch (XAException e) { if (flags != XAResource.TMFAIL) { logger.error("XA end error on " + systemToString(xid), e); } throw e; } }
From source file:org.nuxeo.ecm.core.storage.sql.jdbc.XAResourceConnectionAdapter.java
protected static XAException newXAException(int errorCode, String message) { XAException e = new XAException(message); e.errorCode = errorCode;//from w w w.java 2 s . c om return e; }
From source file:org.nuxeo.ecm.core.storage.sql.SessionImpl.java
@Override public void end(Xid xid, int flags) throws XAException { boolean failed = true; try {/*from w w w . j a v a 2s.c o m*/ if (flags != TMFAIL) { try { flush(); } catch (Exception e) { String msg = "Exception during transaction commit"; if (e instanceof ConcurrentUpdateStorageException) { TransactionHelper.noteSuppressedException(e); log.debug(msg, e); // set rollback only manually instead of throwing, // this avoids a spurious log in Geronimo // TransactionImpl // and has the same effect TransactionHelper.setTransactionRollbackOnly(); return; } else { log.error(msg, e); throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e); } } } failed = false; mapper.end(xid, flags); } finally { if (failed) { mapper.end(xid, TMFAIL); // rollback done by tx manager } } }