[rhq] Branch 'release/jon3.1.x' - 7 commits - modules/plugins

snegrea snegrea at fedoraproject.org
Wed Aug 29 08:39:36 UTC 2012


 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java  |   17 -
 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java         |   43 ++
 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupComponent.java |   11 
 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/TransactionsComponent.java       |   62 +++
 modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml                                      |  160 +++++++---
 modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java   |   21 -
 6 files changed, 252 insertions(+), 62 deletions(-)

New commits:
commit eab14ccfe45e9618601ac74072ebba2071adccc5
Author: Stefan Negrea <snegrea at redhat.com>
Date:   Wed Aug 29 03:39:15 2012 -0500

    [BZ 852552] Updates to set correctly all the data-source and xa-data-source properties that do not support null values and cannot be undefined.
    
    While these properties look undefined in the server, they cannot undefined or set to null at any point in time. The application server makes use of the default value at all times.
    (cherry picked from commit 74aa0f7f9b0f2dd1044450d924f61b3faee78c27)

diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java
index a4efae1..5011120 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java
@@ -13,6 +13,9 @@ import org.rhq.core.domain.configuration.Configuration;
 import org.rhq.core.domain.configuration.Property;
 import org.rhq.core.domain.configuration.PropertyList;
 import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
 import org.rhq.core.domain.measurement.MeasurementDataNumeric;
 import org.rhq.core.domain.measurement.MeasurementDataTrait;
 import org.rhq.core.domain.measurement.MeasurementReport;
@@ -174,6 +177,27 @@ public class DatasourceComponent extends BaseComponent<BaseComponent<?>> impleme
         }
     }
 
+    @Override
+    public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+        Configuration config = report.getConfiguration();
+        ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
+
+        //These properties cannot be undefined once set.
+        //Also the AS7 server does not accept null values even if the properties are still unset.
+        replaceWithDefaultIfNull("max-pool-size", config, configDef);
+        replaceWithDefaultIfNull("min-pool-size", config, configDef);
+        replaceWithDefaultIfNull("pool-prefill", config, configDef);
+        replaceWithDefaultIfNull("pool-use-strict-min", config, configDef);
+        replaceWithDefaultIfNull("blocking-timeout-wait-millis", config, configDef);
+        replaceWithDefaultIfNull("idle-timeout-minutes", config, configDef);
+        replaceWithDefaultIfNull("background-validation-millis", config, configDef);
+        replaceWithDefaultIfNull("background-validation-minutes", config, configDef);
+        replaceWithDefaultIfNull("background-validation", config, configDef);
+
+        ConfigurationWriteDelegate delegate = new ConfigurationWriteDelegate(configDef, getASConnection(), address);
+        delegate.updateResourceConfiguration(report);
+    }
+
     private void getRCAsMetric(MeasurementReport report, MeasurementScheduleRequest request) {
         Operation op = new ReadAttribute(getAddress(), request.getName());
         Result res = getASConnection().execute(op);
@@ -204,4 +228,23 @@ public class DatasourceComponent extends BaseComponent<BaseComponent<?>> impleme
 
         return trait;
     }
+
+    /**
+     * Replace the value configured by the user with the default value from the resource descriptor if
+     * the value to be sent to the server is null or empty.
+     *
+     * @param propertyName property name
+     * @param config configuration update
+     * @param configDef configuration definition
+     */
+    private void replaceWithDefaultIfNull(String propertyName, Configuration config, ConfigurationDefinition configDef) {
+        PropertyDefinitionSimple propertyDefinition = configDef.getPropertyDefinitionSimple(propertyName);
+
+        if (propertyDefinition != null) {
+            String propertyValue = config.getSimpleValue(propertyName);
+            if (propertyValue == null || propertyValue.isEmpty()) {
+                config.put(new PropertySimple(propertyName, propertyDefinition.getDefaultValue()));
+            }
+        }
+    }
 }
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 56f9f73..fd0642c 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -413,10 +413,10 @@
         <c:simple-property name="use-java-context" type="boolean" readOnly="false" required="false" default="true" description="Setting this to false will bind the DataSource into global JNDI;"/>
         <c:simple-property name="enabled" type="boolean" readOnly="true" required="false" description="Specifies if the datasource should be enabled"/>
         <c:simple-property name="jta" type="boolean" readOnly="false" required="false" default="true" description="Enable JTA integration"/>
-        <c:simple-property name="max-pool-size" type="integer" readOnly="false" required="false" description="The max-pool-size element indicates the maximum number of connections for a pool. No more connections will be created in each sub-pool."/>
-        <c:simple-property name="min-pool-size" type="integer" readOnly="false" required="false" description="The min-pool-size element indicates the minimum number of connections a pool should hold. These are not created until a Subject is known from a request for a connection."/>
-        <c:simple-property name="pool-prefill" type="boolean" readOnly="false" required="false" default="false" description="Whether to attempt to prefill the connection pool. Changing this value require a server restart."/>
-        <c:simple-property name="pool-use-strict-min" type="boolean" readOnly="false" required="false" default="false" description="Define if the min-pool-size should be considered a strictly."/>
+        <c:simple-property name="max-pool-size" type="integer" readOnly="false" required="false" defaultValue="20" description="The max-pool-size element indicates the maximum number of connections for a pool. No more connections will be created in each sub-pool."/>
+        <c:simple-property name="min-pool-size" type="integer" readOnly="false" required="false" defaultValue="0" description="The min-pool-size element indicates the minimum number of connections a pool should hold. These are not created until a Subject is known from a request for a connection."/>
+        <c:simple-property name="pool-prefill" type="boolean" readOnly="false" required="false" defaultValue="false" description="Whether to attempt to prefill the connection pool. Changing this value require a server restart."/>
+        <c:simple-property name="pool-use-strict-min" type="boolean" readOnly="false" required="false" defaultValue="false" description="Define if the min-pool-size should be considered a strictly."/>
         <c:simple-property name="security-domain" required="false" type="string" readOnly="false" description="Indicates Subject (from security domain) are used to distinguish connections in the pool. The content of the security-domain is the name of the JAAS security manager that will handleauthentication. This name correlates to the JAAS login-config.xml descriptor application-policy/name attribute."/>
         <c:simple-property name="reauth-plugin-class-name" required="false" type="string" readOnly="false" description="re-authentication plugin implementation provided for specific purpose (i.e vendor)"/>
         <!--
