[jboss-cvs] JBossAS SVN: r110975 - in projects/jboss-jca/trunk: deployers/src/main/java/org/jboss/jca/deployers/common and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Mar 19 00:08:28 EDT 2011


Author: jeff.zhang
Date: 2011-03-19 00:08:25 -0400 (Sat, 19 Mar 2011)
New Revision: 110975

Added:
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/ConnectionFactory.java
Modified:
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/Connector.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/ManagedConnectionFactory.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java
   projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/AbstractResourceComponent.java
   projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/CfResourceComponent.java
   projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/CfResourceDiscoveryComponent.java
   projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/McfResourceComponent.java
   projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/McfResourceDiscoveryComponent.java
   projects/jboss-jca/trunk/rhq/src/main/resources/META-INF/rhq-plugin.xml
   projects/jboss-jca/trunk/rhq/src/test/java/org/jboss/jca/rhq/test/XATestCase.java
Log:
[JBJCA-530] define a ConnectionFactory class in the management api package

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/ConnectionFactory.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/ConnectionFactory.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/ConnectionFactory.java	2011-03-19 04:08:25 UTC (rev 110975)
@@ -0,0 +1,158 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.core.api.management;
+
+import org.jboss.jca.core.api.connectionmanager.pool.Pool;
+import org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration;
+
+import java.lang.ref.WeakReference;
+
+/**
+ * Represents a managed connection factory instance
+ * 
+ * @author <a href="mailto:jeff.zhang at jboss.org">Jeff Zhang</a> 
+ */
+public class ConnectionFactory
+{
+   /** The managed connection factory */
+   private ManagedConnectionFactory managedConnectionFactory;
+
+   /** jndi name */
+   private String jndiName;
+   
+   /** The pool instance */
+   private WeakReference<Pool> pool;
+
+   /** The pool configuration instance */
+   private WeakReference<PoolConfiguration> poolConfiguration;
+   
+   /**
+    * Constructor
+    * @param mcf The managed connection factory instance
+    */
+   public ConnectionFactory(javax.resource.spi.ManagedConnectionFactory mcf)
+   {
+      this.managedConnectionFactory = new ManagedConnectionFactory(mcf);
+      this.pool = null;
+      this.poolConfiguration = null;
+   }
+
+   /**
+    * Get the managed connection factory instance.
+    * 
+    * Note, that the value may be <code>null</code> if the managed connection factory was
+    * undeployed and this object wasn't cleared up correctly.
+    * @return The instance
+    */
+   public ManagedConnectionFactory getMcf()
+   {
+      return managedConnectionFactory;
+   }
+
+   /**
+    * Get the pool instance.
+    * 
+    * Note, that the value may be <code>null</code> if the pool was
+    * undeployed and this object wasn't cleared up correctly.
+    * @return The instance
+    */
+   public Pool getPool()
+   {
+      if (pool == null)
+         return null;
+
+      return pool.get();
+   }
+
+   /**
+    * Set the pool
+    * @param p The pool
+    */
+   public void setPool(Pool p)
+   {
+      this.pool = new WeakReference<Pool>(p);
+   }
+
+   /**
+    * Get the pool configuration instance.
+    * 
+    * Note, that the value may be <code>null</code> if the pool configuration was
+    * undeployed and this object wasn't cleared up correctly.
+    * @return The instance
+    */
+   public PoolConfiguration getPoolConfiguration()
+   {
+      if (poolConfiguration == null)
+         return null;
+
+      return poolConfiguration.get();
+   }
+
+   /**
+    * Set the pool configuration
+    * @param pc The pool configuration
+    */
+   public void setPoolConfiguration(PoolConfiguration pc)
+   {
+      this.poolConfiguration = new WeakReference<PoolConfiguration>(pc);
+   }
+
+
+   /**
+    * Get the jndiName.
+    * 
+    * @return the jndiName.
+    */
+   public String getJndiName()
+   {
+      return jndiName;
+   }
+
+   /**
+    * Set the jndiName.
+    * 
+    * @param jndiName The jndiName to set.
+    */
+   public void setJndiName(String jndiName)
+   {
+      this.jndiName = jndiName;
+   }
+
+   /**
+    * String representation
+    * @return The string
+    */
+   @Override
+   public String toString()
+   {
+      StringBuilder sb = new StringBuilder();
+
+      sb.append("ManagedConnectionFactory@").append(Integer.toHexString(System.identityHashCode(this)));
+      sb.append("[jndiName=").append(getJndiName());
+      sb.append(" pool=").append(getPool());
+      sb.append(" poolconfiguration=").append(getPoolConfiguration());
+      sb.append("]");
+
+      return sb.toString();
+   }
+}

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/Connector.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/Connector.java	2011-03-18 14:35:58 UTC (rev 110974)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/Connector.java	2011-03-19 04:08:25 UTC (rev 110975)
@@ -29,6 +29,7 @@
  * Represents a connector instance
  * 
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @author <a href="mailto:jeff.zhang at jboss.org">Jeff Zhang</a> 
  */
 public class Connector
 {
@@ -38,8 +39,8 @@
    /** The resource adapter instance */
    private ResourceAdapter resourceAdapter;
 
-   /** The managed connection factories */
-   private List<ManagedConnectionFactory> managedConnectionFactories;
+   /** The connection factories */
+   private List<ConnectionFactory> connectionFactories;
 
    /** The admin objects */
    private List<AdminObject> adminObjects;
@@ -52,7 +53,7 @@
    {
       this.uniqueId = uniqueId;
       this.resourceAdapter = null;
-      this.managedConnectionFactories = null;
+      this.connectionFactories = null;
       this.adminObjects = null;
    }
 
@@ -84,15 +85,15 @@
    }
 
    /**
-    * Get the list of managed connection factories
+    * Get the list of connection factories
     * @return The value
     */
