modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
| 5
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
| 47 +++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
| 16 -
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
| 123 +++++-----
4 files changed, 120 insertions(+), 71 deletions(-)
New commits:
commit ba753e1d0ce503b7252ae9e92cbdb9b810ec4519
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Mar 28 22:12:31 2011 +0200
Add server-groups and hosts to the domain.
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 a2b5335..788531b 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
@@ -53,6 +53,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import com.sun.org.apache.xml.internal.security.utils.Base64;
+
public class BaseComponent implements ResourceComponent, MeasurementFacet,
ConfigurationFacet
{
private final Log log = LogFactory.getLog(this.getClass());
@@ -147,13 +149,22 @@ public class BaseComponent implements ResourceComponent,
MeasurementFacet, Confi
public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition configDef =
context.getResourceType().getResourceConfigurationDefinition();
- BaseComponent parentComponent = (BaseComponent)
context.getParentResourceComponent();
+ ResourceComponent parentResourceComponent =
context.getParentResourceComponent();
+ String parentPath =null;
String myPath;
- String parentPath = parentComponent.getPath();
- if (parentPath.endsWith("/") || path.startsWith("/"))
- myPath = parentPath + path;
+ if (parentResourceComponent instanceof BaseComponent) {
+ BaseComponent parentComponent = (BaseComponent) parentResourceComponent;
+ parentPath = parentComponent.getPath();
+ }
+
+ if (parentPath!=null) {
+ if (parentPath.endsWith("/") || path.startsWith("/"))
+ myPath = parentPath + path;
+ else
+ myPath = parentPath + "/" + path;
+ }
else
- myPath = parentPath + "/" + path;
+ myPath = path;
JsonNode json = connection.getLevelData(myPath,true,false);
@@ -169,19 +180,30 @@ public class BaseComponent implements ResourceComponent,
MeasurementFacet, Confi
if (sub!=null)
propertySimple = new
PropertySimple(propDef.getName(),sub.getValueAsText());
else {
- propertySimple = new PropertySimple(propDef.getName(),null); // TODO
store it at all?
+ propertySimple = new PropertySimple(propDef.getName(),null); // TODO
store it at all when it is null?
}
ret.put(propertySimple);
} else if (propDef instanceof PropertyDefinitionList) {
PropertyList propertyList = new PropertyList(propDef.getName());
PropertyDefinition memberDefinition = ((PropertyDefinitionList)
propDef).getMemberDefinition();
if (memberDefinition ==null) {
- 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);
+ if (sub.isObject()) {
+ Iterator<String> fields = sub.getFieldNames();
+ while(fields.hasNext()) {
+ String fieldName = fields.next();
+ JsonNode subNode = sub.get(fieldName);
+ PropertySimple propertySimple = new
PropertySimple(propDef.getName(),fieldName);
+ propertyList.add(propertySimple);
+ }
+ } else {
+ System.out.println("===Sub not object==="); // TODO
evaluate this branch again
+ 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);
+ }
}
}
else if (memberDefinition instanceof PropertyDefinitionMap) {
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 8176e8a..2825e10 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
@@ -104,6 +104,26 @@
<c:simple-property name="path"
default="/server-group/*" readOnly="true"/>
</plugin-configuration>
+ <resource-configuration>
+ <c:simple-property name="profile" />
+ <c:simple-property name="socket-binding-group"/>
+ <c:simple-property name="jvm"/>
+ <c:simple-property name="deployment"
required="false"/> <!-- TODO change structure. Or put below as resource?
-->
+ </resource-configuration>
+ </server>
+ <server name="Host"
+ description="Host involved in this domain"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" default="/host/*"
readOnly="true"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:list-property name="server-config" />
+ </resource-configuration>
+
</server>
</server>
@@ -128,11 +148,6 @@
<process-scan name="StandaloneAS"
query="process|basename|match=^java.*,arg|org.jboss.as.standalone|match=.*"/>
- <operation name="dummyOperation">
- <!-- TODO supply parameters and return values -->
- </operation>
-
-
<resource-configuration>
<c:list-property name="schema-locations"
displayName="Schema locations">
<c:map-property name="location">
@@ -162,17 +177,6 @@
<process-scan name="ManagedAS"
query="process|basename|match=^java.*,arg|org.jboss.as.server|match=.*"/>
-
- <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:group>-->
- </resource-configuration>
-
-
</server>
@@ -290,6 +294,7 @@
<runs-inside>
<parent-resource-type name="Domain"
plugin="jboss-as-7"/>
+ <parent-resource-type name="Host"
plugin="jboss-as-7"/>
<parent-resource-type name="JBossAS7-Standalone"
plugin="jboss-as-7"/>
</runs-inside>
commit 76830060b0233e12f319b7baae24fd23d850756d
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Mar 28 17:55:31 2011 +0200
More path handling improvements.
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 c626c49..192a54f 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
@@ -138,6 +138,9 @@ public class ASConnection {
boolean isErrorReply(JsonNode in) {
+ if (in == null)
+ return true;
+
if (in.has("outcome")) {
String outcome = null;
try {
@@ -262,6 +265,8 @@ public class ASConnection {
}
public String getFailureDescription(JsonNode jsonNode) {
+ if (jsonNode==null)
+ return "getFailureDescription: -input was null-";
JsonNode node = jsonNode.findValue("failure-description");
return node.getValueAsText();
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 9407172..a2b5335 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
@@ -147,7 +147,16 @@ public class BaseComponent implements ResourceComponent,
MeasurementFacet, Confi
public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition configDef =
context.getResourceType().getResourceConfigurationDefinition();
- JsonNode json = connection.getLevelData(path,true,false); // TODO path ? key?
+ BaseComponent parentComponent = (BaseComponent)
context.getParentResourceComponent();
+ String myPath;
+ String parentPath = parentComponent.getPath();
+ if (parentPath.endsWith("/") || path.startsWith("/"))
+ myPath = parentPath + path;
+ else
+ myPath = parentPath + "/" + path;
+
+
+ JsonNode json = connection.getLevelData(myPath,true,false);
Configuration ret = new Configuration();
ObjectMapper mapper = new ObjectMapper();
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index 4cde830..b577407 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -19,6 +19,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.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
@@ -89,6 +90,8 @@ public class SubsystemDiscovery implements
ResourceDiscoveryComponent<BaseCompon
String subPath = path.substring(i+1);
JsonNode subNode = json.findPath(subPath);
+ if (subNode==null || subNode.isNull())
+ subNode = json.get(subPath); // TODO clean this up. to get the
'key' in a path from the AS we need to use get()
Map<String,Subsystem> subsystemMap = mapper.readValue(subNode,new
TypeReference<Map<String,Subsystem>>() {});
@@ -97,7 +100,9 @@ public class SubsystemDiscovery implements
ResourceDiscoveryComponent<BaseCompon
String key = entry.getKey();
Subsystem subsystem = entry.getValue();
String newPath = cpath.replaceAll("\\*",key);
- config.getSimple("path").setStringValue(newPath);
+ Configuration config2 = context.getDefaultPluginConfiguration();
+ PropertySimple pathProp = new
PropertySimple("path",newPath);
+ config2.put(pathProp);
String resKey = context.getParentResourceContext().getResourceKey() +
"/" + key;
String name = resKey.substring(resKey.lastIndexOf("/") +
1);
@@ -109,7 +114,7 @@ public class SubsystemDiscovery implements
ResourceDiscoveryComponent<BaseCompon
name, // Name
null, // Version
subsystem.description, // Description
- config,
+ config2,
null);
details.add(detail);
}
@@ -120,7 +125,10 @@ public class SubsystemDiscovery implements
ResourceDiscoveryComponent<BaseCompon
String resKey = path;
String name = resKey.substring(resKey.lastIndexOf("/") + 1);
- config.getSimple("path").setStringValue(path);
+ Configuration config2 = context.getDefaultPluginConfiguration();
+ PropertySimple pathProp = new PropertySimple("path",path);
+ config2.put(pathProp);
+
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
@@ -129,7 +137,7 @@ public class SubsystemDiscovery implements
ResourceDiscoveryComponent<BaseCompon
name, // Name
null, // Version
path, // Description
- config,
+ config2,
null);
details.add(detail);
}
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 654ee06..8176e8a 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
@@ -96,7 +96,7 @@
<c:simple-property name="path"
default="/profile/*" readOnly="true"/>
</plugin-configuration>
</server>
- <server name="ServerGroups"
+ <server name="ServerGroup"
description="Server groups on this domain"
discovery="SubsystemDiscovery"
class="BaseComponent">
@@ -283,54 +283,54 @@
</server>
- <service name="NetworkInterface"
- discovery="InterfaceDiscovery"
- class="BaseComponent"
- description="A named network interface, along with required
criteria for determining the IP address to associate with that interface">
+ <service name="NetworkInterface"
+ discovery="InterfaceDiscovery"
+ class="BaseComponent"
+ description="A named network interface, along with required criteria
for determining the IP address to associate with that interface">
- <runs-inside>
- <parent-resource-type name="Domain"
plugin="jboss-as-7"/>
- <parent-resource-type name="JBossAS7-Standalone"
plugin="jboss-as-7"/>
- </runs-inside>
+ <runs-inside>
+ <parent-resource-type name="Domain"
plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone"
plugin="jboss-as-7"/>
+ </runs-inside>
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true"
default="/"/>
- </plugin-configuration>
- </service>
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true"
default="/"/>
+ </plugin-configuration>
+ </service>
- <service name="SocketBindingGroup"
- discovery="SocketBindingGroupDiscovery"
- class="BaseComponent"
- >
- <runs-inside>
- <parent-resource-type name="Domain"
plugin="jboss-as-7"/>
- <parent-resource-type name="JBossAS7-Standalone"
plugin="jboss-as-7"/>
- </runs-inside>
+ <service name="SocketBindingGroup"
+ discovery="SocketBindingGroupDiscovery"
+ class="BaseComponent"
+ >
+ <runs-inside>
+ <parent-resource-type name="Domain"
plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone"
plugin="jboss-as-7"/>
+ </runs-inside>
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true"
default="/socket-binding-group/"/>
- </plugin-configuration>
+ <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" required="false"/>
- <!-- note: at domain level there is no port-offset -->
- <c:simple-property name="port-offset"
readOnly="true" displayName="Port Offset" description="Offset
from standard ports for this group" required="false"/>
- <c:list-property name="include">
- <c:simple-property name="binding"
displayName="Included bindings" description="Other bindings that are
included in this one"/>
- </c:list-property>
- <c:list-property name="socket-binding">
- <c:map-property name="binding">
- <c:simple-property name="name" description="The
name of the socket. Services which need to access the socket configuration information
will find it using this name."/>
- <c:simple-property name="interface"
description="Name of the interface to which the socket should be bound, or, for
multicast sockets, the interface on which it should listen. This should be one of the
declared interfaces." required="false"/>
- <c:simple-property name="port"
description="Number of the port to which the socket should be bound."
type="integer"/>
- <c:simple-property name="fixed-port"
description="Whether the port value should remain fixed even if numeric offsets are
applied to the other sockets in the socket group." type="boolean"/>
- <c:simple-property name="multicast-address"
description="Multicast address on which the socket should receive multicast traffic.
If unspecified, the socket will not be configured to receive multicast." />
- <c:simple-property name="multicast-port"
description="Port on which the socket should receive multicast traffic. Must be
configured if 'multicast-address' is configured."
type="integer"/>
- </c:map-property>
- </c:list-property>
- </resource-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" required="false"/>
+ <!-- note: at domain level there is no port-offset -->
+ <c:simple-property name="port-offset" readOnly="true"
displayName="Port Offset" description="Offset from standard ports for this
group" required="false"/>
+ <c:list-property name="include">
+ <c:simple-property name="binding" displayName="Included
bindings" description="Other bindings that are included in this one"/>
+ </c:list-property>
+ <c:list-property name="socket-binding">
+ <c:map-property name="binding">
+ <c:simple-property name="name" description="The
name of the socket. Services which need to access the socket configuration information
will find it using this name."/>
+ <c:simple-property name="interface"
description="Name of the interface to which the socket should be bound, or, for
multicast sockets, the interface on which it should listen. This should be one of the
declared interfaces." required="false"/>
+ <c:simple-property name="port" description="Number
of the port to which the socket should be bound." type="integer"/>
+ <c:simple-property name="fixed-port"
description="Whether the port value should remain fixed even if numeric offsets are
applied to the other sockets in the socket group." type="boolean"/>
+ <c:simple-property name="multicast-address"
description="Multicast address on which the socket should receive multicast traffic.
If unspecified, the socket will not be configured to receive multicast." />
+ <c:simple-property name="multicast-port"
description="Port on which the socket should receive multicast traffic. Must be
configured if 'multicast-address' is configured."
type="integer"/>
+ </c:map-property>
+ </c:list-property>
+ </resource-configuration>
- </service>
+ </service>
</plugin>