List of usage examples for org.apache.commons.transaction.file ResourceManagerException getMessage
public String getMessage()
From source file:org.jboss.jbossts.fileio.xalib.txdirs.dir.XAFileResourceManager.java
/** * Acts like the {@link org.apache.commons.transaction.file.FileResourceManager#prepareTransaction(Object)} * method does.//from w w w .j a v a 2s . co m * * @param xid the global transaction id * @throws XAException * if a <code>ResourceManagerException</code> is thrown */ public int prepare(Xid xid) throws XAException { // flush data on disk here System.out.println("XAFileResourceManager.prepare(Xid=" + xid + ")"); try { return freMngr.prepareTransaction(curTxId); } catch (ResourceManagerException rme) { throw new XAException(rme.getMessage()); } }
From source file:org.jboss.jbossts.fileio.xalib.txdirs.dir.XAFileResourceManager.java
/** * Method to commit the global transaction with the given <code>xid</code>. * <p/>/* w w w . ja v a 2s . c o m*/ * It also acts like the {@link org.apache.commons.transaction.file.FileResourceManager#commitTransaction(Object)} * does. * * @param xid a global Transaction id * @param onePhase If true, the resource manager should use a one-phase * commit protocol to commit the work done on behalf of xid * @throws XAException * if a <code>ResourceManagerException</code> is thrown */ public void commit(Xid xid, boolean onePhase) throws XAException { System.out.println("XAFileResourceManager.commit(Xid=" + xid + ", onePhase=" + onePhase + ")"); if (!xid.equals(currentXid)) { System.out.println("XAFileResourceManager.commit - wrong Xid!"); } try { if (!recovers) { freMngr.commitTransaction(curTxId); } else { // the initFREM() method will take care of incomplete txs } } catch (ResourceManagerException rme) { throw new XAException(rme.getMessage()); } currentXid = null; }
From source file:org.jboss.jbossts.fileio.xalib.txdirs.dir.XAFileResourceManager.java
/** * Obtain the current transaction timeout value set for this * <code>XAFileResourceManager</code> instance. If * <code>XAFileResourceManager.setTransactionTimeout</code> was not used prior to * invoking this method, the return value is the default timeout set for * the resource manager; otherwise, the value used in the previous * <code>setTransactionTimeout</code> call is returned. * * @return the transaction timeout value in seconds *///from w w w. j a v a 2 s. com public int getTransactionTimeout() throws XAException { try { int timeout = (int) freMngr.getTransactionTimeout(curTxId) / 1000; // ms -> secs System.out.println("XAFileResourceManager.getTransactionTimeout() [returning " + timeout + "]"); return timeout; } catch (ResourceManagerException rme) { throw new XAException(rme.getMessage()); } }
From source file:org.jboss.jbossts.fileio.xalib.txdirs.dir.XAFileResourceManager.java
/** * Rollback any updates attempted to be written to the directory. * <p/>//from w w w .j a v a 2 s . c om * The method acts like the * {@link org.apache.commons.transaction.file.FileResourceManager#rollbackTransaction(Object)} * does. * @param xid a global Transaction id * @throws XAException * if a <code>ResourceManagerException</code> is thrown */ public void rollback(Xid xid) throws XAException { System.out.println("XAFileResourceManager.rollback(Xid=" + xid + ")"); try { freMngr.rollbackTransaction(curTxId); } catch (ResourceManagerException rme) { throw new XAException(rme.getMessage()); } currentXid = null; }
From source file:org.jboss.jbossts.fileio.xalib.txdirs.dir.XAFileResourceManager.java
/** * Set the current transaction <code>timeout</code> value for this * <code>XAFileResourceManager</code> instance. Once set, this timeout value is * effective until <code>setTransactionTimeout</code> is invoked again with * a different value.//from w ww .ja va 2 s. c om * The method acts like the * {@link org.apache.commons.transaction.file.FileResourceManager#setTransactionTimeout(Object, long)} * does. * * @param seconds transaction timeout value in seconds * @return true if transaction timeout value is set successfully; * otherwise false */ public boolean setTransactionTimeout(int seconds) throws XAException { System.out.println("XAFileResourceManager.setTransactionTimeout(timeout=" + seconds + ")"); try { freMngr.setTransactionTimeout(curTxId, seconds * 1000); } catch (ResourceManagerException rme) { throw new XAException(rme.getMessage()); } return false; }
From source file:org.jboss.jbossts.fileio.xalib.txdirs.dir.XAFileResourceManager.java
/** * Start work on behalf of a transaction branch specified in <code>xid</code>. * The method act like the//ww w.ja va 2s. com * {@link org.apache.commons.transaction.file.FileResourceManager#startTransaction(Object)} * does. * @param xid a global Transaction id to be associated with this * Resource Manager instance * @param flags (can be anything) * @throws XAException if there is already a Transaction */ public void start(Xid xid, int flags) throws XAException { System.out.println("XAFileResourceManager.start(Xid=" + xid + ", flags=" + flags + ")"); if (currentXid != null) { System.out.println("XAFileResourceManager.start - wrong Xid!"); throw new XAException( "Current Transaction is: <" + currentXid + ">\nCannot start the new Transaction."); } try { freMngr.startTransaction(curTxId); } catch (ResourceManagerException rme) { throw new XAException(rme.getMessage()); } currentXid = xid; }