-   public List<ManagedConnectionFactory> getManagedConnectionFactories()
+   public List<ConnectionFactory> getConnectionFactories()
    {
-      if (managedConnectionFactories == null)
-         managedConnectionFactories = new ArrayList<ManagedConnectionFactory>(1);
+      if (connectionFactories == null)
+         connectionFactories = new ArrayList<ConnectionFactory>(1);
 
-      return managedConnectionFactories;
+      return connectionFactories;
    }
 
    /**
@@ -119,7 +120,7 @@
       sb.append("Connector@").append(Integer.toHexString(System.identityHashCode(this)));
       sb.append("[uniqueId=").append(uniqueId);
       sb.append(" resourceAdapter=").append(resourceAdapter);
-      sb.append(" managedConnectionFactories=").append(managedConnectionFactories);
+      sb.append(" connectionFactories=").append(connectionFactories);
       sb.append(" adminObjects=").append(adminObjects);
       sb.append("]");
 

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/ManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/ManagedConnectionFactory.java	2011-03-18 14:35:58 UTC (rev 110974)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/management/ManagedConnectionFactory.java	2011-03-19 04:08:25 UTC (rev 110975)
@@ -22,9 +22,6 @@
 
 package org.jboss.jca.core.api.management;
 
-import org.jboss.jca.core.api.connectionmanager.pool.Pool;
-import org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration;
-
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.List;
@@ -33,6 +30,7 @@
  * Represents a managed connection factory instance
  * 
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @author <a href="mailto:jeff.zhang at jboss.org">Jeff Zhang</a> 
  */
 public class ManagedConnectionFactory
 {
@@ -41,15 +39,6 @@
 
    /** The config property's */
    private List<ConfigProperty> configProperties;
-
-   /** The pool instance */
-   private WeakReference<Pool> pool;
-
-   /** The pool configuration instance */
-   private WeakReference<PoolConfiguration> poolConfiguration;
-
-   /** jndi name */
-   private String jndiName;
    
    /**
     * Constructor
@@ -59,8 +48,6 @@
    {
       this.instance = new WeakReference<javax.resource.spi.ManagedConnectionFactory>(mcf);
       this.configProperties = null;
-      this.pool = null;
-      this.poolConfiguration = null;
    }
 
    /**
@@ -88,75 +75,6 @@
    }
 
    /**
-    * Get the pool instance.
-    * 
-    * Note, that the value may be <code>null</code> if the pool was
-    * undeployed and this object wasn't cleared up correctly.
-    * @return The instance
-    */
-   public Pool getPool()
-   {
-      if (pool == null)
-         return null;
-
-      return pool.get();
-   }
-
-   /**
-    * Set the pool
-    * @param p The pool
-    */
-   public void setPool(Pool p)
-   {
-      this.pool = new WeakReference<Pool>(p);
-   }
-
-   /**
-    * Get the pool configuration instance.
-    * 
-    * Note, that the value may be <code>null</code> if the pool configuration was
-    * undeployed and this object wasn't cleared up correctly.
-    * @return The instance
-    */
-   public PoolConfiguration getPoolConfiguration()
-   {
-      if (poolConfiguration == null)
-         return null;
-
-      return poolConfiguration.get();
-   }
-
-   /**
-    * Set the pool configuration
-    * @param pc The pool configuration
-    */
-   public void setPoolConfiguration(PoolConfiguration pc)
-   {
-      this.poolConfiguration = new WeakReference<PoolConfiguration>(pc);
-   }
-
-
-   /**
-    * Get the jndiName.
-    * 
-    * @return the jndiName.
-    */
-   public String getJndiName()
-   {
-      return jndiName;
-   }
-
-   /**
-    * Set the jndiName.
-    * 
-    * @param jndiName The jndiName to set.
-    */
-   public void setJndiName(String jndiName)
-   {
-      this.jndiName = jndiName;
-   }
-
-   /**
     * String representation
     * @return The string
     */
@@ -168,8 +86,6 @@
       sb.append("ManagedConnectionFactory@").append(Integer.toHexString(System.identityHashCode(this)));
       sb.append("[instance=").append(getManagedConnectionFactory());
       sb.append(" configProperties=").append(configProperties);
-      sb.append(" pool=").append(getPool());
-      sb.append(" poolconfiguration=").append(getPoolConfiguration());
       sb.append("]");
 
       return sb.toString();

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java	2011-03-18 14:35:58 UTC (rev 110974)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java	2011-03-19 04:08:25 UTC (rev 110975)
@@ -1165,15 +1165,17 @@
 
                         if (activateDeployment)
                         {
-                           org.jboss.jca.core.api.management.ManagedConnectionFactory mgtMcf =
-                              new org.jboss.jca.core.api.management.ManagedConnectionFactory(mcf);
+                           org.jboss.jca.core.api.management.ConnectionFactory mgtCf =
+                              new org.jboss.jca.core.api.management.ConnectionFactory(mcf);
 
-                           mgtMcf.getConfigProperties().addAll(createManagementView(ra10.getConfigProperties()));
-                           mgtMcf.setPoolConfiguration(pc);
-                           mgtMcf.setPool(pool);
-                           mgtMcf.setJndiName(jndiName);
+                           mgtCf.setPoolConfiguration(pc);
+                           mgtCf.setPool(pool);
+                           mgtCf.setJndiName(jndiName);
+                           
+                           mgtCf.getMcf().getConfigProperties().
+                              addAll(createManagementView(ra10.getConfigProperties()));
 
-                           mgtConnector.getManagedConnectionFactories().add(mgtMcf);
+                           mgtConnector.getConnectionFactories().add(mgtCf);
                         }
                      }
                   }
@@ -1611,16 +1613,17 @@
 
                                     if (activateDeployment)
                                     {
-                                       org.jboss.jca.core.api.management.ManagedConnectionFactory mgtMcf =
-                                          new org.jboss.jca.core.api.management.ManagedConnectionFactory(mcf);
+                                       org.jboss.jca.core.api.management.ConnectionFactory mgtCf =
+                                          new org.jboss.jca.core.api.management.ConnectionFactory(mcf);
 
-                                       mgtMcf.getConfigProperties().
+                                       mgtCf.setPoolConfiguration(pc);
+                                       mgtCf.setPool(pool);
+                                       mgtCf.setJndiName(jndiName);
+                                       
+                                       mgtCf.getMcf().getConfigProperties().
                                           addAll(createManagementView(cdMeta.getConfigProperties()));
-                                       mgtMcf.setPoolConfiguration(pc);
-                                       mgtMcf.setPool(pool);
-                                       mgtMcf.setJndiName(jndiName);
 
-                                       mgtConnector.getManagedConnectionFactories().add(mgtMcf);
+                                       mgtConnector.getConnectionFactories().add(mgtCf);
                                     }
                                  }
                               }

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java	2011-03-18 14:35:58 UTC (rev 110974)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/AbstractFungalRADeployer.java	2011-03-19 04:08:25 UTC (rev 110975)
@@ -445,11 +445,12 @@
             }
          }
 
-         for (org.jboss.jca.core.api.management.ManagedConnectionFactory mgtMcf :
-                 mgtConnector.getManagedConnectionFactories())
+         for (org.jboss.jca.core.api.management.ConnectionFactory mgtCf :
+                 mgtConnector.getConnectionFactories())
          {
-            if (mgtMcf.getManagedConnectionFactory() != null)
+            if (mgtCf.getMcf() != null)
             {
+               org.jboss.jca.core.api.management.ManagedConnectionFactory mgtMcf = mgtCf.getMcf();
                Set<String> writeable = new HashSet<String>();
                Set<String> excludeAttributes = new HashSet<String>();
 
@@ -482,13 +483,13 @@
                ons.add(mcfON);
             }
 
-            if (mgtMcf.getPoolConfiguration() != null)
+            if (mgtCf.getPoolConfiguration() != null)
             {
                String mcfPCName = baseName + ",type=ManagedConnectionFactory,class=" +
-                  getClassName(mgtMcf.getManagedConnectionFactory().getClass().getName()) +
+                  getClassName(mgtCf.getMcf().getClass().getName()) +
                   ",subcategory=PoolConfiguration";
 
-               DynamicMBean mcfPCDMB = JMX.createMBean(mgtMcf.getPoolConfiguration(), "Pool configuration");
+               DynamicMBean mcfPCDMB = JMX.createMBean(mgtCf.getPoolConfiguration(), "Pool configuration");
                ObjectName mcfPCON = new ObjectName(mcfPCName);
 
                server.registerMBean(mcfPCDMB, mcfPCON);
@@ -496,12 +497,12 @@
                ons.add(mcfPCON);
             }
 
-            if (mgtMcf.getPool() != null)
+            if (mgtCf.getPool() != null)
             {
                String mcfPName = baseName + ",type=ManagedConnectionFactory,class=" +
-                  getClassName(mgtMcf.getManagedConnectionFactory().getClass().getName()) + ",subcategory=Pool";
+                  getClassName(mgtCf.getMcf().getClass().getName()) + ",subcategory=Pool";
 
-               DynamicMBean mcfPDMB = JMX.createMBean(mgtMcf.getPool(), "Pool");
+               DynamicMBean mcfPDMB = JMX.createMBean(mgtCf.getPool(), "Pool");
                ObjectName mcfPON = new ObjectName(mcfPName);
 
                server.registerMBean(mcfPDMB, mcfPON);

Modified: projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/AbstractResourceComponent.java
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/AbstractResourceComponent.java	2011-03-18 14:35:58 UTC (rev 110974)
+++ projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/AbstractResourceComponent.java	2011-03-19 04:08:25 UTC (rev 110975)
@@ -171,6 +171,21 @@
       }
       return resKey.substring(lastPos + 1);
    }
+   
+   /**
+    * getJndiName
+    * @return binding jndi name
+    */
+   protected String getJndiName()
+   {
+      String resKey = getResourceContext().getResourceKey();
+      int lastPos = resKey.lastIndexOf("#");
+      if (lastPos == -1)
+      {
+         return null;
+      }
+      return resKey.substring(lastPos + 1);
+   }
 
    /**
     * getConfigPropertiesList

Modified: projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/CfResourceComponent.java
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/CfResourceComponent.java	2011-03-18 14:35:58 UTC (rev 110974)
+++ projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/CfResourceComponent.java	2011-03-19 04:08:25 UTC (rev 110975)
@@ -21,22 +21,56 @@
  */
 package org.jboss.jca.rhq.ra;
 
+import org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration;
+import org.jboss.jca.core.api.management.ConnectionFactory;
+import org.jboss.jca.core.api.management.Connector;
+import org.jboss.jca.core.api.management.ManagementRepository;
+
 import org.jboss.jca.rhq.core.AbstractResourceComponent;
