[jboss-cvs] JBossAS SVN: r102864 - in trunk/hornetq-int/src: resources/META-INF and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 24 05:23:47 EDT 2010
Author: ataylor
Date: 2010-03-24 05:23:46 -0400 (Wed, 24 Mar 2010)
New Revision: 102864
Added:
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueComponent.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueDiscoveryComponent.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSResourceComponent.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSTopicDiscoveryComponent.java
Removed:
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSDestinationComponent.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueComponent2.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueDiscoveryComponent2.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSTopicDiscoveryComponent2.java
Modified:
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSConnectionFactoryComponent.java
trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSTopicComponent.java
trunk/hornetq-int/src/resources/META-INF/rhq-plugin.xml
Log:
hornetq component renaming
Modified: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSConnectionFactoryComponent.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSConnectionFactoryComponent.java 2010-03-24 09:17:42 UTC (rev 102863)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSConnectionFactoryComponent.java 2010-03-24 09:23:46 UTC (rev 102864)
@@ -28,7 +28,7 @@
* @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
* Created Mar 19, 2010
*/
-public class JMSConnectionFactoryComponent extends JMSDestinationComponent
+public class JMSConnectionFactoryComponent extends JMSResourceComponent
{
private static ComponentType componentType = new ComponentType("JMSManage", "ConnectionFactoryManage");
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSDestinationComponent.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSDestinationComponent.java 2010-03-24 09:17:42 UTC (rev 102863)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSDestinationComponent.java 2010-03-24 09:23:46 UTC (rev 102864)
@@ -1,347 +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.ManagementSupport;
-import org.jboss.as.integration.hornetq.jopr.util.Operation;
-import org.jboss.deployers.spi.management.ManagementView;
-import org.jboss.managed.api.ComponentType;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.metatype.api.types.ArrayMetaType;
-import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.*;
-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.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.configuration.definition.PropertyDefinition;
-import org.rhq.core.domain.measurement.*;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
-import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
-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.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- * Created: 17-Mar-2010
- */
-public abstract class JMSDestinationComponent implements ResourceComponent, MeasurementFacet, OperationFacet, ConfigurationFacet, JMSComponent, DeleteResourceFacet
-{
- private ResourceContext resourceContext;
- private JMSComponent jmsComponent;
-
- public AvailabilityType getAvailability()
- {
- return null;
- }
-
- public void deleteResource() throws Exception
- {
- ManagementView view = getProfileService();
- ManagedOperation operation = ManagementSupport.getOperation(view, getComponentName(), getDeleteOperationName(), getComponentType());
- operation.invoke(new SimpleValueSupport(SimpleMetaType.STRING, resourceContext.getResourceKey()));
- }
-
-
-
- public void updateResourceConfiguration(ConfigurationUpdateReport configurationUpdateReport)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> measurementScheduleRequests) throws Exception
- {
- ArrayValueSupport support = new ArrayValueSupport(new ArrayMetaType(SimpleMetaType.STRING, false));
- SimpleValueSupport[] valueSupports = new SimpleValueSupport[measurementScheduleRequests.size()];
- Iterator<MeasurementScheduleRequest> it = measurementScheduleRequests.iterator();
- for (int i = 0, valueSupportsLength = valueSupports.length; i < valueSupportsLength; i++)
- {
- valueSupports[i] = new SimpleValueSupport(SimpleMetaType.STRING, it.next().getName());
- }
- support.setValue(valueSupports);
- ManagementView view = getProfileService();
-
- ManagedOperation operation = ManagementSupport.getOperation(view, getComponentName(), getMeasurementsOperationName(), getComponentType());
- ArrayValueSupport vals = (ArrayValueSupport) operation.invoke(new SimpleValueSupport(SimpleMetaType.STRING, resourceContext.getResourceKey()), support);
- it = measurementScheduleRequests.iterator();
- for (int i = 0, valueSupportsLength = valueSupports.length; i < valueSupportsLength; i++)
- {
- MeasurementScheduleRequest request = it.next();
- SimpleValueSupport simpleValueSupport = (SimpleValueSupport) vals.getValue(i);
- simpleValueSupport.getValue();
- if (request.getDataType().equals(DataType.MEASUREMENT))
- {
- report.addData(new MeasurementDataNumeric(request, Double.valueOf(simpleValueSupport.getValue().toString())));
- }
- else if (request.getDataType().equals(DataType.TRAIT))
- {
- report.addData(new MeasurementDataTrait(request, simpleValueSupport.getValue().toString()));
- }
- }
- }
-
- public Configuration loadResourceConfiguration() throws Exception
- {
- Configuration config = new Configuration();
- ManagementView view = getProfileService();
-
- ManagedOperation operation = ManagementSupport.getOperation(view, getComponentName(), getConfigurationOperationName(), getComponentType());
-
- CompositeValueSupport val = (CompositeValueSupport) operation.invoke(new SimpleValueSupport(SimpleMetaType.STRING, resourceContext.getResourceKey()));
-
- ConfigurationDefinition configDef = resourceContext.getResourceType().getResourceConfigurationDefinition();
- List<PropertyDefinition> propertyDefinitionList = configDef.getPropertiesInGroup("HornetQCustomProperties");
- for (PropertyDefinition definition : propertyDefinitionList)
- {
- String name = definition.getName();
- if (val.containsKey(name))
- {
- MetaValue mv = val.get(name);
- if(mv instanceof SimpleValueSupport)
- {
- SimpleValueSupport attr = (SimpleValueSupport) mv;
- PropertySimple simple = new PropertySimple(name, attr.getValue());
- config.put(simple);
- }
- else if(mv instanceof CollectionValueSupport)
- {
- PropertyList property = new PropertyList("securityConfig");
- CollectionValueSupport valueSupport = (CollectionValueSupport) mv;
- MetaValue[] msgs = valueSupport.getElements();
- for (MetaValue mv2 : msgs)
- {
- CompositeValueSupport msg = (CompositeValueSupport) mv2;
- org.rhq.core.domain.configuration.PropertyMap p1 = new org.rhq.core.domain.configuration.PropertyMap("element");
- property.add(p1);
- ImmutableCompositeMetaType metaType = (ImmutableCompositeMetaType) msg.getMetaType();
- Set<String> keys = metaType.keySet();
- for (String key : keys)
- {
- SimpleValueSupport sattr = (SimpleValueSupport) msg.get(key);
- if(sattr != null)
- p1.put(new PropertySimple(key,sattr.getValue()));
- }
- }
- config.put(property);
- }
- }
- }
- return config;
- }
-
- public OperationResult invokeOperation(String s, Configuration configuration) throws InterruptedException, Exception
- {
- Operation oper = Operation.getOperation(s);
- Collection<PropertySimple> props = configuration.getSimpleProperties().values();
- SimpleValueSupport[] params = new SimpleValueSupport[props.size()];
- SimpleValueSupport[] signature = new SimpleValueSupport[props.size()];
- populateParams(props, params, signature);
- ArrayValueSupport param = new ArrayValueSupport(new ArrayMetaType(SimpleMetaType.STRING, false));
- param.setValue(params);
- ArrayValueSupport sig = new ArrayValueSupport(new ArrayMetaType(SimpleMetaType.STRING, false));
- sig.setValue(signature);
- SimpleValueSupport queueName = new SimpleValueSupport(SimpleMetaType.STRING, resourceContext.getResourceKey());
- SimpleValueSupport methodName = new SimpleValueSupport(SimpleMetaType.STRING, oper.getOperationName());
- ManagementView view = getProfileService();
- String methodOperation = getInvokeOperation();
- if("JMSMessage".equalsIgnoreCase(oper.getResultsType()))
- {
- methodOperation = getInvokeOperationJMSMessage();
- }
- else if("SubscriptionInfo".equalsIgnoreCase(oper.getResultsType()))
- {
- methodOperation = getInvokeOperationSubscriptionMessage();
- }
- ManagedOperation operation = ManagementSupport.getOperation(view, getComponentName(), methodOperation, getComponentType());
- Object result = null;
- result = operation.invoke(queueName, methodName, param, sig);
- if (result == null)
- {
- return null;
- }
- return formatResults(result, oper.getResultsType());
- }
-
- protected abstract String getInvokeOperationSubscriptionMessage();
-
- protected abstract String getInvokeOperationJMSMessage();
-
- protected abstract String getInvokeOperation();
-
- public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception
- {
- this.resourceContext = resourceContext;
-
- jmsComponent = (JMSComponent) resourceContext.getParentResourceComponent();
- }
-
- public void stop()
- {
- this.resourceContext = null;
- }
-
- abstract String getComponentName();
-
- abstract ComponentType getComponentType();
-
- abstract String getConfigurationOperationName();
-
- abstract String getMeasurementsOperationName();
-
- abstract String getDeleteOperationName();
-
- private void populateParams(final Collection<PropertySimple> props, final SimpleValueSupport[] params, final SimpleValueSupport[] signature)
- {
- int pos = 0;
- for (PropertySimple prop : props)
- {
- String[] val = prop.getName().split(":");
- if (val.length == 1)
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getStringValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.String");
- }
- else
- {
- if (val[0].equals("Boolean"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getBooleanValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Boolean");
- }
- else if (val[0].equals("boolean"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getBooleanValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "boolean");
- }
- else if (val[0].equals("String"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getStringValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.String");
- }
- else if (val[0].equals("Long"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getLongValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Long");
- }
- else if (val[0].equals("long"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getLongValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "long");
- }
- else if (val[0].equals("Integer"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getIntegerValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Integer");
- }
- else if (val[0].equals("int"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getIntegerValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "int");
- }
- else if (val[0].equals("Double"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getDoubleValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Double");
- }
- else if (val[0].equals("double"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getDoubleValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "double");
- }
- }
- pos++;
- }
- }
-
- private String getStringValue(Object o)
- {
- return o == null ? "null" : o.toString();
- }
-
-
- private OperationResult formatResults(Object val, String type) throws Exception
- {
- if (type == null)
- {
- SimpleValueSupport valueSupport = (SimpleValueSupport) val;
- return new OperationResult(valueSupport.getValue().toString());
- }
- else if(type.equalsIgnoreCase("String"))
- {
- SimpleValueSupport valueSupport = (SimpleValueSupport) val;
- return new OperationResult(valueSupport.getValue().toString());
- }
- else if(type.equalsIgnoreCase("JMSMessage") || type.equalsIgnoreCase("SubscriptionInfo"))
- {
- OperationResult operationResult = new OperationResult();
- Configuration c = operationResult.getComplexResults();
- PropertyList property = new PropertyList("result");
- CollectionValueSupport valueSupport = (CollectionValueSupport) val;
- MetaValue[] msgs = valueSupport.getElements();
- for (MetaValue mv : msgs)
- {
- CompositeValueSupport msg = (CompositeValueSupport) mv;
- org.rhq.core.domain.configuration.PropertyMap p1 = new org.rhq.core.domain.configuration.PropertyMap("element");
- property.add(p1);
- ImmutableCompositeMetaType metaType = (ImmutableCompositeMetaType) msg.getMetaType();
- Set<String> keys = metaType.keySet();
- for (String key : keys)
- {
- SimpleValueSupport sattr = (SimpleValueSupport) msg.get(key);
- if(sattr != null)
- p1.put(new PropertySimple(key,sattr.getValue()));
- }
- }
- c.put(property);
- return operationResult;
- }
- else if (val instanceof CompositeValueSupport)
- {
- CompositeValueSupport valueSupport = (CompositeValueSupport) val;
- if (valueSupport.containsKey("cause"))
- {
- CompositeValueSupport cause = (CompositeValueSupport) valueSupport.get("cause");
- SimpleValueSupport message = (SimpleValueSupport) cause.get("message");
- Exception exception = new Exception(message.toString());
- throw exception;
- }
- return new OperationResult("not yet");
- }
- return new OperationResult("not yet");
- }
-
- public ManagementView getProfileService() throws Exception
- {
- return jmsComponent.getProfileService();
- }
-}
Copied: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueComponent.java (from rev 102862, trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueComponent2.java)
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueComponent.java (rev 0)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueComponent.java 2010-03-24 09:23:46 UTC (rev 102864)
@@ -0,0 +1,342 @@
+/*
+* 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.ManagementSupport;
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.rhq.core.domain.configuration.*;
+import org.rhq.core.domain.measurement.AvailabilityType;
+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;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ * Created: 17-Mar-2010
+ */
+public class JMSQueueComponent extends JMSResourceComponent implements ResourceComponent, MeasurementFacet, OperationFacet, ConfigurationFacet
+{
+ private ResourceContext resourceContext;
+
+ private static ComponentType queueComponentType = new ComponentType("JMSDestinationManage", "QueueManage");
+
+ private static String queueComponentName = "JMSQueueManageMO";
+ private JMSComponent jmsComponent;
+
+ @Override
+ String getMeasurementsOperationName()
+ {
+ return "getQueueMeasurements";
+ }
+
+ public AvailabilityType getAvailability()
+ {
+ return AvailabilityType.UP;
+ }
+
+ @Override
+ String getComponentName()
+ {
+ return queueComponentName;
+ }
+
+ @Override
+ ComponentType getComponentType()
+ {
+ return queueComponentType;
+ }
+
+ @Override
+ String getConfigurationOperationName()
+ {
+ return "getQueueConfiguration";
+ }
+
+ @Override
+ protected String getInvokeOperation()
+ {
+ return "invokeQueueOperation";
+ }
+
+ @Override
+ protected String getInvokeOperationJMSMessage()
+ {
+ return "invokeQueueOperationMessageType";
+ }
+
+ @Override
+ protected String getInvokeOperationSubscriptionMessage()
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ String getDeleteOperationName()
+ {
+ return "deleteQueue";
+ }
+
+ public void updateResourceConfiguration(ConfigurationUpdateReport configurationUpdateReport)
+ {
+ configurationUpdateReport.setStatus(ConfigurationUpdateStatus.INPROGRESS);
+
+ ManagementView view = null;
+ try
+ {
+ view = getProfileService();
+ }
+ catch (Exception e)
+ {
+ configurationUpdateReport.setStatus(ConfigurationUpdateStatus.FAILURE);
+ configurationUpdateReport.setErrorMessage(e.getMessage());
+ e.printStackTrace();
+ return;
+ }
+ Map<String, PropertySimple> simpleProps = configurationUpdateReport.getConfiguration().getSimpleProperties();
+ String name = simpleProps.get("name").getStringValue();
+ String jndiName = simpleProps.get("jndiBindings").getStringValue();
+ String DLA = simpleProps.get("dla").getStringValue();
+ String expiryAddress = simpleProps.get("expiryAddress").getStringValue();
+ int maxSize = simpleProps.get("maxSize").getIntegerValue();
+ int pageSize = simpleProps.get("pageSize").getIntegerValue();
+ int maxDeliveryAttempts = simpleProps.get("maxDeliveryAttempts").getIntegerValue();
+ long redeliveryDelay = simpleProps.get("redeliveryDelay").getLongValue();
+ boolean lastValueQueue = simpleProps.get("lastValueQueue").getBooleanValue();
+ long redistributionDelay = simpleProps.get("redistributionDelay").getLongValue();
+ boolean sendToDLAOnNoRoute = simpleProps.get("sendToDLAOnNoRoute").getBooleanValue();
+ String addressFullMessagePolicy = simpleProps.get("addressFullMessagePolicy").getStringValue();
+
+
+ StringBuffer sendRoles = new StringBuffer();
+ StringBuffer consumeRoles = new StringBuffer();
+ createRoles(configurationUpdateReport, name, sendRoles, consumeRoles);
+ try
+ {
+ ManagedOperation operation = ManagementSupport.getOperation(view, queueComponentName, "updateQueueConfiguration", queueComponentType);
+ operation.invoke(new SimpleValueSupport(SimpleMetaType.STRING, resourceContext.getResourceKey()),
+ new SimpleValueSupport(SimpleMetaType.STRING, jndiName),
+ new SimpleValueSupport(SimpleMetaType.STRING, DLA),
+ new SimpleValueSupport(SimpleMetaType.STRING, expiryAddress),
+ new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, maxSize),
+ new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, pageSize),
+ new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, maxDeliveryAttempts),
+ new SimpleValueSupport(SimpleMetaType.LONG_PRIMITIVE, redeliveryDelay),
+ new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, lastValueQueue),
+ new SimpleValueSupport(SimpleMetaType.LONG_PRIMITIVE, redistributionDelay),
+ new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, sendToDLAOnNoRoute),
+ new SimpleValueSupport(SimpleMetaType.STRING, addressFullMessagePolicy),
+ new SimpleValueSupport(SimpleMetaType.STRING, sendRoles.toString()),
+ new SimpleValueSupport(SimpleMetaType.STRING, consumeRoles.toString()));
+ }
+ catch (Exception e)
+ {
+ configurationUpdateReport.setStatus(ConfigurationUpdateStatus.FAILURE);
+ configurationUpdateReport.setErrorMessage(e.getMessage());
+ e.printStackTrace();
+ return;
+ }
+ configurationUpdateReport.setStatus(ConfigurationUpdateStatus.SUCCESS);
+ }
+
+ private void createRoles(ConfigurationUpdateReport configurationUpdateReport, String name, StringBuffer sendRoles, StringBuffer consumeRoles)
+ {
+ PropertyList propertyList = (PropertyList) configurationUpdateReport.getConfiguration().get("securityConfig");
+ List<Property> roles = propertyList.getList();
+ for (Property role : roles)
+ {
+ PropertyMap actRole = (PropertyMap) role;
+ boolean send;
+ boolean consume;
+ PropertySimple simple = (PropertySimple) actRole.get("name");
+ name = simple.getStringValue();
+ simple = (PropertySimple) actRole.get("send");
+ send = simple.getBooleanValue();
+ simple = (PropertySimple) actRole.get("consume");
+ consume = simple.getBooleanValue();
+ if(send)
+ {
+ if(sendRoles.length() > 0)
+ {
+ sendRoles.append(",");
+ }
+ sendRoles.append(name);
+ }
+ if(consume)
+ {
+ if(consumeRoles.length() > 0)
+ {
+ consumeRoles.append(",");
+ }
+ consumeRoles.append(name);
+ }
+ }
+ }
+
+ public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception
+ {
+ super.start(resourceContext);
+ this.resourceContext = resourceContext;
+ }
+
+ public void stop()
+ {
+ super.stop();
+ this.resourceContext = null;
+ }
+
+ private void populateParams(final Collection<PropertySimple> props, final SimpleValueSupport[] params, final SimpleValueSupport[] signature)
+ {
+ int pos = 0;
+ for (PropertySimple prop : props)
+ {
+ String[] val = prop.getName().split(":");
+ if (val.length == 1)
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getStringValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.String");
+ }
+ else
+ {
+ if (val[0].equals("Boolean"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getBooleanValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Boolean");
+ }
+ else if (val[0].equals("boolean"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getBooleanValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "boolean");
+ }
+ else if (val[0].equals("String"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getStringValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.String");
+ }
+ else if (val[0].equals("Long"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getLongValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Long");
+ }
+ else if (val[0].equals("long"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getLongValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "long");
+ }
+ else if (val[0].equals("Integer"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getIntegerValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Integer");
+ }
+ else if (val[0].equals("int"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getIntegerValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "int");
+ }
+ else if (val[0].equals("Double"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getDoubleValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Double");
+ }
+ else if (val[0].equals("double"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getDoubleValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "double");
+ }
+ }
+ pos++;
+ }
+ }
+
+ private String getStringValue(Object o)
+ {
+ return o == null ? "null" : o.toString();
+ }
+
+
+ private OperationResult formatResults(Object val, String type) throws Exception
+ {
+ if (type == null)
+ {
+ SimpleValueSupport valueSupport = (SimpleValueSupport) val;
+ return new OperationResult(valueSupport.getValue().toString());
+ }
+ else if(type.equalsIgnoreCase("String"))
+ {
+ SimpleValueSupport valueSupport = (SimpleValueSupport) val;
+ return new OperationResult(valueSupport.getValue().toString());
+ }
+ else if(type.equalsIgnoreCase("JMSMessage"))
+ {
+ OperationResult operationResult = new OperationResult();
+ Configuration c = operationResult.getComplexResults();
+ PropertyList property = new PropertyList("result");
+ CollectionValueSupport valueSupport = (CollectionValueSupport) val;
+ MetaValue[] msgs = valueSupport.getElements();
+ for (MetaValue mv : msgs)
+ {
+ CompositeValueSupport msg = (CompositeValueSupport) mv;
+ org.rhq.core.domain.configuration.PropertyMap p1 = new org.rhq.core.domain.configuration.PropertyMap("element");
+ property.add(p1);
+ ImmutableCompositeMetaType metaType = (ImmutableCompositeMetaType) msg.getMetaType();
+ Set<String> keys = metaType.keySet();
+ for (String key : keys)
+ {
+ SimpleValueSupport sattr = (SimpleValueSupport) msg.get(key);
+ p1.put(new PropertySimple(key,sattr.getValue()));
+ }
+ }
+ c.put(property);
+ return operationResult;
+ }
+ else if (val instanceof CompositeValueSupport)
+ {
+ CompositeValueSupport valueSupport = (CompositeValueSupport) val;
+ if (valueSupport.containsKey("cause"))
+ {
+ CompositeValueSupport cause = (CompositeValueSupport) valueSupport.get("cause");
+ SimpleValueSupport message = (SimpleValueSupport) cause.get("message");
+ Exception exception = new Exception(message.toString());
+ throw exception;
+ }
+ return new OperationResult("not yet");
+ }
+ return new OperationResult("not yet");
+ }
+}
\ No newline at end of file
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueComponent2.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueComponent2.java 2010-03-24 09:17:42 UTC (rev 102863)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueComponent2.java 2010-03-24 09:23:46 UTC (rev 102864)
@@ -1,342 +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.ManagementSupport;
-import org.jboss.deployers.spi.management.ManagementView;
-import org.jboss.managed.api.ComponentType;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
-import org.jboss.metatype.api.types.SimpleMetaType;
-import org.jboss.metatype.api.values.CollectionValueSupport;
-import org.jboss.metatype.api.values.CompositeValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.rhq.core.domain.configuration.*;
-import org.rhq.core.domain.measurement.AvailabilityType;
-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;
-
-/**
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- * Created: 17-Mar-2010
- */
-public class JMSQueueComponent2 extends JMSDestinationComponent implements ResourceComponent, MeasurementFacet, OperationFacet, ConfigurationFacet
-{
- private ResourceContext resourceContext;
-
- private static ComponentType queueComponentType = new ComponentType("JMSDestinationManage", "QueueManage");
-
- private static String queueComponentName = "JMSQueueManageMO";
- private JMSComponent jmsComponent;
-
- @Override
- String getMeasurementsOperationName()
- {
- return "getQueueMeasurements";
- }
-
- public AvailabilityType getAvailability()
- {
- return AvailabilityType.UP;
- }
-
- @Override
- String getComponentName()
- {
- return queueComponentName;
- }
-
- @Override
- ComponentType getComponentType()
- {
- return queueComponentType;
- }
-
- @Override
- String getConfigurationOperationName()
- {
- return "getQueueConfiguration";
- }
-
- @Override
- protected String getInvokeOperation()
- {
- return "invokeQueueOperation";
- }
-
- @Override
- protected String getInvokeOperationJMSMessage()
- {
- return "invokeQueueOperationMessageType";
- }
-
- @Override
- protected String getInvokeOperationSubscriptionMessage()
- {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- @Override
- String getDeleteOperationName()
- {
- return "deleteQueue";
- }
-
- public void updateResourceConfiguration(ConfigurationUpdateReport configurationUpdateReport)
- {
- configurationUpdateReport.setStatus(ConfigurationUpdateStatus.INPROGRESS);
-
- ManagementView view = null;
- try
- {
- view = getProfileService();
- }
- catch (Exception e)
- {
- configurationUpdateReport.setStatus(ConfigurationUpdateStatus.FAILURE);
- configurationUpdateReport.setErrorMessage(e.getMessage());
- e.printStackTrace();
- return;
- }
- Map<String, PropertySimple> simpleProps = configurationUpdateReport.getConfiguration().getSimpleProperties();
- String name = simpleProps.get("name").getStringValue();
- String jndiName = simpleProps.get("jndiBindings").getStringValue();
- String DLA = simpleProps.get("dla").getStringValue();
- String expiryAddress = simpleProps.get("expiryAddress").getStringValue();
- int maxSize = simpleProps.get("maxSize").getIntegerValue();
- int pageSize = simpleProps.get("pageSize").getIntegerValue();
- int maxDeliveryAttempts = simpleProps.get("maxDeliveryAttempts").getIntegerValue();
- long redeliveryDelay = simpleProps.get("redeliveryDelay").getLongValue();
- boolean lastValueQueue = simpleProps.get("lastValueQueue").getBooleanValue();
- long redistributionDelay = simpleProps.get("redistributionDelay").getLongValue();
- boolean sendToDLAOnNoRoute = simpleProps.get("sendToDLAOnNoRoute").getBooleanValue();
- String addressFullMessagePolicy = simpleProps.get("addressFullMessagePolicy").getStringValue();
-
-
- StringBuffer sendRoles = new StringBuffer();
- StringBuffer consumeRoles = new StringBuffer();
- createRoles(configurationUpdateReport, name, sendRoles, consumeRoles);
- try
- {
- ManagedOperation operation = ManagementSupport.getOperation(view, queueComponentName, "updateQueueConfiguration", queueComponentType);
- operation.invoke(new SimpleValueSupport(SimpleMetaType.STRING, resourceContext.getResourceKey()),
- new SimpleValueSupport(SimpleMetaType.STRING, jndiName),
- new SimpleValueSupport(SimpleMetaType.STRING, DLA),
- new SimpleValueSupport(SimpleMetaType.STRING, expiryAddress),
- new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, maxSize),
- new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, pageSize),
- new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, maxDeliveryAttempts),
- new SimpleValueSupport(SimpleMetaType.LONG_PRIMITIVE, redeliveryDelay),
- new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, lastValueQueue),
- new SimpleValueSupport(SimpleMetaType.LONG_PRIMITIVE, redistributionDelay),
- new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, sendToDLAOnNoRoute),
- new SimpleValueSupport(SimpleMetaType.STRING, addressFullMessagePolicy),
- new SimpleValueSupport(SimpleMetaType.STRING, sendRoles.toString()),
- new SimpleValueSupport(SimpleMetaType.STRING, consumeRoles.toString()));
- }
- catch (Exception e)
- {
- configurationUpdateReport.setStatus(ConfigurationUpdateStatus.FAILURE);
- configurationUpdateReport.setErrorMessage(e.getMessage());
- e.printStackTrace();
- return;
- }
- configurationUpdateReport.setStatus(ConfigurationUpdateStatus.SUCCESS);
- }
-
- private void createRoles(ConfigurationUpdateReport configurationUpdateReport, String name, StringBuffer sendRoles, StringBuffer consumeRoles)
- {
- PropertyList propertyList = (PropertyList) configurationUpdateReport.getConfiguration().get("securityConfig");
- List<Property> roles = propertyList.getList();
- for (Property role : roles)
- {
- PropertyMap actRole = (PropertyMap) role;
- boolean send;
- boolean consume;
- PropertySimple simple = (PropertySimple) actRole.get("name");
- name = simple.getStringValue();
- simple = (PropertySimple) actRole.get("send");
- send = simple.getBooleanValue();
- simple = (PropertySimple) actRole.get("consume");
- consume = simple.getBooleanValue();
- if(send)
- {
- if(sendRoles.length() > 0)
- {
- sendRoles.append(",");
- }
- sendRoles.append(name);
- }
- if(consume)
- {
- if(consumeRoles.length() > 0)
- {
- consumeRoles.append(",");
- }
- consumeRoles.append(name);
- }
- }
- }
-
- public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception
- {
- super.start(resourceContext);
- this.resourceContext = resourceContext;
- }
-
- public void stop()
- {
- super.stop();
- this.resourceContext = null;
- }
-
- private void populateParams(final Collection<PropertySimple> props, final SimpleValueSupport[] params, final SimpleValueSupport[] signature)
- {
- int pos = 0;
- for (PropertySimple prop : props)
- {
- String[] val = prop.getName().split(":");
- if (val.length == 1)
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getStringValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.String");
- }
- else
- {
- if (val[0].equals("Boolean"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getBooleanValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Boolean");
- }
- else if (val[0].equals("boolean"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getBooleanValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "boolean");
- }
- else if (val[0].equals("String"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getStringValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.String");
- }
- else if (val[0].equals("Long"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getLongValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Long");
- }
- else if (val[0].equals("long"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getLongValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "long");
- }
- else if (val[0].equals("Integer"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getIntegerValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Integer");
- }
- else if (val[0].equals("int"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getIntegerValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "int");
- }
- else if (val[0].equals("Double"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getDoubleValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Double");
- }
- else if (val[0].equals("double"))
- {
- params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getDoubleValue()));
- signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "double");
- }
- }
- pos++;
- }
- }
-
- private String getStringValue(Object o)
- {
- return o == null ? "null" : o.toString();
- }
-
-
- private OperationResult formatResults(Object val, String type) throws Exception
- {
- if (type == null)
- {
- SimpleValueSupport valueSupport = (SimpleValueSupport) val;
- return new OperationResult(valueSupport.getValue().toString());
- }
- else if(type.equalsIgnoreCase("String"))
- {
- SimpleValueSupport valueSupport = (SimpleValueSupport) val;
- return new OperationResult(valueSupport.getValue().toString());
- }
- else if(type.equalsIgnoreCase("JMSMessage"))
- {
- OperationResult operationResult = new OperationResult();
- Configuration c = operationResult.getComplexResults();
- PropertyList property = new PropertyList("result");
- CollectionValueSupport valueSupport = (CollectionValueSupport) val;
- MetaValue[] msgs = valueSupport.getElements();
- for (MetaValue mv : msgs)
- {
- CompositeValueSupport msg = (CompositeValueSupport) mv;
- org.rhq.core.domain.configuration.PropertyMap p1 = new org.rhq.core.domain.configuration.PropertyMap("element");
- property.add(p1);
- ImmutableCompositeMetaType metaType = (ImmutableCompositeMetaType) msg.getMetaType();
- Set<String> keys = metaType.keySet();
- for (String key : keys)
- {
- SimpleValueSupport sattr = (SimpleValueSupport) msg.get(key);
- p1.put(new PropertySimple(key,sattr.getValue()));
- }
- }
- c.put(property);
- return operationResult;
- }
- else if (val instanceof CompositeValueSupport)
- {
- CompositeValueSupport valueSupport = (CompositeValueSupport) val;
- if (valueSupport.containsKey("cause"))
- {
- CompositeValueSupport cause = (CompositeValueSupport) valueSupport.get("cause");
- SimpleValueSupport message = (SimpleValueSupport) cause.get("message");
- Exception exception = new Exception(message.toString());
- throw exception;
- }
- return new OperationResult("not yet");
- }
- return new OperationResult("not yet");
- }
-}
\ No newline at end of file
Copied: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueDiscoveryComponent.java (from rev 102862, trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueDiscoveryComponent2.java)
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueDiscoveryComponent.java (rev 0)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueDiscoveryComponent.java 2010-03-24 09:23:46 UTC (rev 102864)
@@ -0,0 +1,72 @@
+/*
+* 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.ManagementSupport;
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.metatype.api.values.ArrayValueSupport;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.resource.ResourceType;
+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.Set;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ */
+public class JMSQueueDiscoveryComponent implements ResourceDiscoveryComponent
+{
+ private static final ComponentType componentType = new ComponentType("JMSDestinationManage", "QueueManage");
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception
+ {
+ Set<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
+ JMSComponent context = (JMSComponent) resourceDiscoveryContext.getParentResourceComponent();
+ ManagementView managementView = context.getProfileService();
+ ManagedOperation operation = ManagementSupport.getOperation(managementView, "JMSQueueManageMO", "getJMSQueues", componentType);
+
+ ArrayValueSupport value = (ArrayValueSupport) operation.invoke();
+
+ for (int i = 0; i < value.getLength(); i++)
+ {
+ Configuration configuration = new Configuration();
+ SimpleValueSupport queue = (SimpleValueSupport) value.getValue(i);
+ ResourceType resourceType = resourceDiscoveryContext.getResourceType();
+ String queueName = "jms.queue." + queue.getValue();
+ set.add(new DiscoveredResourceDetails(resourceType,
+ queueName,
+ queueName,
+ "a JMS Queue",
+ "",
+ configuration,
+ null));
+ }
+ return set;
+ }
+}
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueDiscoveryComponent2.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueDiscoveryComponent2.java 2010-03-24 09:17:42 UTC (rev 102863)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSQueueDiscoveryComponent2.java 2010-03-24 09:23:46 UTC (rev 102864)
@@ -1,72 +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.ManagementSupport;
-import org.jboss.deployers.spi.management.ManagementView;
-import org.jboss.managed.api.ComponentType;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.metatype.api.values.ArrayValueSupport;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.resource.ResourceType;
-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.Set;
-
-/**
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- */
-public class JMSQueueDiscoveryComponent2 implements ResourceDiscoveryComponent
-{
- private static final ComponentType componentType = new ComponentType("JMSDestinationManage", "QueueManage");
-
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception
- {
- Set<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
- JMSComponent context = (JMSComponent) resourceDiscoveryContext.getParentResourceComponent();
- ManagementView managementView = context.getProfileService();
- ManagedOperation operation = ManagementSupport.getOperation(managementView, "JMSQueueManageMO", "getJMSQueues", componentType);
-
- ArrayValueSupport value = (ArrayValueSupport) operation.invoke();
-
- for (int i = 0; i < value.getLength(); i++)
- {
- Configuration configuration = new Configuration();
- SimpleValueSupport queue = (SimpleValueSupport) value.getValue(i);
- ResourceType resourceType = resourceDiscoveryContext.getResourceType();
- String queueName = "jms.queue." + queue.getValue();
- set.add(new DiscoveredResourceDetails(resourceType,
- queueName,
- queueName,
- "a JMS Queue",
- "",
- configuration,
- null));
- }
- return set;
- }
-}
Copied: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSResourceComponent.java (from rev 102862, trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSDestinationComponent.java)
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSResourceComponent.java (rev 0)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSResourceComponent.java 2010-03-24 09:23:46 UTC (rev 102864)
@@ -0,0 +1,347 @@
+/*
+* 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.ManagementSupport;
+import org.jboss.as.integration.hornetq.jopr.util.Operation;
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.metatype.api.types.ArrayMetaType;
+import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.*;
+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.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.measurement.*;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
+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.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ * Created: 17-Mar-2010
+ */
+public abstract class JMSResourceComponent implements ResourceComponent, MeasurementFacet, OperationFacet, ConfigurationFacet, JMSComponent, DeleteResourceFacet
+{
+ private ResourceContext resourceContext;
+ private JMSComponent jmsComponent;
+
+ public AvailabilityType getAvailability()
+ {
+ return null;
+ }
+
+ public void deleteResource() throws Exception
+ {
+ ManagementView view = getProfileService();
+ ManagedOperation operation = ManagementSupport.getOperation(view, getComponentName(), getDeleteOperationName(), getComponentType());
+ operation.invoke(new SimpleValueSupport(SimpleMetaType.STRING, resourceContext.getResourceKey()));
+ }
+
+
+
+ public void updateResourceConfiguration(ConfigurationUpdateReport configurationUpdateReport)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> measurementScheduleRequests) throws Exception
+ {
+ ArrayValueSupport support = new ArrayValueSupport(new ArrayMetaType(SimpleMetaType.STRING, false));
+ SimpleValueSupport[] valueSupports = new SimpleValueSupport[measurementScheduleRequests.size()];
+ Iterator<MeasurementScheduleRequest> it = measurementScheduleRequests.iterator();
+ for (int i = 0, valueSupportsLength = valueSupports.length; i < valueSupportsLength; i++)
+ {
+ valueSupports[i] = new SimpleValueSupport(SimpleMetaType.STRING, it.next().getName());
+ }
+ support.setValue(valueSupports);
+ ManagementView view = getProfileService();
+
+ ManagedOperation operation = ManagementSupport.getOperation(view, getComponentName(), getMeasurementsOperationName(), getComponentType());
+ ArrayValueSupport vals = (ArrayValueSupport) operation.invoke(new SimpleValueSupport(SimpleMetaType.STRING, resourceContext.getResourceKey()), support);
+ it = measurementScheduleRequests.iterator();
+ for (int i = 0, valueSupportsLength = valueSupports.length; i < valueSupportsLength; i++)
+ {
+ MeasurementScheduleRequest request = it.next();
+ SimpleValueSupport simpleValueSupport = (SimpleValueSupport) vals.getValue(i);
+ simpleValueSupport.getValue();
+ if (request.getDataType().equals(DataType.MEASUREMENT))
+ {
+ report.addData(new MeasurementDataNumeric(request, Double.valueOf(simpleValueSupport.getValue().toString())));
+ }
+ else if (request.getDataType().equals(DataType.TRAIT))
+ {
+ report.addData(new MeasurementDataTrait(request, simpleValueSupport.getValue().toString()));
+ }
+ }
+ }
+
+ public Configuration loadResourceConfiguration() throws Exception
+ {
+ Configuration config = new Configuration();
+ ManagementView view = getProfileService();
+
+ ManagedOperation operation = ManagementSupport.getOperation(view, getComponentName(), getConfigurationOperationName(), getComponentType());
+
+ CompositeValueSupport val = (CompositeValueSupport) operation.invoke(new SimpleValueSupport(SimpleMetaType.STRING, resourceContext.getResourceKey()));
+
+ ConfigurationDefinition configDef = resourceContext.getResourceType().getResourceConfigurationDefinition();
+ List<PropertyDefinition> propertyDefinitionList = configDef.getPropertiesInGroup("HornetQCustomProperties");
+ for (PropertyDefinition definition : propertyDefinitionList)
+ {
+ String name = definition.getName();
+ if (val.containsKey(name))
+ {
+ MetaValue mv = val.get(name);
+ if(mv instanceof SimpleValueSupport)
+ {
+ SimpleValueSupport attr = (SimpleValueSupport) mv;
+ PropertySimple simple = new PropertySimple(name, attr.getValue());
+ config.put(simple);
+ }
+ else if(mv instanceof CollectionValueSupport)
+ {
+ PropertyList property = new PropertyList("securityConfig");
+ CollectionValueSupport valueSupport = (CollectionValueSupport) mv;
+ MetaValue[] msgs = valueSupport.getElements();
+ for (MetaValue mv2 : msgs)
+ {
+ CompositeValueSupport msg = (CompositeValueSupport) mv2;
+ org.rhq.core.domain.configuration.PropertyMap p1 = new org.rhq.core.domain.configuration.PropertyMap("element");
+ property.add(p1);
+ ImmutableCompositeMetaType metaType = (ImmutableCompositeMetaType) msg.getMetaType();
+ Set<String> keys = metaType.keySet();
+ for (String key : keys)
+ {
+ SimpleValueSupport sattr = (SimpleValueSupport) msg.get(key);
+ if(sattr != null)
+ p1.put(new PropertySimple(key,sattr.getValue()));
+ }
+ }
+ config.put(property);
+ }
+ }
+ }
+ return config;
+ }
+
+ public OperationResult invokeOperation(String s, Configuration configuration) throws InterruptedException, Exception
+ {
+ Operation oper = Operation.getOperation(s);
+ Collection<PropertySimple> props = configuration.getSimpleProperties().values();
+ SimpleValueSupport[] params = new SimpleValueSupport[props.size()];
+ SimpleValueSupport[] signature = new SimpleValueSupport[props.size()];
+ populateParams(props, params, signature);
+ ArrayValueSupport param = new ArrayValueSupport(new ArrayMetaType(SimpleMetaType.STRING, false));
+ param.setValue(params);
+ ArrayValueSupport sig = new ArrayValueSupport(new ArrayMetaType(SimpleMetaType.STRING, false));
+ sig.setValue(signature);
+ SimpleValueSupport queueName = new SimpleValueSupport(SimpleMetaType.STRING, resourceContext.getResourceKey());
+ SimpleValueSupport methodName = new SimpleValueSupport(SimpleMetaType.STRING, oper.getOperationName());
+ ManagementView view = getProfileService();
+ String methodOperation = getInvokeOperation();
+ if("JMSMessage".equalsIgnoreCase(oper.getResultsType()))
+ {
+ methodOperation = getInvokeOperationJMSMessage();
+ }
+ else if("SubscriptionInfo".equalsIgnoreCase(oper.getResultsType()))
+ {
+ methodOperation = getInvokeOperationSubscriptionMessage();
+ }
+ ManagedOperation operation = ManagementSupport.getOperation(view, getComponentName(), methodOperation, getComponentType());
+ Object result = null;
+ result = operation.invoke(queueName, methodName, param, sig);
+ if (result == null)
+ {
+ return null;
+ }
+ return formatResults(result, oper.getResultsType());
+ }
+
+ protected abstract String getInvokeOperationSubscriptionMessage();
+
+ protected abstract String getInvokeOperationJMSMessage();
+
+ protected abstract String getInvokeOperation();
+
+ public void start(ResourceContext resourceContext) throws InvalidPluginConfigurationException, Exception
+ {
+ this.resourceContext = resourceContext;
+
+ jmsComponent = (JMSComponent) resourceContext.getParentResourceComponent();
+ }
+
+ public void stop()
+ {
+ this.resourceContext = null;
+ }
+
+ abstract String getComponentName();
+
+ abstract ComponentType getComponentType();
+
+ abstract String getConfigurationOperationName();
+
+ abstract String getMeasurementsOperationName();
+
+ abstract String getDeleteOperationName();
+
+ private void populateParams(final Collection<PropertySimple> props, final SimpleValueSupport[] params, final SimpleValueSupport[] signature)
+ {
+ int pos = 0;
+ for (PropertySimple prop : props)
+ {
+ String[] val = prop.getName().split(":");
+ if (val.length == 1)
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getStringValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.String");
+ }
+ else
+ {
+ if (val[0].equals("Boolean"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getBooleanValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Boolean");
+ }
+ else if (val[0].equals("boolean"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getBooleanValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "boolean");
+ }
+ else if (val[0].equals("String"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getStringValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.String");
+ }
+ else if (val[0].equals("Long"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getLongValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Long");
+ }
+ else if (val[0].equals("long"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getLongValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "long");
+ }
+ else if (val[0].equals("Integer"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getIntegerValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Integer");
+ }
+ else if (val[0].equals("int"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getIntegerValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "int");
+ }
+ else if (val[0].equals("Double"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getDoubleValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "java.lang.Double");
+ }
+ else if (val[0].equals("double"))
+ {
+ params[pos] = new SimpleValueSupport(SimpleMetaType.STRING, getStringValue(prop.getDoubleValue()));
+ signature[pos] = new SimpleValueSupport(SimpleMetaType.STRING, "double");
+ }
+ }
+ pos++;
+ }
+ }
+
+ private String getStringValue(Object o)
+ {
+ return o == null ? "null" : o.toString();
+ }
+
+
+ private OperationResult formatResults(Object val, String type) throws Exception
+ {
+ if (type == null)
+ {
+ SimpleValueSupport valueSupport = (SimpleValueSupport) val;
+ return new OperationResult(valueSupport.getValue().toString());
+ }
+ else if(type.equalsIgnoreCase("String"))
+ {
+ SimpleValueSupport valueSupport = (SimpleValueSupport) val;
+ return new OperationResult(valueSupport.getValue().toString());
+ }
+ else if(type.equalsIgnoreCase("JMSMessage") || type.equalsIgnoreCase("SubscriptionInfo"))
+ {
+ OperationResult operationResult = new OperationResult();
+ Configuration c = operationResult.getComplexResults();
+ PropertyList property = new PropertyList("result");
+ CollectionValueSupport valueSupport = (CollectionValueSupport) val;
+ MetaValue[] msgs = valueSupport.getElements();
+ for (MetaValue mv : msgs)
+ {
+ CompositeValueSupport msg = (CompositeValueSupport) mv;
+ org.rhq.core.domain.configuration.PropertyMap p1 = new org.rhq.core.domain.configuration.PropertyMap("element");
+ property.add(p1);
+ ImmutableCompositeMetaType metaType = (ImmutableCompositeMetaType) msg.getMetaType();
+ Set<String> keys = metaType.keySet();
+ for (String key : keys)
+ {
+ SimpleValueSupport sattr = (SimpleValueSupport) msg.get(key);
+ if(sattr != null)
+ p1.put(new PropertySimple(key,sattr.getValue()));
+ }
+ }
+ c.put(property);
+ return operationResult;
+ }
+ else if (val instanceof CompositeValueSupport)
+ {
+ CompositeValueSupport valueSupport = (CompositeValueSupport) val;
+ if (valueSupport.containsKey("cause"))
+ {
+ CompositeValueSupport cause = (CompositeValueSupport) valueSupport.get("cause");
+ SimpleValueSupport message = (SimpleValueSupport) cause.get("message");
+ Exception exception = new Exception(message.toString());
+ throw exception;
+ }
+ return new OperationResult("not yet");
+ }
+ return new OperationResult("not yet");
+ }
+
+ public ManagementView getProfileService() throws Exception
+ {
+ return jmsComponent.getProfileService();
+ }
+}
Modified: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSTopicComponent.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSTopicComponent.java 2010-03-24 09:17:42 UTC (rev 102863)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSTopicComponent.java 2010-03-24 09:23:46 UTC (rev 102864)
@@ -40,7 +40,7 @@
* @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
* Created: 17-Mar-2010
*/
-public class JMSTopicComponent extends JMSDestinationComponent
+public class JMSTopicComponent extends JMSResourceComponent
{
private ResourceContext resourceContext;
Copied: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSTopicDiscoveryComponent.java (from rev 102862, trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSTopicDiscoveryComponent2.java)
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSTopicDiscoveryComponent.java (rev 0)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSTopicDiscoveryComponent.java 2010-03-24 09:23:46 UTC (rev 102864)
@@ -0,0 +1,72 @@
+/*
+* 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.ManagementSupport;
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.metatype.api.values.ArrayValueSupport;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.resource.ResourceType;
+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.Set;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ */
+public class JMSTopicDiscoveryComponent implements ResourceDiscoveryComponent
+{
+ private static final ComponentType componentType = new ComponentType("JMSDestinationManage", "TopicManage");
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception
+ {
+ Set<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
+ JMSComponent context = (JMSComponent) resourceDiscoveryContext.getParentResourceComponent();
+ ManagementView managementView = context.getProfileService();
+ ManagedOperation operation = ManagementSupport.getOperation(managementView, "JMSTopicManageMO", "getJMSTopics", componentType);
+
+ ArrayValueSupport value = (ArrayValueSupport) operation.invoke();
+
+ for (int i = 0; i < value.getLength(); i++)
+ {
+ Configuration configuration = new Configuration();
+ SimpleValueSupport queue = (SimpleValueSupport) value.getValue(i);
+ ResourceType resourceType = resourceDiscoveryContext.getResourceType();
+ String queueName = "jms.topic." + queue.getValue();
+ set.add(new DiscoveredResourceDetails(resourceType,
+ queueName,
+ queueName,
+ "a JMS Topic",
+ "",
+ configuration,
+ null));
+ }
+ return set;
+ }
+}
\ No newline at end of file
Deleted: trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSTopicDiscoveryComponent2.java
===================================================================
--- trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSTopicDiscoveryComponent2.java 2010-03-24 09:17:42 UTC (rev 102863)
+++ trunk/hornetq-int/src/main/java/org/jboss/as/integration/hornetq/jopr/JMSTopicDiscoveryComponent2.java 2010-03-24 09:23:46 UTC (rev 102864)
@@ -1,72 +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.ManagementSupport;
-import org.jboss.deployers.spi.management.ManagementView;
-import org.jboss.managed.api.ComponentType;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.metatype.api.values.ArrayValueSupport;
-import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.resource.ResourceType;
-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.Set;
-
-/**
- * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
- */
-public class JMSTopicDiscoveryComponent2 implements ResourceDiscoveryComponent
-{
- private static final ComponentType componentType = new ComponentType("JMSDestinationManage", "TopicManage");
-
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException, Exception
- {
- Set<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
- JMSComponent context = (JMSComponent) resourceDiscoveryContext.getParentResourceComponent();
- ManagementView managementView = context.getProfileService();
- ManagedOperation operation = ManagementSupport.getOperation(managementView, "JMSTopicManageMO", "getJMSTopics", componentType);
-
- ArrayValueSupport value = (ArrayValueSupport) operation.invoke();
-
- for (int i = 0; i < value.getLength(); i++)
- {
- Configuration configuration = new Configuration();
- SimpleValueSupport queue = (SimpleValueSupport) value.getValue(i);
- ResourceType resourceType = resourceDiscoveryContext.getResourceType();
- String queueName = "jms.topic." + queue.getValue();
- set.add(new DiscoveredResourceDetails(resourceType,
- queueName,
- queueName,
- "a JMS Topic",
- "",
- configuration,
- null));
- }
- return set;
- }
-}
\ No newline at end of file
Modified: trunk/hornetq-int/src/resources/META-INF/rhq-plugin.xml
===================================================================
--- trunk/hornetq-int/src/resources/META-INF/rhq-plugin.xml 2010-03-24 09:17:42 UTC (rev 102863)
+++ trunk/hornetq-int/src/resources/META-INF/rhq-plugin.xml 2010-03-24 09:23:46 UTC (rev 102864)
@@ -48,8 +48,8 @@
</runs-inside>
<service name="JMS Queue"
- discovery="JMSQueueDiscoveryComponent2"
- class="JMSQueueComponent2"
+ discovery="JMSQueueDiscoveryComponent"
+ class="JMSQueueComponent"
createDeletePolicy="both">
<operation name="removeMessages" displayName="remove messages"
description="Remove the messages corresponding to the given filter.">
@@ -313,7 +313,7 @@
</resource-configuration>
</service>
<service name="JMS Topic"
- discovery="JMSTopicDiscoveryComponent2"
+ discovery="JMSTopicDiscoveryComponent"
class="JMSTopicComponent"
createDeletePolicy="both">
<operation name="listAllSubscriptions,result=SubscriptionInfo" displayName="list all subscriptions"
More information about the jboss-cvs-commits
mailing list