List of usage examples for javax.transaction.xa XAException XA_RBCOMMFAIL
int XA_RBCOMMFAIL
To view the source code for javax.transaction.xa XAException XA_RBCOMMFAIL.
Click Source Link
From source file:org.efaps.db.store.VFSStoreResource.java
/** * The method is called from the transaction manager if the complete * transaction is completed.<br/>//w w w . j av a 2s .c o m * A file in the virtual file system is committed with the algorithms: * <ol> * <li>any existing backup fill will be moved to an older backup file. The * maximum number of backups can be defined by setting the property * {@link #PROPERTY_NUMBER_BACKUP}. Default is one. To disable the * property must be set to 0.</li> * <li>the current file is moved to the backup file (or deleted if property * {@link #PROPERTY_NUMBER_BACKUP} is 0)</li> * <li>the new file is moved to the original name</li> * </ol> * * @param _xid global transaction identifier (not used, because each * file with the file id gets a new VFS store resource * instance) * @param _onePhase <i>true</i> if it is a one phase commitment transaction * (not used) * @throws XAException if any exception occurs (catch on * {@link java.lang.Throwable}) */ @Override public void commit(final Xid _xid, final boolean _onePhase) throws XAException { if (VFSStoreResource.LOG.isDebugEnabled()) { VFSStoreResource.LOG.debug("transaction commit"); } if (getStoreEvent() == VFSStoreResource.StoreEvent.WRITE) { try { final FileObject tmpFile = this.manager.resolveFile(this.manager.getBaseFile(), this.storeFileName + VFSStoreResource.EXTENSION_TEMP); final FileObject currentFile = this.manager.resolveFile(this.manager.getBaseFile(), this.storeFileName + VFSStoreResource.EXTENSION_NORMAL); final FileObject bakFile = this.manager.resolveFile(this.manager.getBaseFile(), this.storeFileName + VFSStoreResource.EXTENSION_BACKUP); if (bakFile.exists() && (this.numberBackup > 0)) { backup(bakFile, 0); } if (currentFile.exists()) { if (this.numberBackup > 0) { currentFile.moveTo(bakFile); } else { currentFile.delete(); } } tmpFile.moveTo(currentFile); tmpFile.close(); currentFile.close(); bakFile.close(); } catch (final FileSystemException e) { VFSStoreResource.LOG .error("transaction commit fails for " + _xid + " (one phase = " + _onePhase + ")", e); final XAException xa = new XAException(XAException.XA_RBCOMMFAIL); xa.initCause(e); throw xa; } } else if (getStoreEvent() == VFSStoreResource.StoreEvent.DELETE) { try { final FileObject curFile = this.manager.resolveFile(this.manager.getBaseFile(), this.storeFileName + VFSStoreResource.EXTENSION_NORMAL); final FileObject bakFile = this.manager.resolveFile(this.manager.getBaseFile(), this.storeFileName + VFSStoreResource.EXTENSION_BACKUP); if (bakFile.exists()) { bakFile.delete(); } if (curFile.exists()) { curFile.moveTo(bakFile); } bakFile.close(); curFile.close(); } catch (final FileSystemException e) { VFSStoreResource.LOG .error("transaction commit fails for " + _xid + " (one phase = " + _onePhase + ")", e); final XAException xa = new XAException(XAException.XA_RBCOMMFAIL); xa.initCause(e); throw xa; } } }
From source file:org.efaps.db.store.VFSStoreResource.java
/** * If the file written in the virtual file system must be rolled back, only * the created temporary file (created from method {@link #write}) is * deleted./* w w w . j a v a 2s . c o m*/ * * @param _xid global transaction identifier (not used, because each * file with the file id gets a new VFS store resource * instance) * @throws XAException if any exception occurs (catch on * {@link java.lang.Throwable}) */ @Override public void rollback(final Xid _xid) throws XAException { if (VFSStoreResource.LOG.isDebugEnabled()) { VFSStoreResource.LOG.debug("rollback (xid = " + _xid + ")"); } try { final FileObject tmpFile = this.manager.resolveFile(this.manager.getBaseFile(), this.storeFileName + VFSStoreResource.EXTENSION_TEMP); if (tmpFile.exists()) { tmpFile.delete(); } } catch (final FileSystemException e) { VFSStoreResource.LOG.error("transaction rollback fails for " + _xid, e); final XAException xa = new XAException(XAException.XA_RBCOMMFAIL); xa.initCause(e); throw xa; } }
From source file:org.wso2.andes.client.XASession_9_1.java
/** * Throw {@link XAException} if the connection is closed * * @throws XAException if connection not active */// www . j a va2s .c o m private void throwErrorIfClosed() throws XAException { if (isClosed()) { XAException xaException = new XAException("Session is already closed"); xaException.errorCode = XAException.XA_RBCOMMFAIL; throw xaException; } }