+import org.jboss.jca.rhq.core.ManagementRepositoryManager;
+import org.jboss.jca.rhq.util.ManagementRepositoryHelper;
 
 import org.jboss.logging.Logger;
 
 import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.PropertySimple;
 
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+
 /**
  * CfResourceComponent represent the ManagedConnectionFactory in JCA container.
  * 
  * @author <a href="mailto:jeff.zhang at jboss.org">Jeff Zhang</a> 
+ * @author <a href="mailto:lgao at redhat.com">Lin Gao</a>
  */
 public class CfResourceComponent extends AbstractResourceComponent
 {
    /** log */
    private static final Logger logger = Logger.getLogger(CfResourceComponent.class);
+   
+   /**
+    * Get associated ConnectionFactory
+    * 
+    * @return ConnectionFactory
+    */
+   public ConnectionFactory getConnectionFactory()
+   {
+      ManagementRepository mr = ManagementRepositoryManager.getManagementRepository();
+      Connector connector = ManagementRepositoryHelper.getConnectorByUniqueId(mr, getRarUniqueId());
+      String jndiName = getJndiName();
 
+      for (ConnectionFactory cf : connector.getConnectionFactories())
+      {
+         if (cf.getJndiName().equals(jndiName))
+         {
+            logger.debug("Class Name is: " + jndiName);
+            return cf;
+         }
+      }
+      return null;
+   }
+   
    /**
     * loadResourceConfiguration
     * 
@@ -48,7 +82,122 @@
    public Configuration loadResourceConfiguration() throws Exception
    {
       Configuration config = new Configuration();
-
+      
+      ConnectionFactory cf = getConnectionFactory();
+      if (cf == null)
+         throw new IllegalStateException("Can not find ConnectionFactory.");
+      
+      // jndi name
+      PropertySimple jndiNameProp = new PropertySimple("jndi-name", cf.getJndiName());
+      config.put(jndiNameProp);
+      
+      // conn-pool
+      PoolConfiguration poolConfig = cf.getPoolConfiguration();
+      
+      PropertySimple poolNameProp = new PropertySimple("pool-name", cf.getPool().getName());
+      config.put(poolNameProp);
+      
+      PropertySimple minSizeProp = new PropertySimple("min-pool-size", Integer.valueOf(poolConfig.getMinSize()));
+      config.put(minSizeProp);
+      
+      PropertySimple maxSizeProp = new PropertySimple("max-pool-size", Integer.valueOf(poolConfig.getMaxSize()));
+      config.put(maxSizeProp);
+      
+      Boolean doBackGroundValidation = Boolean.valueOf(poolConfig.isBackgroundValidation());
+      PropertySimple isBackGroundValidateProp = new PropertySimple("background-validation", doBackGroundValidation);
+      config.put(isBackGroundValidateProp);
+      
+      Long bvInterval = Long.valueOf(poolConfig.getBackgroundValidationInterval());
+      PropertySimple backGroundValidateIntervalProp = new PropertySimple("background-validation-millis", bvInterval);
+      config.put(backGroundValidateIntervalProp);
+      
+      Integer bvMinutes = Integer.valueOf(poolConfig.getBackgroundValidationMinutes());
+      PropertySimple backGroundValidateMintuesProp = new PropertySimple("background-validation-minutes", bvMinutes);
+      config.put(backGroundValidateMintuesProp);
+      
+      Long blTimeout = Long.valueOf(poolConfig.getBlockingTimeout());
+      PropertySimple blockingTimeoutProp = new PropertySimple("blocking-timeout-millis", blTimeout);
+      config.put(blockingTimeoutProp);
+      
+      Long idleTimeoutMills = poolConfig.getIdleTimeout();
+      
+      Integer idleTimeout = (int)(idleTimeoutMills / (1000 * 60)); // convert to minutes
+      PropertySimple idleTimeoutProp = new PropertySimple("idle-timeout-minutes", idleTimeout);
+      config.put(idleTimeoutProp);
+      
+      PropertySimple prefillProp = new PropertySimple("prefill", Boolean.valueOf(poolConfig.isPrefill()));
+      config.put(prefillProp);
+      
+      PropertySimple useStictMinProp = new PropertySimple("use-strict-min", Boolean.valueOf(poolConfig.isStrictMin()));
+      config.put(useStictMinProp);
+      
+      PropertySimple useFasFailProp = new PropertySimple("use-fast-fail", Boolean.valueOf(poolConfig.isUseFastFail()));
+      config.put(useFasFailProp);
+      
       return config;
    }
+   
+   
+   /**
+    * updateResourceConfiguration
+    * 
+    * @param updateResourceConfiguration the ConfigurationUpdateReport
+    */
+   @Override
+   public void updateResourceConfiguration(ConfigurationUpdateReport updateResourceConfiguration)
+   {
+      super.updateResourceConfiguration(updateResourceConfiguration);
+      Configuration config = updateResourceConfiguration.getConfiguration();
+      
+      ConnectionFactory cf = getConnectionFactory();
+      if (cf == null)
+         throw new IllegalStateException("Can not find ConnectionFactory.");
+      
+      // update jndi-name
+      String jndiName = config.getSimpleValue("jndi-name", null);
+      if (null != jndiName && jndiName.length() > 0)
+      {
+         cf.setJndiName(jndiName);
+      }
+      // update conn-pool configurations
+      PoolConfiguration poolConfig = cf.getPoolConfiguration();
+      Integer minPoolSize = Integer.valueOf(config.getSimpleValue("min-pool-size", "0"));
+      poolConfig.setMinSize(minPoolSize.intValue());
+      
+      Integer maxPoolSize = Integer.valueOf(config.getSimpleValue("max-pool-size", "20"));
+      poolConfig.setMaxSize(maxPoolSize.intValue());
+      
+      Boolean backGroundValid = Boolean.valueOf(config.getSimpleValue("background-validation", "false"));
+      poolConfig.setBackgroundValidation(backGroundValid.booleanValue());
+      
+      // background-validation-millis
+      
+      // background-validation-minutes
+      Integer backGroundValidMinutes = Integer.valueOf(config.getSimpleValue("background-validation-minutes", "0"));
+      poolConfig.setBackgroundValidationMinutes(backGroundValidMinutes.intValue());
+
+      // blocking-timeout-millis
+      Long blockTimeoutMillis = Long.valueOf(config.getSimpleValue("blocking-timeout-millis", "30000"));
+      poolConfig.setBlockingTimeout(blockTimeoutMillis.longValue());
+      
+      // idle-timeout-minutes
+      Integer idleTimeoutMinutes = Integer.valueOf(config.getSimpleValue("idle-timeout-minutes", "30"));
+      Long idleTimeoutMillis = Long.valueOf(idleTimeoutMinutes * 60 * 1000);
+      poolConfig.setIdleTimeout(idleTimeoutMillis.longValue());
+      
+      // prefill
+      Boolean preFill = Boolean.valueOf(config.getSimpleValue("prefill", "true"));
+      poolConfig.setPrefill(preFill);
+      
+      // use-strict-min
+      Boolean useStrictMin = Boolean.valueOf(config.getSimpleValue("use-strict-min", "false"));
+      poolConfig.setStrictMin(useStrictMin);
+      
+      // use-fast-fail
+      Boolean useFastFail = Boolean.valueOf(config.getSimpleValue("use-fast-fail", "false"));
+      poolConfig.setUseFastFail(useFastFail);
+      
+      updateResourceConfiguration.setStatus(ConfigurationUpdateStatus.SUCCESS);
+      
+   }
 }

Modified: projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/CfResourceDiscoveryComponent.java
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/CfResourceDiscoveryComponent.java	2011-03-18 14:35:58 UTC (rev 110974)
+++ projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/CfResourceDiscoveryComponent.java	2011-03-19 04:08:25 UTC (rev 110975)
@@ -21,6 +21,12 @@
  */
 package org.jboss.jca.rhq.ra;
 
+import org.jboss.jca.core.api.management.ConnectionFactory;
+import org.jboss.jca.core.api.management.Connector;
+import org.jboss.jca.core.api.management.ManagementRepository;
+import org.jboss.jca.rhq.core.ManagementRepositoryManager;
+import org.jboss.jca.rhq.util.ManagementRepositoryHelper;
+
 import java.util.HashSet;
 import java.util.Set;
 
@@ -52,11 +58,24 @@
    {
       Set<DiscoveredResourceDetails> result = new HashSet<DiscoveredResourceDetails>();
 
-      DiscoveredResourceDetails resConnector = new DiscoveredResourceDetails(
-            context.getResourceType(), "ConnectionFactory", "ConnectionFactory", "1.0.0",
-            "ConnectionFactory", context.getDefaultPluginConfiguration(),
-            null);
-      result.add(resConnector);
+      // the uniqueId is the key of parent component.
+      String rarUniqueId = context.getParentResourceContext().getResourceKey();
+      
+      ManagementRepository mr = ManagementRepositoryManager.getManagementRepository();
+      Connector connector = ManagementRepositoryHelper.getConnectorByUniqueId(mr, rarUniqueId);
+      
+      if (connector == null || connector.getConnectionFactories() == null)
+         return result;
+      
+      for (ConnectionFactory cf : connector.getConnectionFactories())
+      {
+         String jndiName = cf.getJndiName();
+         String key = rarUniqueId + "#" + jndiName;
+
+         DiscoveredResourceDetails cfRes = new DiscoveredResourceDetails(context.getResourceType(), key, jndiName, null,
+            "Connection Factories", context.getDefaultPluginConfiguration(), null);
+         result.add(cfRes);
+      }
       return result;
    }
 

