/[Apache-SVN]/incubator/derby/code/trunk/java/client/org/apache/derby/client/ClientXAConnection.java
ViewVC logotype

Diff of /incubator/derby/code/trunk/java/client/org/apache/derby/client/ClientXAConnection.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- incubator/derby/code/trunk/java/client/org/apache/derby/client/ClientXAConnection.java	2005/05/02 05:18:08	165584
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/ClientXAConnection.java	2005/05/02 06:25:59	165585
@@ -19,120 +19,112 @@
 */
 package org.apache.derby.client;
 
+import java.sql.Connection;
+import javax.sql.XAConnection;
+import javax.transaction.xa.XAResource;
+
 import org.apache.derby.client.am.SqlException;
-import org.apache.derby.jdbc.ClientXADataSource;
-import org.apache.derby.client.net.NetXAConnection;
 import org.apache.derby.client.net.NetLogWriter;
-import java.sql.*;
-import javax.sql.*;
-import javax.transaction.xa.*;
-
-public class ClientXAConnection extends ClientPooledConnection implements XAConnection
-{
-  private static int rmIdSeed_ = 95688932; // semi-random starting value for rmId
-
-  private ClientXADataSource derbyds_ = null;
-  private XAResource xares_ = null;
-  private org.apache.derby.client.net.NetXAResource netXares_ = null;
-  private boolean fFirstGetConnection_ = true;
-  private Connection logicalCon_; // logicalConnection_ is inherited from ClientPooledConnection 
-  // This connection is used to access the indoubt table
-  private NetXAConnection controlCon_ = null;
-
-  public ClientXAConnection (ClientXADataSource ds,
-                          org.apache.derby.client.net.NetLogWriter logWtr,
-                          String          userId,
-                          String          password) throws SqlException
-  {
-    super (ds,logWtr,userId, password, getUnigueRmId());
-    derbyds_ = ds;
-
-    // Have to instantiate a real connection here,
-    // otherwise if XA function is called before the connect happens,
-    // an error will be returned
-    // Note: conApp will be set after this call
-    logicalCon_ = super.getConnection();
-
-    netXares_ = new org.apache.derby.client.net.NetXAResource( this,
-            rmId_, userId, password, netXAPhysicalConnection_ );
-    xares_ = netXares_;
-  }
-
-  public Connection getConnection() throws SqlException
-  {
-    if ( fFirstGetConnection_ )
-    {
-      // Since super.getConnection() has already been called once
-      // in the constructor, we don't need to call it again for the
-      // call of this method.
-      fFirstGetConnection_ = false;
-    }
-    else
-    {
-      // A new connection object is required
-      logicalCon_ = super.getConnection();
-      if( this.physicalConnection_ != null )
-      { // have a physical connection, check if a NetXAResource
-        if( netXAPhysicalConnection_ != null )
-        { // the XAResource is a NetXAResource, re-initialize it
-          netXares_.initForReuse();
+import org.apache.derby.client.net.NetXAConnection;
+import org.apache.derby.jdbc.ClientXADataSource;
+
+public class ClientXAConnection extends ClientPooledConnection implements XAConnection {
+    private static int rmIdSeed_ = 95688932; // semi-random starting value for rmId
+
+    private ClientXADataSource derbyds_ = null;
+    private XAResource xares_ = null;
+    private org.apache.derby.client.net.NetXAResource netXares_ = null;
+    private boolean fFirstGetConnection_ = true;
+    private Connection logicalCon_; // logicalConnection_ is inherited from ClientPooledConnection
+    // This connection is used to access the indoubt table
+    private NetXAConnection controlCon_ = null;
+
+    public ClientXAConnection(ClientXADataSource ds,
+                              org.apache.derby.client.net.NetLogWriter logWtr,
+                              String userId,
+                              String password) throws SqlException {
+        super(ds, logWtr, userId, password, getUnigueRmId());
+        derbyds_ = ds;
+
+        // Have to instantiate a real connection here,
+        // otherwise if XA function is called before the connect happens,
+        // an error will be returned
+        // Note: conApp will be set after this call
+        logicalCon_ = super.getConnection();
+
+        netXares_ = new org.apache.derby.client.net.NetXAResource(this,
+                rmId_, userId, password, netXAPhysicalConnection_);
+        xares_ = netXares_;
+    }
+
+    public Connection getConnection() throws SqlException {
+        if (fFirstGetConnection_) {
+            // Since super.getConnection() has already been called once
+            // in the constructor, we don't need to call it again for the
+            // call of this method.
+            fFirstGetConnection_ = false;
+        } else {
+            // A new connection object is required
+            logicalCon_ = super.getConnection();
+            if (this.physicalConnection_ != null) { // have a physical connection, check if a NetXAResource
+                if (netXAPhysicalConnection_ != null) { // the XAResource is a NetXAResource, re-initialize it
+                    netXares_.initForReuse();
+                }
+            }
+        }
+        return logicalCon_;
+    }
+
+    private static synchronized int getUnigueRmId() {
+        rmIdSeed_ += 1;
+        return rmIdSeed_;
+    }
+
+    public int getRmId() {
+        return rmId_;
+    }
+
+    public XAResource getXAResource() throws SqlException {
+        if (logWriter_ != null) {
+            logWriter_.traceExit(this, "getXAResource", xares_);
+        }
+
+        return xares_;
+    }
+
+    public ClientXADataSource getDataSource() throws SqlException {
+        if (logWriter_ != null) {
+            logWriter_.traceExit(this, "getDataSource", derbyds_);
+        }
+
+        return derbyds_;
+    }
+
+    public NetXAConnection createControlConnection(NetLogWriter logWriter,
+                                                   String user,
+                                                   String password,
+                                                   org.apache.derby.jdbc.ClientDataSource dataSource,
+                                                   int rmId,
+                                                   boolean isXAConn) throws SqlException {
+
+        controlCon_ = new NetXAConnection(logWriter,
+                user,
+                password,
+                dataSource,
+                rmId,
+                isXAConn);
+        controlCon_.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
+
+        if (logWriter_ != null) {
+            logWriter_.traceExit(this, "createControlConnection", controlCon_);
         }
-      }
+
+        return controlCon_;
     }
-    return logicalCon_;
-  }
 
-  private static synchronized int getUnigueRmId()
-  {
-    rmIdSeed_ += 1;
-    return rmIdSeed_;
-  }
-
-  public int getRmId()
-  {
-    return rmId_;
-  }
-
-  public XAResource getXAResource() throws SqlException
-  {
-    if (logWriter_ != null) logWriter_.traceExit (this, "getXAResource", xares_);
-
-    return xares_;
-  }
-
-  public ClientXADataSource getDataSource() throws SqlException
-  {
-    if (logWriter_ != null) logWriter_.traceExit (this, "getDataSource", derbyds_);
-
-    return derbyds_;
-  }
-
-  public NetXAConnection createControlConnection(NetLogWriter logWriter,
-      String user,
-      String password,
-      org.apache.derby.jdbc.ClientDataSource dataSource,
-      int rmId,
-      boolean isXAConn) throws SqlException
-  {
-
-    controlCon_ = new NetXAConnection (
-        logWriter,
-        user,
-        password,
-        dataSource,
-        rmId,
-        isXAConn);
-    controlCon_.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
-
-    if (logWriter_ != null) logWriter_.traceExit (this, "createControlConnection", controlCon_);
-
-    return controlCon_;
-  }
-
-
-  public synchronized void close() throws SqlException
-  {
-    super.close();
-  }
+
+    public synchronized void close() throws SqlException {
+        super.close();
+    }
 }
 

 

infrastructure at apache.org
ViewVC Help
Powered by ViewVC 1.1.26