@@ -434,7 +434,7 @@
         </c:simple-property>
 
         <c:simple-property name="allow-multiple-users" type="boolean" required="false" readOnly="false" description="Specifies if multiple users will access the datasource through the getConnection(user, password) method and hence if the internal pool type should account for that"/>
-        <c:simple-property name="prepared-statements-cacheSize" type="long" readOnly="false" required="false" description="The number of prepared statements per connection in an LRU cache"/>
+        <c:simple-property name="prepared-statements-cache-size" type="long" readOnly="false" required="false" description="The number of prepared statements per connection in an LRU cache"/>
         <c:simple-property name="share-prepared-statements" type="boolean" readOnly="false" required="false" default="false" description="Whether to share prepare statements, i.e. whether asking for same statement twice without closing uses the same underlying prepared statement"/>
         <c:simple-property name="track-statements" type="string" readOnly="false" required="false" description="Whether to check for unclosed statements when a connection is returned to the pool and result sets are closed when a statement is closed/return to the prepared statement cache. valid values are: false - do not track statements and results true - track statements and result sets and warn when they are not closed nowarn - track statements but do no warn about them being unclosed">
           <c:property-options>
@@ -445,8 +445,8 @@
         </c:simple-property>
         <c:simple-property name="allocation-retry" type="integer" readOnly="false" required="false" description="The allocation retry element indicates the number of times that allocating a connection should be tried before throwing an exception."/>
         <c:simple-property name="allocation-retry-wait-millis" type="long" readOnly="false" required="false" description="Indicates the time in milliseconds to wait between retrying to allocate a connection."/>
-        <c:simple-property name="blocking-timeout-wait-millis" type="long" readOnly="false" required="false" description="The blocking-timeout-millis element indicates the maximum time in milliseconds to block while waiting for a connection before throwing an exception. Note that this blocks only while waiting for a permit for a connection, and will never throw an exception if creating a new connection takes an inordinately long time."/>
-        <c:simple-property name="idle-timeout-minutes" type="long" readOnly="false" required="false" description="The idle-timeout-minutes elements indicates the maximum time in minutes a connection may be idle before being closed. The actual maximum time depends also on the IdleRemover scan time, which is 1/2 the smallest idle-timeout-minutes of any pool. Changing this value require a server restart."/>
+        <c:simple-property name="blocking-timeout-wait-millis" type="long" readOnly="false" required="false" defaultValue="30000" description="The blocking-timeout-millis element indicates the maximum time in milliseconds to block while waiting for a connection before throwing an exception. Note that this blocks only while waiting for a permit for a connection, and will never throw an exception if creating a new connection takes an inordinately long time."/>
+        <c:simple-property name="idle-timeout-minutes" type="long" readOnly="false" required="false" defaultValue="15" description="The idle-timeout-minutes elements indicates the maximum time in minutes a connection may be idle before being closed. The actual maximum time depends also on the IdleRemover scan time, which is 1/2 the smallest idle-timeout-minutes of any pool. Changing this value require a server restart."/>
         <c:simple-property name="query-timeout" type="long" readOnly="false" required="false" description="Any configured query timeout in seconds The default is no timeout"/>
         <c:simple-property name="use-try-lock" type="long" readOnly="false" required="false" description="Any configured timeout for internal locks on the resource adapter objects in seconds"/>
         <c:simple-property name="set-tx-query-timeout" type="boolean" readOnly="false" required="false" default="false" description="Whether to set the query timeout based on the time remaining until transaction timeout, any configured query timeout will be used if there is no transaction."/>
@@ -463,8 +463,8 @@
         <c:simple-property name="exception-sorter-class-name" type="string" readOnly="false" required="false" description="An org.jboss.jca.adapters.jdbc.ExceptionSorter that provides a boolean isExceptionFatal(SQLException e) method to validate is an exception should be broadcast to all javax.resource.spi.ConnectionEventListener as a connectionErrorOccurred"/>
         <c:simple-property name="stale-connection-checker-class-name" type="string" readOnly="false" required="false" description="An org.jboss.jca.adapters.jdbc.StaleConnectionChecker that provides a boolean isStaleConnection(SQLException e) method which if it it returns true will wrap the exception in an org.jboss.jca.adapters.jdbc.StaleConnectionException"/>
         <c:simple-property name="valid-connection-checker-class-name" type="string" readOnly="false" required="false" description="An org.jboss.jca.adapters.jdbc.ValidConnectionChecker that provides a SQLException isValidConnection(Connection e) method to validate is a connection is valid. An exception means the connection is destroyed. This overrides the check-valid-connection-sql when present."/>
-        <c:simple-property name="background-validation-millis" type="long" readOnly="false" required="false" description="The background-validation-minutes element specifies the amount of time, in minutes, that background validation will run. Changing this value require a server restart."/>
-        <c:simple-property name="background-validation" type="boolean" readOnly="false" required="false" default="false" description="An element to specify that connections should be validated on a background thread versus being validated prior to use. Changing this value require a server restart."/>
+        <c:simple-property name="background-validation-millis" type="long" readOnly="false" required="false" defaultValue="600000" description="The background-validation-minutes element specifies the amount of time, in minutes, that background validation will run. Changing this value require a server restart."/>
+        <c:simple-property name="background-validation" type="boolean" readOnly="false" required="false" defaultValue="false" description="An element to specify that connections should be validated on a background thread versus being validated prior to use. Changing this value require a server restart."/>
         <c:simple-property name="use-fast-fail" type="boolean" readOnly="false" required="false" description="Whether fail a connection allocation on the first connection if it is invalid (true) or keep trying until the pool is exhausted of all potential connections (false)"/>
         <c:simple-property name="validate-on-match" type="boolean" readOnly="false" required="false" default="false" description="The validate-on-match element indicates whether or not connection level validation should be done when a connection factory attempts to match a managed connection for a given set. This is typically exclusive to the use of background validation"/>
         <c:simple-property name="spy" type="boolean" readOnly="false" required="false" defaultValue="false" description="whatever spy or not the jdbc connection"/>
@@ -516,7 +516,7 @@
           </c:property-options>
         </c:simple-property>
 
-        <c:simple-property name="prepared-statements-cacheSize" type="long" readOnly="true" required="false" description="The number of prepared statements per connection in an LRU cache"/>
+        <c:simple-property name="prepared-statements-cache-size" type="long" readOnly="true" required="false" description="The number of prepared statements per connection in an LRU cache"/>
         <c:simple-property name="share-prepared-statements" type="boolean" readOnly="true" required="false" description="Whether to share prepare statements, i.e. whether asking for same statement twice without closing uses the same underlying prepared statement"/>
         <c:simple-property name="track-statements" type="string" readOnly="true" required="false" description="Whether to check for unclosed statements when a connection is returned to the pool and result sets are closed when a statement is closed/return to the prepared statement cache. valid values are: false - do not track statements and results true - track statements and result sets and warn when they are not closed nowarn - track statements but do no warn about them being unclosed"/>
         <c:simple-property name="allocation-retry" type="integer" readOnly="true" required="false" description="The allocation retry element indicates the number of times that allocating a connection should be tried before throwing an exception."/>
@@ -571,10 +571,10 @@
         <c:simple-property name="url-selector-strategy-class-name" required="false" type="string" readOnly="true" description="A class that implements org.jboss.jca.adapters.jdbc.URLSelectorStrategy"/>
         <c:simple-property name="use-java-context" required="false" type="boolean" readOnly="true" description="Setting this to false will bind the DataSource into global JNDI;"/>
         <c:simple-property name="enabled" required="false" type="boolean" readOnly="true" description="Specifies if the datasource should be enabled"/>
-        <c:simple-property name="max-pool-size" required="false" type="integer" readOnly="false" description="The max-pool-size element indicates the maximum number of connections for a pool. No more connections will be created in each sub-pool."/>
-        <c:simple-property name="min-pool-size" required="false" type="integer" readOnly="false" description="The min-pool-size element indicates the minimum number of connections a pool should hold. These are not created until a Subject is known from a request for a connection."/>
-        <c:simple-property name="pool-prefill" required="false" type="boolean" readOnly="false" description="Whether to attempt to prefill the connection pool. Changing this value require a server restart."/>
-        <c:simple-property name="pool-use-strict-min" required="false" type="boolean" readOnly="false" description="Define if the min-pool-size should be considered a strictly."/>
+        <c:simple-property name="max-pool-size" required="false" type="integer" readOnly="false" defaultValue="20" description="The max-pool-size element indicates the maximum number of connections for a pool. No more connections will be created in each sub-pool."/>
+        <c:simple-property name="min-pool-size" required="false" type="integer" readOnly="false" defaultValue="0" description="The min-pool-size element indicates the minimum number of connections a pool should hold. These are not created until a Subject is known from a request for a connection."/>
+        <c:simple-property name="pool-prefill" required="false" type="boolean" readOnly="false" defaultValue="false" description="Whether to attempt to prefill the connection pool. Changing this value require a server restart."/>
+        <c:simple-property name="pool-use-strict-min" required="false" type="boolean" readOnly="false" defaultValue="false" description="Define if the min-pool-size should be considered a strictly."/>
         <c:simple-property name="interleaving" required="false" type="boolean" readOnly="true" description="An element to enable interleaving for XA connection factories"/>
         <c:simple-property name="no-tx-separate-pool" required="false" type="boolean" readOnly="true" description="Oracle does not like XA connections getting used both inside and outside a JTA transaction. To workaround the problem you can create separate sub-pools for the different context"/>
         <c:simple-property name="pad-xid" required="false" type="boolean" readOnly="true" description="Should the Xid be padded"/>
@@ -597,13 +597,13 @@
             <c:option value="EntirePool"/>
           </c:property-options>
         </c:simple-property>
-        <c:simple-property name="prepared-statements-cacheSize" required="false" type="long" readOnly="true" description="The number of prepared statements per connection in an LRU cache"/>
+        <c:simple-property name="prepared-statements-cache-size" required="false" type="long" readOnly="true" description="The number of prepared statements per connection in an LRU cache"/>
         <c:simple-property name="share-prepared-statements" required="false" type="boolean" readOnly="true" description="Whether to share prepare statements, i.e. whether asking for same statement twice without closing uses the same underlying prepared statement"/>
         <c:simple-property name="track-statements" required="false" type="string" readOnly="true" description="Whether to check for unclosed statements when a connection is returned to the pool and result sets are closed when a statement is closed/return to the prepared statement cache. valid values are: false - do not track statements and results true - track statements and result sets and warn when they are not closed nowarn - track statements but do no warn about them being unclosed"/>
         <c:simple-property name="allocation-retry" required="false" type="integer" readOnly="true" description="The allocation retry element indicates the number of times that allocating a connection should be tried before throwing an exception."/>
         <c:simple-property name="allocation-retry-wait-millis" required="false" type="long" readOnly="true" description="he allocation retry wait millis element indicates the time in milliseconds to wait between retrying to allocate a connection."/>
