From: <mro...@us...> - 2012-11-05 17:29:45
|
Revision: 57314 http://firebird.svn.sourceforge.net/firebird/?rev=57314&view=rev Author: mrotteveel Date: 2012-11-05 17:29:36 +0000 (Mon, 05 Nov 2012) Log Message: ----------- Cleanup IscTrHandle implementations and usage (step towards using interfaces wherever possible) Modified Paths: -------------- client-java/trunk/src/main/org/firebirdsql/gds/IscTrHandle.java client-java/trunk/src/main/org/firebirdsql/gds/impl/AbstractIscTrHandle.java client-java/trunk/src/main/org/firebirdsql/gds/impl/GDSHelper.java client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/BaseGDSImpl.java client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_tr_handle_impl.java client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/AbstractJavaGDSImpl.java client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/XdrInputStream.java client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/isc_tr_handle_impl.java client-java/trunk/src/main/org/firebirdsql/jca/FBManagedConnection.java client-java/trunk/src/test/org/firebirdsql/gds/TestReconnectTransaction.java Modified: client-java/trunk/src/main/org/firebirdsql/gds/IscTrHandle.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/IscTrHandle.java 2012-11-05 15:57:56 UTC (rev 57313) +++ client-java/trunk/src/main/org/firebirdsql/gds/IscTrHandle.java 2012-11-05 17:29:36 UTC (rev 57314) @@ -44,10 +44,79 @@ */ public interface IscTrHandle { + // TODO Replace with enum + public static final int NOTRANSACTION = 0; + public static final int TRANSACTIONSTARTING = 1; + public static final int TRANSACTIONSTARTED = 2; + public static final int TRANSACTIONPREPARING = 3; + public static final int TRANSACTIONPREPARED = 4; + public static final int TRANSACTIONCOMMITTING = 5; + public static final int TRANSACTIONROLLINGBACK = 6; + + int getTransactionId(); + + void setTransactionId(final int rtr_id); + /** * Retrieve a handle to the database to which this transaction is linked. * * @return Handle to the database */ IscDbHandle getDbHandle(); + + /** + * Sets a handle to the database to which this transaction is linked. + * + * @return Handle to the database + */ + void setDbHandle(IscDbHandle db); + + /** + * Clears the database handle associated with this transaction + */ + public void unsetDbHandle(); + + /** + * Add a warning to the connection associated with this transaction. + * + * @param warning Warning to add + */ + void addWarning(GDSException warning); + + /** + * Get the current state of the transaction to which this handle is + * pointing. The state is equal to one of the <code>TRANSACTION*</code> + * constants of this interface, or the <code>NOTRANSACTION</code> constant, + * also of this interface. + * + * @return The corresponding value for the current state + */ + int getState(); + + void setState(int state); + + void addBlob(IscBlobHandle blob); + + void removeBlob(IscBlobHandle blob); + + /** + * Register a statement within the transaction to which this handle points. + * This method allows automated cleanup of the rows fetched within a + * transaction on commit or rollback point. + * + * @param stmt Handle to the statement to be registered. + */ + void registerStatementWithTransaction(IscStmtHandle stmt); + + /** + * Unregister a statement from the transaction in which it was registered. + * + * @param stmt Handle to the statement to be unregistered. + */ + void unregisterStatementFromTransaction(IscStmtHandle stmt); + + /** + * Clear all the saved result sets from this handle. + */ + void forgetResultSets(); } Modified: client-java/trunk/src/main/org/firebirdsql/gds/impl/AbstractIscTrHandle.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/impl/AbstractIscTrHandle.java 2012-11-05 15:57:56 UTC (rev 57313) +++ client-java/trunk/src/main/org/firebirdsql/gds/impl/AbstractIscTrHandle.java 2012-11-05 17:29:36 UTC (rev 57314) @@ -1,27 +1,28 @@ /* - * Public Firebird Java API. + * Firebird Open Source J2ee connector - jdbc driver * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Distributable under LGPL license. + * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * LGPL License for more details. + * + * This file was created by members of the firebird development team. + * All individual contributions remain the Copyright (C) of those + * individuals. Contributors to this file are either listed here or + * can be obtained from a CVS history command. + * + * All rights reserved. */ +/* + * The Original Code is the Firebird Java GDS implementation. + * + * The Initial Developer of the Original Code is Alejandro Alberola. + * Portions created by Alejandro Alberola are Copyright (C) 2001 + * Boix i Oltra, S.L. All Rights Reserved. + */ package org.firebirdsql.gds.impl; import java.util.Collections; @@ -31,30 +32,27 @@ import java.util.List; import java.util.Set; +import org.firebirdsql.gds.GDSException; import org.firebirdsql.gds.IscBlobHandle; +import org.firebirdsql.gds.IscDbHandle; import org.firebirdsql.gds.IscStmtHandle; import org.firebirdsql.gds.IscTrHandle; /** * Abstract implementation of the {@link org.firebirdsql.gds.IscTrHandle} * interface. + * + * @author <a href="mailto:alb...@us...">Alejandro Alberola</a> + * @author <a href="mailto:d_j...@us...">David Jencks</a> */ public abstract class AbstractIscTrHandle implements IscTrHandle { - public final static int NOTRANSACTION = 0; - public final static int TRANSACTIONCOMMITTING = 5; - public final static int TRANSACTIONPREPARED = 4; - public final static int TRANSACTIONPREPARING = 3; - public final static int TRANSACTIONROLLINGBACK = 6; - public final static int TRANSACTIONSTARTED = 2; - public final static int TRANSACTIONSTARTING = 1; - private final List<IscBlobHandle> blobs = Collections.synchronizedList(new LinkedList<IscBlobHandle>()); private final Set<IscStmtHandle> stmts = Collections.synchronizedSet(new HashSet<IscStmtHandle>()); + private IscDbHandle rtr_rdb; + private int state = NOTRANSACTION; + private int rtr_id; - /** - * Clear all the saved result sets from this handle. - */ public void forgetResultSets() { synchronized(stmts) { for (Iterator<IscStmtHandle> iter = stmts.iterator(); iter.hasNext();) { @@ -65,16 +63,6 @@ stmts.clear(); } } - - /** - * Get the current state of the transaction to which this handle is - * pointing. The state is equal to one of the <code>TRANSACTION*</code> - * constants of this interface, or the <code>NOTRANSACTION</code> constant, - * also of this interface. - * - * @return The corresponding value for the current state - */ - public abstract int getState(); public void addBlob(IscBlobHandle blob) { blobs.add(blob); @@ -84,23 +72,60 @@ blobs.remove(blob); } - /** - * Register a statement within the transaction to which this handle points. - * This method allows automated cleanup of the rows fetched within a - * transaction on commit or rollback point. - * - * @param fbStatement Handle to the statement to be registered. - */ public void registerStatementWithTransaction(IscStmtHandle stmt) { stmts.add(stmt); } - /** - * Unregister a statement from the transaction in which it was registered. - * - * @param fbStatement Handle to the statement to be unregistered. - */ public void unregisterStatementFromTransaction(IscStmtHandle stmt) { stmts.remove(stmt); } + + public void addWarning(GDSException warning) { + rtr_rdb.addWarning(warning); + } + + public IscDbHandle getDbHandle() { + return rtr_rdb; + } + + public void setDbHandle(final IscDbHandle db) { + this.rtr_rdb = db; + rtr_rdb.addTransaction(this); + } + + public void unsetDbHandle() { + rtr_rdb.removeTransaction(this); + rtr_rdb = null; + } + + public void setState(int state) { + this.state = state; + } + + public int getState() { + return state; + } + + public void setTransactionId(final int rtr_id) { + this.rtr_id = rtr_id; + } + + public int getTransactionId() { + return rtr_id; + } + + @Override + public int hashCode() { + return rtr_id; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) + return true; + if (!(obj instanceof AbstractIscTrHandle)) + return false; + AbstractIscTrHandle that = (AbstractIscTrHandle) obj; + return this.rtr_id == that.rtr_id; + } } Modified: client-java/trunk/src/main/org/firebirdsql/gds/impl/GDSHelper.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/impl/GDSHelper.java 2012-11-05 15:57:56 UTC (rev 57313) +++ client-java/trunk/src/main/org/firebirdsql/gds/impl/GDSHelper.java 2012-11-05 17:29:36 UTC (rev 57314) @@ -90,7 +90,7 @@ listener.errorOccured(ex); } - public synchronized AbstractIscTrHandle getCurrentTrHandle() { + public synchronized IscTrHandle getCurrentTrHandle() { return currentTr; } @@ -592,7 +592,7 @@ } } - public void prepareTransaction(AbstractIscTrHandle trHandle, byte[] message) throws GDSException { + public void prepareTransaction(IscTrHandle trHandle, byte[] message) throws GDSException { try { gds.iscPrepareTransaction2(trHandle, message); } catch(GDSException ex) { @@ -601,7 +601,7 @@ } } - public void commitTransaction(AbstractIscTrHandle trHandle) throws GDSException { + public void commitTransaction(IscTrHandle trHandle) throws GDSException { try { gds.iscCommitTransaction(trHandle); } catch(GDSException ex) { @@ -610,7 +610,7 @@ } } - public void rollbackTransaction(AbstractIscTrHandle trHandle) throws GDSException { + public void rollbackTransaction(IscTrHandle trHandle) throws GDSException { try { gds.iscRollbackTransaction(trHandle); } catch(GDSException ex) { Modified: client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/BaseGDSImpl.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/BaseGDSImpl.java 2012-11-05 15:57:56 UTC (rev 57313) +++ client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/BaseGDSImpl.java 2012-11-05 17:29:36 UTC (rev 57314) @@ -185,26 +185,25 @@ // isc_commit_retaining // --------------------------------------------------------------------------------------------- public void iscCommitRetaining(IscTrHandle tr_handle) throws GDSException { - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { + if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } - IscDbHandle db = tr.getDbHandle(); + IscDbHandle db = tr_handle.getDbHandle(); if (db == null || !db.isValid()) throw new GDSException(ISCConstants.isc_bad_db_handle); synchronized (db) { - if (tr.getState() != AbstractIscTrHandle.TRANSACTIONSTARTED - && tr.getState() != AbstractIscTrHandle.TRANSACTIONPREPARED) { + if (tr_handle.getState() != IscTrHandle.TRANSACTIONSTARTED + && tr_handle.getState() != IscTrHandle.TRANSACTIONPREPARED) { throw new GDSException(ISCConstants.isc_tra_state); } - tr.setState(AbstractIscTrHandle.TRANSACTIONCOMMITTING); + tr_handle.setState(IscTrHandle.TRANSACTIONCOMMITTING); native_isc_commit_retaining(tr_handle); - tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTED); + tr_handle.setState(IscTrHandle.TRANSACTIONSTARTED); } } @@ -214,24 +213,23 @@ if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - IscDbHandle db = tr.getDbHandle(); + IscDbHandle db = tr_handle.getDbHandle(); if (db == null || !db.isValid()) throw new GDSException(ISCConstants.isc_bad_db_handle); synchronized (db) { - if (tr.getState() != AbstractIscTrHandle.TRANSACTIONSTARTED - && tr.getState() != AbstractIscTrHandle.TRANSACTIONPREPARED) { + if (tr_handle.getState() != IscTrHandle.TRANSACTIONSTARTED + && tr_handle.getState() != IscTrHandle.TRANSACTIONPREPARED) { throw new GDSException(ISCConstants.isc_tra_state); } - tr.setState(AbstractIscTrHandle.TRANSACTIONCOMMITTING); + tr_handle.setState(IscTrHandle.TRANSACTIONCOMMITTING); native_isc_commit_transaction(tr_handle); - tr.setState(AbstractIscTrHandle.NOTRANSACTION); + tr_handle.setState(IscTrHandle.NOTRANSACTION); - tr.unsetDbHandle(); + tr_handle.unsetDbHandle(); } } @@ -241,13 +239,12 @@ IscBlobHandle blob_handle, BlobParameterBuffer blobParameterBuffer) throws GDSException { AbstractIscDbHandle db = (AbstractIscDbHandle) db_handle; - AbstractIscTrHandle tr = (AbstractIscTrHandle) tr_handle; isc_blob_handle_impl blob = (isc_blob_handle_impl) blob_handle; if (db == null) { throw new GDSException(ISCConstants.isc_bad_db_handle); } - if (tr == null) { + if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } if (blob == null) { @@ -262,8 +259,8 @@ native_isc_create_blob2(db_handle, tr_handle, blob_handle, bpb); blob.setDb(db); - blob.setTr(tr); - tr.addBlob(blob); + blob.setTr((AbstractIscTrHandle) tr_handle); + tr_handle.addBlob(blob); } } @@ -540,9 +537,7 @@ if (stmt_handle == null) { throw new GDSException(ISCConstants.isc_bad_req_handle); } - IscDbHandle db = stmt_handle.getRsr_rdb(); - - synchronized (db) { + synchronized (stmt_handle.getRsr_rdb()) { // Does not seem to be possible or necessary to close // an execute procedure statement. if (stmt_handle.isSingletonResult() && option == ISCConstants.DSQL_close) { return; } @@ -674,7 +669,7 @@ // --------------------------------------------------------------------------------------------- public byte[] iscDsqlSqlInfo(IscStmtHandle stmt_handle, byte[] items, int buffer_length) throws GDSException { - synchronized (((AbstractIscStmtHandle) stmt_handle).getRsr_rdb()) { + synchronized (stmt_handle.getRsr_rdb()) { return native_isc_dsql_sql_info(stmt_handle, items, buffer_length); } } @@ -693,14 +688,12 @@ public void iscOpenBlob2(IscDbHandle db_handle, IscTrHandle tr_handle, IscBlobHandle blob_handle, BlobParameterBuffer blobParameterBuffer) throws GDSException { - AbstractIscDbHandle db = (AbstractIscDbHandle) db_handle; - AbstractIscTrHandle tr = (AbstractIscTrHandle) tr_handle; isc_blob_handle_impl blob = (isc_blob_handle_impl) blob_handle; - if (db == null) { + if (db_handle == null) { throw new GDSException(ISCConstants.isc_bad_db_handle); } - if (tr == null) { + if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } if (blob == null) { @@ -711,12 +704,12 @@ : ((BlobParameterBufferImp) blobParameterBuffer) .getBytesForNativeCode(); - synchronized (db) { + synchronized (db_handle) { native_isc_open_blob2(db_handle, tr_handle, blob_handle, bpb); - blob.setDb(db); - blob.setTr(tr); - tr.addBlob(blob); + blob.setDb((AbstractIscDbHandle) db_handle); + blob.setTr((AbstractIscTrHandle) tr_handle); + tr_handle.addBlob(blob); } } @@ -724,19 +717,18 @@ // --------------------------------------------------------------------------------------------- public void iscPrepareTransaction(IscTrHandle tr_handle) throws GDSException { - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { + if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } - synchronized (tr.getDbHandle()) { - if (tr.getState() != AbstractIscTrHandle.TRANSACTIONSTARTED) { throw new GDSException( + synchronized (tr_handle.getDbHandle()) { + if (tr_handle.getState() != IscTrHandle.TRANSACTIONSTARTED) { throw new GDSException( ISCConstants.isc_tra_state); } - tr.setState(AbstractIscTrHandle.TRANSACTIONPREPARING); + tr_handle.setState(IscTrHandle.TRANSACTIONPREPARING); native_isc_prepare_transaction(tr_handle); - tr.setState(AbstractIscTrHandle.TRANSACTIONPREPARED); + tr_handle.setState(IscTrHandle.TRANSACTIONPREPARED); } } @@ -744,21 +736,20 @@ // --------------------------------------------------------------------------------------------- public void iscPrepareTransaction2(IscTrHandle tr_handle, byte[] bytes) throws GDSException { - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { + if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } - synchronized (tr.getDbHandle()) { - if (tr.getState() != AbstractIscTrHandle.TRANSACTIONSTARTED) { + synchronized (tr_handle.getDbHandle()) { + if (tr_handle.getState() != IscTrHandle.TRANSACTIONSTARTED) { throw new GDSException(ISCConstants.isc_tra_state); } - tr.setState(AbstractIscTrHandle.TRANSACTIONPREPARING); + tr_handle.setState(IscTrHandle.TRANSACTIONPREPARING); native_isc_prepare_transaction2(tr_handle, bytes); - tr.setState(AbstractIscTrHandle.TRANSACTIONPREPARED); + tr_handle.setState(IscTrHandle.TRANSACTIONPREPARED); } } @@ -780,43 +771,40 @@ public void iscReconnectTransaction(IscTrHandle tr_handle, IscDbHandle db_handle, long transactionId) throws GDSException { - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - byte[] buffer = new byte[4]; for (int i = 0; i < 4; i++){ buffer[i] = (byte)(transactionId >>> (i * 8)); } synchronized (db_handle) { - tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTING); + tr_handle.setState(IscTrHandle.TRANSACTIONSTARTING); native_isc_reconnect_transaction(db_handle, tr_handle, buffer); - tr.setDbHandle(db_handle); + tr_handle.setDbHandle(db_handle); - tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTED); + tr_handle.setState(IscTrHandle.TRANSACTIONSTARTED); } } // isc_rollback_retaining // --------------------------------------------------------------------------------------------- public void iscRollbackRetaining(IscTrHandle tr_handle) throws GDSException { - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { + if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } - IscDbHandle db = tr.getDbHandle(); + IscDbHandle db = tr_handle.getDbHandle(); if (db == null || !db.isValid()) throw new GDSException(ISCConstants.isc_bad_db_handle); synchronized (db) { - if (tr.getState() != AbstractIscTrHandle.TRANSACTIONSTARTED - && tr.getState() != AbstractIscTrHandle.TRANSACTIONPREPARED) { throw new GDSException( + if (tr_handle.getState() != IscTrHandle.TRANSACTIONSTARTED + && tr_handle.getState() != IscTrHandle.TRANSACTIONPREPARED) { throw new GDSException( ISCConstants.isc_tra_state); } - tr.setState(AbstractIscTrHandle.TRANSACTIONROLLINGBACK); + tr_handle.setState(IscTrHandle.TRANSACTIONROLLINGBACK); native_isc_rollback_retaining(tr_handle); - tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTED); + tr_handle.setState(IscTrHandle.TRANSACTIONSTARTED); } } @@ -824,24 +812,23 @@ // --------------------------------------------------------------------------------------------- public void iscRollbackTransaction(IscTrHandle tr_handle) throws GDSException { - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { + if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } - IscDbHandle db = tr.getDbHandle(); + IscDbHandle db = tr_handle.getDbHandle(); if (db == null || !db.isValid()) throw new GDSException(ISCConstants.isc_bad_db_handle); synchronized (db) { - if (tr.getState() == AbstractIscTrHandle.NOTRANSACTION) { throw new GDSException( + if (tr_handle.getState() == IscTrHandle.NOTRANSACTION) { throw new GDSException( ISCConstants.isc_tra_state); } - tr.setState(AbstractIscTrHandle.TRANSACTIONROLLINGBACK); + tr_handle.setState(IscTrHandle.TRANSACTIONROLLINGBACK); native_isc_rollback_transaction(tr_handle); - tr.setState(AbstractIscTrHandle.NOTRANSACTION); - tr.unsetDbHandle(); + tr_handle.setState(IscTrHandle.NOTRANSACTION); + tr_handle.unsetDbHandle(); } } @@ -927,10 +914,9 @@ public void iscStartTransaction(IscTrHandle tr_handle, IscDbHandle db_handle, TransactionParameterBuffer tpb) throws GDSException { - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; TransactionParameterBufferImpl tpbImpl = (TransactionParameterBufferImpl) tpb; - if (tr == null) { + if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } @@ -939,17 +925,17 @@ } synchronized (db_handle) { - if (tr.getState() != AbstractIscTrHandle.NOTRANSACTION) + if (tr_handle.getState() != IscTrHandle.NOTRANSACTION) throw new GDSException(ISCConstants.isc_tra_state); - tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTING); + tr_handle.setState(IscTrHandle.TRANSACTIONSTARTING); byte[] arg = tpbImpl.getBytesForNativeCode(); native_isc_start_transaction(tr_handle, db_handle, arg); - tr.setDbHandle(db_handle); + tr_handle.setDbHandle(db_handle); - tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTED); + tr_handle.setState(IscTrHandle.TRANSACTIONSTARTED); } } Modified: client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_tr_handle_impl.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_tr_handle_impl.java 2012-11-05 15:57:56 UTC (rev 57313) +++ client-java/trunk/src/main/org/firebirdsql/gds/impl/jni/isc_tr_handle_impl.java 2012-11-05 17:29:36 UTC (rev 57314) @@ -16,20 +16,10 @@ * * All rights reserved. */ -/* - * The Original Code is the Firebird Java GDS implementation. - * - * The Initial Developer of the Original Code is Alejandro Alberola. - * Portions created by Alejandro Alberola are Copyright (C) 2001 - * Boix i Oltra, S.L. All Rights Reserved. - */ package org.firebirdsql.gds.impl.jni; -import org.firebirdsql.gds.IscDbHandle; -import org.firebirdsql.gds.GDSException; import org.firebirdsql.gds.impl.AbstractIscTrHandle; - /** * Describe class <code>isc_tr_handle_impl</code> here. * @@ -38,46 +28,4 @@ * @version 1.0 */ public final class isc_tr_handle_impl extends AbstractIscTrHandle { - private int rtr_id; - - private IscDbHandle rtr_rdb; - private int state = NOTRANSACTION; - - public isc_tr_handle_impl() { - } - - public void addWarning(GDSException warning) { - rtr_rdb.addWarning(warning); - } - - public IscDbHandle getDbHandle() { - return rtr_rdb; - } - - void setState(int state) { - this.state = state; - } - - public int getState() { - return state; - } - - void setTransactionId(final int rtr_id) - { - this.rtr_id = rtr_id; - } - - int getTransactionId() { - return rtr_id; - } - - void setDbHandle(final IscDbHandle db) { - this.rtr_rdb = db; - rtr_rdb.addTransaction(this); - } - - void unsetDbHandle() { - rtr_rdb.removeTransaction(this); - rtr_rdb = null; - } } Modified: client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/AbstractJavaGDSImpl.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/AbstractJavaGDSImpl.java 2012-11-05 15:57:56 UTC (rev 57313) +++ client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/AbstractJavaGDSImpl.java 2012-11-05 17:29:36 UTC (rev 57314) @@ -72,8 +72,9 @@ public static final String PURE_JAVA_TYPE_NAME = "PURE_JAVA"; - private static Logger log = LoggerFactory.getLogger( - AbstractJavaGDSImpl.class, false); + private static Logger log = LoggerFactory.getLogger(AbstractJavaGDSImpl.class, false); + + // TODO Move operation constants to separate class/interface /* Operation (packet) types */ @@ -734,7 +735,6 @@ TransactionParameterBuffer tpb) throws GDSException { boolean debug = log != null && log.isDebugEnabled(); - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; isc_db_handle_impl db = (isc_db_handle_impl) db_handle; TransactionParameterBufferImpl tpbImpl = (TransactionParameterBufferImpl) tpb; @@ -742,15 +742,15 @@ if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } - - if (db_handle == null) { + if (db == null) { throw new GDSException(ISCConstants.isc_bad_db_handle); } + synchronized (db) { - if (tr.getState() != AbstractIscTrHandle.NOTRANSACTION) { + if (tr_handle.getState() != IscTrHandle.NOTRANSACTION) { throw new GDSException(ISCConstants.isc_tra_state); } - tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTING); + tr_handle.setState(IscTrHandle.TRANSACTIONSTARTING); try { if (debug) @@ -765,10 +765,10 @@ } catch (IOException ex) { throw new GDSException(ISCConstants.isc_network_error); } - tr.setTransactionId(db.getResp_object()); + tr_handle.setTransactionId(db.getResp_object()); - tr.setDbHandle(db); - tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTED); + tr_handle.setDbHandle(db); + tr_handle.setState(IscTrHandle.TRANSACTIONSTARTED); } } @@ -777,20 +777,19 @@ IscDbHandle db_handle, long transactionId) throws GDSException { boolean debug = log != null && log.isDebugEnabled(); - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; isc_db_handle_impl db = (isc_db_handle_impl) db_handle; if (tr_handle == null) throw new GDSException(ISCConstants.isc_bad_trans_handle); - if (db_handle == null) + if (db == null) throw new GDSException(ISCConstants.isc_bad_db_handle); synchronized (db) { - if (tr.getState() != AbstractIscTrHandle.NOTRANSACTION) + if (tr_handle.getState() != IscTrHandle.NOTRANSACTION) throw new GDSException(ISCConstants.isc_tra_state); - tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTING); + tr_handle.setState(IscTrHandle.TRANSACTIONSTARTING); try { if (debug) @@ -812,11 +811,10 @@ } catch (IOException ex) { throw new GDSException(ISCConstants.isc_network_error); } - tr.setTransactionId(db.getResp_object()); + tr_handle.setTransactionId(db.getResp_object()); - // tr.rtr_rdb = db; - tr.setDbHandle(db); - tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTED); + tr_handle.setDbHandle(db); + tr_handle.setState(IscTrHandle.TRANSACTIONSTARTED); // db.rdb_transactions.addElement(tr); } } @@ -827,27 +825,26 @@ throw new GDSException(ISCConstants.isc_bad_trans_handle); } - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - isc_db_handle_impl db = (isc_db_handle_impl) tr.getDbHandle(); + isc_db_handle_impl db = (isc_db_handle_impl) tr_handle.getDbHandle(); if (db == null || !db.isValid()) throw new GDSException(ISCConstants.isc_bad_db_handle); synchronized (db) { - if (tr.getState() != AbstractIscTrHandle.TRANSACTIONSTARTED - && tr.getState() != AbstractIscTrHandle.TRANSACTIONPREPARED) { + if (tr_handle.getState() != IscTrHandle.TRANSACTIONSTARTED + && tr_handle.getState() != IscTrHandle.TRANSACTIONPREPARED) { throw new GDSException(ISCConstants.isc_tra_state); } - tr.setState(AbstractIscTrHandle.TRANSACTIONCOMMITTING); + tr_handle.setState(IscTrHandle.TRANSACTIONCOMMITTING); try { if (debug) { log.debug("op_commit "); - log.debug("tr.rtr_id: " + tr.getTransactionId()); + log.debug("tr.rtr_id: " + tr_handle.getTransactionId()); } db.out.writeInt(op_commit); - db.out.writeInt(tr.getTransactionId()); + db.out.writeInt(tr_handle.getTransactionId()); db.out.flush(); if (debug) log.debug("sent"); @@ -856,34 +853,33 @@ throw new GDSException(ISCConstants.isc_net_read_err); } - tr.setState(AbstractIscTrHandle.NOTRANSACTION); - tr.unsetDbHandle(); + tr_handle.setState(IscTrHandle.NOTRANSACTION); + tr_handle.unsetDbHandle(); } } public void iscCommitRetaining(IscTrHandle tr_handle) throws GDSException { boolean debug = log != null && log.isDebugEnabled(); - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { + if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } - isc_db_handle_impl db = (isc_db_handle_impl) tr.getDbHandle(); + isc_db_handle_impl db = (isc_db_handle_impl) tr_handle.getDbHandle(); if (db == null || !db.isValid()) throw new GDSException(ISCConstants.isc_bad_db_handle); synchronized (db) { - if (tr.getState() != AbstractIscTrHandle.TRANSACTIONSTARTED - && tr.getState() != AbstractIscTrHandle.TRANSACTIONPREPARED) { + if (tr_handle.getState() != IscTrHandle.TRANSACTIONSTARTED + && tr_handle.getState() != IscTrHandle.TRANSACTIONPREPARED) { throw new GDSException(ISCConstants.isc_tra_state); } - tr.setState(AbstractIscTrHandle.TRANSACTIONCOMMITTING); + tr_handle.setState(IscTrHandle.TRANSACTIONCOMMITTING); try { if (debug) log.debug("op_commit_retaining "); db.out.writeInt(op_commit_retaining); - db.out.writeInt(tr.getTransactionId()); + db.out.writeInt(tr_handle.getTransactionId()); db.out.flush(); if (debug) log.debug("sent"); @@ -891,7 +887,7 @@ } catch (IOException ex) { throw new GDSException(ISCConstants.isc_net_read_err); } - tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTED); + tr_handle.setState(IscTrHandle.TRANSACTIONSTARTED); } } @@ -899,22 +895,21 @@ public void iscPrepareTransaction(IscTrHandle tr_handle) throws GDSException { boolean debug = log != null && log.isDebugEnabled(); - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { + if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } - isc_db_handle_impl db = (isc_db_handle_impl) tr.getDbHandle(); + isc_db_handle_impl db = (isc_db_handle_impl) tr_handle.getDbHandle(); synchronized (db) { - if (tr.getState() != AbstractIscTrHandle.TRANSACTIONSTARTED) { + if (tr_handle.getState() != IscTrHandle.TRANSACTIONSTARTED) { throw new GDSException(ISCConstants.isc_tra_state); } - tr.setState(AbstractIscTrHandle.TRANSACTIONPREPARING); + tr_handle.setState(IscTrHandle.TRANSACTIONPREPARING); try { if (debug) log.debug("op_prepare "); db.out.writeInt(op_prepare); - db.out.writeInt(tr.getTransactionId()); + db.out.writeInt(tr_handle.getTransactionId()); db.out.flush(); if (debug) log.debug("sent"); @@ -922,29 +917,28 @@ } catch (IOException ex) { throw new GDSException(ISCConstants.isc_net_read_err); } - tr.setState(AbstractIscTrHandle.TRANSACTIONPREPARED); + tr_handle.setState(IscTrHandle.TRANSACTIONPREPARED); } } public void iscPrepareTransaction2(IscTrHandle tr_handle, byte[] bytes) throws GDSException { boolean debug = log != null && log.isDebugEnabled(); - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { + if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } - isc_db_handle_impl db = (isc_db_handle_impl) tr.getDbHandle(); + isc_db_handle_impl db = (isc_db_handle_impl) tr_handle.getDbHandle(); synchronized (db) { - if (tr.getState() != AbstractIscTrHandle.TRANSACTIONSTARTED) { + if (tr_handle.getState() != IscTrHandle.TRANSACTIONSTARTED) { throw new GDSException(ISCConstants.isc_tra_state); } - tr.setState(AbstractIscTrHandle.TRANSACTIONPREPARING); + tr_handle.setState(IscTrHandle.TRANSACTIONPREPARING); try { if (debug) log.debug("op_prepare2 "); db.out.writeInt(op_prepare2); - db.out.writeInt(tr.getTransactionId()); + db.out.writeInt(tr_handle.getTransactionId()); db.out.writeBuffer(bytes); db.out.flush(); if (debug) @@ -954,7 +948,7 @@ throw new GDSException(ISCConstants.isc_net_read_err); } - tr.setState(AbstractIscTrHandle.TRANSACTIONPREPARED); + tr_handle.setState(IscTrHandle.TRANSACTIONPREPARED); } } @@ -962,26 +956,25 @@ throws GDSException { boolean debug = log != null && log.isDebugEnabled(); - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { + if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } - isc_db_handle_impl db = (isc_db_handle_impl) tr.getDbHandle(); + isc_db_handle_impl db = (isc_db_handle_impl) tr_handle.getDbHandle(); if (db == null || !db.isValid()) throw new GDSException(ISCConstants.isc_bad_db_handle); synchronized (db) { - if (tr.getState() == AbstractIscTrHandle.NOTRANSACTION) { + if (tr_handle.getState() == IscTrHandle.NOTRANSACTION) { throw new GDSException(ISCConstants.isc_tra_state); } - tr.setState(AbstractIscTrHandle.TRANSACTIONROLLINGBACK); + tr_handle.setState(IscTrHandle.TRANSACTIONROLLINGBACK); try { if (debug) log.debug("op_rollback "); db.out.writeInt(op_rollback); - db.out.writeInt(tr.getTransactionId()); + db.out.writeInt(tr_handle.getTransactionId()); db.out.flush(); if (debug) log.debug("sent"); @@ -989,34 +982,33 @@ } catch (IOException ex) { throw new GDSException(ISCConstants.isc_net_read_err); } finally { - tr.setState(AbstractIscTrHandle.NOTRANSACTION); - tr.unsetDbHandle(); + tr_handle.setState(IscTrHandle.NOTRANSACTION); + tr_handle.unsetDbHandle(); } } } public void iscRollbackRetaining(IscTrHandle tr_handle) throws GDSException { boolean debug = log != null && log.isDebugEnabled(); - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { + if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } - isc_db_handle_impl db = (isc_db_handle_impl) tr.getDbHandle(); + isc_db_handle_impl db = (isc_db_handle_impl) tr_handle.getDbHandle(); if (db == null || !db.isValid()) throw new GDSException(ISCConstants.isc_bad_db_handle); synchronized (db) { - if (tr.getState() != AbstractIscTrHandle.TRANSACTIONSTARTED - && tr.getState() != AbstractIscTrHandle.TRANSACTIONPREPARED) { + if (tr_handle.getState() != IscTrHandle.TRANSACTIONSTARTED + && tr_handle.getState() != IscTrHandle.TRANSACTIONPREPARED) { throw new GDSException(ISCConstants.isc_tra_state); } - tr.setState(AbstractIscTrHandle.TRANSACTIONROLLINGBACK); + tr_handle.setState(IscTrHandle.TRANSACTIONROLLINGBACK); try { if (debug) log.debug("op_rollback_retaining "); db.out.writeInt(op_rollback_retaining); - db.out.writeInt(tr.getTransactionId()); + db.out.writeInt(tr_handle.getTransactionId()); db.out.flush(); if (debug) log.debug("sent"); @@ -1024,7 +1016,7 @@ } catch (IOException ex) { throw new GDSException(ISCConstants.isc_net_read_err); } - tr.setState(AbstractIscTrHandle.TRANSACTIONSTARTED); + tr_handle.setState(IscTrHandle.TRANSACTIONSTARTED); } } @@ -1032,18 +1024,17 @@ byte[] requestBuffer, int bufferLen) throws GDSException { boolean debug = log != null && log.isDebugEnabled(); - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; - if (tr == null) { + if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } - isc_db_handle_impl db = (isc_db_handle_impl) tr.getDbHandle(); + isc_db_handle_impl db = (isc_db_handle_impl) tr_handle.getDbHandle(); synchronized (db) { try { if (debug) log.debug("op_info_transaction "); db.out.writeInt(op_info_transaction); - db.out.writeInt(tr.getTransactionId()); + db.out.writeInt(tr_handle.getTransactionId()); db.out.writeInt(0); db.out.writeBuffer(requestBuffer); db.out.writeInt(bufferLen); @@ -1102,7 +1093,6 @@ throw new GDSException(ISCConstants.isc_wish_list); } - public XSQLDA iscDsqlDescribe(IscStmtHandle stmt_handle, int da_version) throws GDSException { byte[] describeSelectInfo = getDescribeSelectInfo(stmt_handle); byte[] buffer = iscDsqlSqlInfo(stmt_handle, describeSelectInfo, MAX_BUFFER_SIZE); @@ -1129,7 +1119,6 @@ XSQLDA out_xsqlda) throws GDSException { boolean debug = log != null && log.isDebugEnabled(); - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; isc_db_handle_impl db = (isc_db_handle_impl) stmt_handle.getRsr_rdb(); // Test Handles needed here @@ -1142,7 +1131,7 @@ out.writeInt((out_xsqlda == null) ? op_execute : op_execute2); out.writeInt(stmt_handle.getRsrId()); - out.writeInt(tr.getTransactionId()); + out.writeInt(tr_handle.getTransactionId()); if (in_xsqlda != null) { out.writeBuffer(in_xsqlda.blr); @@ -1180,7 +1169,7 @@ } // end of else receiveResponse(db, op); - stmt_handle.registerTransaction(tr); + stmt_handle.registerTransaction(tr_handle); } catch (IOException ex) { throw new GDSException(ISCConstants.isc_net_read_err); @@ -1234,7 +1223,6 @@ throws GDSException { boolean debug = log != null && log.isDebugEnabled(); - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; isc_db_handle_impl db = (isc_db_handle_impl) db_handle; // Test Handles @@ -1269,7 +1257,7 @@ out.writeInt(0); } - out.writeInt(tr.getTransactionId()); + out.writeInt(tr_handle.getTransactionId()); out.writeInt(0); out.writeInt(dialect); out.writeBuffer(statement); @@ -1342,7 +1330,8 @@ sqldata_messages = in.readInt(); if (sqldata_messages > 0 && sqldata_status == 0) { - in.readSQLData(xsqlda.ioLength, (isc_stmt_handle_impl) stmt_handle); + in.readSQLData(xsqlda.ioLength, stmt_handle); + // TODO Replace with while do { op = nextOperation(db.in); if (op == op_response) { @@ -1444,14 +1433,14 @@ stmt_handle.clearRows(); try { - AbstractIscTrHandle tr = (AbstractIscTrHandle)stmt_handle.getTransaction(); + IscTrHandle tr = stmt_handle.getTransaction(); if (tr != null) tr.unregisterStatementFromTransaction(stmt_handle); } finally { stmt_handle.unregisterTransaction(); } - /** @todo implement statement handle tracking correctly */ + // TODO implement statement handle tracking correctly // db.rdb_sql_requests.remove(stmt); } catch (IOException ex) { throw new GDSException(ISCConstants.isc_net_read_err); @@ -1488,7 +1477,6 @@ } boolean debug = log != null && log.isDebugEnabled(); - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; isc_db_handle_impl db = (isc_db_handle_impl) stmt_handle.getRsr_rdb(); // reinitialize stmt SQLDA members. @@ -1500,7 +1488,7 @@ if (debug) log.debug("op_prepare_statement "); db.out.writeInt(op_prepare_statement); - db.out.writeInt(tr.getTransactionId()); + db.out.writeInt(tr_handle.getTransactionId()); db.out.writeInt(stmt_handle.getRsrId()); db.out.writeInt(dialect); db.out.writeBuffer(statement); @@ -1703,13 +1691,12 @@ throws GDSException { boolean debug = log != null && log.isDebugEnabled(); isc_db_handle_impl db = (isc_db_handle_impl) db_handle; - isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; isc_blob_handle_impl blob = (isc_blob_handle_impl) blob_handle; if (db == null) { throw new GDSException(ISCConstants.isc_bad_db_handle); } - if (tr == null) { + if (tr_handle == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } if (blob == null) { @@ -1729,7 +1716,7 @@ db.out.writeTyped(ISCConstants.isc_bpb_version1, (Xdrable) blobParameterBuffer); } - db.out.writeInt(tr.getTransactionId()); // ??really a short? + db.out.writeInt(tr_handle.getTransactionId()); // ??really a short? if (debug) log.debug("sending blob_id: " + blob.getBlobId()); db.out.writeLong(blob.getBlobId()); @@ -1739,10 +1726,10 @@ log.debug("sent"); receiveResponse(db, -1); blob.setDb(db); - blob.setTr(tr); + blob.setTr((AbstractIscTrHandle) tr_handle); blob.setRbl_id(db.getResp_object()); blob.setBlobId(db.getResp_blob_id()); - tr.addBlob(blob); + tr_handle.addBlob(blob); } catch (IOException ioe) { throw new GDSException(ISCConstants.isc_net_read_err); } @@ -1757,7 +1744,7 @@ if (db == null) { throw new GDSException(ISCConstants.isc_bad_db_handle); } - AbstractIscTrHandle tr = blob.getTr(); + IscTrHandle tr = blob.getTr(); if (tr == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } @@ -1827,7 +1814,7 @@ if (db == null) { throw new GDSException(ISCConstants.isc_bad_db_handle); } - AbstractIscTrHandle tr = blob.getTr(); + IscTrHandle tr = blob.getTr(); if (tr == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } @@ -1859,7 +1846,7 @@ if (db == null) { throw new GDSException(ISCConstants.isc_bad_db_handle); } - AbstractIscTrHandle tr = blob.getTr(); + IscTrHandle tr = blob.getTr(); if (tr == null) { throw new GDSException(ISCConstants.isc_bad_trans_handle); } @@ -2164,11 +2151,9 @@ int op = 0; do { op = in.readInt(); - if (debug) { - if (op == op_dummy) { - log.debug("op_dummy received"); - } - } + if (debug && op == op_dummy) { + log.debug("op_dummy received"); + } } while (op == op_dummy); return op; } Modified: client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/XdrInputStream.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/XdrInputStream.java 2012-11-05 15:57:56 UTC (rev 57313) +++ client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/XdrInputStream.java 2012-11-05 17:29:36 UTC (rev 57314) @@ -25,15 +25,14 @@ * Boix i Oltra, S.L. All Rights Reserved. * */ - package org.firebirdsql.gds.impl.wire; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; +import org.firebirdsql.gds.IscStmtHandle; - /** * <code>XdrInputStream</code> is an input stream for reading in data that * is in the XDR format. An <code>XdrInputStream</code> instance is wrapped @@ -127,7 +126,7 @@ * @throws IOException if an error occurs while reading from the * underlying input stream */ - public void readSQLData(int[] ioLength, isc_stmt_handle_impl stmt) throws IOException { + public void readSQLData(int[] ioLength, IscStmtHandle stmt) throws IOException { // This only works if not (port->port_flags & PORT_symmetric) int numCols = ioLength.length; byte[][] row = new byte[numCols][]; Modified: client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/isc_tr_handle_impl.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/isc_tr_handle_impl.java 2012-11-05 15:57:56 UTC (rev 57313) +++ client-java/trunk/src/main/org/firebirdsql/gds/impl/wire/isc_tr_handle_impl.java 2012-11-05 17:29:36 UTC (rev 57314) @@ -16,77 +16,16 @@ * * All rights reserved. */ -/* - * The Original Code is the Firebird Java GDS implementation. - * - * The Initial Developer of the Original Code is Alejandro Alberola. - * Portions created by Alejandro Alberola are Copyright (C) 2001 - * Boix i Oltra, S.L. All Rights Reserved. - */ - package org.firebirdsql.gds.impl.wire; -import org.firebirdsql.gds.IscDbHandle; import org.firebirdsql.gds.impl.AbstractIscTrHandle; - /** * Describe class <code>isc_tr_handle_impl</code> here. - * + * * @author <a href="mailto:alb...@us...">Alejandro Alberola</a> * @author <a href="mailto:d_j...@us...">David Jencks</a> * @version 1.0 */ public final class isc_tr_handle_impl extends AbstractIscTrHandle { - private int rtr_id; - private IscDbHandle rtr_rdb; - private int state = NOTRANSACTION; - - public isc_tr_handle_impl() { - } - - public IscDbHandle getDbHandle() { - return rtr_rdb; - } - - void setState(int state) { - this.state = state; - } - - public int getState() { - return state; - } - - void setTransactionId(final int rtr_id) - { - this.rtr_id = rtr_id; - } - - int getTransactionId() - { - return rtr_id; - } - - void setDbHandle(final IscDbHandle db) - { - this.rtr_rdb = db; - rtr_rdb.addTransaction(this); - } - - void unsetDbHandle() - { - rtr_rdb.removeTransaction(this); - rtr_rdb = null; - } - - public int hashCode() { - return rtr_id; - } - - public boolean equals(Object obj) { - if (obj == this) return true; - if (!(obj instanceof isc_tr_handle_impl)) return false; - isc_tr_handle_impl that = (isc_tr_handle_impl)obj; - return this.rtr_id == that.rtr_id; - } } Modified: client-java/trunk/src/main/org/firebirdsql/jca/FBManagedConnection.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/jca/FBManagedConnection.java 2012-11-05 15:57:56 UTC (rev 57313) +++ client-java/trunk/src/main/org/firebirdsql/jca/FBManagedConnection.java 2012-11-05 17:29:36 UTC (rev 57314) @@ -860,7 +860,7 @@ int internalPrepare(Xid xid) throws FBXAException, GDSException { if (log != null) log.trace("prepare called: " + xid); - AbstractIscTrHandle committingTr = xidMap.get(xid); + IscTrHandle committingTr = xidMap.get(xid); if (committingTr == null) throw new FBXAException("Prepare called with unknown transaction", XAException.XAER_NOTA); Modified: client-java/trunk/src/test/org/firebirdsql/gds/TestReconnectTransaction.java =================================================================== --- client-java/trunk/src/test/org/firebirdsql/gds/TestReconnectTransaction.java 2012-11-05 15:57:56 UTC (rev 57313) +++ client-java/trunk/src/test/org/firebirdsql/gds/TestReconnectTransaction.java 2012-11-05 17:29:36 UTC (rev 57314) @@ -86,7 +86,7 @@ GDSHelper gdsHelper1 = new GDSHelper(gds, dpb, dbHandle1, null); - AbstractIscTrHandle trHandle1 = (AbstractIscTrHandle)gds.createIscTrHandle(); + IscTrHandle trHandle1 = gds.createIscTrHandle(); gds.iscStartTransaction(trHandle1, dbHandle1, tpb.getTransactionParameterBuffer()); gdsHelper1.getTransactionId(trHandle1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |