List of usage examples for javax.transaction.xa XAException XAER_INVAL
int XAER_INVAL
To view the source code for javax.transaction.xa XAException XAER_INVAL.
Click Source Link
From source file:com.alibaba.napoli.metamorphosis.client.transaction.TransactionContext.java
@Override public void end(final Xid xid, final int flags) throws XAException { if (LOG.isDebugEnabled()) { LOG.debug("End: " + xid); }//from www. j a v a 2 s . com if (this.isInLocalTransaction()) { throw new XAException(XAException.XAER_PROTO); } if ((flags & (TMSUSPEND | TMFAIL)) != 0) { // You can only suspend the associated xid. if (!this.equals(this.associatedXid, xid)) { throw new XAException(XAException.XAER_PROTO); } // TODO implement resume? this.setXid(null); } else if ((flags & TMSUCCESS) == TMSUCCESS) { if (this.equals(this.associatedXid, xid)) { this.setXid(null); } } else { throw new XAException(XAException.XAER_INVAL); } }
From source file:com.alibaba.napoli.metamorphosis.client.transaction.TransactionContext.java
@Override public boolean setTransactionTimeout(final int seconds) throws XAException { if (seconds < 0) { throw new XAException(XAException.XAER_INVAL); }/*from www . ja v a2 s .co m*/ this.transactionTimeout = seconds; return true; }
From source file:org.apache.slide.common.AbstractXAServiceBase.java
public void end(Xid xid, int flags) throws XAException { TransactionalResource ts = getActiveTransactionalResource(xid); if (ts == null) { setCurrentlyActiveTransactionalResource(null); throw new XAException(XAException.XAER_NOTA); }//w w w . ja va2s. c o m if (getCurrentlyActiveTransactionalResource() == null) { throw new XAException(XAException.XAER_INVAL); } if (getLoggerFacade().isFineEnabled()) { getLoggerFacade().logFine(new StringBuffer(128).append("Thread ").append(Thread.currentThread()) .append(flags == TMSUSPEND ? " suspends" : flags == TMFAIL ? " fails" : " ends") .append(" work on behalf of transaction branch ").append(ts).toString()); } switch (flags) { case TMSUSPEND: ts.suspend(); addSuspendedTransactionalResource(xid, ts); removeActiveTransactionalResource(xid); break; case TMFAIL: ts.setStatus(STATUS_MARKED_ROLLBACK); break; case TMSUCCESS: break; } setCurrentlyActiveTransactionalResource(null); }
From source file:org.apache.slide.common.AbstractXAServiceBase.java
public void start(Xid xid, int flags) throws XAException { if (getCurrentlyActiveTransactionalResource() != null) { throw new XAException(XAException.XAER_INVAL); }/* w ww .j av a 2 s . c om*/ if (getLoggerFacade().isFineEnabled()) { getLoggerFacade().logFine(new StringBuffer(128).append("Thread ").append(Thread.currentThread()) .append(flags == TMNOFLAGS ? " starts" : flags == TMJOIN ? " joins" : " resumes") .append(" work on behalf of transaction branch ").append(xid).toString()); } TransactionalResource ts; switch (flags) { // a new transaction case TMNOFLAGS: case TMJOIN: default: try { ts = createTransactionResource(xid); ts.begin(); } catch (Exception e) { getLoggerFacade().logSevere("Could not create new transactional resource", e); throw new XAException(e.getMessage()); } break; case TMRESUME: ts = getSuspendedTransactionalResource(xid); if (ts == null) { throw new XAException(XAException.XAER_NOTA); } ts.resume(); removeSuspendedTransactionalResource(xid); break; } setCurrentlyActiveTransactionalResource(ts); addAcitveTransactionalResource(xid, ts); }
From source file:org.apache.slide.store.impl.rdbms.AbstractRDBMSStore.java
public void start(Xid xid, int flags) throws XAException { TransactionalResource resource = getCurrentlyActiveTransactionalResource(); if (resource != null) { throw new XAException(XAException.XAER_INVAL); }// ww w . j a va 2 s . c o m if (getLoggerFacade().isFineEnabled()) { getLoggerFacade().logFine(new StringBuffer(128).append("Thread ").append(Thread.currentThread()) .append(flags == TMNOFLAGS ? " starts" : flags == TMJOIN ? " joins" : " resumes") .append(" work on behalf of transaction branch ").append(xid).toString()); } TransactionalResource ts; switch (flags) { // a new transaction case TMNOFLAGS: case TMJOIN: default: try { ts = createTransactionResource(xid); ts.begin(); } catch (Exception e) { getLoggerFacade().logSevere("Could not create new transactional resource", e); throw new XAException(e.getMessage()); } break; case TMRESUME: ts = getSuspendedTransactionalResource(xid); if (ts == null) { throw new XAException(XAException.XAER_NOTA); } ts.resume(); removeSuspendedTransactionalResource(xid); break; } setCurrentlyActiveTransactionalResource(ts); addAcitveTransactionalResource(xid, ts); }
From source file:org.apache.slide.store.txfile.AbstractTxFileStoreService.java
public synchronized void commit(Xid xid, boolean onePhase) throws XAException { Object txId = wrap(xid);/*from ww w . j av a 2 s . c o m*/ Thread currentThread = Thread.currentThread(); getLogger().log("Thread " + currentThread + " commits transaction branch " + txId, getLogChannel(), DEBUG_LEVEL); try { if (!onePhase && rm.getTransactionState(txId) != STATUS_PREPARED) { throw new XAException(XAException.XAER_INVAL); } rm.commitTransaction(txId); activeTransactionBranch.set(null); } catch (ResourceManagerException e) { getLogger().log("Thread " + currentThread + " failed to commit transaction branch " + txId, e, getLogChannel(), Logger.CRITICAL); throw createXAException(e); } }
From source file:org.apache.slide.store.txfile.AbstractTxFileStoreService.java
public synchronized void start(Xid xid, int flags) throws XAException { Object txId = wrap(xid);/* ww w.j a v a 2 s.c o m*/ Thread currentThread = Thread.currentThread(); getLogger().log("Thread " + currentThread + (flags == TMNOFLAGS ? " starts" : flags == TMJOIN ? " joins" : " resumes") + " work on behalf of transaction branch " + txId, getLogChannel(), DEBUG_LEVEL); switch (flags) { // a new transaction case TMNOFLAGS: if (getActiveTxId() != null) { throw new XAException(XAException.XAER_INVAL); } try { rm.startTransaction(txId); activeTransactionBranch.set(txId); } catch (ResourceManagerException e) { throw createXAException(e); } break; case TMJOIN: if (getActiveTxId() != null) { throw new XAException(XAException.XAER_INVAL); } try { if (rm.getTransactionState(txId) == STATUS_NO_TRANSACTION) { throw new XAException(XAException.XAER_INVAL); } } catch (ResourceManagerException e) { throw createXAException(e); } activeTransactionBranch.set(txId); break; case TMRESUME: activeTransactionBranch.set(txId); break; } }
From source file:org.apache.slide.store.txfile.TxXMLFileDescriptorsStore.java
public synchronized void end(Xid xid, int flags) throws XAException { if (getActiveTxId() == null) { throw new XAException(XAException.XAER_INVAL); }//from w w w . j a v a2 s .com Object txId = wrap(xid); Thread currentThread = Thread.currentThread(); getLogger().log("Thread " + currentThread + (flags == TMSUSPEND ? " suspends" : flags == TMFAIL ? " fails" : " ends") + " work on behalf of transaction branch " + txId, LOG_CHANNEL, DEBUG_LEVEL); switch (flags) { case TMSUSPEND: suspendedContexts.put(txId, getActiveTxContext()); activeContexts.remove(txId); activeTransactionBranch.set(null); break; case TMFAIL: try { rm.markTransactionForRollback(wrap(xid)); } catch (ResourceManagerException e) { throw createXAException(e); } activeTransactionBranch.set(null); break; case TMSUCCESS: activeTransactionBranch.set(null); break; } }
From source file:org.apache.slide.store.txfile.TxXMLFileDescriptorsStore.java
public synchronized void start(Xid xid, int flags) throws XAException { Object txId = wrap(xid);//from w ww. j a va 2 s . c om Thread currentThread = Thread.currentThread(); getLogger().log("Thread " + currentThread + (flags == TMNOFLAGS ? " starts" : flags == TMJOIN ? " joins" : " resumes") + " work on behalf of transaction branch " + txId, LOG_CHANNEL, DEBUG_LEVEL); switch (flags) { // a new transaction case TMNOFLAGS: if (getActiveTxId() != null) { throw new XAException(XAException.XAER_INVAL); } try { rm.startTransaction(txId); TxContext txContext = new TxContext(txId); activeTransactionBranch.set(txContext); activeContexts.put(txId, txContext); } catch (ResourceManagerException e) { throw createXAException(e); } break; case TMJOIN: if (getActiveTxId() != null) { throw new XAException(XAException.XAER_INVAL); } try { if (rm.getTransactionState(txId) == STATUS_NO_TRANSACTION) { throw new XAException(XAException.XAER_INVAL); } } catch (ResourceManagerException e) { throw createXAException(e); } TxContext txContext = new TxContext(txId); activeTransactionBranch.set(txContext); activeContexts.put(txId, txContext); break; case TMRESUME: if (getActiveTxId() != null) { throw new XAException(XAException.XAER_INVAL); } txContext = (TxContext) suspendedContexts.remove(txId); if (txContext == null) { throw new XAException(XAException.XAER_NOTA); } activeTransactionBranch.set(txContext); break; } }
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 ww .j a va 2 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); }