-        <c:simple-property name="blocking-timeout-wait-millis" required="false" type="long" readOnly="false" description="The blocking-timeout-millis element indicates the maximum time in milliseconds to block while waiting for a connection before throwing an exception. Note that this blocks only while waiting for a permit for a connection, and will never throw an exception if creating a new connection takes an inordinately long time."/>
-        <c:simple-property name="idle-timeout-minutes" required="false" type="long" readOnly="false" description="The idle-timeout-minutes elements indicates the maximum time in minutes a connection may be idle before being closed. The actual maximum time depends also on the IdleRemover scan time, which is 1/2 the smallest idle-timeout-minutes of any pool. Changing this value require a server restart."/>
+        <c:simple-property name="blocking-timeout-wait-millis" required="false" type="long" readOnly="false" defaultValue="30000" description="The blocking-timeout-millis element indicates the maximum time in milliseconds to block while waiting for a connection before throwing an exception. Note that this blocks only while waiting for a permit for a connection, and will never throw an exception if creating a new connection takes an inordinately long time."/>
+        <c:simple-property name="idle-timeout-minutes" required="false" type="long" readOnly="false" defaultValue="15" description="The idle-timeout-minutes elements indicates the maximum time in minutes a connection may be idle before being closed. The actual maximum time depends also on the IdleRemover scan time, which is 1/2 the smallest idle-timeout-minutes of any pool. Changing this value require a server restart."/>
         <c:simple-property name="query-timeout" required="false" type="long" readOnly="true" description="Any configured query timeout in seconds The default is no timeout"/>
         <c:simple-property name="use-try-lock" required="false" type="long" readOnly="true" description="Any configured timeout for internal locks on the resource adapter objects in seconds"/>
         <c:simple-property name="set-tx-query-timeout" required="false" type="boolean" readOnly="true" description="Whether to set the query timeout based on the time remaining until transaction timeout, any configured query timeout will be used if there is no transaction."/>
@@ -638,8 +638,8 @@
                             configuration
                         </c:map-property>
         -->
-        <c:simple-property name="background-validation-minutes" required="false" type="long" readOnly="false" description="The background-validation-minutes element specifies the amount of time, in minutes, that background validation will run. Changing this value require a server restart."/>
-        <c:simple-property name="background-validation" required="false" type="boolean" readOnly="false" description="An element to specify that connections should be validated on a background thread versus being validated prior to use. Changing this value require a server restart."/>
+        <c:simple-property name="background-validation-minutes" required="false" type="long" readOnly="false" defaultValue="10" description="The background-validation-minutes element specifies the amount of time, in minutes, that background validation will run. Changing this value require a server restart."/>
+        <c:simple-property name="background-validation" required="false" type="boolean" readOnly="false" defaultValue="false" description="An element to specify that connections should be validated on a background thread versus being validated prior to use. Changing this value require a server restart."/>
         <c:simple-property name="use-fast-fail" required="false" type="boolean" readOnly="false" description="Whether fail a connection allocation on the first connection if it is invalid (true) or keep trying until the pool is exhausted of all potential connections (false)"/>
         <c:simple-property name="validate-on-match" required="false" type="boolean" readOnly="true" description="The validate-on-match element indicates whether or not connection level validation should be done when a connection factory attempts to match a managed connection for a given set. This is typically exclusive to the use of background validation"/>
         <c:simple-property name="xa-resource-timeout" required="false" type="integer" readOnly="true" description="Passed to XAResource.setTransactionTimeout() Default is zero which does not invoke the setter. In seconds"/>
@@ -707,7 +707,7 @@
             <c:option value="EntirePool"/>
           </c:property-options>
         </c:simple-property>
-        <c:simple-property name="prepared-statements-cacheSize" required="false" type="long" readOnly="true" description="The number of prepared statements per connection in an LRU cache"/>
+        <c:simple-property name="prepared-statements-cache-size" required="false" type="long" readOnly="true" description="The number of prepared statements per connection in an LRU cache"/>
         <c:simple-property name="share-prepared-statements" required="false" type="boolean" readOnly="true" description="Whether to share prepare statements, i.e. whether asking for same statement twice without closing uses the same underlying prepared statement"/>
         <c:simple-property name="track-statements" required="false" type="string" readOnly="true" description="Whether to check for unclosed statements when a connection is returned to the pool and result sets are closed when a statement is closed/return to the prepared statement cache. valid values are: false - do not track statements and results true - track statements and result sets and warn when they are not closed nowarn - track statements but do no warn about them being unclosed"/>
         <c:simple-property name="allocation-retry" required="false" type="integer" readOnly="true" description="The allocation retry element indicates the number of times that allocating a connection should be tried before throwing an exception."/>


commit 7ac46f60f75ade6559d420ee19136b5ce542c1cb
Author: Stefan Negrea <snegrea at redhat.com>
Date:   Wed Aug 29 03:38:45 2012 -0500

    [BZ 852552] Adding special validation for the transaction subsystem.
    
    The special case for this subsystem:
    
    If [process-id-uuid] == true then do not send updates for [process-id-socket-binding], this property will be undefined by the AS7 on the next reload/restart
    
    If [process-id-uuid] == false then allow AS7 to perform property validation * If [process-id-uuid] == false then send [process-id-socket-binding] value and allow AS7 to perform property validation
    (cherry picked from commit 96602db100b087e36016b1aa6a2e39780b583898)

diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/TransactionsComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/TransactionsComponent.java
new file mode 100644
index 0000000..102118b
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/TransactionsComponent.java
@@ -0,0 +1,62 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2012, 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 program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.modules.plugins.jbossas7;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+
+/**
+ * Support for transactions subsystem configuration updates.
+ *
+ * The special case for this subsystem:
+ *
+ * If [process-id-uuid] == true then do not send updates for [process-id-socket-binding], this property
+ * will be undefined by the AS7 on the next server reload/restart
+ *
+ * If [process-id-uuid] == false then send [process-id-socket-binding] value and
+ * allow AS7 to perform property validation
+ *
+ *
+ * @author Stefan Negrea
+ */
+public class TransactionsComponent extends BaseComponent<ResourceComponent<?>> {
+
+    @Override
+    public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+        Configuration config = report.getConfiguration();
+        ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
+
+        boolean processIdUuid = Boolean.valueOf(config.getSimpleValue("process-id-uuid"));
+        if (processIdUuid == true) {
+            //Do not even send the updates for [process-id-socket-binding] because the AS7 will
+            //undefine it during the next reload/restart.
+            //Also, sending null for [process-id-socket-binding] with [process-id-uuid] == true causes
+            //a validation error on the server.
+            configDef.getPropertyDefinitions().remove("process-id-socket-binding");
+            config.remove("process-id-socket-binding");
+        }
+
+        ConfigurationWriteDelegate delegate = new ConfigurationWriteDelegate(configDef, getASConnection(), address);
+        delegate.updateResourceConfiguration(report);
+    }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index aa4ae01..56f9f73 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -8339,7 +8339,7 @@
 
   <service name="Transactions Subsystem (Standalone)"
            discovery="SubsystemDiscovery"
