User: starksm
Date: 02/04/05 12:07:39
Modified: src/main/org/jboss/pool/jdbc/xa Tag: Branch_2_4
XAConnectionFactory.java XAPoolDataSource.java
Log:
Apply fix for Bug #525840 and reduce logging threshold to trace for per
connection messages
Revision Changes Path
No revision
No revision
1.2.2.3 +45 -12
jbosspool/src/main/org/jboss/pool/jdbc/xa/Attic/XAConnectionFactory.java
Index: XAConnectionFactory.java
===================================================================
RCS file:
/cvsroot/jboss/jbosspool/src/main/org/jboss/pool/jdbc/xa/Attic/XAConnectionFactory.java,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -r1.2.2.2 -r1.2.2.3
--- XAConnectionFactory.java 4 Mar 2002 23:35:08 -0000 1.2.2.2
+++ XAConnectionFactory.java 5 Apr 2002 20:07:39 -0000 1.2.2.3
@@ -41,6 +41,7 @@
*
* REVISIONS:
* 20010703 bill added code for transaction isolation
+@version $Revision: 1.2.2.3 $
*/
public class XAConnectionFactory
extends PoolObjectFactory
@@ -271,18 +272,25 @@
if( log.isTraceEnabled() )
log.trace( "Opening new XAConnection" );
+ Object obj = null;
try
{
- if(userName != null && userName.length() > 0)
- return source.getXAConnection(userName, password);
+ if( parameters != null )
+ {
+ String credentials[] = (String[]) parameters;
+ if (credentials.length == 2)
+ obj = source.getXAConnection(credentials[0], credentials[1]);
+ }
+ else if(userName != null && userName.length() > 0)
+ obj = source.getXAConnection(userName, password);
else
- return source.getXAConnection();
+ obj = source.getXAConnection();
}
catch(SQLException e)
{
log.error( "Can't get an XAConnection", e );
}
- return null;
+ return obj;
}
/**
@@ -292,7 +300,7 @@
*/
public Object prepareObject(Object pooledObject)
{
- boolean debug = log.isDebugEnabled();
+ boolean trace = log.isTraceEnabled();
XAConnection con = (XAConnection)pooledObject;
con.addConnectionEventListener(listener);
Transaction trans = null;
@@ -304,12 +312,12 @@
XAResource res = con.getXAResource();
trans.enlistResource(res);
rms.put(con, res);
- if( debug )
- log.debug( "Resource '" + res + "' enlisted for '" + con + "'." );
+ if( trace )
+ log.trace( "Resource '" + res + "' enlisted for '" + con + "'." );
} else
{
- if( debug )
- log.debug( "No transaction right now." );
+ if( trace )
+ log.trace( "No transaction right now." );
}
}
catch(Exception e)
@@ -368,7 +376,32 @@
} catch(Exception e) {}
return null;
}
+
+ /**
+ * Tells whether a pooled object matches the specified parameters.
+ * This is only called if the client requested an object with
+ * specific parameters. Usually all objects are "the same" so this
+ * is not necessary.
+ */
+ public boolean checkValidObject(Object source, Object parameters)
+ {
+ boolean validObject = false;
+ if (parameters != null)
+ {
+ XAConnectionImpl con = (XAConnectionImpl) source;
+ String credentials[] = (String[]) parameters;
+ if (credentials.length == 2)
+ {
+ String user = con.getUser();
+ String password = con.getPassword();
+ boolean validUser = ( (user == null) && (credentials[0] == null) )
+ || ( (user != null) && user.equals(credentials[0]) );
+ boolean validPassword = ( (password == null) && (credentials[1] ==
null) )
+ || ( (password != null) && password.equals(credentials[1]) );
+ validObject = validUser && validPassword;
+ }
+ }
+ return validObject;
+ }
+
}
-/*
-vim:tabstop=3:et:shiftwidth=3
-*/
1.3.2.3 +13 -6
jbosspool/src/main/org/jboss/pool/jdbc/xa/Attic/XAPoolDataSource.java
Index: XAPoolDataSource.java
===================================================================
RCS file:
/cvsroot/jboss/jbosspool/src/main/org/jboss/pool/jdbc/xa/Attic/XAPoolDataSource.java,v
retrieving revision 1.3.2.2
retrieving revision 1.3.2.3
diff -u -r1.3.2.2 -r1.3.2.3
--- XAPoolDataSource.java 4 Mar 2002 23:35:08 -0000 1.3.2.2
+++ XAPoolDataSource.java 5 Apr 2002 20:07:39 -0000 1.3.2.3
@@ -200,6 +200,8 @@
/**
* Gets a connection from the pool.
+ * Since no userid or password is specified, we get a connection using the
default
+ * userid and password, specified when the factory was created.
*/
public Connection getConnection()
throws java.sql.SQLException
@@ -207,7 +209,11 @@
if(!initialized) initialize();
if( log.isTraceEnabled() )
log.trace( "Getting a Connection" );
- return ((XAConnection)pool.getObject()).getConnection();
+ String user = factory.getUser();
+ String password = factory.getPassword();
+ String[] params = {user, password};
+ XAConnection xaConn = (XAConnection) pool.getObject(params);
+ return xaConn.getConnection();
}
/**
@@ -216,13 +222,14 @@
* a connection available in the pool, it will be used, regardless of the
* user name and password use to created it initially.
*/
- public Connection getConnection(String user, String password) throws
java.sql.SQLException {
+ public Connection getConnection(String user, String password) throws
java.sql.SQLException
+ {
if(!initialized) initialize();
if( log.isTraceEnabled() )
- log.trace( "Getting a connection for user " + user + " with password " +
password );
- factory.setUser(user);
- factory.setPassword(password);
- return ((XAConnection)pool.getObject()).getConnection();
+ log.trace("Getting a connection for user " + user + " with password " +
password );
+ String[] params = {user, password};
+ XAConnection xaConn = (XAConnection) pool.getObject(params);
+ return xaConn.getConnection();
}
/**
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development