modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 5 modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/NamingComponent.java | 92 ++++++++++ modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 24 +- 3 files changed, 107 insertions(+), 14 deletions(-)
New commits: commit 24aff88ad572c843e5817b6e3798a55e1b20be24 Author: Heiko W. Rupp hwr@redhat.com Date: Thu Feb 9 16:12:22 2012 +0100
BZ 742705 - make JNDIView result sensible data again.
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 14022d0..bc0374a 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 @@ -579,11 +579,6 @@ public class BaseComponent<T extends ResourceComponent<?>> implements ResourceCo ((CompositeOperation)operation).addStep(step); } } - } else if (what.equals("naming")) { - if (op.equals("jndi-view")) { - theAddress.add(address); - operation = new Operation("jndi-view",theAddress); - } }
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/NamingComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/NamingComponent.java new file mode 100644 index 0000000..e95c512 --- /dev/null +++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/NamingComponent.java @@ -0,0 +1,92 @@ +package org.rhq.modules.plugins.jbossas7; + +import java.util.Map; + +import org.rhq.core.domain.configuration.Configuration; +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.pluginapi.operation.OperationFacet; +import org.rhq.core.pluginapi.operation.OperationResult; +import org.rhq.modules.plugins.jbossas7.json.Address; +import org.rhq.modules.plugins.jbossas7.json.Operation; +import org.rhq.modules.plugins.jbossas7.json.Result; + +/** + * Component for the naming subsystem + * @author Heiko W. Rupp + */ +public class NamingComponent extends BaseComponent implements OperationFacet { + + @Override + public OperationResult invokeOperation(String name, + Configuration parameters) throws InterruptedException, Exception { + + OperationResult result = new OperationResult(); + + Operation operation; + if (name.equals("jndi-view")) { + Address address = new Address(path); + operation = new Operation("jndi-view",address); + Result res = getASConnection().execute(operation); + + if (!res.isSuccess()) { + result.setErrorMessage(res.getFailureDescription()); + return result; + } + + Configuration config = result.getComplexResults(); + + Map<String,Map> contexts = (Map<String, Map>) res.getResult(); + + String entryName = "java: contexts"; + Map<String,Map> javaContexts = contexts.get(entryName); + PropertyList javaContextsMap = fillMap(javaContexts, "java-contexts", false); + config.put(javaContextsMap); + entryName = "applications"; + Map<String,Map> applications = contexts.get(entryName); + PropertyList applicationsMap = fillMap(applications, entryName, true); + config.put(applicationsMap); + + return result; + } + + return super.invokeOperation(name,parameters); + } + + private PropertyList fillMap(Map<String, Map> contexts, String name, boolean isAppCtx) { + PropertyList pl = new PropertyList(name); + for (String entry : contexts.keySet() ) { + Map<String,Object> map = contexts.get(entry); + if (map==null) + continue; + + for (String innerkey : map.keySet()) { + PropertyMap pm = new PropertyMap(name); + pm.put(new PropertySimple("context",entry)); + pm.put(new PropertySimple("name",innerkey)); + Object val = map.get(innerkey); + if (val!=null) { + if (isAppCtx) { + Map<String,Object> cvmap = (Map<String, Object>) val; + if (cvmap.containsKey("AppName")) { + Map<String,String> nameMap = (Map<String, String>) cvmap.get("AppName"); + pm.put(new PropertySimple("value", nameMap.get("value"))); + } + else + pm.put(new PropertySimple("value",val.toString() )); + } + else { + Map<String,String> cvmap = (Map<String, String>) val; + String clazz = cvmap.get("class-name"); + String value = cvmap.get("value"); + pm.put(new PropertySimple("value",clazz + "="+ value)); + } + } + pl.add(pm); + } + } + + return pl; + } +} 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 a3552a4..94fe410 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 @@ working area for individual server instances</li></ul>"/>
<server name="Naming" discovery="SubsystemDiscovery" - class="BaseComponent" + class="NamingComponent" singleton="true" >
@@ -2016,15 +2016,21 @@ working area for individual server instances</li></ul>"/> <c:simple-property name="path" readOnly="true" default="subsystem=naming"/> </plugin-configuration>
- <operation name="naming:jndi-view" displayName="JNDIView" description="Peek at the JNDI tree"> + <operation name="jndi-view" displayName="JNDIView" description="Peek at the JNDI tree"> <results> - <c:list-property name="operationResult"> - <c:list-property name="innerContext"> - <c:map-property name="innerContexts"> - <c:simple-property name="class-name"/> - <c:simple-property name="value"/> - </c:map-property> - </c:list-property> + <c:list-property name="java-contexts"> + <c:map-property name="context"> + <c:simple-property name="context" /> + <c:simple-property name="name"/> + <c:simple-property name="value"/> + </c:map-property> + </c:list-property> + <c:list-property name="applications"> + <c:map-property name="context"> + <c:simple-property name="context" /> + <c:simple-property name="name"/> + <c:simple-property name="value"/> + </c:map-property> </c:list-property> </results> </operation>
rhq-commits@lists.fedorahosted.org