-           class="BaseComponent"
+           class="TransactionsComponent"
            singleton="true"
            description="The transactions subsystem.">
 
@@ -8461,7 +8461,7 @@
 
   <service name="Transactions Subsystem (Profile)"
            discovery="SubsystemDiscovery"
-           class="BaseComponent"
+           class="TransactionsComponent"
            singleton="true"
            description="The transactions subsystem.">
 
@@ -8517,7 +8517,7 @@
 
   <service name="Transactions Subsystem (Managed)"
            discovery="SubsystemDiscovery"
-           class="BaseComponent"
+           class="TransactionsComponent"
            singleton="true"
            description="The transactions subsystem.">
 


commit dd060fd9f2f49693f52a2e073641e23bab5fff78
Author: Stefan Negrea <snegrea at redhat.com>
Date:   Wed Aug 29 03:38:06 2012 -0500

    [BZ 852552] Update socket binding group to not send at all port-offset for non-standalone servers.
    
    Just setting port-offset to null was not enough since now all the unset properties are sent to the AS7 server. The property and property definition are now removed from updates sent host controllers.
    (cherry picked from commit a31197fcd63548c6e49606525b9938c123e5ffb2)

diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupComponent.java
index 00d28ca..573db2e 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupComponent.java
@@ -2,6 +2,7 @@ package org.rhq.modules.plugins.jbossas7;
 
 import org.rhq.core.domain.configuration.Configuration;
 import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
 import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
 import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
 
@@ -29,12 +30,14 @@ public class SocketBindingGroupComponent extends BaseComponent implements Config
     public void updateResourceConfiguration(ConfigurationUpdateReport report) {
 
         Configuration config = report.getConfiguration();
+        ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
+
         if (!(context.getParentResourceComponent() instanceof StandaloneASComponent)) { // TODO what about managed servers
-            config.put(new PropertySimple("port-offset",null));
+            configDef.getPropertyDefinitions().remove("port-offset");
+            config.remove("port-offset");
         }
 
-        super.updateResourceConfiguration(report);
-
-
+        ConfigurationWriteDelegate delegate = new ConfigurationWriteDelegate(configDef, getASConnection(), address);
+        delegate.updateResourceConfiguration(report);
     }
 }


commit 0d75b66fd8952290aba7decd717a542dba4ab1ed
Author: Stefan Negrea <snegrea at redhat.com>
Date:   Wed Aug 29 03:37:38 2012 -0500

    [BZ 852552] Create a separate distributed cache definition because this resource contains addtional properties not available for invalidation and replicate caches.
    
    The diferrence between these caches was obvious only after the updates to always send unset properties. All these extra properties (which are null) were sent to the server causing failures for caches that do not have them in their definition.
    (cherry picked from commit 91aaaf71e585022ca85f62e371a7d63ae554ff6d)

diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index be9e0e8..aa4ae01 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -2003,7 +2003,7 @@
                  class="TemplatedComponent">
 
           <plugin-configuration>
-            <c:simple-property name="path" readOnly="true" default="distributed-cache|invalidation-cache|replicated-cache"/>
+            <c:simple-property name="path" readOnly="true" default="invalidation-cache|replicated-cache"/>
           </plugin-configuration>
 
           <resource-configuration>
@@ -2032,30 +2032,64 @@
             <c:simple-property name="queue-flush-interval" required="false" type="long" readOnly="true" default="10" description="In ASYNC mode, this attribute controls how often the asynchronous thread used to flush the replication queue runs. This should be a positive integer which represents thread wakeup time in milliseconds."/>
             <c:simple-property name="remote-timeout" required="false" type="long" readOnly="true" default="17500" description="In SYNC mode, the timeout (in ms) used to wait for an acknowledgment when making a remote call, after which the call is aborted and an exception is thrown."/>
             <c:simple-property name="async-marshalling" required="false" type="boolean" readOnly="true" defaultValue="false" description="If enabled, this will cause marshalling of entries to be performed asynchronously. The default value is false."/>
-            <c:simple-property name="l1-lifespan" required="false" type="long" readOnly="true" defaultValue="600000" description="Maximum lifespan of an entry placed in the L1 cache. This element configures the L1 cache behavior in &apos;distributed&apos; caches instances. In any other cache modes, this element is ignored. The default value is 600000."/>
             <c:simple-property name="module" required="false" type="string" readOnly="true" description="The module whose class loader should be used when building this cache&apos;s configuration."/>
-            <c:simple-property name="owners" required="false" type="integer" readOnly="true" defaultValue="2" description="Number of cluster&#45;wide replicas for each cache entry. The default value is 2."/>
-            <c:simple-property name="virtual-nodes" required="false" type="integer" readOnly="true" defaultValue="1" description="Controls the number of virtual nodes per &apos;real&apos; node. If numVirtualNodes is 1, then virtual nodes are disabled. The topology aware consistent hash must be used if you wish to take advantage of virtual nodes. A default of 1 is used. The default value is 1."/>
 
-            <c:simple-property name="__type" displayName="Type of cache" required="true" readOnly="true" default="local-cache" description="Type of cache">
+            <c:simple-property name="__type" displayName="Type of cache" required="true" readOnly="true" default="invalidation-cache" description="Type of cache">
               <c:property-options>
                 <c:option value="invalidation-cache"/>
-                <c:option value="distributed-cache"/>
                 <c:option value="replicated-cache"/>
               </c:property-options>
             </c:simple-property>
             <c:template name="Invalidation Cache" description="Invalidation Cache">
               <c:simple-property name="__type" readOnly="true" default="invalidation-cache"/>
             </c:template>
