/** * @see com.atomikos.jdbc.HeuristicDataSource#getConnection(com.atomikos.icatch.HeuristicMessage) */ public Connection getConnection ( HeuristicMessage msg ) throws SQLException { DTPPooledConnection ret = (DTPPooledConnection) pool_ .getPooledConnection (); ret.addConnectionEventListener ( this ); return ret.getConnection ( msg ); }
/** * @see com.atomikos.jdbc.HeuristicDataSource#getConnection(com.atomikos.icatch.HeuristicMessage) */ public synchronized Connection getConnection ( HeuristicMessage msg ) throws SQLException { // ThreadLocalConnection ret = ( ThreadLocalConnection ) // previousConnections.get(); Connection proxy = (Connection) previousConnections.get ( Thread .currentThread () ); if ( proxy == null ) { // no previous connection -> get one from pool NonXAPooledConnectionImp pc = (NonXAPooledConnectionImp) pool .getPooledConnection (); pc.addConnectionEventListener ( this ); proxy = (Connection) ThreadLocalConnection.newInstance ( pc ); previousConnections.put ( Thread.currentThread (), proxy ); } // here we are certain that proxy is not null -> increase the use count ThreadLocalConnection previous = (ThreadLocalConnection) Proxy .getInvocationHandler ( proxy ); // if ( previous.isStale() ) System.out.println ( "WARNING: STALE // CONNECTION STILL MAPPED TO THREAD"); previous.incUseCount (); previous.addHeuristicMessage ( msg ); return proxy; }