Modified: projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/McfResourceComponent.java
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/McfResourceComponent.java	2011-03-18 14:35:58 UTC (rev 110974)
+++ projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/McfResourceComponent.java	2011-03-19 04:08:25 UTC (rev 110975)
@@ -21,16 +21,10 @@
  */
 package org.jboss.jca.rhq.ra;
 
-import org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration;
 import org.jboss.jca.core.api.management.ConfigProperty;
-import org.jboss.jca.core.api.management.Connector;
 import org.jboss.jca.core.api.management.ManagedConnectionFactory;
-import org.jboss.jca.core.api.management.ManagementRepository;
 import org.jboss.jca.rhq.core.AbstractResourceComponent;
 
-import org.jboss.jca.rhq.core.ManagementRepositoryManager;
-import org.jboss.jca.rhq.util.ManagementRepositoryHelper;
-
 import java.util.List;
 
 import javax.resource.spi.ResourceAdapterAssociation;
@@ -61,19 +55,8 @@
     */
    private ManagedConnectionFactory getManagedConnectionFactory()
    {
-      ManagementRepository mr = ManagementRepositoryManager.getManagementRepository();
-      Connector connector = ManagementRepositoryHelper.getConnectorByUniqueId(mr, getRarUniqueId());
-      String jcaClsName = getJCAClassName();
-      for (ManagedConnectionFactory mcf : connector.getManagedConnectionFactories())
-      {
-         Class<?> mcfCls = mcf.getManagedConnectionFactory().getClass();
-         if (mcfCls.getName().equals(jcaClsName))
-         {
-            logger.debug("Class Name is: " + jcaClsName);
-            return mcf;
-         }
-      }
-      throw new IllegalStateException("Can not find ManagedConnectionFactory.");
+      CfResourceComponent parentRes = (CfResourceComponent)getResourceContext().getParentResourceComponent();
+      return parentRes.getConnectionFactory().getMcf();
    }
    
    /**
@@ -91,12 +74,9 @@
       ManagedConnectionFactory mcf = getManagedConnectionFactory();
       javax.resource.spi.ManagedConnectionFactory jcaMcf = mcf.getManagedConnectionFactory();
       
-      // jndi name
-      PropertySimple jndiNameProp = new PropertySimple("jndi-name", mcf.getJndiName());
-      config.put(jndiNameProp);
-      
       // mcf-class-name
-      PropertySimple clsNameProp = new PropertySimple("mcf-class-name", getJCAClassName());
+      Class<?> mcfCls = jcaMcf.getClass();
+      PropertySimple clsNameProp = new PropertySimple("mcf-class-name", mcfCls.getName());
       config.put(clsNameProp);
       
       // cf-interface-name
@@ -112,49 +92,6 @@
       PropertySimple useRaAssoProp = new PropertySimple("use-ra-association", Boolean.valueOf(useRaAsso));
       config.put(useRaAssoProp);
       
-      // conn-pool
-      PoolConfiguration poolConfig = mcf.getPoolConfiguration();
-      
-      PropertySimple poolNameProp = new PropertySimple("pool-name", mcf.getPool().getName());
-      config.put(poolNameProp);
-      
-      PropertySimple minSizeProp = new PropertySimple("min-pool-size", Integer.valueOf(poolConfig.getMinSize()));
-      config.put(minSizeProp);
-      
-      PropertySimple maxSizeProp = new PropertySimple("max-pool-size", Integer.valueOf(poolConfig.getMaxSize()));
-      config.put(maxSizeProp);
-      
-      Boolean doBackGroundValidation = Boolean.valueOf(poolConfig.isBackgroundValidation());
-      PropertySimple isBackGroundValidateProp = new PropertySimple("background-validation", doBackGroundValidation);
-      config.put(isBackGroundValidateProp);
-      
-      Long bvInterval = Long.valueOf(poolConfig.getBackgroundValidationInterval());
-      PropertySimple backGroundValidateIntervalProp = new PropertySimple("background-validation-millis", bvInterval);
-      config.put(backGroundValidateIntervalProp);
-      
-      Integer bvMinutes = Integer.valueOf(poolConfig.getBackgroundValidationMinutes());
-      PropertySimple backGroundValidateMintuesProp = new PropertySimple("background-validation-minutes", bvMinutes);
-      config.put(backGroundValidateMintuesProp);
-      
-      Long blTimeout = Long.valueOf(poolConfig.getBlockingTimeout());
-      PropertySimple blockingTimeoutProp = new PropertySimple("blocking-timeout-millis", blTimeout);
-      config.put(blockingTimeoutProp);
-      
-      Long idleTimeoutMills = poolConfig.getIdleTimeout();
-      
-      Integer idleTimeout = (int)(idleTimeoutMills / (1000 * 60)); // convert to minutes
-      PropertySimple idleTimeoutProp = new PropertySimple("idle-timeout-minutes", idleTimeout);
-      config.put(idleTimeoutProp);
-      
-      PropertySimple prefillProp = new PropertySimple("prefill", Boolean.valueOf(poolConfig.isPrefill()));
-      config.put(prefillProp);
-      
-      PropertySimple useStictMinProp = new PropertySimple("use-strict-min", Boolean.valueOf(poolConfig.isStrictMin()));
-      config.put(useStictMinProp);
-      
-      PropertySimple useFasFailProp = new PropertySimple("use-fast-fail", Boolean.valueOf(poolConfig.isUseFastFail()));
-      config.put(useFasFailProp);
-      
       // config properties
       List<ConfigProperty> mcfConfProps = mcf.getConfigProperties();
       PropertyList configList = getConfigPropertiesList(jcaMcf, mcfConfProps);
@@ -174,52 +111,9 @@
    {
       super.updateResourceConfiguration(updateResourceConfiguration);
       Configuration config = updateResourceConfiguration.getConfiguration();
+      
       ManagedConnectionFactory mcf = getManagedConnectionFactory();
       
-      // update jndi-name
-      String jndiName = config.getSimpleValue("jndi-name", null);
-      if (null != jndiName && jndiName.length() > 0)
-      {
-         mcf.setJndiName(jndiName);
-      }
-      // update conn-pool configurations
-      PoolConfiguration poolConfig = mcf.getPoolConfiguration();
-      Integer minPoolSize = Integer.valueOf(config.getSimpleValue("min-pool-size", "0"));
-      poolConfig.setMinSize(minPoolSize.intValue());
-      
-      Integer maxPoolSize = Integer.valueOf(config.getSimpleValue("max-pool-size", "20"));
-      poolConfig.setMaxSize(maxPoolSize.intValue());
-      
-      Boolean backGroundValid = Boolean.valueOf(config.getSimpleValue("background-validation", "false"));
-      poolConfig.setBackgroundValidation(backGroundValid.booleanValue());
-      
-      // background-validation-millis
-      
-      // background-validation-minutes
-      Integer backGroundValidMinutes = Integer.valueOf(config.getSimpleValue("background-validation-minutes", "0"));
-      poolConfig.setBackgroundValidationMinutes(backGroundValidMinutes.intValue());
-
-      // blocking-timeout-millis
-      Long blockTimeoutMillis = Long.valueOf(config.getSimpleValue("blocking-timeout-millis", "30000"));
-      poolConfig.setBlockingTimeout(blockTimeoutMillis.longValue());
-      
-      // idle-timeout-minutes
-      Integer idleTimeoutMinutes = Integer.valueOf(config.getSimpleValue("idle-timeout-minutes", "30"));
-      Long idleTimeoutMillis = Long.valueOf(idleTimeoutMinutes * 60 * 1000);
-      poolConfig.setIdleTimeout(idleTimeoutMillis.longValue());
-      
-      // prefill
-      Boolean preFill = Boolean.valueOf(config.getSimpleValue("prefill", "true"));
-      poolConfig.setPrefill(preFill);
-      
-      // use-strict-min
-      Boolean useStrictMin = Boolean.valueOf(config.getSimpleValue("use-strict-min", "false"));
-      poolConfig.setStrictMin(useStrictMin);
-      
-      // use-fast-fail
-      Boolean useFastFail = Boolean.valueOf(config.getSimpleValue("use-fast-fail", "false"));
-      poolConfig.setUseFastFail(useFastFail);
-      
       // config-properties
       PropertyList configPropertiesList = config.getList("config-property");
       javax.resource.spi.ManagedConnectionFactory jcaMcf = mcf.getManagedConnectionFactory();

Modified: projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/McfResourceDiscoveryComponent.java
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/McfResourceDiscoveryComponent.java	2011-03-18 14:35:58 UTC (rev 110974)
+++ projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/McfResourceDiscoveryComponent.java	2011-03-19 04:08:25 UTC (rev 110975)
@@ -21,19 +21,11 @@
  */
 package org.jboss.jca.rhq.ra;
 
