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

  Added:       src/main/org/jboss/resource/connectionmanager/jboss
                        JBossSecurityManager.java MinervaNoTransCM.java
                        MinervaNoTransCMFactory.java
                        MinervaSharedLocalCM.java
                        MinervaSharedLocalCMFactory.java MinervaXACM.java
                        MinervaXACMFactory.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/connectionmanager/jboss/JBossSecurityManager.java
  
  Index: JBossSecurityManager.java
  ===================================================================
  /*
   * Licensed under the X license (see http://www.x.org/terms.htm)
   */
  package org.jboss.resource.connectionmanager.jboss;
  
  import javax.resource.spi.ManagedConnectionFactory;
  
  import javax.security.auth.Subject;
  import org.jboss.resource.ResourceSubjectFactory;
  import org.jboss.resource.connectionmanager.ServerSecurityManager;
  
  /**
   * JBoss implementation of ServerSecurityManager
   *
   * @author   Aaron Mulder <[EMAIL PROTECTED]>
   */
  public class JBossSecurityManager implements ServerSecurityManager
  {
     private ResourceSubjectFactory security;
  
     /**
      * Constructor for the JBossSecurityManager object
      *
      * @param factory  Description of Parameter
      */
     public JBossSecurityManager(ResourceSubjectFactory factory)
     {
        security = factory;
     }
  
     /**
      * Gets the Subject attribute of the JBossSecurityManager object
      *
      * @param factory   Description of Parameter
      * @param poolName  Description of Parameter
      * @return          The Subject value
      */
     public Subject getSubject(ManagedConnectionFactory factory, String poolName)
     {
        return security.getSubject(factory, poolName);
     }
  }
  
  
  
  1.1                  
jbosscx/src/main/org/jboss/resource/connectionmanager/jboss/MinervaNoTransCM.java
  
  Index: MinervaNoTransCM.java
  ===================================================================
  /*
   * Licensed under the X license (see http://www.x.org/terms.htm)
   */
  package org.jboss.resource.connectionmanager.jboss;
  
  import java.util.*;
  import org.jboss.resource.JBossConnectionListener;
  import org.jboss.resource.JBossConnectionManager;
  import org.jboss.resource.connectionmanager.NoTransConnectionManager;
  
  /**
   * JBoss implementation of no-transaction ConnectionManager.
   *
   * @author    Aaron Mulder <[EMAIL PROTECTED]>
   * @version   $Revision: 1.1 $
   */
  public class MinervaNoTransCM extends NoTransConnectionManager implements 
JBossConnectionManager
  {
     private ArrayList listeners;
  
     /**
      * Constructor for the MinervaNoTransCM object
      */
     public MinervaNoTransCM()
     {
        listeners = new ArrayList();
     }
  
     /**
      * Adds a feature to the JBossConnectionListener attribute of the
      * MinervaNoTransCM object
      *
      * @param listener  The feature to be added to the JBossConnectionListener
      *      attribute
      */
     public void addJBossConnectionListener(JBossConnectionListener listener)
     {
        if (!listeners.contains(listener))
        {
           listeners.add(listener);
        }
     }
  
     /**
      * #Description of the Method
      *
      * @param listener  Description of Parameter
      */
     public void removeJBossConnectionListener(JBossConnectionListener listener)
     {
        listeners.remove(listener);
     }
  
     /**
      * #Description of the Method
      *
      * @param handle    Description of Parameter
      * @param listener  Description of Parameter
      */
     protected void connectionHandleIssued(Object handle, Object listener)
     {
        super.connectionHandleIssued(handle, listener);
        JBossConnectionListener[] copy = 
(JBossConnectionListener[])listeners.toArray(new 
JBossConnectionListener[listeners.size()]);
        for (int i = 0; i < copy.length; copy[i++].connectionHandleIssued(handle))
        {
           ;
        }
     }
  
     /**
      * #Description of the Method
      *
      * @param handle  Description of Parameter
      */
     protected void connectionHandleClosed(Object handle)
     {
        super.connectionHandleClosed(handle);
        JBossConnectionListener[] copy = 
(JBossConnectionListener[])listeners.toArray(new 
JBossConnectionListener[listeners.size()]);
        for (int i = 0; i < copy.length; copy[i++].connectionHandleClosed(handle))
        {
           ;
        }
     }
  }
  
  
  
  1.1                  
