User: mulder  
  Date: 01/01/31 12:36:44

  Added:       src/main/org/jboss/resource ConnectionManagerFactory.java
                        ConnectorConfig.java JBossConnectionListener.java
                        JBossConnectionManager.java
                        ResourceSubjectFactory.java
  Log:
  Added new interface files for the JBoss J2EE Connector implementation.
  This allows any number of different ConnectionManager implementations.
  The current ConnectionFactoryLoader will be updated to use this (by Toby)
  shortly, and a Minerva-based implementation will be added (by Aaron)
  shortly.
  
  Revision  Changes    Path
  1.1                  jboss/src/main/org/jboss/resource/ConnectionManagerFactory.java
  
  Index: ConnectionManagerFactory.java
  ===================================================================
  /*
   * JBoss, the OpenSource EJB server
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jboss.resource;
  
  import java.io.PrintWriter;
  import java.util.Properties;
  import javax.resource.ResourceException;
  import javax.resource.spi.ManagedConnectionFactory;
  import javax.transaction.TransactionManager;
  
  /**
   *   Generates ConnectionManager instances for the container to use.  The
   *   factory may return one ConnectionManager per request, or use the same
   *   ConnectionManager to service multiple ManagedConnectionFactories.
   *
   *   @author Toby Allsopp ([EMAIL PROTECTED])
   *   @author Aaron Mulder <[EMAIL PROTECTED]>
   *   @version $Revision: 1.1 $
   */
  public interface ConnectionManagerFactory {
      /**
       * Default logger for all ConnectionManagers.
       */
      void setLogWriter(PrintWriter writer);
  
      /**
       * Default TM for all ConnectionManagers.
       */
      void setTransactionManager(TransactionManager tm);
  
      /**
       * Default subject factory for all ConnectionManagers.
       */
      void setResourceSubjectFactory(ResourceSubjectFactory rsf);
  
      /**
       * Sets any properties for the factory, which may apply to the factory
       * itself, or by extension, all the ConnectionManagers it creates.
       * These properties should *not* be specific to the factories serviced
       * by the ConnectionManagers.
       */
      void setProperties(Properties props);
  
      /**
       * Creates and/or configures a ConnectionManager for the specified
       * ManagedConnectionFactory.
       * @param factory The factory to prepare a CM for
       * @param config The factory-specific settings for the CM (such as pool
       *               configuration, etc.)
       * @param name A name to use for this factory configuration, for logging,
       *             management, etc.  May be null, in which case a name will
       *             be generated automatically.
       */
      JBossConnectionManager addManagedConnectionFactory(
                                ManagedConnectionFactory factory,
                                ConnectorConfig config,
                                String name)
                             throws ResourceException;
  }
  
  
  1.1                  jboss/src/main/org/jboss/resource/ConnectorConfig.java
  
  Index: ConnectorConfig.java
  ===================================================================
  /*
   * JBoss, the OpenSource EJB server
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jboss.resource;
  
  import java.io.PrintWriter;
  import java.util.Properties;
  import javax.transaction.TransactionManager;
  
  /**
   *   Provides access to configuration parameters for a JCA ConnectionManager.
   *   Specifically, all the properties for a single ResourceAdapter configuration
   *   that the ConnectionManager will use.
   *
   *   @author Toby Allsopp ([EMAIL PROTECTED])
   *   @author Aaron Mulder <[EMAIL PROTECTED]>
   *   @version $Revision: 1.1 $
   */
  public class ConnectorConfig {
      /**
       * Listens for Connection open/close events.  Used by the container to
       * track which beans use which connections, so that if a connection is
       * held by a bean across many transactions, the container can tell the
       * ConnectionManager to re-enlist it with each transaction as the
       * transactions are started.
       */
      public JBossConnectionListener listener;
  
      /**
       * Holds any implementation-specific properties (such as connection pool
       * configuration).
       */
      public Properties properties;
  
      /**
       * Used for logging.
       */
      public PrintWriter logWriter;
  
      /**
       * The TransactionManager to use.
       */
      public TransactionManager tm;
  
      /**
       * Fetches the current Subject for a Connector request.
       */
      public ResourceSubjectFactory rsf;
  
      /**
       * Whether an existing connection can be switched to use different
       * authentication settings.  Not possible for JDBC connections, where
       * you specify a username and password when you create the connection,
       * and there's no way to change them later.  May be supported by other
       * Resource Adapters.
       */
      public boolean isReauthenticationSupported;
  }
  
  
  
  1.1                  jboss/src/main/org/jboss/resource/JBossConnectionListener.java
  
  Index: JBossConnectionListener.java
  ===================================================================
  /*
   * JBoss, the OpenSource EJB server
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jboss.resource;
  
  /**
   *   Listens for connection open/close events.  Used by the EJB container to
   *   track which beans use which resources.  That way if a bean keeps a
   *   resource across several transactions, the container will know to
   *   re-enlist it each time.
   *
   *   @author Toby Allsopp ([EMAIL PROTECTED])
   *   @author Aaron Mulder <[EMAIL PROTECTED]>
   *   @version $Revision: 1.1 $
   */
  public interface JBossConnectionListener {
      /**
       * A new Connection was issued.  Known as a handle because the instance of
       * ManagedConnection represents the "physical" connection, and the clients
       * only receive handles to it, not the real thing.
       */
      void connectionHandleIssued(Object connection);
  
      /**
       * A connection handle was closed.  The physical connection is probably
       * still open, but the client cannot access it any more.
       */
      void connectionHandleClosed(Object connection);
  }
  
  
  1.1                  jboss/src/main/org/jboss/resource/JBossConnectionManager.java
  
  Index: JBossConnectionManager.java
  ===================================================================
  /*
   * JBoss, the OpenSource EJB server
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jboss.resource;
  
  import javax.resource.ResourceException;
  
  /**
   *   Custom extensions to the standard ConnectionManager interface.  This
   *   supports re-enlisting connections under new transactions, and closing
   *   down the ConnectionManager.
   *
   *   @author Toby Allsopp ([EMAIL PROTECTED])
   *   @author Aaron Mulder <[EMAIL PROTECTED]>
   *   @version $Revision: 1.1 $
   */
  public interface JBossConnectionManager {
      /**
       * Reuses connections for different transactions.  This call tells the
       * ConnectionManager that a connection generated previously under a
       * different transaction is now going to be reused under the current
       * transaction.  The connection must never have been closed for this to
       * work (i.e. stuffed in an instance variable of a stateful session bean).
       */
      void enlistExistingConnection(Object connection) throws ResourceException;
  
      /**
       * Closes all pools, connections, etc.
       */
      void shutDown();
  }
  
  
  1.1                  jboss/src/main/org/jboss/resource/ResourceSubjectFactory.java
  
  Index: ResourceSubjectFactory.java
  ===================================================================
  /*
   * JBoss, the OpenSource EJB server
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jboss.resource;
  
  import javax.resource.spi.ManagedConnectionFactory;
  import javax.security.auth.Subject;
  
  /**
   *   Looks up a Subject for a particular connector request.  The implementation
   *   may perform authentication translation, so that user "foo" logged into
   *   the EJB container is authenticated as user "bar" for the Resource
   *   Adapter (aka ManagedConnectionFactory).
   *
   *   @author Toby Allsopp ([EMAIL PROTECTED])
   *   @author Aaron Mulder <[EMAIL PROTECTED]>
   *   @version $Revision: 1.1 $
   */
  public interface ResourceSubjectFactory {
      /**
       * Gets a subject for the curent request.
       * @param factory The factory that the request will authenticate to.
       * @param name A name for the factory, which corresponds to the name
       *             passed in to the ConnectionManagerFactory at deployment
       *             time if any, or an auto-generated name otherwise.  Just a
       *             convenience in case it's easier to use than the factory
       *             itself.
       * @return The Subject to use to authenticate to the ManagedConnectionFactory.
       */
      public Subject getSubject(ManagedConnectionFactory factory, String name);
  }
  
  

Reply via email to