modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
| 111 ++++++++--
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
| 53 ++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
| 4
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
| 42 +++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
| 67 +-----
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/OperationDescription.java
| 80 +++++++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java
| 4
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
| 73 ++++--
8 files changed, 335 insertions(+), 99 deletions(-)
New commits:
commit f70a35bfea7d230783b3079a2d16edcf0b60adb0
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Mar 23 16:47:25 2011 +0100
Include more items and allow for reading of list properties.
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 005421d..c136b20 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
@@ -23,17 +23,22 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
+import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.jetbrains.annotations.Nullable;
+import org.omg.CORBA.NamedValue;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
/**
* Provide connections to the AS and reading / writing date from/to it.
@@ -83,7 +88,7 @@ public class ASConnection {
* Return the JSON-Ojbect for a certain path.
*
* @param base Path to the object/subsystem. Can be null/"" for the base
objects
- * @param ops Operation to run on the api can be null
+ * @param ops OperationDescription to run on the api can be null
* @return A JSONObject encoding the level plus sub levels provided
* @throws Exception If anything goes wrong
*/
@@ -151,21 +156,62 @@ public class ASConnection {
try {
URL url = getBaseUrl(path,"operation="+s);
- URLConnection conn = url.openConnection();
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setDoOutput(true);
+// conn.setRequestMethod("POST");
OutputStream out = conn.getOutputStream();
ObjectMapper mapper = new ObjectMapper();
- mapper.writeValue(out,nvp);
+
+ Operation operation = new Operation();
+ operation.operation=s;
+ operation.nvp=nvp;
+ operation.address=pathToAddress(path);
+
+
+ String result = mapper.writeValueAsString(operation);
+ System.out.println("Json to send: " + result);
+ mapper.writeValue(out, operation);
+
out.flush();
out.close();
+
+ InputStream inputStream;
+ if (conn.getResponseCode()==HttpURLConnection.HTTP_OK) {
+ inputStream = conn.getInputStream();
+
+ BufferedReader in = new BufferedReader(new InputStreamReader(
+ inputStream));
+ String line;
+ StringBuilder builder = new StringBuilder();
+ while ((line = in.readLine()) != null) {
+ builder.append(line);
+ }
+ System.out.println(builder.toString());
+ }
+
} catch (IOException e) {
e.printStackTrace(); // TODO: Customise this generated block
}
}
+ private List<NameValuePair> pathToAddress(String path) {
+ if (path.endsWith("/"))
+ path = path.substring(0,path.length()-1);
+ if (path.startsWith("/"))
+ path = path.substring(1);
+ List<NameValuePair> result = new ArrayList<NameValuePair>();
+ String[] components = path.split("/");
+ for (int i = 0; i < components.length ; i+=2) {
+ NameValuePair valuePair = new NameValuePair(components[i],components[i+1]);
+ result.add(valuePair);
+ }
+
+ return result;
+ }
private URL getBaseUrl(String base, String ops) throws MalformedURLException {
String spec;
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index ca746e0..28c0592 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -24,9 +24,12 @@ import org.codehaus.jackson.JsonNode;
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.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
@@ -44,6 +47,8 @@ import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -144,14 +149,26 @@ public class BaseComponent implements ResourceComponent,
MeasurementFacet, Confi
public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition configDef =
context.getResourceType().getResourceConfigurationDefinition();
- JsonNode json = connection.getLevelData(path,false,false);
+ JsonNode json = connection.getLevelData(key,false,false); // TODO path ? key?
Configuration ret = new Configuration();
for (PropertyDefinition propDef: configDef.getNonGroupedProperties()) {
JsonNode sub = json.findValue(propDef.getName());
- PropertySimple propertySimple = new
PropertySimple(propDef.getName(),sub.getValueAsText());
- ret.put(propertySimple);
+ if (propDef instanceof PropertyDefinitionSimple) {
+ PropertySimple propertySimple = new
PropertySimple(propDef.getName(),sub.getValueAsText());
+ ret.put(propertySimple);
+ } else if (propDef instanceof PropertyDefinitionList) {
+ PropertyList propertyList = new PropertyList(propDef.getName());
+ Iterator<JsonNode> values = sub.getElements();
+ while (values.hasNext()) {
+ JsonNode node = values.next();
+ String value = node.getTextValue();
+ PropertySimple propertySimple = new
PropertySimple(propDef.getName(),value);
+ propertyList.add(propertySimple);
+ }
+ ret.put(propertyList);
+ }
}
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
index 83d0e3e..571dbab 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
@@ -61,7 +61,11 @@ public class BaseDiscovery implements ResourceDiscoveryComponent
serverNameFull = "ASManager";
} else {
serverNameFull = getBaseDirFromCommandLine(commandLine);
+ if (serverNameFull==null || serverNameFull.isEmpty())
+ serverNameFull="JBossAS7";
serverName =
serverNameFull.substring(serverNameFull.lastIndexOf("/")+1);
+ if (serverName.isEmpty())
+ serverName = serverNameFull;
// DomainClient client =
DomainClient.Factory.create(InetAddress.getByName("localhost"),9990); //
// Map<ServerIdentity,ServerStatus> serverStatuses =
client.getServerStatuses();
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
index 9c8ca19..ff3f10c 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
@@ -18,6 +18,8 @@
*/
package org.rhq.modules.plugins.jbossas7.json;
+import org.codehaus.jackson.annotate.JsonValue;
+
/**
*
* @author Heiko W. Rupp
@@ -31,4 +33,10 @@ public class NameValuePair {
this.name = name;
this.value = value;
}
+
+ @JsonValue
+ @Override
+ public String toString() {
+ return name +":"+ value ;
+ }
}
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
index f00c421..4f5cda1 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -18,63 +18,30 @@
*/
package org.rhq.modules.plugins.jbossas7.json;
-import java.util.Map;
+import java.util.List;
-import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.annotate.JsonValue;
/**
- * // TODO: Document this
+ * Operation to run on the server
* @author Heiko W. Rupp
*/
public class Operation {
- @JsonProperty("operation-name")
- public String operationName;
- public String description;
- @JsonProperty("request-properties")
- public Map<String,As7RequestProperty> requestProperties;
-// @JsonProperty("reply-properties")
-// public ArrayList<As7ReplyProperty> replyProperties;
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("Operation");
-
sb.append("{operationName='").append(operationName).append('\'');
- sb.append(",
description='").append(description).append('\'');
- sb.append(", requestProperties=").append(requestProperties);
-// sb.append(", replyProperties=").append(replyProperties);
- sb.append('}');
- return sb.toString();
- }
+ public String operation;
+ public List<NameValuePair> address;
- public static class As7RequestProperty {
- public String description;
- public boolean required;
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("As7RequestProperty");
-
sb.append("{description='").append(description).append('\'');
- sb.append(", required=").append(required);
- sb.append('}');
- return sb.toString();
- }
- }
+ public NameValuePair nvp;
- public static class As7ReplyProperty {
- @JsonProperty("value-type")
- public String valueType;
- public String description;
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("As7ReplyProperty");
-
sb.append("{valueType='").append(valueType).append('\'');
- sb.append(",
description='").append(description).append('\'');
- sb.append('}');
- return sb.toString();
- }
+ @JsonValue
+ public String toString() {
+ StringBuilder b = new StringBuilder();
+ b.append("{");
+ b.append("operation:").append(operation).append(",\n");
+ b.append("address:").append(address).append(",\n");
+ b.append(nvp);
+ b.append("}");
+ return b.toString();
}
}
+
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/OperationDescription.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/OperationDescription.java
new file mode 100644
index 0000000..18b3a40
--- /dev/null
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/OperationDescription.java
@@ -0,0 +1,80 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * 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.json;
+
+import java.util.Map;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * // TODO: Document this
+ * @author Heiko W. Rupp
+ */
+public class OperationDescription {
+ @JsonProperty("operation-name")
+ public String operationName;
+ public String description;
+ @JsonProperty("request-properties")
+ public Map<String,As7RequestProperty> requestProperties;
+// @JsonProperty("reply-properties")
+// public ArrayList<As7ReplyProperty> replyProperties;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("OperationDescription");
+
sb.append("{operationName='").append(operationName).append('\'');
+ sb.append(",
description='").append(description).append('\'');
+ sb.append(", requestProperties=").append(requestProperties);
+// sb.append(", replyProperties=").append(replyProperties);
+ sb.append('}');
+ return sb.toString();
+ }
+
+ public static class As7RequestProperty {
+ public String description;
+ public boolean required;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("As7RequestProperty");
+
sb.append("{description='").append(description).append('\'');
+ sb.append(", required=").append(required);
+ sb.append('}');
+ return sb.toString();
+ }
+ }
+
+ public static class As7ReplyProperty {
+ @JsonProperty("value-type")
+ public String valueType;
+ public String description;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("As7ReplyProperty");
+
sb.append("{valueType='").append(valueType).append('\'');
+ sb.append(",
description='").append(description).append('\'');
+ sb.append('}');
+ return sb.toString();
+ }
+ }
+}
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java
index 89b41a0..7774cd3 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java
@@ -37,7 +37,7 @@ public class Subsystem {
@JsonProperty("attributes") Map <String,Attribute> attributes;
@JsonProperty("model-description")
Subsystem modelDescription;
- @JsonProperty("operations") Map<String,Operation> operations = new
HashMap<String, Operation>();
+ @JsonProperty("operations") Map<String,OperationDescription>
operations = new HashMap<String, OperationDescription>();
public Map<String,Subsystem> children;
@@ -57,7 +57,7 @@ public class Subsystem {
sb.append(",
model-description=").append(modelDescription).append('\n');
sb.append("\n, operations=");
if (operations!=null) {
- for (Map.Entry<String,Operation> ops : operations.entrySet())
+ for (Map.Entry<String,OperationDescription> ops :
operations.entrySet())
sb.append(" ").append(ops).append('\n');
}
sb.append(", children=").append(children).append('\n');
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 81da4b6..9a04f04 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,6 +169,7 @@
<c:simple-property name="path" readOnly="true"
default="/subsystem/web/connector/*"/>
</plugin-configuration>
+
<metric property="bytesSent"
measurementType="trendsup"/>
<metric property="bytesReceived"
measurementType="trendsup"/>
<metric property="processingTime"
measurementType="trendsup"/>
@@ -176,6 +177,12 @@
<metric property="maxTime" />
<metric property="requestCount"
measurementType="trendsup"/>
+ <resource-configuration>
+ <c:simple-property name="protocol"
required="false" description="The web connector protocol."/>
+ <c:simple-property name="socket-binding"
required="false" description="The web connector socket-binding reference,
this connector should be bound to."/>
+ <c:simple-property name="scheme"
required="false" description="The web connector scheme"/>
+ </resource-configuration>
+
</service>
<service name="VHost"
@@ -185,6 +192,11 @@
<c:simple-property name="path" readOnly="true"
default="/subsystem/web/virtual-server/*"/>
</plugin-configuration>
+ <resource-configuration>
+ <c:simple-property name="access-log"/>
+ <c:list-property name="alias" description="The
virtual server aliases"/>
+ <c:simple-property name="rewrite"/>
+ </resource-configuration>
</service>
@@ -209,8 +221,8 @@
</plugin-configuration>
<resource-configuration>
- <c:simple-property name="default-interface"
readOnly="true" displayName="Default Interface"
description="Default Interface for these bindings. See NetworkInterfaces for its
definition"/>
- <c:simple-property name="port-offset"
readOnly="true" displayName="Port Offset" description="Offset
from standard ports for this group"/>
+ <c:simple-property name="default-interface"
readOnly="true" displayName="Default Interface"
description="Default Interface for these bindings. See NetworkInterfaces for its
definition" required="false"/>
+ <c:simple-property name="port-offset"
readOnly="true" displayName="Port Offset" description="Offset
from standard ports for this group" required="false"/>
</resource-configuration>
<service name="SocketBinding"
commit 3914a1c51bcb6f24e70ff2243664778b79b04873
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Mar 23 10:41:56 2011 +0100
Add support for reading of resource-config
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 6b64b7b..005421d 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
@@ -22,6 +22,7 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
@@ -32,6 +33,8 @@ import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.jetbrains.annotations.Nullable;
+import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+
/**
* Provide connections to the AS and reading / writing date from/to it.
* @author Heiko W. Rupp
@@ -88,23 +91,7 @@ public class ASConnection {
URL url2;
String spec;
- if (base!=null && !base.isEmpty()) {
- if (!base.startsWith("/")) {
- spec = urlString + "/" + base;
- }
- else {
- spec = urlString + base;
- }
- if (ops!=null) {
- if (!ops.startsWith("?"))
- ops = "?" + ops;
- spec += ops;
- }
-
- url2 = new URL(spec);
- }
- else
- url2 = url;
+ url2 = getBaseUrl(base, ops);
JsonNode tree = null;
@@ -160,5 +147,47 @@ public class ASConnection {
return false;
}
+ public void execute(String path, String s, NameValuePair nvp) {
+
+ try {
+ URL url = getBaseUrl(path,"operation="+s);
+ URLConnection conn = url.openConnection();
+ OutputStream out = conn.getOutputStream();
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.writeValue(out,nvp);
+ out.flush();
+ out.close();
+ } catch (IOException e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ }
+
+ }
+
+
+
+
+ private URL getBaseUrl(String base, String ops) throws MalformedURLException {
+ String spec;
+ URL url2;
+ if (base!=null && !base.isEmpty()) {
+ if (!base.startsWith("/")) {
+ spec = urlString + "/" + base;
+ }
+ else {
+ spec = urlString + base;
+ }
+ if (ops!=null) {
+ if (!ops.startsWith("?"))
+ ops = "?" + ops;
+ spec += ops;
+ }
+
+ url2 = new URL(spec);
+ }
+ else
+ url2 = url;
+ return url2;
+ }
}
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 2f293d9..ca746e0 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -23,12 +23,18 @@ import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.core.domain.measurement.MeasurementDataTrait;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
@@ -36,10 +42,12 @@ import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationContext;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+import java.util.Map;
import java.util.Set;
-public class BaseComponent implements ResourceComponent, MeasurementFacet
+public class BaseComponent implements ResourceComponent, MeasurementFacet,
ConfigurationFacet
{
private final Log log = LogFactory.getLog(this.getClass());
@@ -134,7 +142,33 @@ public class BaseComponent implements ResourceComponent,
MeasurementFacet
protected String getPath() { return path; }
+ public Configuration loadResourceConfiguration() throws Exception {
+ ConfigurationDefinition configDef =
context.getResourceType().getResourceConfigurationDefinition();
+ JsonNode json = connection.getLevelData(path,false,false);
+ Configuration ret = new Configuration();
+
+ for (PropertyDefinition propDef: configDef.getNonGroupedProperties()) {
+ JsonNode sub = json.findValue(propDef.getName());
+ PropertySimple propertySimple = new
PropertySimple(propDef.getName(),sub.getValueAsText());
+ ret.put(propertySimple);
+ }
+
+
+ return ret;
+ }
+
+ public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ Configuration conf = report.getConfiguration();
+ for (Map.Entry<String, PropertySimple> entry :
conf.getSimpleProperties().entrySet()) {
+
+ NameValuePair nvp = new
NameValuePair(entry.getKey(),entry.getValue().getStringValue());
+ connection.execute(path,"write-attribute",nvp);
+ }
+
+
+ // TODO: Customise this generated block
+ }
}
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
new file mode 100644
index 0000000..9c8ca19
--- /dev/null
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
@@ -0,0 +1,34 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * 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.json;
+
+/**
+ *
+ * @author Heiko W. Rupp
+ */
+public class NameValuePair {
+
+ public String name;
+ public String value;
+
+ public NameValuePair(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+}
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 98a97d8..81da4b6 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
@@ -93,7 +93,7 @@
</server>
- <server name="JBossAS7 (Standalone)"
+ <server name="JBossAS7-Standalone"
discovery="BaseDiscovery"
class="BaseComponent"
@@ -127,29 +127,29 @@
/>
-->
- <server name="Messaging"
+ <server name="Messaging"
discovery="SubsystemDiscovery"
class="BaseComponent">
<plugin-configuration>
<c:simple-property name="path" readOnly="true"
default="/subsystem/messaging"/>
</plugin-configuration>
- <resource-configuration>
- <c:simple-property name="journal-min-files" />
- <c:simple-property name="journal-type" />
- </resource-configuration>
+ <resource-configuration>
+ <c:simple-property name="journal-min-files" />
+ <c:simple-property name="journal-type" />
+ </resource-configuration>
- <service name="Acceptor"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
-
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true"
default="/subsystem/messaging/acceptor"/>
- </plugin-configuration>
+ <service name="Acceptor"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+
+
<plugin-configuration>
+ <c:simple-property name="path" readOnly="true"
default="/subsystem/messaging/acceptor"/>
+ </plugin-configuration>
- </service>
+ </service>
</server>
@@ -164,7 +164,7 @@
<service name="Connector"
discovery="SubsystemDiscovery"
class="BaseComponent"
-
+
<plugin-configuration>
<c:simple-property name="path" readOnly="true"
default="/subsystem/web/connector/*"/>
</plugin-configuration>
@@ -176,11 +176,11 @@
<metric property="maxTime" />
<metric property="requestCount"
measurementType="trendsup"/>
- </service>
+ </service>
<service name="VHost"
- discovery="SubsystemDiscovery"
- class="BaseComponent">
+ discovery="SubsystemDiscovery"
+ class="BaseComponent">
<plugin-configuration>
<c:simple-property name="path" readOnly="true"
default="/subsystem/web/virtual-server/*"/>
</plugin-configuration>
@@ -196,32 +196,37 @@
class="BaseComponent"
description="A named network interface, along with required
criteria for determining the IP address to associate with that interface">
<plugin-configuration>
- <c:simple-property name="path" readOnly="true"
default="/"/>
+ <c:simple-property name="path" readOnly="true"
default="/"/>
</plugin-configuration>
</service>
<service name="SocketBindingGroup"
discovery="SocketBindingGroupDiscovery"
class="BaseComponent"
-
+
<plugin-configuration>
<c:simple-property name="path" readOnly="true"
default="/socket-binding-group/"/>
</plugin-configuration>
+ <resource-configuration>
+ <c:simple-property name="default-interface"
readOnly="true" displayName="Default Interface"
description="Default Interface for these bindings. See NetworkInterfaces for its
definition"/>
+ <c:simple-property name="port-offset"
readOnly="true" displayName="Port Offset" description="Offset
from standard ports for this group"/>
+ </resource-configuration>
+
<service name="SocketBinding"
discovery="SocketBindingDiscovery"
class="BaseComponent">
<plugin-configuration>
- <c:simple-property name="path"
readOnly="true"/>
+ <c:simple-property name="path"
readOnly="true"/>
</plugin-configuration>
- </service>
- </service>
+ </service>
+ </service>
</server>
- <server name="JBossAS (Managed)"
+ <server name="JBossAS-Managed"
discovery="BaseDiscovery"
class="BaseComponent"
@@ -238,9 +243,9 @@
<metric property="serverGroup" dataType="trait"
displayType="summary" />
<resource-configuration>
<!--<c:group name="interfaces">-->
- <c:simple-property name="loopback"
default="127.0.0.1" />
- <c:simple-property name="external" default="any"
/>
- <c:simple-property name="public" default="any"
/>
+ <c:simple-property name="loopback" default="127.0.0.1"
/>
+ <c:simple-property name="external" default="any"
/>
+ <c:simple-property name="public" default="any" />
<!--</c:group>-->
</resource-configuration>
@@ -251,7 +256,7 @@
discovery="org.rhq.plugins.jmx.LocalJMXServerDiscoveryComponent"
class="org.rhq.plugins.jmx.JMXServerComponent"
singleton="true"
- />
+ />
</server>