-import org.jboss.jca.core.api.management.Connector;
-import org.jboss.jca.core.api.management.ManagedConnectionFactory;
-import org.jboss.jca.core.api.management.ManagementRepository;
-
-import org.jboss.jca.rhq.core.ManagementRepositoryManager;
-import org.jboss.jca.rhq.util.ManagementRepositoryHelper;
-
 import java.util.HashSet;
 import java.util.Set;
 
 import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
 import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
 import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
 import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
 
@@ -62,30 +54,10 @@
    {
       Set<DiscoveredResourceDetails> result = new HashSet<DiscoveredResourceDetails>();
 
-      // the uniqueId is the key of parent component.
-      
-      ResourceContext<RarResourceComponent> parentResContext = context.getParentResourceContext();
-      
-      RarResourceComponent raResourceCom = parentResContext.getParentResourceComponent();
-      String rarUniqueId = raResourceCom.getResourceContext().getResourceKey();
-      
-      ManagementRepository mr = ManagementRepositoryManager.getManagementRepository();
-      Connector connector = ManagementRepositoryHelper.getConnectorByUniqueId(mr, rarUniqueId);
-      
-      if (connector == null || connector.getManagedConnectionFactories() == null)
-         return result;
-      
-      for (ManagedConnectionFactory mcf : connector.getManagedConnectionFactories())
-      {
-         javax.resource.spi.ManagedConnectionFactory jcaMcf = mcf.getManagedConnectionFactory();
-         
-         Class<?> mcfCls = jcaMcf.getClass();
-         String key = rarUniqueId + "#" + mcfCls.getName(); //IMPORTANT: make the key uniqueId#class name
-         String name = mcfCls.getSimpleName();
-         DiscoveredResourceDetails mcfRes = new DiscoveredResourceDetails(context.getResourceType(), key, name, null,
-            "Managed Connection Factories", context.getDefaultPluginConfiguration(), null);
-         result.add(mcfRes);
-      }
+      DiscoveredResourceDetails mcfRes = new DiscoveredResourceDetails(context.getResourceType(), 
+            "ManagedConnectionFactory", "ManagedConnectionFactory", null,
+            "Managed Connection Factory", context.getDefaultPluginConfiguration(), null);
+      result.add(mcfRes);
       return result;
    }
 

Modified: projects/jboss-jca/trunk/rhq/src/main/resources/META-INF/rhq-plugin.xml
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/resources/META-INF/rhq-plugin.xml	2011-03-18 14:35:58 UTC (rev 110974)
+++ projects/jboss-jca/trunk/rhq/src/main/resources/META-INF/rhq-plugin.xml	2011-03-19 04:08:25 UTC (rev 110975)
@@ -411,6 +411,7 @@
             
                 <resource-configuration>
                     <c:group name="general" displayName="General">
+                        <c:simple-property name="jndi-name" displayName="JNDI Name"/>
                         <c:simple-property name="transaction-type" displayName="Transaction type" description="Transaction type">
                             <c:property-options>
                                 <c:option name="No Transaction" value="no"/>
@@ -419,7 +420,12 @@
                             </c:property-options>
                         </c:simple-property>
                     </c:group>
-                     
+
+                    <c:group name="conn-pool" displayName="Connection Pool">
+                         &datasourceAndConnectionFactoryConnectionResourceConfigProps;
+                         &datasourceAndConnectionFactoryAdvancedResourceConfigProps;
+                    </c:group>
+
                     <c:group name="Authentication" displayName="Authentication">
                          <c:simple-property name="re-auth_support" displayName="Reauthentication Support" type="boolean" description="Does this outbound connection support reauthentication?"></c:simple-property>
                          <c:simple-property name="res-auth-src" displayName="Resource Authentication Source">
@@ -443,7 +449,7 @@
                 
                     <resource-configuration>
                         <c:group name="general" displayName="General">
-                            <c:simple-property name="jndi-name" displayName="JNDI Name"/>
+
                             <c:simple-property name="mcf-class-name" displayName="ManagedConnectionFactory class name" readOnly="true" />
                             <c:simple-property name="cf-interface-name" displayName="ConnectionFactory interface class name" readOnly="true"/>
                             <c:simple-property name="cf-impl-name" displayName="ConnectionFactory implement class name" readOnly="true"/>