jbosscx/src/main/org/jboss/resource/connectionmanager/jboss/MinervaNoTransCMFactory.java
  
  Index: MinervaNoTransCMFactory.java
  ===================================================================
  /*
   * Licensed under the X license (see http://www.x.org/terms.htm)
   */
  package org.jboss.resource.connectionmanager.jboss;
  
  import java.util.Properties;
  import javax.resource.spi.ManagedConnectionFactory;
  import javax.transaction.TransactionManager;
  import org.jboss.pool.PoolParameters;
  import org.jboss.resource.ConnectionManagerFactory;
  import org.jboss.resource.ConnectorConfig;
  import org.jboss.resource.JBossConnectionListener;
  import org.jboss.resource.JBossConnectionManager;
  import org.jboss.resource.ResourceSubjectFactory;
  import org.jboss.resource.connectionmanager.NoTransConnectionManager;
  
  /**
   * Implementation of JBoss connector initialization for no-transaction
   * connection managers.
   *
   * @author    Aaron Mulder <[EMAIL PROTECTED]>
   * @author    <a href="mailto:[EMAIL PROTECTED]";>David Jencks</a>
   * @version   $Revision: 1.1 $
   */
  public class MinervaNoTransCMFactory implements ConnectionManagerFactory
  {
     private TransactionManager tm;
     private ResourceSubjectFactory security;
     private MinervaNoTransCM manager;
  
     /**
      * Constructor for the MinervaNoTransCMFactory object
      */
     public MinervaNoTransCMFactory()
     {
     }
  
     /**
      * Sets the TransactionManager attribute of the MinervaNoTransCMFactory
      * object
      *
      * @param tm  The new TransactionManager value
      */
     public void setTransactionManager(TransactionManager tm)
     {
     }
  
     /**
      * Sets the ResourceSubjectFactory attribute of the MinervaNoTransCMFactory
      * object
      *
      * @param security  The new ResourceSubjectFactory value
      */
     public void setResourceSubjectFactory(ResourceSubjectFactory security)
     {
        this.security = security;
     }
  
     /**
      * Sets the Properties attribute of the MinervaNoTransCMFactory object
      *
      * @param props  The new Properties value
      */
     public void setProperties(Properties props)
     {
     }
  
     /**
      * Adds a feature to the ManagedConnectionFactory attribute of the
      * MinervaNoTransCMFactory object
      *
      * @param factory  The feature to be added to the ManagedConnectionFactory
      *      attribute
      * @param config   The feature to be added to the ManagedConnectionFactory
      *      attribute
      * @param name     The feature to be added to the ManagedConnectionFactory
      *      attribute
      * @return         Description of the Returned Value
      */
     public JBossConnectionManager 
addManagedConnectionFactory(ManagedConnectionFactory factory, ConnectorConfig config, 
String name)
     {
        MinervaNoTransCM cm = null;
  
        // Reuse the existing CM if the current settings all are empty or
        // match the defaults
        if ((config.tm == null || config.tm.equals(tm)) &&
              (config.rsf == null || config.rsf.equals(security))
              )
        {
           if (manager == null)
           {
              manager = new MinervaNoTransCM();
              manager.setSecurityManager(new JBossSecurityManager(security));
           }
           cm = manager;
        }
        else
        {
           cm = new MinervaNoTransCM();
           cm.setSecurityManager(new JBossSecurityManager(config.rsf == null ? 
security : config.rsf));
        }
        if (config.listener != null)
        {
           cm.addJBossConnectionListener(config.listener);
        }
  
        // Configure the connection pool properties
        Properties props = config.properties;
        PoolParameters params = new PoolParameters();
        params.blocking = true;
        //never return null
        String s = props.getProperty(PoolParameters.BLOCKING_TIMEOUT_MS_KEY);
        if (s != null)
        {
           try
           {
              params.blockingTimeoutMillis = Long.parseLong(s);
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.GC_ENABLED_KEY);
        if (s != null)
        {
           try
           {
              params.gcEnabled = new Boolean(s).booleanValue();
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.GC_INTERVAL_MS_KEY);
        if (s != null)
        {
           try
           {
              params.gcIntervalMillis = Long.parseLong(s);
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.GC_MIN_IDLE_MS_KEY);
        if (s != null)
        {
           try
           {
              params.gcMinIdleMillis = Long.parseLong(s);
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.IDLE_TIMEOUT_ENABLED_KEY);
        if (s != null)
        {
           try
           {
              params.idleTimeoutEnabled = new Boolean(s).booleanValue();
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.IDLE_TIMEOUT_MS_KEY);
        if (s != null)
        {
           try
           {
              params.idleTimeoutMillis = Long.parseLong(s);
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.INVALIDATE_ON_ERROR_KEY);
        if (s != null)
        {
           try
           {
              params.invalidateOnError = new Boolean(s).booleanValue();
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.MAX_IDLE_TIMEOUT_PERCENT_KEY);
        if (s != null)
        {
           try
           {
              params.maxIdleTimeoutPercent = new Float(s).floatValue();
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.MAX_SIZE_KEY);
        if (s != null)
        {
           try
           {
              params.maxSize = Integer.parseInt(s);
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.MIN_SIZE_KEY);
        if (s != null)
        {
           try
           {
              params.minSize = Integer.parseInt(s);
           }
           catch (Exception e)
           {
           }
        }
  
        // Check pool configuration
        String configuration = 
props.getProperty(NoTransConnectionManager.POOL_CONFIGURATION_KEY);
        boolean perFactory = NoTransConnectionManager.DEFAULT_POOL_PER_FACTORY;
        if (configuration != null)
        {
           if 
(configuration.equals(NoTransConnectionManager.POOL_CONFIG_VALUE_PER_FACTORY))
           {
              perFactory = true;
           }
           else if 
(configuration.equals(NoTransConnectionManager.POOL_CONFIG_VALUE_PER_USER))
           {
              perFactory = false;
           }
        }
        if (perFactory)
        {
           cm.createPerFactoryPool(factory, params, name);
        }
        else
        {
           cm.createPerUserPool(factory, params, name);
        }
  
        return cm;
     }
  }
  
  
  
  1.1                  
jbosscx/src/main/org/jboss/resource/connectionmanager/jboss/MinervaSharedLocalCM.java
  
  Index: MinervaSharedLocalCM.java
  ===================================================================
  /*
   * Licensed under the X license (see http://www.x.org/terms.htm)
   */
  package org.jboss.resource.connectionmanager.jboss;
  
  import java.util.*;
  import org.jboss.resource.JBossConnectionListener;
  import org.jboss.resource.JBossConnectionManager;
  import org.jboss.resource.connectionmanager.SharedLocalConnectionManager;
  
  /**
   * JBoss implementation of shared LocalTransaction ConnectionManager.
   *
   * @author    Aaron Mulder <[EMAIL PROTECTED]>
   * @version   $Revision: 1.1 $
   */
  public class MinervaSharedLocalCM extends SharedLocalConnectionManager
         implements JBossConnectionManager
  {
     private ArrayList listeners;
  
     /**
      * Constructor for the MinervaSharedLocalCM object
      */
     public MinervaSharedLocalCM()
     {
        listeners = new ArrayList();
     }
  
     /**
      * Adds a feature to the JBossConnectionListener attribute of the
      * MinervaSharedLocalCM object
      *
      * @param listener  The feature to be added to the JBossConnectionListener
      *      attribute
      */
     public void addJBossConnectionListener(JBossConnectionListener listener)
     {
        if (!listeners.contains(listener))
        {
           listeners.add(listener);
        }
     }
  
     /**
      * #Description of the Method
      *
      * @param listener  Description of Parameter
      */
     public void removeJBossConnectionListener(JBossConnectionListener listener)
     {
        listeners.remove(listener);
     }
  
     /**
      * #Description of the Method
      *
      * @param handle    Description of Parameter
      * @param listener  Description of Parameter
      */
     protected void connectionHandleIssued(Object handle, Object listener)
     {
        super.connectionHandleIssued(handle, listener);
        JBossConnectionListener[] copy = 
(JBossConnectionListener[])listeners.toArray(new 
JBossConnectionListener[listeners.size()]);
        for (int i = 0; i < copy.length; copy[i++].connectionHandleIssued(handle))
        {
           ;
        }
     }
  
     /**
      * #Description of the Method
      *
      * @param handle  Description of Parameter
      */
     protected void connectionHandleClosed(Object handle)
     {
        super.connectionHandleClosed(handle);
        JBossConnectionListener[] copy = 
(JBossConnectionListener[])listeners.toArray(new 
JBossConnectionListener[listeners.size()]);
        for (int i = 0; i < copy.length; copy[i++].connectionHandleClosed(handle))
        {
           ;
        }
     }
  }
  
  
  
  1.1                  
jbosscx/src/main/org/jboss/resource/connectionmanager/jboss/MinervaSharedLocalCMFactory.java
  
  Index: MinervaSharedLocalCMFactory.java
  ===================================================================
  /*
   * Licensed under the X license (see http://www.x.org/terms.htm)
   */
  package org.jboss.resource.connectionmanager.jboss;
  
  import java.util.Properties;
  import javax.resource.spi.ManagedConnectionFactory;
  import javax.transaction.TransactionManager;
  import org.jboss.pool.PoolParameters;
  import org.jboss.resource.ConnectionManagerFactory;
  import org.jboss.resource.ConnectorConfig;
  import org.jboss.resource.JBossConnectionListener;
  import org.jboss.resource.JBossConnectionManager;
  import org.jboss.resource.ResourceSubjectFactory;
  import org.jboss.resource.connectionmanager.SharedLocalConnectionManager;
  
  /**
   * Implementation of JBoss connector initialization.
   *
   * @author    Aaron Mulder <[EMAIL PROTECTED]>
   * @author    <a href="mailto:[EMAIL PROTECTED]";>David Jencks</a>
   * @version   $Revision: 1.1 $
   */
  public class MinervaSharedLocalCMFactory implements ConnectionManagerFactory
  {
     private TransactionManager tm;
     private ResourceSubjectFactory security;
     private MinervaSharedLocalCM manager;
  
     /**
      * Constructor for the MinervaSharedLocalCMFactory object
      */
     public MinervaSharedLocalCMFactory()
     {
     }
  
     /**
      * Sets the TransactionManager attribute of the MinervaSharedLocalCMFactory
      * object
      *
      * @param tm  The new TransactionManager value
      */
     public void setTransactionManager(TransactionManager tm)
     {
        this.tm = tm;
     }
  
     /**
      * Sets the ResourceSubjectFactory attribute of the MinervaSharedLocalCMFactory
      * object
      *
      * @param security  The new ResourceSubjectFactory value
      */
     public void setResourceSubjectFactory(ResourceSubjectFactory security)
     {
        this.security = security;
     }
  
     /**
      * Sets the Properties attribute of the MinervaSharedLocalCMFactory object
      *
      * @param props  The new Properties value
      */
     public void setProperties(Properties props)
     {
     }
  
     /**
      * Adds a feature to the ManagedConnectionFactory attribute of the
      * MinervaSharedLocalCMFactory object
      *
      * @param factory  The feature to be added to the ManagedConnectionFactory
      *      attribute
      * @param config   The feature to be added to the ManagedConnectionFactory
      *      attribute
      * @param name     The feature to be added to the ManagedConnectionFactory
      *      attribute
      * @return         Description of the Returned Value
      */
     public JBossConnectionManager 
addManagedConnectionFactory(ManagedConnectionFactory factory, ConnectorConfig config, 
String name)
     {
        MinervaSharedLocalCM cm = null;
  
        // Reuse the existing CM if the current settings all are empty or
        // match the defaults
        if ((config.tm == null || config.tm.equals(tm)) &&
              (config.rsf == null || config.rsf.equals(security))
              )
        {
           if (manager == null)
           {
              manager = new MinervaSharedLocalCM();
              manager.setTransactionManager(tm);
              manager.setSecurityManager(new JBossSecurityManager(security));
           }
           cm = manager;
        }
        else
        {
           cm = new MinervaSharedLocalCM();
           cm.setTransactionManager(config.tm == null ? tm : config.tm);
           cm.setSecurityManager(new JBossSecurityManager(config.rsf == null ? 
security : config.rsf));
        }
        if (config.listener != null)
        {
           cm.addJBossConnectionListener(config.listener);
        }
  
        // Configure the connection pool properties
        Properties props = config.properties;
        PoolParameters params = new PoolParameters();
        params.blocking = true;
        //never return null
        String s = props.getProperty(PoolParameters.BLOCKING_TIMEOUT_MS_KEY);
        if (s != null)
        {
           try
           {
              params.blockingTimeoutMillis = Long.parseLong(s);
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.GC_ENABLED_KEY);
        if (s != null)
        {
           try
           {
              params.gcEnabled = new Boolean(s).booleanValue();
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.GC_INTERVAL_MS_KEY);
        if (s != null)
        {
           try
           {
              params.gcIntervalMillis = Long.parseLong(s);
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.GC_MIN_IDLE_MS_KEY);
        if (s != null)
        {
           try
           {
              params.gcMinIdleMillis = Long.parseLong(s);
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.IDLE_TIMEOUT_ENABLED_KEY);
        if (s != null)
        {
           try
           {
              params.idleTimeoutEnabled = new Boolean(s).booleanValue();
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.IDLE_TIMEOUT_MS_KEY);
        if (s != null)
        {
           try
           {
              params.idleTimeoutMillis = Long.parseLong(s);
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.INVALIDATE_ON_ERROR_KEY);
        if (s != null)
        {
           try
           {
              params.invalidateOnError = new Boolean(s).booleanValue();
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.MAX_IDLE_TIMEOUT_PERCENT_KEY);
        if (s != null)
        {
           try
           {
              params.maxIdleTimeoutPercent = new Float(s).floatValue();
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.MAX_SIZE_KEY);
        if (s != null)
        {
           try
           {
              params.maxSize = Integer.parseInt(s);
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.MIN_SIZE_KEY);
        if (s != null)
        {
           try
           {
              params.minSize = Integer.parseInt(s);
           }
           catch (Exception e)
           {
           }
        }
  
        // Check pool configuration
        String configuration = 
props.getProperty(SharedLocalConnectionManager.POOL_CONFIGURATION_KEY);
        boolean perFactory = SharedLocalConnectionManager.DEFAULT_POOL_PER_FACTORY;
        if (configuration != null)
        {
           if 
(configuration.equals(SharedLocalConnectionManager.POOL_CONFIG_VALUE_PER_FACTORY))
           {
              perFactory = true;
           }
           else if 
(configuration.equals(SharedLocalConnectionManager.POOL_CONFIG_VALUE_PER_USER))
           {
              perFactory = false;
           }
        }
        if (perFactory)
        {
           cm.createPerFactoryPool(factory, params, name);
        }
        else
        {
           cm.createPerUserPool(factory, params, name);
        }
  
        return cm;
     }
  }
  
  
  
  1.1                  
jbosscx/src/main/org/jboss/resource/connectionmanager/jboss/MinervaXACM.java
  
  Index: MinervaXACM.java
  ===================================================================
  /*
   * Licensed under the X license (see http://www.x.org/terms.htm)
   */
  package org.jboss.resource.connectionmanager.jboss;
  
  import java.util.*;
  import org.jboss.resource.JBossConnectionListener;
  import org.jboss.resource.JBossConnectionManager;
  import org.jboss.resource.connectionmanager.XAConnectionManager;
  
  /**
   * JBoss implementation of non-shared JTA ConnectionManager.
   *
   * @author    Aaron Mulder <[EMAIL PROTECTED]>
   * @version   $Revision: 1.1 $
   */
  public class MinervaXACM extends XAConnectionManager implements 
JBossConnectionManager
  {
     private ArrayList listeners;
  
     /**
      * Constructor for the MinervaXACM object
      */
     public MinervaXACM()
     {
        listeners = new ArrayList();
     }
  
     /**
      * Adds a feature to the JBossConnectionListener attribute of the MinervaXACM
      * object
      *
      * @param listener  The feature to be added to the JBossConnectionListener
      *      attribute
      */
     public void addJBossConnectionListener(JBossConnectionListener listener)
     {
        if (!listeners.contains(listener))
        {
           listeners.add(listener);
        }
     }
  
     /**
      * #Description of the Method
      *
      * @param listener  Description of Parameter
      */
     public void removeJBossConnectionListener(JBossConnectionListener listener)
     {
        listeners.remove(listener);
     }
  
     /**
      * #Description of the Method
      *
      * @param handle    Description of Parameter
      * @param listener  Description of Parameter
      */
     protected void connectionHandleIssued(Object handle, Object listener)
     {
        super.connectionHandleIssued(handle, listener);
        JBossConnectionListener[] copy = 
(JBossConnectionListener[])listeners.toArray(new 
JBossConnectionListener[listeners.size()]);
        for (int i = 0; i < copy.length; copy[i++].connectionHandleIssued(handle))
        {
           ;
        }
     }
  
     /**
      * #Description of the Method
      *
      * @param handle  Description of Parameter
      */
     protected void connectionHandleClosed(Object handle)
     {
        super.connectionHandleClosed(handle);
        JBossConnectionListener[] copy = 
(JBossConnectionListener[])listeners.toArray(new 
JBossConnectionListener[listeners.size()]);
        for (int i = 0; i < copy.length; copy[i++].connectionHandleClosed(handle))
        {
           ;
        }
     }
  }
  
  
  
  1.1                  
jbosscx/src/main/org/jboss/resource/connectionmanager/jboss/MinervaXACMFactory.java
  
  Index: MinervaXACMFactory.java
  ===================================================================
  /*
   * Licensed under the X license (see http://www.x.org/terms.htm)
   */
  package org.jboss.resource.connectionmanager.jboss;
  
  import java.util.Properties;
  import javax.resource.spi.ManagedConnectionFactory;
  import javax.transaction.TransactionManager;
  import org.jboss.pool.PoolParameters;
  import org.jboss.resource.ConnectionManagerFactory;
  import org.jboss.resource.ConnectorConfig;
  import org.jboss.resource.JBossConnectionListener;
  import org.jboss.resource.JBossConnectionManager;
  import org.jboss.resource.ResourceSubjectFactory;
  import org.jboss.resource.connectionmanager.XAConnectionManager;
  
  /**
   * Implementation of JBoss connector initialization.
   *
   * @author    Aaron Mulder <[EMAIL PROTECTED]>
   * @author    <a href="mailto:[EMAIL PROTECTED]";>David Jencks</a>
   * @version   $Revision: 1.1 $
   */
  public class MinervaXACMFactory implements ConnectionManagerFactory
  {
     private TransactionManager tm;
     private ResourceSubjectFactory security;
     private MinervaXACM manager;
  
     /**
      * Constructor for the MinervaXACMFactory object
      */
     public MinervaXACMFactory()
     {
     }
  
     /**
      * Sets the TransactionManager attribute of the MinervaXACMFactory object
      *
      * @param tm  The new TransactionManager value
      */
     public void setTransactionManager(TransactionManager tm)
     {
        this.tm = tm;
     }
  
     /**
      * Sets the ResourceSubjectFactory attribute of the MinervaXACMFactory object
      *
      * @param security  The new ResourceSubjectFactory value
      */
     public void setResourceSubjectFactory(ResourceSubjectFactory security)
     {
        this.security = security;
     }
  
     /**
      * Sets the Properties attribute of the MinervaXACMFactory object
      *
      * @param props  The new Properties value
      */
     public void setProperties(Properties props)
     {
     }
  
     /**
      * Adds a feature to the ManagedConnectionFactory attribute of the
      * MinervaXACMFactory object
      *
      * @param factory  The feature to be added to the ManagedConnectionFactory
      *      attribute
      * @param config   The feature to be added to the ManagedConnectionFactory
      *      attribute
      * @param name     The feature to be added to the ManagedConnectionFactory
      *      attribute
      * @return         Description of the Returned Value
      */
     public JBossConnectionManager 
addManagedConnectionFactory(ManagedConnectionFactory factory, ConnectorConfig config, 
String name)
     {
        MinervaXACM cm = null;
  
        // Reuse the existing CM if the current settings all are empty or
        // match the defaults
        if ((config.tm == null || config.tm.equals(tm)) &&
              (config.rsf == null || config.rsf.equals(security))
              )
        {
           if (manager == null)
           {
              manager = new MinervaXACM();
              manager.setTransactionManager(tm);
              manager.setSecurityManager(new JBossSecurityManager(security));
           }
           cm = manager;
        }
        else
        {
           cm = new MinervaXACM();
           cm.setTransactionManager(config.tm == null ? tm : config.tm);
           cm.setSecurityManager(new JBossSecurityManager(config.rsf == null ? 
security : config.rsf));
        }
        if (config.listener != null)
        {
           cm.addJBossConnectionListener(config.listener);
        }
  
        // Configure the connection pool properties
        Properties props = config.properties;
        PoolParameters params = new PoolParameters();
        params.blocking = true;
        //never return null
        String s = props.getProperty(PoolParameters.BLOCKING_TIMEOUT_MS_KEY);
        if (s != null)
        {
           try
           {
              params.blockingTimeoutMillis = Long.parseLong(s);
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.GC_ENABLED_KEY);
        if (s != null)
        {
           try
           {
              params.gcEnabled = new Boolean(s).booleanValue();
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.GC_INTERVAL_MS_KEY);
        if (s != null)
        {
           try
           {
              params.gcIntervalMillis = Long.parseLong(s);
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.GC_MIN_IDLE_MS_KEY);
        if (s != null)
        {
           try
           {
              params.gcMinIdleMillis = Long.parseLong(s);
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.IDLE_TIMEOUT_ENABLED_KEY);
        if (s != null)
        {
           try
           {
              params.idleTimeoutEnabled = new Boolean(s).booleanValue();
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.IDLE_TIMEOUT_MS_KEY);
        if (s != null)
        {
           try
           {
              params.idleTimeoutMillis = Long.parseLong(s);
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.INVALIDATE_ON_ERROR_KEY);
        if (s != null)
        {
           try
           {
              params.invalidateOnError = new Boolean(s).booleanValue();
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.MAX_IDLE_TIMEOUT_PERCENT_KEY);
        if (s != null)
        {
           try
           {
              params.maxIdleTimeoutPercent = new Float(s).floatValue();
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.MAX_SIZE_KEY);
        if (s != null)
        {
           try
           {
              params.maxSize = Integer.parseInt(s);
           }
           catch (Exception e)
           {
           }
        }
        s = props.getProperty(PoolParameters.MIN_SIZE_KEY);
        if (s != null)
        {
           try
           {
              params.minSize = Integer.parseInt(s);
           }
           catch (Exception e)
           {
           }
        }
  
        // Check pool configuration
        String configuration = 
props.getProperty(XAConnectionManager.POOL_CONFIGURATION_KEY);
        boolean perFactory = XAConnectionManager.DEFAULT_POOL_PER_FACTORY;
        if (configuration != null)
        {
           if (configuration.equals(XAConnectionManager.POOL_CONFIG_VALUE_PER_FACTORY))
           {
              perFactory = true;
           }
           else if 
(configuration.equals(XAConnectionManager.POOL_CONFIG_VALUE_PER_USER))
           {
              perFactory = false;
           }
        }
        if (perFactory)
        {
           cm.createPerFactoryPool(factory, params, name);
        }
        else
        {
           cm.createPerUserPool(factory, params, name);
        }
  
        return cm;
     }
  }
  
  
  

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

Reply via email to