[jboss-cvs] JBossAS SVN: r101022 - in branches/Branch_Hornet_Temporary_2/hornetq-int/src: main/java/org/jboss/as/integration/hornetq/jopr/util and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Feb 16 09:48:43 EST 2010
Author: ataylor
Date: 2010-02-16 09:48:43 -0500 (Tue, 16 Feb 2010)
New Revision: 101022
Added:
branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQJMXDiscoveryComponent.java
branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/BeanNotAvailableException.java
Modified:
branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQDiscoveryComponent.java
branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQServerDiscoveryComponent.java
branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/EMSHelper.java
branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/Invoker.java
branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/JMXInvoker.java
branches/Branch_Hornet_Temporary_2/hornetq-int/src/resources/META-INF/rhq-plugin.xml
Log:
fixes for jopr plugin
Modified: branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQDiscoveryComponent.java
===================================================================
--- branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQDiscoveryComponent.java 2010-02-16 14:44:02 UTC (rev 101021)
+++ branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQDiscoveryComponent.java 2010-02-16 14:48:43 UTC (rev 101022)
@@ -15,12 +15,12 @@
import org.jboss.as.integration.hornetq.jopr.util.EMSHelper;
import org.jboss.as.integration.hornetq.jopr.util.Invoker;
import org.jboss.as.integration.hornetq.jopr.util.JMXInvoker;
+import org.mc4j.ems.connection.EmsConnection;
import org.mc4j.ems.connection.bean.EmsBean;
+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.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.pluginapi.inventory.*;
+import org.rhq.plugins.jmx.JMXDiscoveryComponent;
import java.util.HashSet;
import java.util.List;
@@ -33,13 +33,13 @@
* @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
* Created Jan 27, 2010
*/
-public class HornetQDiscoveryComponent implements ResourceDiscoveryComponent
+public class HornetQDiscoveryComponent extends HornetQJMXDiscoveryComponent implements ResourceDiscoveryComponent//, ManualAddFacet
{
-
public Set<DiscoveredResourceDetails> discoverResources(final ResourceDiscoveryContext ctx) throws InvalidPluginConfigurationException, Exception
{
Set<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
+ MBeanComponent mBeanComponent = (MBeanComponent) ctx.getParentResourceComponent();
Map<String, PropertySimple> props = ctx.getDefaultPluginConfiguration().getSimpleProperties();
PropertySimple objectNameProperty = props.get(OBJECT_NAME);
PropertySimple useParentObjectName = props.get(USE_PARENT_OBJECT_NAME);
@@ -47,6 +47,10 @@
PropertySimple searchStringProperty = props.get(SEARCH_STRING);
boolean useParentObject = useParentObjectName != null && (useParentObjectName.getBooleanValue() == null ? false : useParentObjectName.getBooleanValue());
+
+/* Configuration c = new Configuration();
+ c.put(new PropertySimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY, getConnectorAddress()));*/
+
if (objectNameProperty == null && useParentObjectName == null)
{
throw new InvalidPluginConfigurationException("objectName or useParentObjectName should be configured on service plugin " + ctx.getResourceType());
@@ -65,8 +69,8 @@
String mBeanName = objectNameProperty.getStringValue();
name = mBeanName + "," + searchStringProperty.getStringValue();
}
- EMSHelper emsHelper = new EMSHelper();
- Invoker invoker = new JMXInvoker(emsHelper.loadConnection(ctx.getDefaultPluginConfiguration()));
+
+ Invoker invoker = mBeanComponent.getInvoker();
List<EmsBean> beans = invoker.query(name);
for (EmsBean bean : beans)
{
Added: branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQJMXDiscoveryComponent.java
===================================================================
--- branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQJMXDiscoveryComponent.java (rev 0)
+++ branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQJMXDiscoveryComponent.java 2010-02-16 14:48:43 UTC (rev 101022)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.jboss.as.integration.hornetq.jopr;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ * Created Feb 16, 2010
+ */
+public abstract class HornetQJMXDiscoveryComponent
+{
+ private String connectorAddress;
+
+ public void setConnectorAddress(String connectorAddress)
+ {
+ this.connectorAddress = connectorAddress;
+ }
+
+ protected String getConnectorAddress()
+ {
+ return connectorAddress;
+ }
+}
Modified: branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQServerDiscoveryComponent.java
===================================================================
--- branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQServerDiscoveryComponent.java 2010-02-16 14:44:02 UTC (rev 101021)
+++ branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQServerDiscoveryComponent.java 2010-02-16 14:48:43 UTC (rev 101022)
@@ -12,70 +12,80 @@
*/
package org.jboss.as.integration.hornetq.jopr;
+import org.jboss.as.integration.hornetq.jopr.util.BeanNotAvailableException;
import org.jboss.as.integration.hornetq.jopr.util.EMSHelper;
import org.jboss.as.integration.hornetq.jopr.util.Invoker;
import org.jboss.as.integration.hornetq.jopr.util.JMXInvoker;
+import org.mc4j.ems.connection.EmsConnection;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.*;
import org.rhq.plugins.jmx.JMXDiscoveryComponent;
+import java.util.Collections;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
/**
* @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
* Created Jan 26, 2010
*/
-public class HornetQServerDiscoveryComponent implements ResourceDiscoveryComponent<HornetQServerComponent>, ManualAddFacet
+public class HornetQServerDiscoveryComponent extends HornetQJMXDiscoveryComponent implements ResourceDiscoveryComponent<HornetQServerComponent>
{
private static final String ORG_HORNETQ_MODULE_JMS_TYPE_SERVER = "org.hornetq:module=JMS,type=Server";
public Set<DiscoveredResourceDetails> discoverResources(final ResourceDiscoveryContext<HornetQServerComponent> ctx) throws InvalidPluginConfigurationException, Exception
{
+ EMSHelper emsHelper = new EMSHelper();
- Set<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
+ setConnectorAddress(getConnectorAddressFromContext(ctx));
- EMSHelper emsHelper = new EMSHelper();
- Invoker invoker = new JMXInvoker(emsHelper.loadConnection(ctx.getDefaultPluginConfiguration()));
- String version = (String) invoker.getAttribute(ORG_HORNETQ_MODULE_JMS_TYPE_SERVER, "Version");
Configuration c = new Configuration();
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- ctx.getResourceType(), // Resource type
- "HornetQServer", // Resource key
- "HornetQ Local Server", // Resource name
- version, // Resource version
- "HornetQ Local Server", // Description
- c, // Plugin config
- null // Process info from a process scan
- );
- set.add(detail);
- return set;
- }
- public DiscoveredResourceDetails discoverResource(Configuration configuration, ResourceDiscoveryContext ctx) throws InvalidPluginConfigurationException
- {
+ c.put(new PropertySimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY, getConnectorAddress()));
+
+ EmsConnection emsConnection = emsHelper.loadConnection(c);
+
+ Invoker invoker = new JMXInvoker(emsConnection);
+
try
{
- EMSHelper emsHelper = new EMSHelper();
- Invoker invoker = new JMXInvoker(emsHelper.loadConnection(ctx.getDefaultPluginConfiguration()));
String version = (String) invoker.getAttribute(ORG_HORNETQ_MODULE_JMS_TYPE_SERVER, "Version");
- Configuration c = new Configuration();
- PropertySimple serverUrl = ctx.getDefaultPluginConfiguration()
- .getSimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY);
- return new DiscoveredResourceDetails(
+ String serverName = "HornetQ Local Server";
+ if(getConnectorAddress() != null)
+ {
+ serverName = "HornetQ Server (" + getConnectorAddress() + ")";
+ }
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
ctx.getResourceType(), // Resource type
- "HornetQServer" + serverUrl.getStringValue(), // Resource key
- "HornetQ Remote Server " + serverUrl.getStringValue(), // Resource name
+ "HornetQServer", // Resource key
+ serverName, // Resource name
version, // Resource version
- "HornetQ Remote Server", // Description
+ serverName, // Description
c, // Plugin config
null // Process info from a process scan
);
+
+ return Collections.singleton(detail);
}
- catch (Exception e)
+ catch (BeanNotAvailableException e)
{
- throw new InvalidPluginConfigurationException(e);
+ return null;
}
}
+
+ private String getConnectorAddressFromContext(ResourceDiscoveryContext<HornetQServerComponent> ctx)
+ {
+ if(ctx.getPluginConfigurations().isEmpty())
+ {
+ PropertySimple serverUrl = ctx.getDefaultPluginConfiguration().getSimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY);
+ return serverUrl == null?null:serverUrl.getStringValue();
+ }
+ else
+ {
+ PropertySimple serverUrl = ctx.getPluginConfigurations().get(0).getSimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY);
+ return serverUrl == null?null:serverUrl.getStringValue();
+ }
+ }
}
Added: branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/BeanNotAvailableException.java
===================================================================
--- branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/BeanNotAvailableException.java (rev 0)
+++ branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/BeanNotAvailableException.java 2010-02-16 14:48:43 UTC (rev 101022)
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.jboss.as.integration.hornetq.jopr.util;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ * Created Feb 16, 2010
+ */
+public class BeanNotAvailableException extends Exception
+{
+ public BeanNotAvailableException()
+ {
+ super(); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public BeanNotAvailableException(String message)
+ {
+ super(message); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public BeanNotAvailableException(String message, Throwable cause)
+ {
+ super(message, cause); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public BeanNotAvailableException(Throwable cause)
+ {
+ super(cause); //To change body of overridden methods use File | Settings | File Templates.
+ }
+}
Modified: branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/EMSHelper.java
===================================================================
--- branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/EMSHelper.java 2010-02-16 14:44:02 UTC (rev 101021)
+++ branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/EMSHelper.java 2010-02-16 14:48:43 UTC (rev 101022)
@@ -35,36 +35,34 @@
*/
public class EMSHelper
{
- private static String INVM_TRANSPORT_TYPE = "org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor";
+ public static String INVM_TRANSPORT_TYPE = "org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor";
- private static String REMOTE_TRANSPORT_TYPE = "org.mc4j.ems.connection.support.metadata.J2SE5ConnectionTypeDescriptor";
+ public static String REMOTE_TRANSPORT_TYPE = "org.mc4j.ems.connection.support.metadata.J2SE5ConnectionTypeDescriptor";
EmsConnection connection = null;
- public synchronized EmsConnection loadConnection(Configuration pluginConfig) throws Exception
+ public synchronized EmsConnection loadConnection(Configuration c) throws Exception
{
if (this.connection == null)
{
try
{
- //Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
+ PropertySimple connectorAddressProp = c.getSimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY);
+ String connectorAddress = connectorAddressProp == null?null:connectorAddressProp.getStringValue();
ConnectionSettings connectionSettings = new ConnectionSettings();
- PropertySimple serverUrl = pluginConfig
- .getSimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY);
String connectionType;
- if(serverUrl != null && serverUrl.getStringValue() != null)
+ if(connectorAddress != null)
{
connectionType = REMOTE_TRANSPORT_TYPE;
- connectionSettings.setServerUrl(serverUrl.getStringValue());
+ connectionSettings.setServerUrl(connectorAddress);
}
else
{
connectionType = INVM_TRANSPORT_TYPE;
}
- connectionSettings.initializeConnectionType((ConnectionTypeDescriptor) getInstance(
- connectionType));
+ connectionSettings.setConnectionType((ConnectionTypeDescriptor) getInstance(connectionType));
/*if (connectionSettings.getAdvancedProperties() == null)
{
Modified: branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/Invoker.java
===================================================================
--- branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/Invoker.java 2010-02-16 14:44:02 UTC (rev 101021)
+++ branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/Invoker.java 2010-02-16 14:48:43 UTC (rev 101022)
@@ -14,9 +14,9 @@
*/
public interface Invoker
{
- public Object invoke(final String objectName, final String oper, final Collection<PropertySimple> props) throws Exception;
+ public Object invoke(final String objectName, final String oper, final Collection<PropertySimple> props) throws BeanNotAvailableException;
- public Object getAttribute(final String objectName, final String attr) throws Exception;
+ public Object getAttribute(final String objectName, final String attr) throws BeanNotAvailableException;
List<EmsBean> query(String name);
}
Modified: branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/JMXInvoker.java
===================================================================
--- branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/JMXInvoker.java 2010-02-16 14:44:02 UTC (rev 101021)
+++ branches/Branch_Hornet_Temporary_2/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/JMXInvoker.java 2010-02-16 14:48:43 UTC (rev 101022)
@@ -18,7 +18,6 @@
import org.mc4j.ems.connection.bean.operation.EmsOperation;
import org.rhq.core.domain.configuration.PropertySimple;
-import javax.management.ObjectName;
import java.util.Collection;
import java.util.List;
@@ -36,19 +35,27 @@
this.connection = connection;
}
- public Object invoke(final String objectName, final String oper, final Collection<PropertySimple> props) throws Exception
+ public Object invoke(final String objectName, final String oper, final Collection<PropertySimple> props) throws BeanNotAvailableException
{
Object[] params = new Object[props.size()];
Class[] signature = new Class[props.size()];
populateParams(props, params, signature);
EmsBean bean = connection.getBean(objectName);
+ if(bean == null)
+ {
+ throw new BeanNotAvailableException(objectName);
+ }
EmsOperation ops = bean.getOperation(oper, signature);
return ops.invoke(params);
}
- public Object getAttribute(final String objectName, final String attr) throws Exception
+ public Object getAttribute(final String objectName, final String attr) throws BeanNotAvailableException
{
EmsBean bean = connection.getBean(objectName);
+ if(bean == null)
+ {
+ throw new BeanNotAvailableException(objectName);
+ }
EmsAttribute attribute = bean.getAttribute(attr);
return attribute.getValue();
}
Modified: branches/Branch_Hornet_Temporary_2/hornetq-int/src/resources/META-INF/rhq-plugin.xml
===================================================================
--- branches/Branch_Hornet_Temporary_2/hornetq-int/src/resources/META-INF/rhq-plugin.xml 2010-02-16 14:44:02 UTC (rev 101021)
+++ branches/Branch_Hornet_Temporary_2/hornetq-int/src/resources/META-INF/rhq-plugin.xml 2010-02-16 14:48:43 UTC (rev 101022)
@@ -55,7 +55,7 @@
displayName="HornetQPlugin"
description="Supports management and monitoring of HornetQ Servers"
package="org.jboss.as.integration.hornetq.jopr"
- version="2.1.5"
+ version="2.1.10"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
xmlns:c="urn:xmlns:rhq-configuration">
@@ -70,6 +70,8 @@
<subcategories>
<subcategory name="JMS"
description="JMS Management">
+ <subcategory name="queues" description="JMS Queues"/>
+ <subcategory name="topics" description="JMS Topics"/>
</subcategory>
<subcategory name="Core"
description="Core Management">
@@ -596,7 +598,7 @@
</results>
</operation>
<metric property="Started"
- displayName="HornetQ Started"
+ displayName="HornetQ Started"
description="Is the JMSServer Started"
dataType="trait" displayType="summary"/>
<metric property="Version"
More information about the jboss-cvs-commits
mailing list