FileDocCategorySizeDatePackage
WrapperDataSource.javaAPI DocJBoss 4.2.14404Fri Jul 13 21:01:14 BST 2007org.jboss.resource.adapter.jdbc

WrapperDataSource

public class WrapperDataSource extends Object implements Serializable, javax.resource.Referenceable, DataSource
WrapperDataSource
author
David Jencks
author
Adrian Brock
version
$Revision: 57189 $

Fields Summary
static final long
serialVersionUID
private final BaseWrapperManagedConnectionFactory
mcf
private final javax.resource.spi.ConnectionManager
cm
private Reference
reference
Constructors Summary
public WrapperDataSource(BaseWrapperManagedConnectionFactory mcf, javax.resource.spi.ConnectionManager cm)


          
   
      this.mcf = mcf;
      this.cm = cm;   
   
Methods Summary
public java.sql.ConnectiongetConnection()

      try 
      {
         WrappedConnection wc = (WrappedConnection) cm.allocateConnection(mcf, null);
         wc.setDataSource(this);
         return wc;
      }
      catch (ResourceException re)
      {
         throw new NestedSQLException(re);
      }
   
public java.sql.ConnectiongetConnection(java.lang.String user, java.lang.String password)

      ConnectionRequestInfo cri = new WrappedConnectionRequestInfo(user, password);
      try 
      {
         WrappedConnection wc = (WrappedConnection) cm.allocateConnection(mcf, cri);
         wc.setDataSource(this);
         return wc;
      }
      catch (ResourceException re)
      {
         throw new NestedSQLException(re);
      }
   
public java.io.PrintWritergetLogWriter()

      // TODO: implement this javax.sql.DataSource method
      return null;
   
public intgetLoginTimeout()

      // TODO: implement this javax.sql.DataSource method
      return 0;
   
public javax.naming.ReferencegetReference()

      return reference;
   
protected intgetTimeLeftBeforeTransactionTimeout()

      try
      {
         if (cm instanceof TransactionTimeoutConfiguration)
         {
            long timeout = ((TransactionTimeoutConfiguration) cm).getTimeLeftBeforeTransactionTimeout(true);
            // No timeout
            if (timeout == -1)
               return -1;
            // Round up to the nearest second
            long result = timeout / 1000;
            if ((result % 1000) != 0)
               ++result;
            return (int) result;
         }
         else
            return -1;
      }
      catch (RollbackException e)
      {
         throw new NestedSQLException(e);
      }
   
public voidsetLogWriter(java.io.PrintWriter param1)

      // TODO: implement this javax.sql.DataSource method
   
public voidsetLoginTimeout(int param1)

      // TODO: implement this javax.sql.DataSource method
   
public voidsetReference(javax.naming.Reference reference)

      this.reference = reference;