-            <c:template name="Distributed Cache" description="Distributed Cache">
-              <c:simple-property name="__type" readOnly="true" default="distributed-cache"/>
-            </c:template>
             <c:template name="Replicated Cache" description="Replicated Cache">
               <c:simple-property name="__type" readOnly="true" default="replicated-cache"/>
             </c:template>
           </resource-configuration>
         </service>
 
+        <service name="Distributed Cache (Managed Server)"
+                 discovery="SubsystemDiscovery"
+                 class="BaseComponent">
+
+          <plugin-configuration>
+            <c:simple-property name="path" readOnly="true" default="distributed-cache"/>
+          </plugin-configuration>
+
+          <resource-configuration>
+            <c:simple-property name="start" required="false" type="string" readOnly="true" default="LAZY" description="The cache start mode, which can be EAGER (immediate start) or LAZY (on-demand start).">
+              <c:property-options>
+                <c:option value="LAZY"/>
+                <c:option value="EAGER"/>
+              </c:property-options>
+            </c:simple-property>
+            <c:simple-property name="batching" required="false" type="boolean" readOnly="true" default="false" description="If enabled, the invocation batching API will be made available for this cache."/>
+            <c:simple-property name="indexing" required="false" type="string" readOnly="true" default="NONE" description="If enabled, entries will be indexed when they are added to the cache. Indexes will be updated as entries change or are removed.">
+              <c:property-options>
+                <c:option value="NONE"/>
+                <c:option value="LOCAL"/>
+                <c:option value="ALL"/>
+              </c:property-options>
+            </c:simple-property>
+            <c:simple-property name="jndi-name" required="false" type="string" readOnly="true" description="The jndi-name to which to bind this cache instance."/>
+            <c:simple-property name="mode" required="false" type="string" readOnly="true" default="SYNC" description="Sets the clustered cache mode, ASYNC for asynchronous operation, or SYNC for synchronous operation.">
+              <c:property-options>
+                <c:option value="SYNC"/>
+                <c:option value="ASYNC"/>
+              </c:property-options>
+            </c:simple-property>
+            <c:simple-property name="queue-size" required="false" type="integer" readOnly="true" default="0" description="In ASYNC mode, this attribute can be used to trigger flushing of the queue when it reaches a specific threshold."/>
+            <c:simple-property name="queue-flush-interval" required="false" type="long" readOnly="true" default="10" description="In ASYNC mode, this attribute controls how often the asynchronous thread used to flush the replication queue runs. This should be a positive integer which represents thread wakeup time in milliseconds."/>
+            <c:simple-property name="remote-timeout" required="false" type="long" readOnly="true" default="17500" description="In SYNC mode, the timeout (in ms) used to wait for an acknowledgment when making a remote call, after which the call is aborted and an exception is thrown."/>
+            <c:simple-property name="async-marshalling" required="false" type="boolean" readOnly="true" defaultValue="false" description="If enabled, this will cause marshalling of entries to be performed asynchronously. The default value is false."/>
+            <c:simple-property name="l1-lifespan" required="false" type="long" readOnly="true" defaultValue="600000" description="Maximum lifespan of an entry placed in the L1 cache. This element configures the L1 cache behavior in &apos;distributed&apos; caches instances. In any other cache modes, this element is ignored. The default value is 600000."/>
+            <c:simple-property name="module" required="false" type="string" readOnly="true" description="The module whose class loader should be used when building this cache&apos;s configuration."/>
+            <c:simple-property name="owners" required="false" type="integer" readOnly="true" defaultValue="2" description="Number of cluster&#45;wide replicas for each cache entry. The default value is 2."/>
+            <c:simple-property name="virtual-nodes" required="false" type="integer" readOnly="true" defaultValue="1" description="Controls the number of virtual nodes per &apos;real&apos; node. If numVirtualNodes is 1, then virtual nodes are disabled. The topology aware consistent hash must be used if you wish to take advantage of virtual nodes. A default of 1 is used. The default value is 1."/>
+          </resource-configuration>
+        </service>
+
         <service name="Local Cache (Managed Server)"
                  discovery="SubsystemDiscovery"
                  class="BaseComponent"
@@ -11332,7 +11366,7 @@
                creationDataType="configuration">
 
         <plugin-configuration>
-          <c:simple-property name="path" readOnly="true" default="distributed-cache|invalidation-cache|replicated-cache"/>
+          <c:simple-property name="path" readOnly="true" default="invalidation-cache|replicated-cache"/>
         </plugin-configuration>
 
         <resource-configuration>
@@ -11361,30 +11395,66 @@
           <c:simple-property name="queue-flush-interval" required="false" type="long" readOnly="false" default="10" description="In ASYNC mode, this attribute controls how often the asynchronous thread used to flush the replication queue runs. This should be a positive integer which represents thread wakeup time in milliseconds."/>
           <c:simple-property name="remote-timeout" required="false" type="long" readOnly="false" default="17500" description="In SYNC mode, the timeout (in ms) used to wait for an acknowledgment when making a remote call, after which the call is aborted and an exception is thrown."/>
           <c:simple-property name="async-marshalling" required="false" type="boolean" readOnly="false" defaultValue="false" description="If enabled, this will cause marshalling of entries to be performed asynchronously. The default value is false."/>
-          <c:simple-property name="l1-lifespan" required="false" type="long" readOnly="false" defaultValue="600000" description="Maximum lifespan of an entry placed in the L1 cache. This element configures the L1 cache behavior in &apos;distributed&apos; caches instances. In any other cache modes, this element is ignored. The default value is 600000."/>
           <c:simple-property name="module" required="false" type="string" readOnly="false" description="The module whose class loader should be used when building this cache&apos;s configuration."/>
-          <c:simple-property name="owners" required="false" type="integer" readOnly="false" defaultValue="2" description="Number of cluster&#45;wide replicas for each cache entry. The default value is 2."/>
-          <c:simple-property name="virtual-nodes" required="false" type="integer" readOnly="false" defaultValue="1" description="Controls the number of virtual nodes per &apos;real&apos; node. If numVirtualNodes is 1, then virtual nodes are disabled. The topology aware consistent hash must be used if you wish to take advantage of virtual nodes. A default of 1 is used. The default value is 1."/>
 
