User: d_jencks
  Date: 01/09/08 12:32:20

  Added:       src/main/org/jboss/resource/adapter/jdbc
                        BaseManagedConnection.java
                        JDBCConnectionRequestInfo.java JDBCDataSource.java
  Log:
  Reorganized connector packaging under connector (from pool), made jca stuff into a 
sar, made default hypsersonic DefaultDS into hsql-default-service.xml, and made 
jbossmq into jbossmq-service.xml
  
  Revision  Changes    Path
  1.1                  
jbosscx/src/main/org/jboss/resource/adapter/jdbc/BaseManagedConnection.java
  
  Index: BaseManagedConnection.java
  ===================================================================
  /*
   * Licensed under the X license (see http://www.x.org/terms.htm)
   */
  package org.jboss.resource.adapter.jdbc;
  
  import java.io.PrintWriter;
  import java.sql.SQLException;
  import java.util.*;
  import javax.resource.ResourceException;
  import javax.resource.spi.ConnectionEvent;
  import javax.resource.spi.ConnectionEventListener;
  import javax.resource.spi.ConnectionRequestInfo;
  import javax.resource.spi.LocalTransaction;
  import javax.resource.spi.ManagedConnection;
  import javax.resource.spi.ManagedConnectionMetaData;
  import javax.security.auth.Subject;
  import javax.transaction.xa.XAResource;
  
  import org.jboss.logging.log4j.JBossCategory;
  
  /**
   * Abstract base class for ManagedConnections.
   *
   * @author    Aaron Mulder <[EMAIL PROTECTED]>
   * @author    <a href="mailto:[EMAIL PROTECTED]";>David Jencks</a>
   * @version   $Revision: 1.1 $
   */
  public abstract class BaseManagedConnection implements ManagedConnection
  {
     /**
      * Description of the Field
      */
     protected ArrayList listeners;
     private String user;
     private JBossCategory log;
  
     /**
      * Constructor for the BaseManagedConnection object
      *
      * @param user  Description of Parameter
      */
     public BaseManagedConnection(String user)
     {
        this.user = user;
        listeners = new ArrayList();
        log = (JBossCategory)JBossCategory.getInstance(getClass().getName() + "." + 
this);
  
     }
  
     /*
      * We ignore this and use log4j
      */
     /**
      * Sets the LogWriter attribute of the BaseManagedConnection object
      *
      * @param writer  The new LogWriter value
      */
     public void setLogWriter(PrintWriter writer)
     {
     }
  
     /**
      * Gets the LogWriter attribute of the BaseManagedConnection object
      *
      * @return   The LogWriter value
      */
     public PrintWriter getLogWriter()
     {
        return null;
     }
  
     /**
      * Gets the User attribute of the BaseManagedConnection object
      *
      * @return   The User value
      */
     public String getUser()
     {
        return user;
     }
  
     /**
      * #Description of the Method
      *
      * @param Tx                     Description of Parameter
      * @exception ResourceException  Description of Exception
      */
     public void associateConnection(Object Tx)
            throws ResourceException
     {
        throw new ResourceException("associateConnection not supported");
     }
  
     /**
      * Adds a feature to the ConnectionEventListener attribute of the
      * BaseManagedConnection object
      *
      * @param listener  The feature to be added to the ConnectionEventListener
      *      attribute
      */
     public void addConnectionEventListener(ConnectionEventListener listener)
     {
        listeners.add(listener);
     }
  
     /**
      * #Description of the Method
      *
      * @param listener  Description of Parameter
      */
     public void removeConnectionEventListener(ConnectionEventListener listener)
     {
        listeners.remove(listener);
     }
  
     /**
      * #Description of the Method
      *
      * @exception ResourceException  Description of Exception
      */
     public void destroy()
            throws ResourceException
     {
        listeners.clear();
        listeners = null;
        log = null;
        user = null;
     }
  
     /**
      * Gets the Log attribute of the BaseManagedConnection object
      *
      * @return   The Log value
      */
     protected JBossCategory getLog()
     {
        return log;
     }
  
     /**
      * #Description of the Method
      *
      * @param evt  Description of Parameter
      */
     protected void fireConnectionEvent(ConnectionEvent evt)
     {
        List local = (List)listeners.clone();
        for (int i = local.size() - 1; i >= 0; i--)
        {
           if (evt.getId() == ConnectionEvent.CONNECTION_CLOSED)
           {
              ((ConnectionEventListener)local.get(i)).connectionClosed(evt);
           }
           else if (evt.getId() == ConnectionEvent.CONNECTION_ERROR_OCCURRED)
           {
              ((ConnectionEventListener)local.get(i)).connectionErrorOccurred(evt);
           }
        }
     }
  }
  
  
  
  1.1                  
