[jboss-cvs] JBossAS SVN: r102863 - in trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr: util and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 24 05:17:43 EDT 2010
Author: ataylor
Date: 2010-03-24 05:17:42 -0400 (Wed, 24 Mar 2010)
New Revision: 102863
Removed:
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQComponent.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQComponentConstants.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQDiscoveryComponent.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQJMXDiscoveryComponent.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQServerComponent.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQServerDiscoveryComponent.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/MBeanComponent.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/BeanNotAvailableException.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/EMSHelper.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/Invoker.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/JMXInvoker.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/ResultsFormatter.java
Log:
removed un wanted jopr components
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQComponent.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQComponent.java 2010-03-24 09:07:37 UTC (rev 102862)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQComponent.java 2010-03-24 09:17:42 UTC (rev 102863)
@@ -1,202 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.as.integration.hornetq.jopr;
-
-import org.jboss.as.integration.hornetq.jopr.util.Invoker;
-import org.jboss.as.integration.hornetq.jopr.util.Operation;
-import org.jboss.as.integration.hornetq.jopr.util.ResultsFormatter;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-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.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;
-import org.rhq.core.pluginapi.measurement.MeasurementFacet;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.core.pluginapi.operation.OperationResult;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.jboss.as.integration.hornetq.jopr.HornetQComponentConstants.*;
-
-/**
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- * Created Feb 2, 2010
- */
-public class HornetQComponent extends MBeanComponent implements ResourceComponent, MeasurementFacet, OperationFacet, ConfigurationFacet
-{
- private String objectName;
-
- private ResultsFormatter resultsFormatter;
-
- private ResourceContext resourceContext;
-
- private Invoker invoker;
-
- public void getValues(final MeasurementReport report, final Set<MeasurementScheduleRequest> measurementScheduleRequests) throws Exception
- {
- for (MeasurementScheduleRequest request : measurementScheduleRequests)
- {
- Operation operation = Operation.getOperation(request.getName());
- if (DataType.TRAIT.equals(request.getDataType()))
- {
- Object attr = invoker.getAttribute(objectName, operation.getOperationName());
- report.addData(resultsFormatter.formatMetricResults(attr, operation, resourceContext, request));
- }
- else if(DataType.MEASUREMENT.equals(request.getDataType()))
- {
- Object attr = invoker.getAttribute(objectName, operation.getOperationName());
- report.addData(resultsFormatter.formatMetricResults(attr, operation, resourceContext, request));
- }
- }
- }
-
- public OperationResult invokeOperation(final String oper, final Configuration configuration) throws InterruptedException, Exception
- {
- Operation operation = Operation.getOperation(oper);
- Collection<PropertySimple> props = configuration.getSimpleProperties().values();
- Object o = invoker.invoke(objectName, operation.getOperationName(), props);
- return resultsFormatter.formatResults(operation, o, resourceContext);
- }
-
- public void start(final ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception
- {
- MBeanComponent hornetQServerComponent = (MBeanComponent) resourceContext.getParentResourceComponent();
- invoker = hornetQServerComponent.getInvoker();
-
- Map<String, PropertySimple> props = resourceContext.getPluginConfiguration().getSimpleProperties();
- PropertySimple objectNameProperty = props.get(OBJECT_NAME);
- PropertySimple useParentObjectName = props.get(USE_PARENT_OBJECT_NAME);
- PropertySimple resourceNameProperty = props.get(RESOURCE_NAME_PROPERTY);
- PropertySimple searchStringProperty = props.get(SEARCH_STRING);
- boolean useParentObject = useParentObjectName != null && (useParentObjectName.getBooleanValue() == null ? false : useParentObjectName.getBooleanValue());
-
- if (objectNameProperty == null && useParentObjectName == null)
- {
- throw new InvalidPluginConfigurationException("objectName or useParentObjectName should be configured on service plugin " + resourceContext.getResourceKey());
- }
-
- String mBeanName;
- if (useParentObject)
- {
- HornetQComponent hornetQComponent = (HornetQComponent) resourceContext.getParentResourceComponent();
- mBeanName = hornetQComponent.getObjectName();
- }
- else
- {
- mBeanName = objectNameProperty.getStringValue();
- }
- if (searchStringProperty != null)
- {
- objectName = mBeanName + "," + resourceNameProperty.getStringValue() + "=" + resourceContext.getResourceKey().split(":")[1];
- }
- else
- {
- objectName = mBeanName;
- }
- this.resourceContext = resourceContext;
- resultsFormatter = new ResultsFormatter();
- }
-
- public void stop()
- {
- invoker = null;
- }
-
- public AvailabilityType getAvailability()
- {
- return AvailabilityType.UP;
- }
-
-
- public String getObjectName()
- {
- return objectName;
- }
-
- @Override
- Invoker getInvoker()
- {
- return invoker;
- }
-
- public Configuration loadResourceConfiguration() throws Exception
- {
- Configuration config = new Configuration();
- ConfigurationDefinition configDef = resourceContext.getResourceType().getResourceConfigurationDefinition();
- List<PropertyDefinition> propertyDefinitionList = configDef.getPropertiesInGroup("HornetQCustomProperties");
- for (PropertyDefinition definition : propertyDefinitionList)
- {
- String name = definition.getName();
- Object o = invoker.getAttribute(objectName, name);
- PropertySimple simple = new PropertySimple(name, o);
- config.put(simple);
- }
- return config;
- }
-
- public void updateResourceConfiguration(final ConfigurationUpdateReport configurationUpdateReport)
- {
- configurationUpdateReport.setStatus(ConfigurationUpdateStatus.INPROGRESS);
- Map<String,PropertySimple> propertySimpleMap = configurationUpdateReport.getConfiguration().getSimpleProperties();
- for (String name : propertySimpleMap.keySet())
- {
- try
- {
- PropertySimple ps = propertySimpleMap.get(name);
- Object o = invoker.getAttribute(objectName, name);
- if(o == null && ps.getStringValue() != null)
- {
- invoker.setAttribute(objectName, name, ps);
- }
- else if(o != null && ps.getStringValue() == null)
- {
- invoker.setAttribute(objectName, name, ps);
- }
- else if((o != null && ps.getStringValue() != null) && !o.equals(ps.getStringValue()))
- {
- invoker.setAttribute(objectName, name, ps);
- }
- }
- catch (Exception e)
- {
- configurationUpdateReport.setErrorMessage(e.getMessage());
- e.printStackTrace();
- configurationUpdateReport.setStatus(ConfigurationUpdateStatus.FAILURE);
- return;
- }
- }
- configurationUpdateReport.setStatus(ConfigurationUpdateStatus.SUCCESS);
- }
-
-}
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQComponentConstants.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQComponentConstants.java 2010-03-24 09:07:37 UTC (rev 102862)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQComponentConstants.java 2010-03-24 09:17:42 UTC (rev 102863)
@@ -1,38 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.as.integration.hornetq.jopr;
-
-/**
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- * Created Feb 11, 2010
- */
-public class HornetQComponentConstants
-{
-
- public static final String OBJECT_NAME = "objectName";
-
- public static final String USE_PARENT_OBJECT_NAME = "useParentObjectName";
-
- public static final String RESOURCE_NAME_PROPERTY = "resourceNameProperty";
-
- public static final String SEARCH_STRING = "searchString";
-}
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQDiscoveryComponent.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQDiscoveryComponent.java 2010-03-24 09:07:37 UTC (rev 102862)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQDiscoveryComponent.java 2010-03-24 09:17:42 UTC (rev 102863)
@@ -1,117 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.as.integration.hornetq.jopr;
-
-import org.jboss.as.integration.hornetq.jopr.util.Invoker;
-import org.mc4j.ems.connection.bean.EmsBean;
-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 java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static org.jboss.as.integration.hornetq.jopr.HornetQComponentConstants.*;
-
-/**
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- * Created Jan 27, 2010
- */
-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);
- PropertySimple resourceNameProperty = props.get(RESOURCE_NAME_PROPERTY);
- 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());
- }
-
- if (searchStringProperty != null)
- {
- String name;
- if(useParentObject)
- {
- HornetQComponent hornetQComponent = (HornetQComponent) ctx.getParentResourceComponent();
- name = hornetQComponent.getObjectName() + "," + searchStringProperty.getStringValue();
- }
- else
- {
- String mBeanName = objectNameProperty.getStringValue();
- name = mBeanName + "," + searchStringProperty.getStringValue();
- }
-
- Invoker invoker = mBeanComponent.getInvoker();
- List<EmsBean> beans = invoker.query(name);
- for (EmsBean bean : beans)
- {
- String resourceName = bean.getBeanName().getKeyProperty(resourceNameProperty.getStringValue());
- String resourceKey = ctx.getResourceType().getName() + ":" + resourceName;
- System.out.println("resourceKey = " + resourceKey);
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- ctx.getResourceType(), // Resource type
- resourceKey, // Resource key
- resourceName, // Resource name
- null, // Resource version
- ctx.getResourceType().getDescription(), // Description
- ctx.getDefaultPluginConfiguration(), // Plugin config
- null // Process info from a process scan
- );
- set.add(detail);
- }
- }
- else
- {
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- ctx.getResourceType(), // Resource type
- ctx.getResourceType().getName(), // Resource key
- ctx.getResourceType().getName(), // Resource name
- null, // Resource version
- ctx.getResourceType().getDescription(), // Description
- ctx.getDefaultPluginConfiguration(), // Plugin config
- null // Process info from a process scan
- );
- set.add(detail);
- }
-
-
- return set;
-
- }
-}
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQJMXDiscoveryComponent.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQJMXDiscoveryComponent.java 2010-03-24 09:07:37 UTC (rev 102862)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQJMXDiscoveryComponent.java 2010-03-24 09:17:42 UTC (rev 102863)
@@ -1,41 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-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;
- }
-}
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQServerComponent.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQServerComponent.java 2010-03-24 09:07:37 UTC (rev 102862)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQServerComponent.java 2010-03-24 09:17:42 UTC (rev 102863)
@@ -1,81 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.as.integration.hornetq.jopr;
-
-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.rhq.core.domain.measurement.*;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.measurement.MeasurementFacet;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- * Created Jan 26, 2010
- */
-public class HornetQServerComponent extends MBeanComponent implements ResourceComponent, MeasurementFacet
-{
- private ResourceContext resourceContext;
-
- private Invoker invoker;
-
- public void getValues(final MeasurementReport report, final Set<MeasurementScheduleRequest> measurementScheduleRequests) throws Exception
- {
- for (MeasurementScheduleRequest request : measurementScheduleRequests)
- {
- if(DataType.TRAIT.equals(request.getDataType()))
- {
- if(request.getName().equals("hornetqversion"))
- {
- report.addData(new MeasurementDataTrait(request, resourceContext.getVersion()));
- }
- }
- }
- }
-
- public void start(final ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception
- {
- this.resourceContext = resourceContext;
- EMSHelper emsHelper = new EMSHelper();
- invoker = new JMXInvoker(emsHelper.loadConnection(resourceContext.getPluginConfiguration()));
- }
-
- public void stop()
- {
- resourceContext = null;
- }
-
- public AvailabilityType getAvailability()
- {
- return AvailabilityType.UP;
- }
-
- @Override
- public Invoker getInvoker()
- {
- return invoker;
- }
-}
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQServerDiscoveryComponent.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQServerDiscoveryComponent.java 2010-03-24 09:07:37 UTC (rev 102862)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/HornetQServerDiscoveryComponent.java 2010-03-24 09:17:42 UTC (rev 102863)
@@ -1,101 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-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.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.plugins.jmx.JMXDiscoveryComponent;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- * Created Jan 26, 2010
- */
-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();
-
- setConnectorAddress(getConnectorAddressFromContext(ctx));
-
- Configuration c = new Configuration();
-
- c.put(new PropertySimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY, getConnectorAddress()));
-
- EmsConnection emsConnection = emsHelper.loadConnection(c);
-
- Invoker invoker = new JMXInvoker(emsConnection);
-
- try
- {
- String version = (String) invoker.getAttribute(ORG_HORNETQ_MODULE_JMS_TYPE_SERVER, "Version");
- String serverName = "HornetQ Local Server";
- if(getConnectorAddress() != null)
- {
- serverName = "HornetQ Server (" + getConnectorAddress() + ")";
- }
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- ctx.getResourceType(), // Resource type
- "HornetQServer", // Resource key
- serverName, // Resource name
- version, // Resource version
- serverName, // Description
- c, // Plugin config
- null // Process info from a process scan
- );
-
- return Collections.singleton(detail);
- }
- catch (BeanNotAvailableException 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();
- }
- }
-}
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/MBeanComponent.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/MBeanComponent.java 2010-03-24 09:07:37 UTC (rev 102862)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/MBeanComponent.java 2010-03-24 09:17:42 UTC (rev 102863)
@@ -1,57 +0,0 @@
-package org.jboss.as.integration.hornetq.jopr;
-
-import org.jboss.as.integration.hornetq.jopr.util.Invoker;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-/**
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- * Created Feb 11, 2010
- */
-public abstract class MBeanComponent
-{
- abstract Invoker getInvoker();
-
- public static Object getInstance(String classname) throws ClassNotFoundException, IllegalAccessException, InstantiationException
- {
- if (classname == null) throw new IllegalArgumentException("Cannot load null class!");
- Class clazz = loadClass(classname);
- return getInstance(clazz);
- }
-
- public static Class loadClass(String classname) throws ClassNotFoundException
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null)
- cl = ClassLoader.getSystemClassLoader();
- return cl.loadClass(classname);
- }
-
- public static <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException
- {
- // first look for a getInstance() constructor
- T instance = null;
- try
- {
- Method factoryMethod = getFactoryMethod(clazz);
- if (factoryMethod != null) instance = (T) factoryMethod.invoke(null);
- }
- catch (Exception e)
- {
- // no factory method or factory method failed. Try a constructor.
- instance = null;
- }
- if (instance == null) instance = clazz.newInstance();
- return instance;
- }
-
- private static Method getFactoryMethod(Class c)
- {
- for (Method m : c.getMethods())
- {
- if (m.getName().equals("getInstance") && m.getParameterTypes().length == 0 && Modifier.isStatic(m.getModifiers()))
- return m;
- }
- return null;
- }
-}
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/BeanNotAvailableException.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/BeanNotAvailableException.java 2010-03-24 09:07:37 UTC (rev 102862)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/BeanNotAvailableException.java 2010-03-24 09:17:42 UTC (rev 102863)
@@ -1,49 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-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.
- }
-}
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/EMSHelper.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/EMSHelper.java 2010-03-24 09:07:37 UTC (rev 102862)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/EMSHelper.java 2010-03-24 09:17:42 UTC (rev 102863)
@@ -1,150 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.as.integration.hornetq.jopr.util;
-
-import org.mc4j.ems.connection.ConnectionFactory;
-import org.mc4j.ems.connection.EmsConnection;
-import org.mc4j.ems.connection.settings.ConnectionSettings;
-import org.mc4j.ems.connection.support.ConnectionProvider;
-import org.mc4j.ems.connection.support.metadata.ConnectionTypeDescriptor;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.plugins.jmx.JMXDiscoveryComponent;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-/**
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- * Created Feb 12, 2010
- */
-public class EMSHelper
-{
- public static String INVM_TRANSPORT_TYPE = "org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor";
-
- public static String REMOTE_TRANSPORT_TYPE = "org.mc4j.ems.connection.support.metadata.J2SE5ConnectionTypeDescriptor";
-
- EmsConnection connection = null;
-
- public synchronized EmsConnection loadConnection(Configuration c) throws Exception
- {
- if (this.connection == null)
- {
- try
- {
- PropertySimple connectorAddressProp = c.getSimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY);
- String connectorAddress = connectorAddressProp == null?null:connectorAddressProp.getStringValue();
-
- ConnectionSettings connectionSettings = new ConnectionSettings();
-
- String connectionType;
- if(connectorAddress != null)
- {
- connectionType = REMOTE_TRANSPORT_TYPE;
- connectionSettings.setServerUrl(connectorAddress);
- }
- else
- {
- connectionType = INVM_TRANSPORT_TYPE;
- }
- connectionSettings.setConnectionType((ConnectionTypeDescriptor) getInstance(connectionType));
-
- /*if (connectionSettings.getAdvancedProperties() == null)
- {
- connectionSettings.setAdvancedProperties(new Properties());
- }*/
-
- ConnectionFactory connectionFactory = new ConnectionFactory();
-
-
- ConnectionProvider connectionProvider = connectionFactory.getConnectionProvider(connectionSettings);
- this.connection = connectionProvider.connect();
-
- this.connection.loadSynchronous(false); // this loads all the MBeans
-
- System.out.println("connectionProvider = " + connectionProvider.getClass().getName());
- }
- catch (Exception e)
- {
-
- // The connection will be established even in the case that the principal cannot be authenticated,
- // but the connection will not work. That failure seems to come from the call to loadSynchronous after
- // the connection is established. If we get to this point that an exception was thrown, close any
- // connection that was made and null it out so we can try to establish it again.
- if (connection != null)
- {
- connection.close();
- connection = null;
- }
-
- throw e;
- }
- }
-
- return connection;
- }
-
- public static Object getInstance(String classname) throws ClassNotFoundException, IllegalAccessException, InstantiationException
- {
- if (classname == null) throw new IllegalArgumentException("Cannot load null class!");
- Class clazz = loadClass(classname);
- return getInstance(clazz);
- }
-
- public static Class loadClass(String classname) throws ClassNotFoundException
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null)
- cl = ClassLoader.getSystemClassLoader();
- return cl.loadClass(classname);
- }
-
- public static <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException
- {
- // first look for a getInstance() constructor
- T instance = null;
- try
- {
- Method factoryMethod = getFactoryMethod(clazz);
- if (factoryMethod != null) instance = (T) factoryMethod.invoke(null);
- }
- catch (Exception e)
- {
- // no factory method or factory method failed. Try a constructor.
- instance = null;
- }
- if (instance == null) instance = clazz.newInstance();
- return instance;
- }
-
- private static Method getFactoryMethod(Class c)
- {
- for (Method m : c.getMethods())
- {
- if (m.getName().equals("getInstance") && m.getParameterTypes().length == 0 && Modifier.isStatic(m.getModifiers()))
- return m;
- }
- return null;
- }
-
-
-}
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/Invoker.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/Invoker.java 2010-03-24 09:07:37 UTC (rev 102862)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/Invoker.java 2010-03-24 09:17:42 UTC (rev 102863)
@@ -1,43 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.as.integration.hornetq.jopr.util;
-
-import org.mc4j.ems.connection.bean.EmsBean;
-import org.rhq.core.domain.configuration.PropertySimple;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- * Created Feb 12, 2010
- */
-public interface Invoker
-{
- 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 BeanNotAvailableException;
-
- List<EmsBean> query(String name);
-
- void setAttribute(String objectName, String name, PropertySimple stringValue) throws Exception;
-}
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/JMXInvoker.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/JMXInvoker.java 2010-03-24 09:07:37 UTC (rev 102862)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/JMXInvoker.java 2010-03-24 09:17:42 UTC (rev 102863)
@@ -1,167 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.as.integration.hornetq.jopr.util;
-
-import org.mc4j.ems.connection.EmsConnection;
-import org.mc4j.ems.connection.bean.EmsBean;
-import org.mc4j.ems.connection.bean.attribute.EmsAttribute;
-import org.mc4j.ems.connection.bean.operation.EmsOperation;
-import org.rhq.core.domain.configuration.PropertySimple;
-
-import java.util.Collection;
-import java.util.List;
-
-/**
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- * Created Feb 12, 2010
- */
-public class JMXInvoker implements Invoker
-{
- EmsConnection connection;
-
-
- public JMXInvoker(EmsConnection connection)
- {
- this.connection = connection;
- }
-
- 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 BeanNotAvailableException
- {
- EmsBean bean = connection.getBean(objectName);
- if(bean == null)
- {
- throw new BeanNotAvailableException(objectName);
- }
- EmsAttribute attribute = bean.getAttribute(attr);
- return attribute.getValue();
- }
-
- public List<EmsBean> query(final String name)
- {
- return connection.queryBeans(name);
- }
-
- public void setAttribute(final String objectName, final String attr, final PropertySimple value) throws Exception
- {
- EmsBean bean = connection.getBean(objectName);
- if(bean == null)
- {
- throw new BeanNotAvailableException(objectName);
- }
- EmsAttribute attribute = bean.getAttribute(attr);
- String type = attribute.getType();
- if(type.equals("java.lang.String"))
- {
- attribute.setValue(value.getStringValue());
- }
- else if(type.equals("java.lang.Long") || type.equals("long"))
- {
- attribute.setValue(value.getLongValue());
- }
- else if(type.equals("java.lang.Integer") || type.equals("int"))
- {
- attribute.setValue(value.getIntegerValue());
- }
- else if(type.equals("java.lang.Double") || type.equals("double"))
- {
- attribute.setValue(value.getDoubleValue());
- }
-
- }
-
- private static void populateParams(final Collection<PropertySimple> props, final Object[] params, final Class[] signature)
- {
- int pos = 0;
- for (PropertySimple prop : props)
- {
- String[] val = prop.getName().split(":");
- if(val.length == 1)
- {
- params[pos] = prop.getStringValue();
- signature[pos] = java.lang.String.class;
- }
- else
- {
- if(val[0].equals("Boolean"))
- {
- params[pos] = prop.getBooleanValue();
- signature[pos] = java.lang.Boolean.class;
- }
- else if(val[0].equals("boolean"))
- {
- params[pos] = prop.getBooleanValue();
- signature[pos] = boolean.class;
- }
- else if(val[0].equals("String"))
- {
- params[pos] = prop.getStringValue();
- signature[pos] = java.lang.String.class;
- }
- else if(val[0].equals("Long"))
- {
- params[pos] = prop.getLongValue();
- signature[pos] = java.lang.Long.class;
- }
- else if(val[0].equals("long"))
- {
- params[pos] = prop.getLongValue();
- signature[pos] = long.class;
- }
- else if(val[0].equals("Integer"))
- {
- params[pos] = prop.getIntegerValue();
- signature[pos] = java.lang.Integer.class;
- }
- else if(val[0].equals("int"))
- {
- params[pos] = prop.getIntegerValue();
- signature[pos] = int.class;
- }
- else if(val[0].equals("Double"))
- {
- params[pos] = prop.getDoubleValue ();
- signature[pos] = java.lang.Integer.class;
- }
- else if(val[0].equals("double"))
- {
- params[pos] = prop.getDoubleValue ();
- signature[pos] = int.class;
- }
- }
- pos++;
- }
- }
-}
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/ResultsFormatter.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/ResultsFormatter.java 2010-03-24 09:07:37 UTC (rev 102862)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/util/ResultsFormatter.java 2010-03-24 09:17:42 UTC (rev 102863)
@@ -1,279 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.as.integration.hornetq.jopr.util;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.measurement.MeasurementDataTrait;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.rhq.core.pluginapi.operation.OperationResult;
-
-import java.util.Map;
-
-/**
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- * Created Feb 9, 2010
- */
-public class ResultsFormatter
-{
- public OperationResult formatResults(final Operation oper, final Object result, final ResourceContext resourceContext)
- {
- if (result == null)
- {
- return null;
- }
- else
- {
-
- if (oper.getResultsType() == null)
- {
- return formatStringResults(result.toString());
- }
- else
- {
- if ("String".equalsIgnoreCase(oper.getResultsType()))
- {
- return formatStringResults(result.toString());
- }
- else if ("JMSMessage".equalsIgnoreCase(oper.getResultsType()))
- {
- return formatJmsMessageResults(result);
- }
- else if ("String[]".equalsIgnoreCase(oper.getResultsType()))
- {
- return formatStringArrayResults(result);
- }
- else if ("SubscriptionInfo".equalsIgnoreCase(oper.getResultsType()))
- {
- return formatSubscriptionInfoResults(result);
- }
- else if ("Message".equalsIgnoreCase(oper.getResultsType()))
- {
- return formatMessageResults(result);
- }
- else
- {
- return formatStringResults(result.toString());
- }
- }
- }
- }
-
- public MeasurementDataTrait formatMetricResults(Object attr, Operation operation, ResourceContext resourceContext, MeasurementScheduleRequest request)
- {
- String data;
- if("roles".equalsIgnoreCase(operation.getResultsType()))
- {
- data = formatRolesMetric((Object[]) attr);
- }
- else if("connectorpairs".equalsIgnoreCase(operation.getResultsType()))
- {
- data = formatConnectorPairsMetric((Object[]) attr);
- }
-
- else if("clusternodes".equalsIgnoreCase(operation.getResultsType()))
- {
- data = formatClusterNodesMetric((Map<String, String>) attr);
- }
- else if(attr instanceof Object[])
- {
- Object[] objects = (Object[]) attr;
- data = formatObjectArray(objects);
- }
- else
- {
- data = attr == null?null:attr.toString();
- }
- return new MeasurementDataTrait(request, data);
- }
- OperationResult formatStringResults(final Object result)
- {
- return new OperationResult((String) result);
- }
-
- String formatRolesMetric(Object[] results)
- {
- StringBuffer sb = new StringBuffer();
- for (int i = 0, resultsLength = results.length; i < resultsLength; i++)
- {
- Object[] result = (Object[]) results[i];
- if(i > 0)
- {
- sb.append(",");
- }
- sb.append("{name=").append(result[0].toString());
- sb.append(",SEND=").append(result[1].toString());
- sb.append(",CONSUME=").append(result[2].toString());
- sb.append(",CREATE_DURABLE_QUEUE=").append(result[3].toString());
- sb.append(",DELETE_DURABLE_QUEUE=").append(result[4].toString());
- sb.append(",CREATE_NON_DURABLE_QUEUE=").append(result[5].toString());
- sb.append(",DELETE_NON_DURABLE_QUEUE=").append(result[6].toString());
- sb.append(",MANAGE=").append(result[7].toString()).append("}");
- }
- return sb.toString();
- }
-
- String formatConnectorPairsMetric(Object[] results)
- {
- StringBuffer sb = new StringBuffer();
- if (results != null)
- {
- for (int i = 0, resultsLength = results.length; i < resultsLength; i++)
- {
- Object[] result = (Object[]) results[i];
- if(i > 0)
- {
- sb.append(",");
- }
- sb.append("{a=").append(result[0].toString());
- sb.append(",b=").append(result[1] == null?null:result[1].toString()).append("}");
- }
- }
- return sb.toString();
- }
-
- String formatClusterNodesMetric(Map<String, String> results)
- {
- StringBuffer sb = new StringBuffer();
- boolean first = true;
- if (results != null)
- {
- for (String s : results.keySet())
- {
- if(!first)
- {
- sb.append(",");
- }
- first = false;
- sb.append("{").append(s).append("=").append(results.get(s)).append("}");
- }
- }
- return sb.toString();
- }
-
- OperationResult formatJmsMessageResults(final Object result)
- {
- OperationResult operationResult = new OperationResult();
- Configuration c = operationResult.getComplexResults();
- PropertyList property = new PropertyList("result");
- Map[] map = (Map[]) result;
- for (Map map1 : map)
- {
- org.rhq.core.domain.configuration.PropertyMap p1 = new org.rhq.core.domain.configuration.PropertyMap("element");
- property.add(p1);
- for (Object o1 : map1.keySet())
- {
- p1.put(new PropertySimple((String) o1, map1.get(o1)));
- }
- }
- c.put(property);
- return operationResult;
- }
-
- OperationResult formatMessageResults(final Object result)
- {
- OperationResult operationResult = new OperationResult();
- Configuration c = operationResult.getComplexResults();
- PropertyList property = new PropertyList("result");
- Map[] map = (Map[]) result;
- for (Map map1 : map)
- {
- org.rhq.core.domain.configuration.PropertyMap p1 = new org.rhq.core.domain.configuration.PropertyMap("element");
- property.add(p1);
- for (Object o1 : map1.keySet())
- {
- p1.put(new PropertySimple((String) o1, map1.get(o1)));
- }
- }
- c.put(property);
- return operationResult;
- }
-
- OperationResult formatSubscriptionInfoResults(final Object result)
- {
- OperationResult operationResult = new OperationResult();
- Configuration c = operationResult.getComplexResults();
- PropertyList property = new PropertyList("result");
- Object[] map = (Object[]) result;
- for (Object o : map)
- {
- org.rhq.core.domain.configuration.PropertyMap p1 = new org.rhq.core.domain.configuration.PropertyMap("element");
- property.add(p1);
- Object[] subscriptionInfo = (Object[]) o;
- String name = (String) subscriptionInfo[0];
- String clientID = (String) subscriptionInfo[1];
- String subName = (String) subscriptionInfo[2];
- Boolean durable = (Boolean) subscriptionInfo[3];
- Integer messageCount = (Integer) subscriptionInfo[4];
- String filter = (String) subscriptionInfo[5];
- p1.put(new PropertySimple("name", name));
- p1.put(new PropertySimple("clientID", clientID));
- p1.put(new PropertySimple("subName", subName));
- p1.put(new PropertySimple("durable", durable));
- p1.put(new PropertySimple("messageCount", messageCount));
- p1.put(new PropertySimple("filter", filter));
- }
- c.put(property);
- return operationResult;
- }
-
- OperationResult formatStringArrayResults(final Object result)
- {
- OperationResult operationResult = new OperationResult();
- Configuration c = operationResult.getComplexResults();
- PropertyList property = new PropertyList("result");
- String[] Strings = (String[]) result;
- for (String string : Strings)
- {
- org.rhq.core.domain.configuration.PropertyMap p1 = new org.rhq.core.domain.configuration.PropertyMap("element");
- p1.put(new PropertySimple("value", string));
- property.add(p1);
- }
- c.put(property);
- return operationResult;
- }
-
- private String formatObjectArray(Object[] objects)
- {
- StringBuilder sb = new StringBuilder();
- for (int i = 0, objectsLength = objects.length; i < objectsLength; i++)
- {
- Object object = objects[i];
- if(i > 0)
- {
- sb.append(", ");
- }
-
- if(object instanceof Object[])
- {
- sb.append("{").append(formatObjectArray((Object[]) object)).append("}");
- }
- else
- {
- sb.append(object.toString());
- }
- }
- return sb.toString();
- }
-}
More information about the jboss-cvs-commits
mailing list