@@ -452,12 +458,7 @@
                             
                             <c:simple-property name="use-ra-association" displayName="Use ResourceAdapterAssociation" type="boolean" readOnly="true"/>
                         </c:group>
-                         
-                        <c:group name="conn-pool" displayName="Connection Pool">
-                             &datasourceAndConnectionFactoryConnectionResourceConfigProps;
-                             &datasourceAndConnectionFactoryAdvancedResourceConfigProps;
-                        </c:group>
-                         
+
                         <c:group name="ConfigProperties" displayName="All Config Properties">
                             &advancedResourceConfigProps;                        
                         </c:group>

Modified: projects/jboss-jca/trunk/rhq/src/test/java/org/jboss/jca/rhq/test/XATestCase.java
===================================================================
--- projects/jboss-jca/trunk/rhq/src/test/java/org/jboss/jca/rhq/test/XATestCase.java	2011-03-18 14:35:58 UTC (rev 110974)
+++ projects/jboss-jca/trunk/rhq/src/test/java/org/jboss/jca/rhq/test/XATestCase.java	2011-03-19 04:08:25 UTC (rev 110975)
@@ -24,6 +24,7 @@
 import org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration;
 import org.jboss.jca.core.api.management.AdminObject;
 import org.jboss.jca.core.api.management.ConfigProperty;
+import org.jboss.jca.core.api.management.ConnectionFactory;
 import org.jboss.jca.core.api.management.Connector;
 import org.jboss.jca.core.api.management.ManagedConnectionFactory;
 import org.jboss.jca.core.api.management.ManagementRepository;
@@ -64,9 +65,13 @@
  * RHQ plugin test cases for an XA resource adapter
  * 
  * @author Jesper Pedersen <jesper.pedersen at jboss.org>