jbosscx/src/main/org/jboss/resource/adapter/jdbc/JDBCConnectionRequestInfo.java
  
  Index: JDBCConnectionRequestInfo.java
  ===================================================================
  /*
   * Licensed under the X license (see http://www.x.org/terms.htm)
   */
  package org.jboss.resource.adapter.jdbc;
  
  import javax.resource.spi.ConnectionRequestInfo;
  
  /**
   * JDBC parameters for creating connections.
   *
   * @author    Aaron Mulder <[EMAIL PROTECTED]>
   * @version   $Revision: 1.1 $
   */
  public class JDBCConnectionRequestInfo implements ConnectionRequestInfo
  {
     /**
      * Description of the Field
      */
     public String user;
     /**
      * Description of the Field
      */
     public String password;
  
     /**
      * Constructor for the JDBCConnectionRequestInfo object
      */
     public JDBCConnectionRequestInfo()
     {
     }
  
     /**
      * Constructor for the JDBCConnectionRequestInfo object
      *
      * @param user      Description of Parameter
      * @param password  Description of Parameter
      */
     public JDBCConnectionRequestInfo(String user, String password)
     {
        this.user = user;
        this.password = password;
     }
  }
  
  
  
  1.1                  
jbosscx/src/main/org/jboss/resource/adapter/jdbc/JDBCDataSource.java
  
  Index: JDBCDataSource.java
  ===================================================================
  /*
   * Licensed under the X license (see http://www.x.org/terms.htm)
   */
  package org.jboss.resource.adapter.jdbc;
  
  import java.io.PrintWriter;
  import java.io.Serializable;
  import java.sql.Connection;
  import java.sql.SQLException;
  import javax.naming.Reference;
  import javax.resource.Referenceable;
  import javax.resource.ResourceException;
  import javax.resource.spi.ConnectionManager;
  import javax.resource.spi.ManagedConnectionFactory;
  import javax.sql.DataSource;
  
  /**
   * ConnectionFactory implementation for JDBC drivers, i.e. javax.sql.DataSource.
   * As of this writing, CCI ConnectionFactory is inconsistent with DataSource due
   * to some incompatible exceptions. It doesn't actually implement the CCI
   * interfaces because JDBC already has well-defined interfaces, but it is the
   * equivalent. Note that this implementation will not work if JNDI Serialization
   * is used instead of a JNDI Reference. The Reference should be set by the app
   * server at deployment.
   *
   * @see       javax.resource.Referenceable
   * @author    Aaron Mulder <[EMAIL PROTECTED]>
   * @author    <a href="mailto:[EMAIL PROTECTED]";>David Jencks</a>
   * @version   $Revision: 1.1 $
   */
  public class JDBCDataSource implements DataSource, Serializable, Referenceable
  {
  
     /*
      * No logging is done in this, so there is no log4j Category
      */
     private transient ConnectionManager manager;
     private transient ManagedConnectionFactory factory;
     private Reference jndiReference;
  
     /**
      * Constructor for the JDBCDataSource object
      *
      * @param manager  Description of Parameter
      * @param factory  Description of Parameter
      */
     public JDBCDataSource(ConnectionManager manager, ManagedConnectionFactory factory)
     {
        this.manager = manager;
        this.factory = factory;
     }
  
     /**
      * JNDI reference is set during deployment
      *
      * @param ref  The new Reference value
      */
     public void setReference(Reference ref)
     {
        jndiReference = ref;
     }
  
     /*
      * We ignore this and use log4j instead
      */
     /**
      * Sets the LogWriter attribute of the JDBCDataSource object
      *
      * @param writer                     The new LogWriter value
      * @exception java.sql.SQLException  Description of Exception
      */
     public void setLogWriter(PrintWriter writer)
            throws java.sql.SQLException
     {
     }
  
     /**
      * Sets the LoginTimeout attribute of the JDBCDataSource object
      *
      * @param timeout                    The new LoginTimeout value
      * @exception java.sql.SQLException  Description of Exception
      */
     public void setLoginTimeout(int timeout)
            throws java.sql.SQLException
     {
        throw new SQLException("Method setLoginTimeout() not implemented.");
     }
  
     /**
      * Used by JNDI
      *
      * @return   The Reference value
      */
     public Reference getReference()
     {
        return jndiReference;
     }
  
     /**
      * Gets the Connection attribute of the JDBCDataSource object
      *
      * @return                           The Connection value
      * @exception java.sql.SQLException  Description of Exception
      */
     public Connection getConnection()
            throws java.sql.SQLException
     {
        try
        {
           return (Connection)manager.allocateConnection(factory, null);
        }
        catch (ResourceException e)
        {
           throw new SQLException("Unable to get Connection: " + e);
        }
     }
  
     /**
      * Gets the Connection attribute of the JDBCDataSource object
      *
      * @param user                       Description of Parameter
      * @param password                   Description of Parameter
      * @return                           The Connection value
      * @exception java.sql.SQLException  Description of Exception
      */
     public Connection getConnection(String user, String password)
            throws java.sql.SQLException
     {
        try
        {
           return (Connection)manager.allocateConnection(factory, new 
JDBCConnectionRequestInfo(user, password));
        }
        catch (ResourceException e)
        {
           throw new SQLException("Unable to get Connection: " + e);
        }
     }
  
     /*
      * We ignore this and use log4j instead
      */
     /**
      * Gets the LogWriter attribute of the JDBCDataSource object
      *
      * @return                           The LogWriter value
      * @exception java.sql.SQLException  Description of Exception
      */
     public PrintWriter getLogWriter()
            throws java.sql.SQLException
     {
        return null;
     }
  
     /**
      * Gets the LoginTimeout attribute of the JDBCDataSource object
      *
      * @return                           The LoginTimeout value
      * @exception java.sql.SQLException  Description of Exception
      */
     public int getLoginTimeout()
            throws java.sql.SQLException
     {
        return 0;
     }
  }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to