[jboss-cvs] JBossAS SVN: r111061 - in projects/jboss-jca/trunk/rhq/src: main/java/org/jboss/jca/rhq/ds and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 29 06:06:23 EDT 2011


Author: gaol
Date: 2011-03-29 06:06:23 -0400 (Tue, 29 Mar 2011)
New Revision: 111061

Added:
   projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/PoolResourceComponent.java
   projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/DsResourceComponent.java
   projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/DsResourceDiscoveryComponent.java
Removed:
   projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/XADatasourceResourceComponent.java
   projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/XADatasourceResourceDiscoveryComponent.java
Modified:
   projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/CfResourceComponent.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/PluginDescriptorTestCase.java
Log:
[JBJCA-500] DsResourceComponent discovery and get/update configurations

Added: projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/PoolResourceComponent.java
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/PoolResourceComponent.java	                        (rev 0)
+++ projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/core/PoolResourceComponent.java	2011-03-29 10:06:23 UTC (rev 111061)
@@ -0,0 +1,134 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.rhq.core;
+
+import org.jboss.jca.core.api.connectionmanager.pool.Pool;
+import org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+
+/**
+ * PoolResourceComponent
+ * 
+ * @author <a href="mailto:lgao at redhat.com">Lin Gao</a>
+ *
+ */
+public abstract class PoolResourceComponent extends AbstractResourceComponent
+{
+
+   /**
+    * Puts configurations in the connection pool to the resource configuration
+    * 
+    * @param pool Pool
+    * @param poolConfig PoolConfiguration
+    * @param config Configuration
+    */
+   protected void putPoolConfigToResourceConfiguration(Pool pool, PoolConfiguration poolConfig, Configuration config)
+   {
+      PropertySimple poolNameProp = new PropertySimple("pool-name", pool.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);
+   }
+   
+   /**
+    * Updates PoolConfiguration
+    * 
+    * @param poolConfig PoolConfiguration
+    * @param config Configuration
+    */
+   protected void updatePoolConfiguration(PoolConfiguration poolConfig, Configuration config)
+   {
+      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);
+   }
+   
+}

Copied: projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/DsResourceComponent.java (from rev 111059, projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/XADatasourceResourceComponent.java)
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/DsResourceComponent.java	                        (rev 0)
+++ projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/DsResourceComponent.java	2011-03-29 10:06:23 UTC (rev 111061)
@@ -0,0 +1,121 @@
+/*
+ * 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.rhq.ds;
+
+import org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration;
+import org.jboss.jca.core.api.management.DataSource;
+import org.jboss.jca.core.api.management.ManagementRepository;
+
+import org.jboss.jca.rhq.core.ManagementRepositoryManager;
+import org.jboss.jca.rhq.core.PoolResourceComponent;
+
+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;
+
+/**
+ * Represent <b>XA Datasource</b> in JCA container
+ * 
+ * @author <a href="mailto:lgao at redhat.com">Lin Gao</a>
+ */
+public class DsResourceComponent extends PoolResourceComponent
+{
+   
+   /**
+    * getDataSource
+    * 
+    * @return DataSource associated with this ResourceComponent
+    */
+   private DataSource getDataSource()
+   {
+      ManagementRepository mr = ManagementRepositoryManager.getManagementRepository();
+      Configuration plugConfig = getPluginConfiguration();
+      String dsJndiName = plugConfig.getSimpleValue("jndi-name", null);
+      if (dsJndiName == null || dsJndiName.length() == 0)
+      {
+         throw new IllegalStateException("DataSource jndi name is null.");
+      }
+      for (DataSource ds : mr.getDataSources())
+      {
+         if (dsJndiName.equals(ds.getJndiName()))
+         {
+            return ds;
+         }
+      }
+      throw new IllegalStateException("Can not find the DataSource");
+   }
+
+   
+   /**
+    * loadResourceConfiguration
+    * @return The resource Configuration
+    * @throws Exception exception
+    */
+   @Override
+   public Configuration loadResourceConfiguration() throws Exception
+   {
+      Configuration config = new Configuration();
+      DataSource ds = getDataSource();
+      
+      // jndi name
+      PropertySimple jndiNameProp = new PropertySimple("jndi-name", ds.getJndiName());
+      config.put(jndiNameProp);
+      
+      // is xa
+      PropertySimple isXAProp = new PropertySimple("xa", Boolean.valueOf(ds.isXA()));
+      config.put(isXAProp);
+      
+      // conn-pool
+      PoolConfiguration poolConfig = ds.getPoolConfiguration();
+      putPoolConfigToResourceConfiguration(ds.getPool(), poolConfig, config);
+      
+      return config;
+   }
+   
+   /**
+    * updateResourceConfiguration
+    * 
+    * @param updateResourceConfiguration the ConfigurationUpdateReport
+    */
+   @Override
+   public void updateResourceConfiguration(ConfigurationUpdateReport updateResourceConfiguration)
+   {
+      super.updateResourceConfiguration(updateResourceConfiguration);
+      Configuration config = updateResourceConfiguration.getConfiguration();
+      DataSource ds = getDataSource();
+      
+      // update jndi-name
+      String jndiName = config.getSimpleValue("jndi-name", null);
+      if (null != jndiName && jndiName.length() > 0)
+      {
+         ds.setJndiName(jndiName);
+      }
+      
+      // update conn-pool configurations
+      PoolConfiguration poolConfig = ds.getPoolConfiguration();
+      updatePoolConfiguration(poolConfig, config);
+      
+      updateResourceConfiguration.setStatus(ConfigurationUpdateStatus.SUCCESS);
+   }
+   
+}