+ * @author <a href="mailto:jeff.zhang at jboss.org">Jeff Zhang</a> 
+ * @author <a href="mailto:lgao at redhat.com">Lin Gao</a>
  */
 public class XATestCase
 {
+   /** cf jndi name */
+   private static final String CF_JNDI_NAME = "java:/eis/XA";
    
    /** RAR resource */
    private static Resource rarServiceResource;
@@ -91,11 +96,11 @@
          {
             assertEquals("xa.rar#XAResourceAdapter", res.getResourceKey());
          }
-         else if (res.getName().equals("ConnectionFactory"))
+         else if (res.getName().equals(CF_JNDI_NAME))
          {
-            assertEquals(1, res.getChildResources().size());
+            //assertEquals(1, res.getChildResources().size());
             Resource mcfRes = res.getChildResources().iterator().next();
-            assertEquals("XAManagedConnectionFactory", mcfRes.getName());
+            assertEquals("ManagedConnectionFactory", mcfRes.getName());
          }
          else if (res.getName().equals("java:/XAAdminObjectImpl"))
          {
@@ -188,38 +193,35 @@
       
    }
    
-   
    /**
-    * Tests McfResourceComponent loadResourceConfiguration
+    * Tests CfResourceComponent loadResourceConfiguration
     * 
     * @throws Exception exception
     */
    @Test
-   public void testMcfLoadResourceConfiguration() throws Exception
+   public void testCfLoadResourceConfiguration() throws Exception
    {
       Resource cfResource = null;
       for (Resource res : rarServiceResource.getChildResources())
       {
-         if (res.getName().equals("ConnectionFactory"))
+         if (res.getName().equals(CF_JNDI_NAME))
          {
             cfResource = res;
          }
       }
       assertNotNull(cfResource);
-      assertEquals(1, cfResource.getChildResources().size());
+      //assertEquals(1, cfResource.getChildResources().size());
       PluginContainer pc = PluginContainer.getInstance();
       InventoryManager im = pc.getInventoryManager();
       
-      // test mcf loadConfiguration
-      Resource mcfRes = cfResource.getChildResources().iterator().next();
-      ConfigurationFacet mcfConfigFacet = (ConfigurationFacet)im.getResourceComponent(mcfRes);
+      // test cf loadConfiguration
+      Resource cfRes = cfResource;
+      ConfigurationFacet mcfConfigFacet = (ConfigurationFacet)im.getResourceComponent(cfRes);
       Configuration mcfConfig = mcfConfigFacet.loadResourceConfiguration();
       
       assertEquals("XA", mcfConfig.getSimpleValue("pool-name", null));
       assertEquals("java:/eis/XA", mcfConfig.getSimpleValue("jndi-name", null));
-      String mcfCls = mcfConfig.getSimpleValue("mcf-class-name", null);
-      assertEquals("org.jboss.jca.rhq.rar.xa.XAManagedConnectionFactory", mcfCls);
-      assertEquals("true", mcfConfig.getSimpleValue("use-ra-association", null));
+
       assertEquals("0", mcfConfig.getSimpleValue("min-pool-size", null));
       assertEquals("20", mcfConfig.getSimpleValue("max-pool-size", null));
       assertEquals("false", mcfConfig.getSimpleValue("background-validation", null));
@@ -230,7 +232,38 @@
       assertEquals("true", mcfConfig.getSimpleValue("prefill", null));
       assertEquals("false", mcfConfig.getSimpleValue("use-strict-min", null));
       assertEquals("false", mcfConfig.getSimpleValue("use-fast-fail", null));
+   }
+   
+   /**
+    * Tests McfResourceComponent loadResourceConfiguration
+    * 
+    * @throws Exception exception
+    */
+   @Test
+   public void testMcfLoadResourceConfiguration() throws Exception
+   {
+      Resource cfResource = null;
+      for (Resource res : rarServiceResource.getChildResources())
+      {
+         if (res.getName().equals(CF_JNDI_NAME))
+         {
+            cfResource = res;
+         }
+      }
+      assertNotNull(cfResource);
+      //assertEquals(1, cfResource.getChildResources().size());
+      PluginContainer pc = PluginContainer.getInstance();
+      InventoryManager im = pc.getInventoryManager();
       
+      // test mcf loadConfiguration
+      Resource mcfRes = cfResource.getChildResources().iterator().next();
+      ConfigurationFacet mcfConfigFacet = (ConfigurationFacet)im.getResourceComponent(mcfRes);
+      Configuration mcfConfig = mcfConfigFacet.loadResourceConfiguration();
+      
+      String mcfCls = mcfConfig.getSimpleValue("mcf-class-name", null);
+      assertEquals("org.jboss.jca.rhq.rar.xa.XAManagedConnectionFactory", mcfCls);
+      assertEquals("true", mcfConfig.getSimpleValue("use-ra-association", null));
+      
       // config-properties
       PropertyList configPropList = mcfConfig.getList("config-property");
       List<Property> configs = configPropList.getList();
@@ -242,6 +275,60 @@
    }
    
    /**
+    * Tests CfResourceComponent update resource configuration.
+    * 
+    * @throws Exception exception
+    */
+   @Test
+   public void testCfUpdateResourceConfinguration() throws Exception
+   {
+      Resource cfResource = null;
+      for (Resource res : rarServiceResource.getChildResources())
+      {
+         if (res.getName().equals(CF_JNDI_NAME))
+         {
+            cfResource = res;
+         }
+      }
+      assertNotNull(cfResource);
+      PluginContainer pc = PluginContainer.getInstance();
+      InventoryManager im = pc.getInventoryManager();
+      
+      Resource cfRes = cfResource;
+      ConfigurationFacet cfConfigFacet = (ConfigurationFacet)im.getResourceComponent(cfRes);
+      Configuration cfConfig = cfConfigFacet.loadResourceConfiguration();
+      
+      // test cf updateConfiguration
+      cfConfig.put(new PropertySimple("min-pool-size", 5));
+      cfConfig.put(new PropertySimple("max-pool-size", 15));
+      cfConfig.put(new PropertySimple("background-validation", true));
+      cfConfig.put(new PropertySimple("background-validation-minutes", 30));
+      cfConfig.put(new PropertySimple("blocking-timeout-millis", 10000));
+      cfConfig.put(new PropertySimple("idle-timeout-minutes", 15));
+      cfConfig.put(new PropertySimple("prefill", false));
+      cfConfig.put(new PropertySimple("use-strict-min", true));
+      cfConfig.put(new PropertySimple("use-fast-fail", true));
+      
+      ConfigurationUpdateReport updateConfigReport = new ConfigurationUpdateReport(cfConfig);
+      cfConfigFacet.updateResourceConfiguration(updateConfigReport);
+      
+      ManagementRepository manRepo = ManagementRepositoryManager.getManagementRepository();
+      Connector connector = ManagementRepositoryHelper.getConnectorByUniqueId(manRepo, "xa.rar");
+      ConnectionFactory mcf = connector.getConnectionFactories().get(0);
+      PoolConfiguration poolConfig = mcf.getPoolConfiguration();
+      
+      assertEquals(5, poolConfig.getMinSize());
+      assertEquals(15, poolConfig.getMaxSize());
+      assertTrue(poolConfig.isBackgroundValidation());
+      assertEquals(30, poolConfig.getBackgroundValidationMinutes());
+      assertEquals(10000, poolConfig.getBlockingTimeout());
+      assertEquals(15 * 60 * 1000L, poolConfig.getIdleTimeout());
+      assertFalse(poolConfig.isPrefill());
+      assertTrue(poolConfig.isStrictMin());
+      assertTrue(poolConfig.isUseFastFail());
+   }
+   
+   /**
     * Tests McfResourceComponent update resource configuration.
     * 
     * @throws Exception exception
@@ -252,7 +339,7 @@
       Resource cfResource = null;
       for (Resource res : rarServiceResource.getChildResources())
       {
-         if (res.getName().equals("ConnectionFactory"))
+         if (res.getName().equals(CF_JNDI_NAME))
          {
             cfResource = res;
          }
@@ -266,16 +353,6 @@
       Configuration mcfConfig = mcfConfigFacet.loadResourceConfiguration();
       
       // test mcf updateConfiguration
-      mcfConfig.put(new PropertySimple("jndi-name", "TestMcfJndiName"));
-      mcfConfig.put(new PropertySimple("min-pool-size", 5));
-      mcfConfig.put(new PropertySimple("max-pool-size", 15));
-      mcfConfig.put(new PropertySimple("background-validation", true));
-      mcfConfig.put(new PropertySimple("background-validation-minutes", 30));
-      mcfConfig.put(new PropertySimple("blocking-timeout-millis", 10000));
-      mcfConfig.put(new PropertySimple("idle-timeout-minutes", 15));
-      mcfConfig.put(new PropertySimple("prefill", false));
-      mcfConfig.put(new PropertySimple("use-strict-min", true));
-      mcfConfig.put(new PropertySimple("use-fast-fail", true));
       
       PropertyList updateConfigPropList = new PropertyList("config-property");
       PropertyMap mcfConfigPropMap = new PropertyMap("config-property");
@@ -293,20 +370,8 @@
       
       ManagementRepository manRepo = ManagementRepositoryManager.getManagementRepository();
       Connector connector = ManagementRepositoryHelper.getConnectorByUniqueId(manRepo, "xa.rar");
-      ManagedConnectionFactory mcf = connector.getManagedConnectionFactories().get(0);
-      PoolConfiguration poolConfig = mcf.getPoolConfiguration();
+      ManagedConnectionFactory mcf = connector.getConnectionFactories().get(0).getMcf();
       
-      assertEquals("TestMcfJndiName", mcf.getJndiName());
-      assertEquals(5, poolConfig.getMinSize());
-      assertEquals(15, poolConfig.getMaxSize());
-      assertTrue(poolConfig.isBackgroundValidation());
-      assertEquals(30, poolConfig.getBackgroundValidationMinutes());
-      assertEquals(10000, poolConfig.getBlockingTimeout());
-      assertEquals(15 * 60 * 1000L, poolConfig.getIdleTimeout());
-      assertFalse(poolConfig.isPrefill());
-      assertTrue(poolConfig.isStrictMin());
-      assertTrue(poolConfig.isUseFastFail());
-      
       XAManagedConnectionFactory xaMcf = (XAManagedConnectionFactory)mcf.getManagedConnectionFactory();
       assertEquals("new-rhq", xaMcf.getManagement());
    }
@@ -434,7 +499,7 @@
       ManagementRepository manRepo = EmbeddedJcaDiscover.getInstance().getManagementRepository();
       Connector xaConnector = manRepo.getConnectors().get(0);
       AdminObject ao = xaConnector.getAdminObjects().get(0);
-      ManagedConnectionFactory mcf = xaConnector.getManagedConnectionFactories().get(0);
+      ManagedConnectionFactory mcf = xaConnector.getConnectionFactories().get(0).getMcf();
       ResourceAdapter ra = xaConnector.getResourceAdapter();
 
       // ao-config 



More information about the jboss-cvs-commits mailing list