-          <c:simple-property name="__type" displayName="Type of cache" required="true" readOnly="true" default="local-cache" description="Type of cache">
+          <c:simple-property name="__type" displayName="Type of cache" required="true" readOnly="true" default="invalidation-cache" description="Type of cache">
             <c:property-options>
               <c:option value="invalidation-cache"/>
-              <c:option value="distributed-cache"/>
               <c:option value="replicated-cache"/>
             </c:property-options>
           </c:simple-property>
           <c:template name="Invalidation Cache" description="Invalidation Cache">
             <c:simple-property name="__type" readOnly="true" default="invalidation-cache"/>
           </c:template>
-          <c:template name="Distributed Cache" description="Distributed Cache">
-            <c:simple-property name="__type" readOnly="true" default="distributed-cache"/>
-          </c:template>
           <c:template name="Replicated Cache" description="Replicated Cache">
             <c:simple-property name="__type" readOnly="true" default="replicated-cache"/>
           </c:template>
         </resource-configuration>
       </service>
 
+      <service name="Distributed Cache"
+               discovery="SubsystemDiscovery"
+               class="BaseComponent"
+               createDeletePolicy="both"
+               creationDataType="configuration">
+
+        <plugin-configuration>
+          <c:simple-property name="path" readOnly="true" default="distributed-cache"/>
+        </plugin-configuration>
+
+        <resource-configuration>
+          <c:simple-property name="start" required="false" type="string" readOnly="false" default="LAZY" description="The cache start mode, which can be EAGER (immediate start) or LAZY (on-demand start).">
+            <c:property-options>
+              <c:option value="LAZY"/>
+              <c:option value="EAGER"/>
+            </c:property-options>
+          </c:simple-property>
+          <c:simple-property name="batching" required="false" type="boolean" readOnly="false" default="false" description="If enabled, the invocation batching API will be made available for this cache."/>
+          <c:simple-property name="indexing" required="false" type="string" readOnly="false" default="NONE" description="If enabled, entries will be indexed when they are added to the cache. Indexes will be updated as entries change or are removed.">
+            <c:property-options>
+              <c:option value="NONE"/>
+              <c:option value="LOCAL"/>
+              <c:option value="ALL"/>
+            </c:property-options>
+          </c:simple-property>
+          <c:simple-property name="jndi-name" required="false" type="string" readOnly="false" description="The jndi-name to which to bind this cache instance."/>
+          <c:simple-property name="mode" required="true" type="string" readOnly="false" default="SYNC" defaultValue="SYNC" description="Sets the clustered cache mode, ASYNC for asynchronous operation, or SYNC for synchronous operation.">
+            <c:property-options>
+              <c:option value="SYNC"/>
+              <c:option value="ASYNC"/>
+            </c:property-options>
+          </c:simple-property>
+          <c:simple-property name="queue-size" required="false" type="integer" readOnly="false" default="0" description="In ASYNC mode, this attribute can be used to trigger flushing of the queue when it reaches a specific threshold."/>
+          <c:simple-property name="queue-flush-interval" required="false" type="long" readOnly="false" default="10" description="In ASYNC mode, this attribute controls how often the asynchronous thread used to flush the replication queue runs. This should be a positive integer which represents thread wakeup time in milliseconds."/>
+          <c:simple-property name="remote-timeout" required="false" type="long" readOnly="false" default="17500" description="In SYNC mode, the timeout (in ms) used to wait for an acknowledgment when making a remote call, after which the call is aborted and an exception is thrown."/>
+          <c:simple-property name="async-marshalling" required="false" type="boolean" readOnly="false" defaultValue="false" description="If enabled, this will cause marshalling of entries to be performed asynchronously. The default value is false."/>
+          <c:simple-property name="l1-lifespan" required="false" type="long" readOnly="false" defaultValue="600000" description="Maximum lifespan of an entry placed in the L1 cache. This element configures the L1 cache behavior in &apos;distributed&apos; caches instances. In any other cache modes, this element is ignored. The default value is 600000."/>
+          <c:simple-property name="module" required="false" type="string" readOnly="false" description="The module whose class loader should be used when building this cache&apos;s configuration."/>
+          <c:simple-property name="owners" required="false" type="integer" readOnly="false" defaultValue="2" description="Number of cluster&#45;wide replicas for each cache entry. The default value is 2."/>
+          <c:simple-property name="virtual-nodes" required="false" type="integer" readOnly="false" defaultValue="1" description="Controls the number of virtual nodes per &apos;real&apos; node. If numVirtualNodes is 1, then virtual nodes are disabled. The topology aware consistent hash must be used if you wish to take advantage of virtual nodes. A default of 1 is used. The default value is 1."/>
+        </resource-configuration>
+      </service>
+
       <service name="Local Cache"
                discovery="SubsystemDiscovery"
                class="BaseComponent"


commit 2e6e37ac2f8ac23b548842c045b67324db10d4a5
Author: Stefan Negrea <snegrea at redhat.com>
Date:   Wed Aug 29 03:36:59 2012 -0500

    [BZ 852552] Update mod-cluster property name to load-balancing-group. The "domain" alias no longer works for load-balancing-group causing configuration updates to fail with unknown domain property.
    (cherry picked from commit 9320bfa050c332a5f89334fcf5606395e5ef9098)

diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 6f008f6..be9e0e8 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -169,7 +169,7 @@
             <c:simple-property name="connector" required="true" type="string" readOnly="false" defaultValue="ajp" description="Name of the web connector used to communicate with the load balancer.">
               <c:option-source target="resource" expression="type=Connector plugin=&pluginName;"/>
             </c:simple-property>