Copied: projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/DsResourceDiscoveryComponent.java (from rev 111059, projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/XADatasourceResourceDiscoveryComponent.java)
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/DsResourceDiscoveryComponent.java	                        (rev 0)
+++ projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/DsResourceDiscoveryComponent.java	2011-03-29 10:06:23 UTC (rev 111061)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.rhq.ds;
+
+import org.jboss.jca.core.api.management.DataSource;
+import org.jboss.jca.core.api.management.ManagementRepository;
+import org.jboss.jca.rhq.core.ManagementRepositoryManager;
+import org.jboss.jca.rhq.ra.RarResourceComponent;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+/**
+ * Discovery<code>DatasourceResourceDiscoveryComponent</code> from JCA container.
+ * 
+ * @author <a href="mailto:lgao at redhat.com">Lin Gao</a>
+ */
+public class DsResourceDiscoveryComponent
+   implements ResourceDiscoveryComponent<RarResourceComponent>
+{
+   /**
+    * discoverResources
+    * 
+    * @param context ResourceDiscoveryContext<AdminObjectResourceComponent>
+    * @return Set<DiscoveredResourceDetails> set of DiscoveredResourceDetails
+    * @throws InvalidPluginConfigurationException invalidPluginConfigurationException
+    * @throws Exception exception
+    */
+   @Override
+   public Set<DiscoveredResourceDetails> discoverResources(
+      ResourceDiscoveryContext<RarResourceComponent> context) 
+      throws InvalidPluginConfigurationException, Exception
+   {
+      Set<DiscoveredResourceDetails> result = new HashSet<DiscoveredResourceDetails>();
+
+      ManagementRepository mr = ManagementRepositoryManager.getManagementRepository();
+      for (DataSource ds : mr.getDataSources())
+      {
+         String dsJndiName = ds.getJndiName();
+         DiscoveredResourceDetails dsRes = new DiscoveredResourceDetails(context.getResourceType(),
+               dsJndiName, dsJndiName, null, "Datasource of " + dsJndiName, context.getDefaultPluginConfiguration(),
+               null);
+         Configuration configuration = dsRes.getPluginConfiguration();
+         configuration.put(new PropertySimple("jndi-name", dsJndiName));
+         result.add(dsRes);
+      }
+      return result;
+   }
+
+}

Deleted: projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/XADatasourceResourceComponent.java
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/XADatasourceResourceComponent.java	2011-03-29 07:04:48 UTC (rev 111060)
+++ projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/XADatasourceResourceComponent.java	2011-03-29 10:06:23 UTC (rev 111061)
@@ -1,33 +0,0 @@
-/*
- * 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.rhq.ds;
-
-import org.jboss.jca.rhq.core.BaseResourceComponent;
-
-/**
- * Represent <b>XA Datasource</b> in JCA container
- * 
- * @author <a href="mailto:lgao at redhat.com">Lin Gao</a>
- */
-public class XADatasourceResourceComponent extends BaseResourceComponent
-{
-}

Deleted: projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/XADatasourceResourceDiscoveryComponent.java
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/XADatasourceResourceDiscoveryComponent.java	2011-03-29 07:04:48 UTC (rev 111060)
+++ projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ds/XADatasourceResourceDiscoveryComponent.java	2011-03-29 10:06:23 UTC (rev 111061)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, 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.rhq.ds;
-
-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.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-
-/**
- * Discovery<code>XADatasourceResourceComponent</code> from JCA container.
- * 
- * @author <a href="mailto:lgao at redhat.com">Lin Gao</a>
- */
-public class XADatasourceResourceDiscoveryComponent
-   implements ResourceDiscoveryComponent<XADatasourceResourceComponent>
-{
-   /**
-    * discoverResources
-    * 
-    * @param context ResourceDiscoveryContext<AdminObjectResourceComponent>
-    * @return Set<DiscoveredResourceDetails> set of DiscoveredResourceDetails
-    * @throws InvalidPluginConfigurationException invalidPluginConfigurationException
-    * @throws Exception exception
-    */
-   @Override
-   public Set<DiscoveredResourceDetails> discoverResources(
-      ResourceDiscoveryContext<XADatasourceResourceComponent> context) 
-      throws InvalidPluginConfigurationException, Exception
-   {
-      Set<DiscoveredResourceDetails> result = new HashSet<DiscoveredResourceDetails>();
-
-      DiscoveredResourceDetails xaDatasourceRes = new DiscoveredResourceDetails(context.getResourceType(),
-         "XA_Datasource", "XA Datasource", null, "XA Datasource(Demo)", context.getDefaultPluginConfiguration(),
-         null);
-      result.add(xaDatasourceRes);
-
-      // TODO find XA Datasource resources.
-
-      return result;
-   }
-
-}

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-29 07:04:48 UTC (rev 111060)
+++ projects/jboss-jca/trunk/rhq/src/main/java/org/jboss/jca/rhq/ra/CfResourceComponent.java	2011-03-29 10:06:23 UTC (rev 111061)
@@ -26,8 +26,8 @@
 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.core.PoolResourceComponent;
 import org.jboss.jca.rhq.util.ManagementRepositoryHelper;
 
 import org.jboss.logging.Logger;
