modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 54 +++---
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java | 78 +++++++---
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterComponent.java | 6
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebservicesComponent.java | 55 +++++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java | 1
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 47 ++++--
6 files changed, 179 insertions(+), 62 deletions(-)
New commits:
commit 372c772cfec9ac3cda5d70e30c5e8ee773d63950
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sat Mar 31 19:52:43 2012 -0400
Move plugin configuration exception code into IOException block to correctly detects unauthorized/401
since the exception handling behavior has been modified.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index e87c68f..c024db7 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -156,7 +156,7 @@ public class ASConnection {
// This most likely just means the server is down.
if (log.isDebugEnabled()) {
log.debug("Failed to open connection to [" + urlString + "] in order to invoke [" + operation + "]: "
- + e);
+ + e);
}
// TODO (ips): Would it make more sense to return null here, since we didn't even connect?
Result failure = new Result();
@@ -182,7 +182,8 @@ public class ASConnection {
if ((operation != null) && (operation.getAddress() != null) && operation.getAddress().getPath() != null) {
if (containsSpaces(operation.getAddress().getPath())) {
Result noResult = new Result();
- String outcome = "- Path '" + operation.getAddress().getPath() + "' is invalid as it contains spaces -";
+ String outcome = "- Path '" + operation.getAddress().getPath()
+ + "' is invalid as it contains spaces -";
if (verbose) {
log.error(outcome);
}
@@ -229,22 +230,6 @@ public class ASConnection {
}
return operationResult;
- } else {
- // Empty response body - probably some sort of error - check the response code.
- int responseCode = conn.getResponseCode();
- if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
- if (log.isDebugEnabled()) {
- log.debug("Response to " + operation + " was empty and response code was " + responseCode + " "
- + conn.getResponseMessage() + " - throwing InvalidPluginConfigurationException...");
- }
- // Throw a InvalidPluginConfigurationException, so the user will get a yellow plugin connection
- // warning message in the GUI.
- throw new InvalidPluginConfigurationException(
- "Credentials for plugin to connect to AS7 management interface are invalid - update Connection Settings with valid credentials.");
- } else {
- log.warn("Response body for " + operation + " was empty and response code was " + responseCode + " ("
- + conn.getResponseMessage() + ").");
- }
}
} catch (IllegalArgumentException iae) {
log.error("Illegal argument for input " + operation + ": " + iae.getMessage());
@@ -273,11 +258,28 @@ public class ASConnection {
String responseCodeString;
try {
responseCodeString = conn.getResponseCode() + " (" + conn.getResponseMessage() + ")";
+
+ // Process response code to generate plugin configuration exception and/or logging
+ int responseCode = conn.getResponseCode();
+ if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
+ if (log.isDebugEnabled()) {
+ log.debug("Response to " + operation + " was " + responseCode + " " + conn.getResponseMessage()
+ + " - throwing InvalidPluginConfigurationException...");
+ }
+ // Throw a InvalidPluginConfigurationException, so the user will get a yellow plugin connection
+ // warning message in the GUI.
+ throw new InvalidPluginConfigurationException(
+ "Credentials for plugin to connect to AS7 management interface are invalid - update Connection Settings with valid credentials.");
+ } else {
+ log.warn("Response body for " + operation + " was empty and response code was " + responseCode
+ + " (" + conn.getResponseMessage() + ").");
+ }
+
} catch (IOException ioe) {
responseCodeString = "unknown response code";
}
String failureDescription = operation + " failed with " + responseCodeString + " - response body was ["
- + responseBody + "].";
+ + responseBody + "].";
log.error(failureDescription, e);
JsonNode operationResult = null;
@@ -331,7 +333,7 @@ public class ASConnection {
* @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation, boolean)
*/
public Result execute(Operation op) {
- return execute(op, false,10);
+ return execute(op, false, 10);
}
/**
@@ -342,8 +344,8 @@ public class ASConnection {
* @return Result of the execution
* @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation, boolean)
*/
- public Result execute(Operation op,int timeoutSec) {
- return execute(op, false,timeoutSec);
+ public Result execute(Operation op, int timeoutSec) {
+ return execute(op, false, timeoutSec);
}
/**
@@ -354,7 +356,7 @@ public class ASConnection {
* @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation, boolean)
*/
public ComplexResult executeComplex(Operation op) {
- return (ComplexResult) execute(op, true,10);
+ return (ComplexResult) execute(op, true, 10);
}
/**
@@ -365,8 +367,8 @@ public class ASConnection {
* @return ComplexResult of the execution
* @see #execute(org.rhq.modules.plugins.jbossas7.json.Operation, boolean)
*/
- public ComplexResult executeComplex(Operation op,int timeoutSec) {
- return (ComplexResult) execute(op, true,timeoutSec);
+ public ComplexResult executeComplex(Operation op, int timeoutSec) {
+ return (ComplexResult) execute(op, true, timeoutSec);
}
/**
@@ -390,7 +392,7 @@ public class ASConnection {
* @return ComplexResult of the execution
*/
public Result execute(Operation op, boolean isComplex, int timeoutSec) {
- JsonNode node = executeRaw(op,timeoutSec);
+ JsonNode node = executeRaw(op, timeoutSec);
if (node == null) {
log.warn("Operation [" + op + "] returned null");
commit d09955b381a700a9fa97a457d6c8d6cea6853728
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sat Mar 31 18:53:57 2012 -0400
Add WebServiceComponent class.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebservicesComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebservicesComponent.java
new file mode 100644
index 0000000..0dea886
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebservicesComponent.java
@@ -0,0 +1,55 @@
+package org.rhq.modules.plugins.jbossas7;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * Support for Webservices subsystem.
+ *
+ * @author Simeon Pinder
+ */
+public class WebservicesComponent extends BaseComponent implements OperationFacet, ConfigurationFacet {
+
+ @Override
+ public Configuration loadResourceConfiguration() throws Exception {
+ Configuration config = super.loadResourceConfiguration();
+
+ return config;
+ }
+
+ @Override
+ public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+
+ super.updateResourceConfiguration(report);
+ }
+
+ @Override
+ public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
+ Operation op = new Operation(name, getAddress());
+ OperationResult operationResult = new OperationResult();
+ Result result = null;
+
+ if ("list-proxies".equals(name)) {
+
+ } else {
+ /*
+ * This is a catch all for operations that are not explicitly treated above.
+ */
+ result = getASConnection().execute(op);
+ if (result.isSuccess()) {
+ operationResult.setSimpleResult("Success");
+ }
+ }
+
+ if (!result.isSuccess()) {
+ operationResult.setErrorMessage(result.getFailureDescription());
+ }
+
+ return operationResult;
+ }
+}
commit 53b98bcc3526825d3a9ec431f197e5e1c2433c3d
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sat Mar 31 18:37:20 2012 -0400
Remove duplicate ThreadPool and Cache elements from plugin descriptor.
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 429a395..19b992d 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
@@ -3024,7 +3024,7 @@ working area for individual server instances</li></ul>"/>
<c:simple-property name="in-vm-remote-interface-invocation-pass-by-value" required="false" type="boolean" readOnly="false" defaultValue="true" description="If set to false, the parameters to invocations on remote interface of an EJB, will be passed by reference. Else, the parameters will be passed by value. The default value is true."/>
</resource-configuration>
- <service name="ThreadPool"
+<!-- <service name="ThreadPool"
discovery="SubsystemDiscovery"
class="BaseComponent"
description="A thread pool executor with an unbounded queue. Such a thread pool has a core size and a queue with no upper bound. When a task is submitted, if the number of running threads is less than the core size, a new thread is created. Otherwise, the task is placed in queue. If too many tasks are allowed to be submitted to this type of executor, an out of memory condition may occur.">
@@ -3051,7 +3051,7 @@ working area for individual server instances</li></ul>"/>
<c:simple-property name="name" required="false" type="string" readOnly="true" description="The name of the thread pool."/>
<c:simple-property name="thread-factory" required="false" type="string" readOnly="false" description="Specifies the name of a specific thread factory to use to create worker threads. If not defined an appropriate default thread factory will be used."/>
</resource-configuration>
- </service>
+ </service>-->
<service name="FilePassivationStore"
discovery="SubsystemDiscovery"
@@ -3089,7 +3089,7 @@ working area for individual server instances</li></ul>"/>
</resource-configuration>
</service>
- <service name="Cache"
+<!-- <service name="Cache"
discovery="SubsystemDiscovery"
class="BaseComponent"
description="A SFSB cache.">
@@ -3104,7 +3104,7 @@ working area for individual server instances</li></ul>"/>
</c:list-property>
<c:simple-property name="passivation-store" required="false" type="string" readOnly="false" description="The passivation store used by this cache"/>
</resource-configuration>
- </service>
+ </service>-->
<service name="ClusterPassivationStore"
discovery="SubsystemDiscovery"
commit 4bd1f66b32291238b3300064ab13a6f1ab9f367e
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sat Mar 31 13:33:33 2012 -0400
fix invalid webservice component attributes.
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 f3f06e3..429a395 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
@@ -2079,9 +2079,10 @@ working area for individual server instances</li></ul>"/>
class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="endpoint"/>
+ <c:simple-property name="path" readOnly="true" default="endpoint-config"/>
</plugin-configuration>
+<!--
<metric property="average-processing-time" description="Average endpoint processing time." displayType="summary" units="milliseconds"/>
<metric property="min-processing-time" description="Minimal endpoint processing time." units="milliseconds"/>
<metric property="max-processing-time" description="Maximal endpoint processing time." units="milliseconds"/>
@@ -2089,7 +2090,7 @@ working area for individual server instances</li></ul>"/>
<metric property="request-count" description="Count of requests the endpoint processed." displayType="summary" measurementType="trendsup"/>
<metric property="response-count" description="Count of responses the endpoint generated." measurementType="trendsup"/>
<metric property="fault-count" description="Count of faults the endpoint generated." displayType="summary" measurementType="trendsup"/>
-
+-->
<resource-configuration>
<c:simple-property name="name" required="true" type="string" readOnly="true" description="Webservice endpoint name."/>
<c:simple-property name="context" required="true" type="string" readOnly="true" description="Webservice endpoint context."/>
commit 4ebcfc84e6a07d3dff6bd848465b5ad27a57a650
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Mar 30 11:41:51 2012 -0400
Update configuration data for webservices subsystem afer attribute changes.
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 c0d32b0..f3f06e3 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
@@ -2034,7 +2034,7 @@ working area for individual server instances</li></ul>"/>
<server name="Webservices"
discovery="SubsystemDiscovery"
- class="BaseComponent"
+ class="WebservicesComponent"
singleton="true"
>
@@ -2047,15 +2047,31 @@ working area for individual server instances</li></ul>"/>
<c:simple-property name="path" readOnly="true" default="subsystem=webservices"/>
</plugin-configuration>
+<!-- REMOVING. These are lifecycle operations for AS container itself. Don't think we want to allow
+ customers to be able to remove/add a subsystem via RHQ.
+ <operation name="add" description="Adds the web services subsystem.">
+ <parameters>
+ <c:simple-property name="modify-wsdl-address" required="false" type="boolean" readOnly="false" description="Whether the soap address can be modified."/>
+ <c:simple-property name="wsdl-host" required="false" type="string" readOnly="false" description="The WSDL, that is a required deployment artifact for an endpoint, has a <soap:address> element which points to the location of the endpoint. JBoss supports rewriting of that SOAP address. If the content of <soap:address> is a valid URL, JBossWS will not rewrite it unless 'modify-wsdl-address' is true. If the content of <soap:address> is not a valid URL, JBossWS will rewrite it using the attribute values given below. If 'wsdl-host' is set to 'jbossws.undefined.host', JBossWS uses requesters host when rewriting the <soap:address>"/>
+ <c:simple-property name="wsdl-port" required="false" type="integer" readOnly="false" description="The non-secure port that will be used for rewriting the SOAP address. If absent the port will be identified by querying the list of installed connectors."/>
+ <c:simple-property name="wsdl-secure-port" required="false" type="integer" readOnly="false" description="The secure port that will be used for rewriting the SOAP address. If absent the port will be identified by querying the list of installed connectors."/>
+ </parameters>
+ <results>
+ <c:simple-property name="operationResult" description="Adds the web services subsystem."/>
+ </results>
+ </operation>
+
+ <operation name="remove" description="Removes the web services subsystem.">
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation> -->
+
<resource-configuration>
- <c:simple-property name="modify-soap-address" required="true" type="boolean" readOnly="true"
- description="Whether the soap address can be modified."/>
- <c:simple-property name="webservice-host" required="true" type="string" readOnly="true"
- description="The WSDL, that is a required deployment artifact for an endpoint, has a &soap:address> element which points to the location of the endpoint. JBoss supports rewriting of that SOAP address. If the content of &soap:address> is a valid URL, JBossWS will not rewrite it unless 'modifySOAPAddress' is true. If the content of &soap:address> is not a valid URL, JBossWS will rewrite it using the attribute values given below. If 'webServiceHost' is set to 'jbossws.undefined.host', JBossWS uses requesters host when rewriting the &soap:address>"/>
- <c:simple-property name="webservice-port" type="integer" readOnly="true"
- description="The non-secure port that will be used for rewriting the SOAP address. If absent the port will be identified by querying the list of installed connectors."/>
- <c:simple-property name="webservice-secure-port" type="integer" readOnly="true"
- description="The non-secure port that will be used for rewriting the SOAP address. If absent the port will be identified by querying the list of installed connectors."/>
+ <c:simple-property name="modify-wsdl-address" required="false" type="boolean" readOnly="false" description="Whether the soap address can be modified."/>
+ <c:simple-property name="wsdl-host" required="false" type="string" readOnly="false" description="The WSDL, that is a required deployment artifact for an endpoint, has a <soap:address> element which points to the location of the endpoint. JBoss supports rewriting of that SOAP address. If the content of <soap:address> is a valid URL, JBossWS will not rewrite it unless 'modify-wsdl-address' is true. If the content of <soap:address> is not a valid URL, JBossWS will rewrite it using the attribute values given below. If 'wsdl-host' is set to 'jbossws.undefined.host', JBossWS uses requesters host when rewriting the <soap:address>"/>
+ <c:simple-property name="wsdl-port" required="false" type="integer" readOnly="false" description="The non-secure port that will be used for rewriting the SOAP address. If absent the port will be identified by querying the list of installed connectors."/>
+ <c:simple-property name="wsdl-secure-port" required="false" type="integer" readOnly="false" description="The secure port that will be used for rewriting the SOAP address. If absent the port will be identified by querying the list of installed connectors."/>
</resource-configuration>
<service name="Endpoint"
commit da08bb9c65ffefe88a0578a5b94a3f9e65a81744
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Mar 30 09:06:34 2012 -0400
Exclude a few more shared operations from generated operations descriptor list.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index 347032f..a185461 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -171,6 +171,13 @@ public class Domain2Descriptor {
if (key.equals("write-attribute")) {
continue;
}
+ //exclude a few more shared operations: whoami, undefine-attribute
+ if (key.equals("whoami")) {
+ continue;
+ }
+ if (key.equals("undefine-attribute")) {
+ continue;
+ }
//for each custom operation found, retrieve child hierarchy and pass into
Map<String, Object> value = (Map<String, Object>) attributesMap.get(key);
commit c4847c45f5bf3b26edb7e51d7ef73e256b9c6c3a
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Mar 29 16:04:40 2012 -0400
Some cleanup and more docs.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index ba2e445..347032f 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -49,6 +49,8 @@ public class Domain2Descriptor {
private void run(String[] args) {
+ //process and populate command line args passed in and determine
+ //operation modes.
D2DMode mode = null;
String user = null;
String pass = null;
@@ -87,20 +89,28 @@ public class Domain2Descriptor {
String path = arg;
path = path.replaceAll("/", ","); // Allow path from jboss-cli.sh's
// pwd command
+
+ //spinder 3/29/12: if additional child type info passed in then load it. What does this look like?
String childType = null;
if (args.length > pos + 1) {
childType = args[pos + 1];
}
+ //create connection
ASConnection conn = new ASConnection("localhost", 9990, user, pass);
Address address = new Address(path);
+
+ //create request to get metadata type information
Operation op = new Operation("read-resource-description", address);
+ //recurse down the tree.
op.addAdditionalProperty("recursive", "true");
+ //additionally request operation metadata
if (mode == D2DMode.OPERATION) {
op.addAdditionalProperty("operations", true);
}
+ //additionally request metric metadata
if (mode == D2DMode.METRICS) {
op.addAdditionalProperty("include-runtime", true);
}
@@ -115,6 +125,7 @@ public class Domain2Descriptor {
return;
}
+ //load json object hierarchy of response
Map<String, Object> resMap = res.getResult();
String what;
if (mode == D2DMode.OPERATION) {
@@ -123,8 +134,12 @@ public class Domain2Descriptor {
what = "attributes";
}
+ //Determine which attributes to focus on.
Map<String, Object> attributesMap;
+
+ //when will childtype is actually passed then...
if (childType != null) {
+
Map childMap = (Map) resMap.get("children");
Map<String, Object> typeMap = (Map<String, Object>) childMap.get(childType);
if (typeMap == null) {
@@ -138,16 +153,18 @@ public class Domain2Descriptor {
}
Map starMap = (Map) descriptionMap.get("*");
attributesMap = (Map<String, Object>) starMap.get(what);
- } else {
+ } else {//no child type passed in just load typical map
attributesMap = (Map<String, Object>) resMap.get(what);
}
if (mode == D2DMode.OPERATION) {
+ //populate operations(each special map type) and sort them for ordered listing
Set<String> strings = attributesMap.keySet();
String[] keys = strings.toArray(new String[strings.size()]);
Arrays.sort(keys);
for (String key : keys) {
+ //exclude typical 'read-' and 'write-attribute' operations typical to all types.
if (key.startsWith("read-")) {
continue;
}
@@ -155,6 +172,7 @@ public class Domain2Descriptor {
continue;
}
+ //for each custom operation found, retrieve child hierarchy and pass into
Map<String, Object> value = (Map<String, Object>) attributesMap.get(key);
createOperation(key, value);
}
@@ -177,8 +195,8 @@ public class Domain2Descriptor {
Type ptype = getTypeFromProps(props);
if (ptype == Type.OBJECT && mode != D2DMode.METRICS) {
- System.out.println("<c:map-property name=\"" + key + "\" description=\""
- + props.get("description") + "\" >");
+ System.out.println("<c:map-property name=\"" + key + "\" description=\"" + props.get("description")
+ + "\" >");
Map<String, Object> attributesMap1 = (Map<String, Object>) props.get("attributes");
Map<String, Object> valueTypes = (Map<String, Object>) props.get("value-type");
@@ -200,7 +218,7 @@ public class Domain2Descriptor {
Map<String, Object> emapEntryValue = (Map<String, Object>) emapEntry.getValue();
Type ts = getTypeFromProps(emapEntryValue);
StringBuilder sb = generateProperty(indent, emapEntryValue, ts, emapEntry.getKey(),
- getAccessType(emapEntryValue));
+ getAccessType(emapEntryValue));
System.out.println(sb.toString());
} else {
System.out.println(emapEntry.getValue());
@@ -248,7 +266,7 @@ public class Domain2Descriptor {
HashMap<String, Object> myMap = (HashMap<String, Object>) props.get("value-type");
for (Map.Entry<String, Object> myEntry : myMap.entrySet()) {
createMetricEntry(indent, (Map<String, Object>) myEntry.getValue(),
- key + ":" + myEntry.getKey(), getTypeFromProps(myMap));
+ key + ":" + myEntry.getKey(), getTypeFromProps(myMap));
}
} else {
if (!accessType.equals("metric")) {
@@ -289,32 +307,41 @@ public class Domain2Descriptor {
if (emapEntry.getValue() instanceof Map) {
Map<String, Object> emapEntryValue = (Map<String, Object>) emapEntry.getValue();
- sb = generateProperty(indent, emapEntryValue, getTypeFromProps(emapEntryValue),
- emapEntry.getKey(), getAccessType(emapEntryValue));
+ sb = generateProperty(indent, emapEntryValue, getTypeFromProps(emapEntryValue), emapEntry.getKey(),
+ getAccessType(emapEntryValue));
} else {
sb = new StringBuilder();
- doIndent(indent,sb);
+ doIndent(indent, sb);
sb.append(emapEntry.getValue().toString());
}
System.out.println(sb.toString());
}
+ /** Assumes custom operation for AS7 node.
+ *
+ * @param name of custom operation.
+ * @param operationMap Json node representation of operation details as Map<String,Object>.
+ */
private void createOperation(String name, Map<String, Object> operationMap) {
- if (operationMap == null) {
+ if ((name == null) && (operationMap == null)) {
return;
}
+ //container for flexible string concatenation and each operation
StringBuilder builder = new StringBuilder("<operation name=\"");
builder.append(name).append('"');
+ //description attribute
String description = (String) operationMap.get("description");
appendDescription(builder, description, null);
+ //close xml tag
builder.append(">\n");
+ //detect operation parameters if present.
Map<String, Object> reqMap = (Map<String, Object>) operationMap.get("request-properties");
- if (reqMap != null && !reqMap.isEmpty()) {
+ if (reqMap != null && !reqMap.isEmpty()) {//if present build parameters segment for plugin descriptor.
builder.append(" <parameters>\n");
generatePropertiesForMap(builder, reqMap);
builder.append(" </parameters>\n");
@@ -333,13 +360,21 @@ public class Domain2Descriptor {
System.out.println(builder.toString());
}
+ /** Builds 'description' attribute for an xml node.
+ *
+ * @param builder
+ * @param description
+ * @param defaultValueText
+ */
private void appendDescription(StringBuilder builder, String description, String defaultValueText) {
if (description != null && !description.isEmpty()) {
+ //wrap onto a new line
if (builder.length() > 120) {
builder.append("\n ");
}
builder.append(" description=\"");
+ //trim period off of descriptions for consistency.
if (defaultValueText != null) {
if (description.charAt(description.length() - 1) != '.') {
description += ".";
@@ -347,6 +382,7 @@ public class Domain2Descriptor {
description = description + " " + defaultValueText;
}
+ //replace problematic strings with correct escaped xml references.
description = description.replace("<", "<");
description = description.replace(">", ">");
description = description.replace("\"", "\'");
@@ -370,8 +406,9 @@ public class Domain2Descriptor {
builder.append(generateProperty(4, entryValue, type, entryKey, null));
builder.append('\n');
} else {
+
builder.append("<!--").append(entry.getKey()).append("..").append(entry.getValue().toString())
- .append("-->");
+ .append("-->");
}
}
}
@@ -385,7 +422,7 @@ public class Domain2Descriptor {
}
private StringBuilder generateProperty(int indent, Map<String, Object> props, Type type, String entryName,
- String accessType) {
+ String accessType) {
boolean expressionsAllowed = false;
Boolean tmp = (Boolean) props.get("expressions-allowed");
@@ -466,14 +503,8 @@ public class Domain2Descriptor {
public enum Type {
- STRING(false,"string"),
- INT(true,"integer"),
- BOOLEAN(false,"boolean"),
- LONG(true,"long"),
- BIG_DECIMAL(true,"long"),
- OBJECT(false,"-object-"),
- LIST(false,"-list-"),
- DOUBLE(true,"long");
+ STRING(false, "string"), INT(true, "integer"), BOOLEAN(false, "boolean"), LONG(true, "long"), BIG_DECIMAL(true,
+ "long"), OBJECT(false, "-object-"), LIST(false, "-list-"), DOUBLE(true, "long");
private boolean numeric;
private String rhqName;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
index 9fbe31b..36bf8c2 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Address.java
@@ -83,7 +83,6 @@ public class Address {
String tmp = component.trim();
if (tmp.contains("=")) {
- // strip / from the start of the key if it happens to be there
PROPERTY_VALUE valuePair = pathFromSegment(tmp);
this.path.add(valuePair);
}
commit 75139360af7f2e7da66635cf8f5e9148f99e8b3e
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Tue Mar 27 17:26:26 2012 -0400
Enable operations for modcluster domain mode.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterComponent.java
index e90bd03..94c17cf 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ModClusterComponent.java
@@ -191,4 +191,10 @@ public class ModClusterComponent extends BaseComponent implements OperationFacet
op.addAdditionalProperty(parameterName, value);
}
}
+
+ @Override
+ public Address getAddress() {
+ return new Address(key);
+ }
+
}