-            <c:simple-property name="domain" required="false" type="string" readOnly="false" description="loadBalancingGroup name."/>
+            <c:simple-property name="load-balancing-group" required="false" type="string" readOnly="false" description="loadBalancingGroup name."/>
           </c:group>
 
           <c:group name="context" displayName="Web Context Options">


commit 9aeb0c35d984911e418dbd2d69ebd4ac9e367d4c
Author: Stefan Negrea <snegrea at redhat.com>
Date:   Wed Aug 29 03:36:29 2012 -0500

    [BZ 852552] Removing properties from the Transport subresource because the resource definition no longer contains them.
    
    Because unset properties are now always sent to the AS7 server, all these removed Transport properties were sent to the AS7 causing an unknown property failure.
    (cherry picked from commit 9f82d413e980967ea3fae7ffe2579c44cc29cbb7)

diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index c4a5de6..6f008f6 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -2100,9 +2100,6 @@
             <c:simple-property name="cluster" required="false" type="string" readOnly="true" description="The name of the group communication cluster"/>
             <c:simple-property name="executor" required="false" type="string" readOnly="true" description="The executor to use for the transport"/>
             <c:simple-property name="lock-timeout" required="false" type="long" readOnly="true" defaultValue="240000" description="The timeout for locks for the transport. The default value is 240000."/>
-            <c:simple-property name="machine" required="false" type="string" readOnly="true" description="A machine identifier for the transport"/>
-            <c:simple-property name="rack" required="false" type="string" readOnly="true" description="A rack identifier for the transport"/>
-            <c:simple-property name="site" required="false" type="string" readOnly="true" description="A site identifier for the transport"/>
             <c:simple-property name="stack" required="false" type="string" readOnly="true" description="The jgroups stack to use for the transport"/>
           </resource-configuration>
         </service>
@@ -11432,9 +11429,6 @@
           <c:simple-property name="cluster" required="false" type="string" readOnly="false" description="The name of the group communication cluster"/>
           <c:simple-property name="executor" required="false" type="string" readOnly="false" description="The executor to use for the transport"/>
           <c:simple-property name="lock-timeout" required="false" type="long" readOnly="false" defaultValue="240000" description="The timeout for locks for the transport. The default value is 240000."/>
-          <c:simple-property name="machine" required="false" type="string" readOnly="false" description="A machine identifier for the transport"/>
-          <c:simple-property name="rack" required="false" type="string" readOnly="false" description="A rack identifier for the transport"/>
-          <c:simple-property name="site" required="false" type="string" readOnly="false" description="A site identifier for the transport"/>
           <c:simple-property name="stack" required="false" type="string" readOnly="false" description="The jgroups stack to use for the transport"/>
         </resource-configuration>
       </service>


commit f23b9df8bb5de19b72b80635e7adf920993f2945
Author: Stefan Negrea <snegrea at redhat.com>
Date:   Wed Aug 29 03:35:56 2012 -0500

    [BZ 852552] Send unset properties to AS7 as null.
    
    Existing code was not sending updates for unset properties at all to AS7 making it impossible to unset (or set to empty) a property after it was set to something not null.
    (cherry picked from commit c1655d4d576311b9034a31b505e75981b1d6e720)

diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java
index aad2105..f73ccf5 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationWriteDelegate.java
@@ -431,16 +431,25 @@ public class ConfigurationWriteDelegate implements ConfigurationFacet {
     private void createWriteAttributePropertySimple(CompositeOperation cop, PropertySimple property,
         PropertyDefinitionSimple propertyDefinition, Address address) {
 
-        // If the property value is null and the property is optional, skip too
-        if (property.getStringValue() == null && !propertyDefinition.isRequired())
-            return;
-
         if (property.getName().endsWith(":ignore")) // Caller takes care
             return;
 
         if (propertyDefinition.isReadOnly() && !createChildRequested)
             return;
 
+        //If the property value is null and the property is optional,
+        //then send default value or null to the server
+        if (property.getStringValue() == null && !propertyDefinition.isRequired()) {
+            String name = property.getName();
+            if (name.indexOf(':') != -1) {
+                name = name.substring(0, name.indexOf(":"));
+            }
+
+            Operation writeAttribute = new WriteAttribute(address, name, null);
+            cop.addStep(writeAttribute);
+            return;
+        }
+
         SimpleEntry<String, Object> entry = this.preparePropertySimple(property, propertyDefinition);
         Operation writeAttribute = new WriteAttribute(address, entry.getKey(), entry.getValue());
         cop.addStep(writeAttribute);
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java
index 21e3d5f..48b6783 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationUpdatingTest.java
@@ -59,7 +59,6 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest
     public void test1() throws Exception {
 
         ConfigurationDefinition definition = loadDescriptor("simple1");
-
         FakeConnection connection = new FakeConnection();
 
         ConfigurationWriteDelegate delegate = new ConfigurationWriteDelegate(definition, connection, null);
@@ -70,12 +69,22 @@ public class ConfigurationUpdatingTest extends AbstractConfigurationHandlingTest
 
         CompositeOperation cop = delegate.updateGenerateOperationFromProperties(conf, new Address());
 
-        assert cop.numberOfSteps() == 1;
-        Operation step1 = cop.step(0);
-        assert step1.getOperation().equals("write-attribute");
-        Map<String, Object> props = step1.getAdditionalProperties();
-        assert props.size() == 2;
+        Assert.assertEquals(cop.numberOfSteps(), 2);
 
+        for (int i = 0; i < cop.numberOfSteps(); i++) {
+            Operation step = cop.step(0);
+            Assert.assertEquals(step.getOperation(), "write-attribute");
+            Map<String, Object> stepProps = step.getAdditionalProperties();
+            Assert.assertEquals(stepProps.size(), 2);
+
+            if (stepProps.get("name").equals("needed")) {
+                Assert.assertEquals(stepProps.get("value"), "test");
+            } else if (stepProps.get("name").equals("optional")) {
+                Assert.assertEquals(stepProps.get("value"), null);
+            } else {
+                Assert.fail("Unexepected property found!");
+            }
+        }
     }
 
     public void test2() throws Exception {




More information about the rhq-commits mailing list