@@ -44,7 +44,7 @@
  * @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
+public class CfResourceComponent extends PoolResourceComponent
 {
    /** log */
    private static final Logger logger = Logger.getLogger(CfResourceComponent.class);
@@ -93,47 +93,8 @@
       
       // conn-pool
       PoolConfiguration poolConfig = cf.getPoolConfiguration();
+      putPoolConfigToResourceConfiguration(cf.getPool(), poolConfig, config);
       
-      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;
    }
    
@@ -159,44 +120,11 @@
       {
          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());
+      updatePoolConfiguration(poolConfig, config);
       
-      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/resources/META-INF/rhq-plugin.xml
===================================================================
--- projects/jboss-jca/trunk/rhq/src/main/resources/META-INF/rhq-plugin.xml	2011-03-29 07:04:48 UTC (rev 111060)
+++ projects/jboss-jca/trunk/rhq/src/main/resources/META-INF/rhq-plugin.xml	2011-03-29 10:06:23 UTC (rev 111061)
@@ -427,7 +427,7 @@
                     </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="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">
                              <c:description>
                                 Is reauthentication application-based or container-based?
@@ -492,14 +492,49 @@
             </service>
              -->
 
-            <!-- XA Datasource 
-            <service name="XA Datasources" subCategory="Datasources"
-                discovery="org.jboss.jca.rhq.ds.XADatasourceResourceDiscoveryComponent" 
-                class="org.jboss.jca.rhq.ds.XADatasourceResourceComponent" supportsManualAdd="true">
-    
+            <!-- XA Datasource -->
+            <service name="Datasources" discovery="org.jboss.jca.rhq.ds.XADatasourceResourceDiscoveryComponent" 
+                class="org.jboss.jca.rhq.ds.XADatasourceResourceComponent">
+
+            <plugin-configuration>
+                <c:group name="general" displayName="General">
+                    <c:simple-property name="jndi-name" description="JNDI Name of the datasource" readOnly="true"/>
+                </c:group>
+            </plugin-configuration>
+
+                <resource-configuration>
+                    <c:group name="general" displayName="General">
+                        <c:simple-property name="jndi-name" displayName="JNDI Name"/>
+                        <c:simple-property name="xa" type="boolean" displayName="Is XA datasource" required="true" />
+                        <c:simple-property name="transaction-type" displayName="Transaction type" description="Transaction type">
+                            <c:property-options>
+                                <c:option name="No Transaction" value="no"/>
+                                <c:option name="Local Transaction" value="local"/>
+                                <c:option name="XA Transaction" value="xa"/>
+                            </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 datasource support reauthentication?"></c:simple-property>
+                         <c:simple-property name="res-auth-src" displayName="Resource Authentication Source">
+                             <c:description>
+                                Is reauthentication application-based or container-based?
+                             </c:description>
+                             <c:property-options>
+                                 <c:option name="Container" value="Container"></c:option>
+                                 <c:option name="Application" value="Application"></c:option>
+                             </c:property-options>
+                         </c:simple-property>
+                    </c:group>
+
+                </resource-configuration>
             </service>
-            -->
-            
         </service>
         
     </server>

Modified: projects/jboss-jca/trunk/rhq/src/test/java/org/jboss/jca/rhq/test/PluginDescriptorTestCase.java
===================================================================
--- projects/jboss-jca/trunk/rhq/src/test/java/org/jboss/jca/rhq/test/PluginDescriptorTestCase.java	2011-03-29 07:04:48 UTC (rev 111060)
+++ projects/jboss-jca/trunk/rhq/src/test/java/org/jboss/jca/rhq/test/PluginDescriptorTestCase.java	2011-03-29 10:06:23 UTC (rev 111061)
@@ -99,9 +99,9 @@
       ConfigurationDescriptor resConfDesc = rarServiceDesc.getResourceConfiguration();
       assertNotNull(resConfDesc);
       
-      // 3 sub services in RAR service
+      // 4 sub services in RAR service
       List<ServiceDescriptor> subServiceDesc = rarServiceDesc.getServices();
-      assertEquals(3, subServiceDesc.size());
+      assertEquals(4, subServiceDesc.size());
       
    }
    



More information about the jboss-cvs-commits mailing list