[jboss-cvs] JBossAS SVN: r87013 - in branches/Branch_5_x: messaging/src/main/org/jboss/jms/server/destination and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Apr 8 18:06:46 EDT 2009
Author: scott.stark at jboss.org
Date: 2009-04-08 18:06:46 -0400 (Wed, 08 Apr 2009)
New Revision: 87013
Added:
branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/MessageListMapper.java
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationDelegate.java
Modified:
branches/Branch_5_x/component-matrix/pom.xml
branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/QueueServiceMO.java
branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/TopicServiceMO.java
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/PlatformMBeanKernelRegistryPlugin.java
branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
Log:
JBAS-6736, update handling of topic/queue list of message operations
Modified: branches/Branch_5_x/component-matrix/pom.xml
===================================================================
--- branches/Branch_5_x/component-matrix/pom.xml 2009-04-08 22:02:28 UTC (rev 87012)
+++ branches/Branch_5_x/component-matrix/pom.xml 2009-04-08 22:06:46 UTC (rev 87013)
@@ -69,12 +69,12 @@
<version.org.jboss.ejb3.proxy.clustered.client>1.0.1</version.org.jboss.ejb3.proxy.clustered.client>
<version.org.jboss.ejb3.security.client>1.0.0</version.org.jboss.ejb3.security.client>
<version.org.jboss.ejb3>1.1.3</version.org.jboss.ejb3>
- <version.org.jboss.integration>5.1.0.CR2</version.org.jboss.integration>
+ <version.org.jboss.integration>5.1.0.CR3</version.org.jboss.integration>
<version.org.jboss.jbossxb>2.0.1.CR1</version.org.jboss.jbossxb>
<version.org.jboss.jpa>1.0.0-CR1</version.org.jboss.jpa>
<version.org.jboss.logbridge>1.0.0.CR4</version.org.jboss.logbridge>
<version.org.jboss.logmanager>1.0.0.CR3</version.org.jboss.logmanager>
- <version.org.jboss.man>2.1.0.CR6</version.org.jboss.man>
+ <version.org.jboss.man>2.1.0.CR7</version.org.jboss.man>
<version.org.jboss.mdr>2.0.1.GA</version.org.jboss.mdr>
<version.org.jboss.metadata>1.0.0.CR17</version.org.jboss.metadata>
<version.org.jboss.microcontainer>2.2.0.M1</version.org.jboss.microcontainer>
Added: branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/MessageListMapper.java
===================================================================
--- branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/MessageListMapper.java (rev 0)
+++ branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/MessageListMapper.java 2009-04-08 22:06:46 UTC (rev 87013)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * 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.jms.server.destination;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jms.Message;
+
+import org.jboss.logging.Logger;
+import org.jboss.metatype.api.types.CollectionMetaType;
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.MetaMapper;
+
+/**
+ * Maps a List<JBossMessage> into a CollectMetaType of CompositeValues.
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class MessageListMapper extends MetaMapper<List<Message>>
+{
+ private static final Logger log = Logger.getLogger(MessageListMapper.class);
+ public static final CollectionMetaType TYPE;
+ public static final CompositeMetaType MSG_TYPE;
+
+ static
+ {
+ String[] itemNames = {
+ "JMSMessageID",
+ "JMSTimestamp",
+ "JMSCorrelationID"
+ };
+ String[] itemDescriptions = {
+ "JMSMessageID",
+ "JMSTimestamp",
+ "JMSCorrelationID"
+ };
+ MetaType[] itemTypes = {
+ SimpleMetaType.STRING,
+ SimpleMetaType.LONG,
+ SimpleMetaType.STRING
+ };
+ MSG_TYPE = new ImmutableCompositeMetaType("javax.jms.Message", "JMS Message",
+ itemNames, itemDescriptions, itemTypes);
+ TYPE = new CollectionMetaType("java.util.List", MSG_TYPE);
+ }
+
+ @Override
+ public MetaValue createMetaValue(MetaType metaType, List<Message> object)
+ {
+ ArrayList<MetaValue> tmp = new ArrayList<MetaValue>();
+ if(object != null)
+ {
+ for(Message m : object)
+ {
+ try
+ {
+ MapCompositeValueSupport cvs = new MapCompositeValueSupport(MSG_TYPE);
+ cvs.put("JMSCorrelationID", SimpleValueSupport.wrap(m.getJMSCorrelationID()));
+ cvs.put("JMSTimestamp", SimpleValueSupport.wrap(m.getJMSTimestamp()));
+ cvs.put("JMSMessageID", SimpleValueSupport.wrap(m.getJMSMessageID()));
+ tmp.add(cvs);
+ }
+ catch(Exception e)
+ {
+ log.warn("Skipping msg: "+m, e);
+ }
+ }
+ }
+ MetaValue[] elements = new MetaValue[tmp.size()];
+ tmp.toArray(elements);
+ CollectionValueSupport msgs = new CollectionValueSupport(TYPE, elements);
+ return msgs;
+ }
+
+ @Override
+ public MetaType getMetaType()
+ {
+ return TYPE;
+ }
+
+ @Override
+ public Type mapToType()
+ {
+ return List.class;
+ }
+
+ /**
+ * This always returns null as Messages cannot be created from a meta value
+ */
+ @Override
+ public List<Message> unwrapMetaValue(MetaValue metaValue)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Property changes on: branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/MessageListMapper.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Modified: branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/QueueServiceMO.java
===================================================================
--- branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/QueueServiceMO.java 2009-04-08 22:02:28 UTC (rev 87012)
+++ branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/QueueServiceMO.java 2009-04-08 22:06:46 UTC (rev 87013)
@@ -192,21 +192,27 @@
public void removeAllMessages() throws Exception { }
@ManagementOperation(description = "List all messages", impact = Impact.ReadOnly)
+ @MetaMapping(MessageListMapper.class)
public List listAllMessages() throws Exception { return null; }
@ManagementOperation(description = "List all messages with selector", impact = Impact.ReadOnly)
+ @MetaMapping(MessageListMapper.class)
public List listAllMessages(String selector) throws Exception { return null; }
@ManagementOperation(description = "List all durable mesages", impact = Impact.ReadOnly)
+ @MetaMapping(MessageListMapper.class)
public List listDurableMessages() throws Exception { return null; }
@ManagementOperation(description = "List all durable mesages using a selector", impact = Impact.ReadOnly)
+ @MetaMapping(MessageListMapper.class)
public List listDurableMessages(String selector) throws Exception { return null; }
@ManagementOperation(description = "List all non durable mesages", impact = Impact.ReadOnly)
+ @MetaMapping(MessageListMapper.class)
public List listNonDurableMessages() throws Exception { return null; }
@ManagementOperation(description = "List all non durable mesages using a selector", impact = Impact.ReadOnly)
+ @MetaMapping(MessageListMapper.class)
public List listNonDurableMessages(String selector) throws Exception { return null; }
@ManagementOperation(description = "Reset the message counter", impact = Impact.WriteOnly)
Modified: branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/TopicServiceMO.java
===================================================================
--- branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/TopicServiceMO.java 2009-04-08 22:02:28 UTC (rev 87012)
+++ branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/destination/TopicServiceMO.java 2009-04-08 22:06:46 UTC (rev 87013)
@@ -209,21 +209,27 @@
public String listNonDurableSubscriptionsAsHTML() throws Exception { return null; }
@ManagementOperation(description = "List all messages for the specified subscription", impact = Impact.ReadOnly)
+ @MetaMapping(MessageListMapper.class)
public List listAllMessages(String subscriptionID) throws Exception { return null; }
@ManagementOperation(description = "List all messages for the specified subscription with the specified selector", impact = Impact.ReadOnly)
+ @MetaMapping(MessageListMapper.class)
public List listAllMessages(String subscriptionID, String selector) throws Exception { return null; }
@ManagementOperation(description = "List all durable messages for the specified subscription", impact = Impact.ReadOnly)
+ @MetaMapping(MessageListMapper.class)
public List listDurableMessages(String subscriptionID) throws Exception { return null; }
@ManagementOperation(description = "List all durable messages for the specified subscription with the specified selector", impact = Impact.ReadOnly)
+ @MetaMapping(MessageListMapper.class)
public List listDurableMessages(String subscriptionID, String selector) throws Exception { return null; }
@ManagementOperation(description = "List all non durable messages for the specified subscription", impact = Impact.ReadOnly)
+ @MetaMapping(MessageListMapper.class)
public List listNonDurableMessages(String subscriptionID) throws Exception { return null; }
@ManagementOperation(description = "List all non durable messages for the specified subscription with the specified selector", impact = Impact.ReadOnly)
+ @MetaMapping(MessageListMapper.class)
public List listNonDurableMessages(String subscriptionID, String selector) throws Exception { return null; }
}
\ No newline at end of file
Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java 2009-04-08 22:02:28 UTC (rev 87012)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/AbstractRuntimeComponentDispatcher.java 2009-04-08 22:06:46 UTC (rev 87013)
@@ -22,8 +22,12 @@
package org.jboss.profileservice.management;
import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.TransientAttachments;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.spi.values.MetaMapper;
/**
* Abstract component dispatcher.
@@ -33,7 +37,29 @@
public abstract class AbstractRuntimeComponentDispatcher implements RuntimeComponentDispatcher
{
private MetaValueFactory valueFactory;
+ /** */
+ private static ThreadLocal<ManagedProperty> activeProperty =
+ new ThreadLocal<ManagedProperty>();
+ private static ThreadLocal<ManagedOperation> activeOperation =
+ new ThreadLocal<ManagedOperation>();
+ public static ManagedProperty getActiveProperty()
+ {
+ return activeProperty.get();
+ }
+ public static void setActiveProperty(ManagedProperty property)
+ {
+ activeProperty.set(property);
+ }
+ public static ManagedOperation getActiveOperation()
+ {
+ return activeOperation.get();
+ }
+ public static void setActiveOperation(ManagedOperation op)
+ {
+ activeOperation.set(op);
+ }
+
protected AbstractRuntimeComponentDispatcher(MetaValueFactory valueFactory)
{
if (valueFactory == null)
@@ -57,7 +83,8 @@
*/
protected MetaValue create(Object value)
{
- return valueFactory.create(value);
+ MetaValue mvalue = valueFactory.create(value);
+ return mvalue;
}
/**
Added: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java (rev 0)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java 2009-04-08 22:06:46 UTC (rev 87013)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * 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.profileservice.management;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
+import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * A delegating runtime component dispatcher, used as the proxy for
+ * ManagedProperty gets and ManagedOperation invokes.
+ *
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class DelegatingComponentDispatcherImpl
+ implements DelegatingComponentDispatcher
+{
+ private static Map<Long, ManagedProperty> properties = new HashMap<Long, ManagedProperty>();
+ private static Map<Long, ManagedOperation> operations = new HashMap<Long, ManagedOperation>();
+
+ private RuntimeComponentDispatcher dispatcher;
+
+ public static void addManagedProperty(Long id, ManagedProperty mp)
+ {
+ properties.put(id, mp);
+ }
+ public static void addManagedOperation(Long id, ManagedOperation op)
+ {
+ operations.put(id, op);
+ }
+
+ public DelegatingComponentDispatcherImpl(RuntimeComponentDispatcher dispatcher)
+ {
+ this.dispatcher = dispatcher;
+ }
+
+ public MetaValue get(Long propID, Object componentName, String propertyName)
+ {
+ ManagedProperty mp = properties.get(propID);
+ AbstractRuntimeComponentDispatcher.setActiveProperty(mp);
+ return dispatcher.get(componentName, propertyName);
+ }
+
+ public MetaValue invoke(Long opID, Object componentName, String methodName, MetaValue... param)
+ {
+ ManagedOperation op = operations.get(opID);
+ AbstractRuntimeComponentDispatcher.setActiveOperation(op);
+
+ MetaValue result = null;
+ if (componentName != null)
+ {
+ result = (MetaValue) dispatcher.invoke(componentName, methodName, param);
+ }
+ return result;
+ }
+
+}
Property changes on: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/DelegatingComponentDispatcherImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java 2009-04-08 22:02:28 UTC (rev 87012)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java 2009-04-08 22:06:46 UTC (rev 87013)
@@ -29,13 +29,18 @@
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.registry.KernelBus;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedParameter;
+import org.jboss.managed.api.ManagedProperty;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.spi.values.MetaMapper;
/**
* Microcontainer KernelBus runtime component dispatcher.
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ * @author Scott.Stark at jboss.org
* @version $Revision$
*/
public class KernelBusRuntimeComponentDispatcher extends AbstractRuntimeComponentDispatcher
@@ -73,7 +78,24 @@
{
try
{
- return create(bus.get(componentName, propertyName));
+ ManagedProperty prop = AbstractRuntimeComponentDispatcher.getActiveProperty();
+ Object value = bus.get(componentName, propertyName);
+ MetaValue mvalue = null;
+ if(value != null)
+ {
+ if(prop != null)
+ {
+ MetaMapper mapper = prop.getTransientAttachment(MetaMapper.class);
+ if(mapper != null)
+ mvalue = mapper.createMetaValue(prop.getMetaType(), value);
+ mvalue = create(value);
+ }
+ else
+ {
+ mvalue = create(value);
+ }
+ }
+ return mvalue;
}
catch (Throwable t)
{
@@ -85,7 +107,21 @@
{
try
{
- bus.set(componentName, propertyName, unwrap(value));
+ ManagedProperty prop = AbstractRuntimeComponentDispatcher.getActiveProperty();
+ Object uvalue = null;
+ if(prop != null)
+ {
+ MetaMapper mapper = prop.getTransientAttachment(MetaMapper.class);
+ if(mapper != null)
+ uvalue = mapper.unwrapMetaValue(value);
+ else
+ uvalue = unwrap(value);
+ }
+ else
+ {
+ uvalue = unwrap(value);
+ }
+ bus.set(componentName, propertyName, uvalue);
}
catch (Throwable t)
{
@@ -97,7 +133,35 @@
{
try
{
- return bus.invoke(componentName, methodName, toArguments(param), toSignature(param));
+ ManagedOperation op = AbstractRuntimeComponentDispatcher.getActiveOperation();
+ ManagedParameter[] params = op.getParameters();
+ String[] sig;
+ Object[] args = new Object[param.length];
+ for(int i=0; i < param.length; i++)
+ {
+ if(params != null && params.length < i)
+ {
+ ManagedParameter mp = params[i];
+ MetaMapper mapper = mp.getTransientAttachment(MetaMapper.class);
+ if(mapper != null)
+ args[i] = mapper.unwrapMetaValue(param[i]);
+ }
+ else
+ args[i] = unwrap(param[i]);
+ }
+
+ Object value = bus.invoke(componentName, methodName, toArguments(param), toSignature(param));
+ MetaValue mvalue = null;
+ if (value != null)
+ {
+ // Look for a return type MetaMapper
+ MetaMapper returnTypeMapper = op.getTransientAttachment(MetaMapper.class);
+ if (returnTypeMapper != null)
+ mvalue = returnTypeMapper.createMetaValue(op.getReturnType(), value);
+ else
+ mvalue = create(value);
+ }
+ return mvalue;
}
catch (Throwable t)
{
Added: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationDelegate.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationDelegate.java (rev 0)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationDelegate.java 2009-04-08 22:06:46 UTC (rev 87013)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * 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.profileservice.management;
+
+import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedParameter;
+import org.jboss.managed.api.ManagedOperation.Impact;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class ManagedOperationDelegate
+ implements ManagedOperation
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 2031110731596810579L;
+ private ManagedOperation delegate;
+ private DelegatingComponentDispatcher dispatcherProxy;
+ private Object componentName;
+ private long opID;
+
+ public ManagedOperationDelegate(long opID, ManagedOperation delegate, Object componentName,
+ DelegatingComponentDispatcher dispatcherProxy)
+ {
+ if (delegate == null)
+ throw new IllegalArgumentException("Null delegate.");
+ this.opID = opID;
+ this.delegate = delegate;
+ this.componentName = componentName;
+ this.dispatcherProxy = dispatcherProxy;
+ }
+
+ public MetaValue invoke(MetaValue... metaValues)
+ {
+ MetaValue mvalue = dispatcherProxy.invoke(opID, componentName, delegate.getName(), metaValues);
+ return mvalue;
+ }
+
+ public String getDescription()
+ {
+ return delegate.getDescription();
+ }
+
+ public String getName()
+ {
+ return delegate.getName();
+ }
+
+ public Impact getImpact()
+ {
+ return delegate.getImpact();
+ }
+
+ public MetaType getReturnType()
+ {
+ return delegate.getReturnType();
+ }
+
+ public ManagedParameter[] getParameters()
+ {
+ return delegate.getParameters();
+ }
+
+ public String[] getReflectionSignature()
+ {
+ return delegate.getReflectionSignature();
+ }
+
+ public <T> T getTransientAttachment(Class<T> expectedType)
+ {
+ return delegate.getTransientAttachment(expectedType);
+ }
+
+ public Object getTransientAttachment(String name)
+ {
+ return delegate.getTransientAttachment(name);
+ }
+
+ public void setTransientAttachment(String name, Object attachment)
+ {
+ delegate.setTransientAttachment(name, attachment);
+ }
+}
Property changes on: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationDelegate.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java 2009-04-08 22:02:28 UTC (rev 87012)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedOperationProxyFactory.java 2009-04-08 22:06:46 UTC (rev 87013)
@@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
import org.jboss.aop.Dispatcher;
import org.jboss.aop.advice.Interceptor;
@@ -32,6 +33,7 @@
import org.jboss.aspects.remoting.MergeMetaDataInterceptor;
import org.jboss.aspects.remoting.Remoting;
import org.jboss.aspects.security.SecurityClientInterceptor;
+import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
import org.jboss.managed.api.ManagedOperation;
import org.jboss.managed.api.ManagedParameter;
@@ -39,6 +41,7 @@
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.spi.values.MetaMapper;
import org.jboss.remoting.InvokerLocator;
/**
@@ -52,12 +55,14 @@
{
/** The serialVersionUID */
private static final long serialVersionUID = 1343224268002757169L;
+ private AtomicLong operationID = new AtomicLong(0);
+ private AtomicLong propertyID = new AtomicLong(0);
private transient RuntimeComponentDispatcher dispatcher;
private transient MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
private transient InvokerLocator locator;
/** The runtime component dispatcher proxy. */
- private RuntimeComponentDispatcher dispatcherProxy;
+ private DelegatingComponentDispatcher dispatcherProxy;
public RuntimeComponentDispatcher getDispatcher()
{
@@ -78,7 +83,7 @@
this.locator = locator;
}
- public RuntimeComponentDispatcher getDispatcherProxy()
+ public DelegatingComponentDispatcher getDispatcherProxy()
{
return dispatcherProxy;
}
@@ -103,9 +108,12 @@
*/
public ManagedProperty createPropertyProxy(ManagedProperty delegate, Object componentName)
{
- return new ManagedPropertyDelegate(delegate, dispatcherProxy, componentName);
+ long propID = propertyID.incrementAndGet();
+ ManagedPropertyDelegate proxy = new ManagedPropertyDelegate(propID, delegate, componentName, dispatcherProxy);
+ DelegatingComponentDispatcherImpl.addManagedProperty(propID, proxy);
+ return proxy;
}
-
+
/**
* Create managed operations for runtime components, where the invoke() can
* be invoked on the client side.
@@ -121,18 +129,21 @@
HashSet<ManagedOperation> opProxies = new HashSet<ManagedOperation>();
for (ManagedOperation op : ops)
{
- opProxies.add(new ManagedOperationDelegate(op, componentName));
+ long opID = operationID.incrementAndGet();
+ ManagedOperationDelegate proxy = new ManagedOperationDelegate(opID, op, componentName, dispatcherProxy);
+ DelegatingComponentDispatcherImpl.addManagedOperation(opID, proxy);
+ opProxies.add(proxy);
}
return opProxies;
}
/**
- * Create a remoting dispachter proxy.
+ * Create a remoting DelegatingComponentDispatcher proxy.
*
* @return the proxy
* @throws Exception
*/
- protected RuntimeComponentDispatcher createDispatcherProxy() throws Exception
+ protected DelegatingComponentDispatcher createDispatcherProxy() throws Exception
{
// The interceptors
ArrayList<Interceptor> interceptors = new ArrayList<Interceptor>();
@@ -140,93 +151,13 @@
interceptors.add(MergeMetaDataInterceptor.singleton);
interceptors.add(InvokeRemoteInterceptor.singleton);
- String dispatchName = "ProfileService.RuntimeComponentDispatcher";
- Class<?>[] ifaces = {RuntimeComponentDispatcher.class};
+ String dispatchName = "ProfileService.DelegatingComponentDispatcher";
+ Class<?>[] ifaces = {DelegatingComponentDispatcher.class};
- RuntimeComponentDispatcher delegate = new DelegatingComponentDispatcher();
+ DelegatingComponentDispatcher delegate = new DelegatingComponentDispatcherImpl(this.dispatcher);
Dispatcher.singleton.registerTarget(dispatchName, delegate);
- return (RuntimeComponentDispatcher) Remoting.createRemoteProxy(dispatchName,
+ return (DelegatingComponentDispatcher) Remoting.createRemoteProxy(dispatchName,
getClass().getClassLoader(), ifaces, locator, interceptors, "ProfileService");
}
- public class ManagedOperationDelegate implements ManagedOperation
- {
- /** The serialVersionUID */
- private static final long serialVersionUID = 2031110731596810579L;
- private ManagedOperation delegate;
- private Object componentName;
-
- public ManagedOperationDelegate(ManagedOperation delegate, Object componentName)
- {
- if (delegate == null)
- throw new IllegalArgumentException("Null delegate.");
- this.delegate = delegate;
- this.componentName = componentName;
- }
-
- public MetaValue invoke(MetaValue... metaValues)
- {
- return (MetaValue) dispatcherProxy.invoke(componentName, delegate.getName(), metaValues);
- }
-
- public String getDescription()
- {
- return delegate.getDescription();
- }
-
- public String getName()
- {
- return delegate.getName();
- }
-
- public Impact getImpact()
- {
- return delegate.getImpact();
- }
-
- public MetaType getReturnType()
- {
- return delegate.getReturnType();
- }
-
- public ManagedParameter[] getParameters()
- {
- return delegate.getParameters();
- }
-
- public String[] getReflectionSignature()
- {
- return delegate.getReflectionSignature();
- }
- }
-
- /**
- * A delegating runtime component dispatcher, used as the proxy.
- * This contains additional unwrapping for managed operations.
- */
- public class DelegatingComponentDispatcher implements RuntimeComponentDispatcher
- {
- public MetaValue get(Object componentName, String propertyName)
- {
- return dispatcher.get(componentName, propertyName);
- }
-
- public Object invoke(Object componentName, String methodName, MetaValue... param)
- {
- MetaValue result = null;
- if (componentName != null)
- {
- Object value = dispatcher.invoke(componentName, methodName, param);
- if (value != null)
- result = metaValueFactory.create(value);
- }
- return result;
- }
-
- public void set(Object componentName, String propertyName, MetaValue value)
- {
- throw new IllegalArgumentException("Operation not supported remote.");
- }
- }
}
-
Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java 2009-04-08 22:02:28 UTC (rev 87012)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagedPropertyDelegate.java 2009-04-08 22:06:46 UTC (rev 87013)
@@ -26,7 +26,7 @@
import java.util.Map;
import java.util.Set;
-import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
+import org.jboss.deployers.spi.management.DelegatingComponentDispatcher;
import org.jboss.managed.api.Fields;
import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.ManagedProperty;
@@ -45,15 +45,17 @@
{
private final static long serialVersionUID = 1;
private ManagedProperty delegate;
- /** The dispatcher handles ManagedOperation dispatches */
- private RuntimeComponentDispatcher dispatcher;
+ /** The dispatcher handles property get dispatches */
+ private DelegatingComponentDispatcher dispatcher;
private Object componentName;
+ private long propID;
- public ManagedPropertyDelegate(ManagedProperty delegate,
- RuntimeComponentDispatcher dispatcher, Object componentName)
+ public ManagedPropertyDelegate(long propID, ManagedProperty delegate,
+ Object componentName, DelegatingComponentDispatcher dispatcher)
{
super();
+ this.propID = propID;
this.delegate = delegate;
this.dispatcher = dispatcher;
this.componentName = componentName;
@@ -142,7 +144,8 @@
public MetaValue getValue()
{
String propName = getMappedName();
- MetaValue propValue = dispatcher.get(componentName, propName);
+ AbstractRuntimeComponentDispatcher.setActiveProperty(delegate);
+ MetaValue propValue = dispatcher.get(propID, componentName, propName);
return propValue;
}
Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2009-04-08 22:02:28 UTC (rev 87012)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2009-04-08 22:06:46 UTC (rev 87013)
@@ -1295,6 +1295,7 @@
String propName = prop.getMappedName();
try
{
+ AbstractRuntimeComponentDispatcher.setActiveProperty(prop);
MetaValue propValue = dispatcher.get(componentName, propName);
if(propValue != null)
prop.setValue(propValue);
Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/PlatformMBeanKernelRegistryPlugin.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/PlatformMBeanKernelRegistryPlugin.java 2009-04-08 22:02:28 UTC (rev 87012)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/PlatformMBeanKernelRegistryPlugin.java 2009-04-08 22:06:46 UTC (rev 87013)
@@ -35,7 +35,9 @@
import java.util.List;
import java.util.Map;
+import javax.management.InstanceNotFoundException;
import javax.management.MBeanServer;
+import javax.management.ObjectInstance;
import javax.management.ObjectName;
import org.jboss.kernel.spi.registry.KernelRegistryEntry;
@@ -53,6 +55,7 @@
private Map<String, KernelRegistryEntry> mbeans = new HashMap<String, KernelRegistryEntry>();
/** The service controller */
private ServiceController serviceController;
+ private MBeanServer mbeanServer;
public ServiceController getServiceController()
{
@@ -63,14 +66,41 @@
this.serviceController = serviceController;
}
+ public MBeanServer getMbeanServer()
+ {
+ return mbeanServer;
+ }
+ public void setMbeanServer(MBeanServer mbeanServer)
+ {
+ this.mbeanServer = mbeanServer;
+ }
+
public KernelRegistryEntry getEntry(Object name)
{
String key;
+ ObjectName oname = null;
if(name instanceof ObjectName)
- key = ((ObjectName)name).getCanonicalName();
+ {
+ oname = ObjectName.class.cast(name);
+ key = oname.getCanonicalName();
+ }
else
key = name.toString();
KernelRegistryEntry entry = mbeans.get(key);
+ // If
+ if(entry == null && oname != null)
+ {
+ System.out.println("Searching for MBean: "+oname);
+ try
+ {
+ ObjectInstance oi = mbeanServer.getObjectInstance(oname);
+ System.out.println("Found "+oname+", "+oi.getClassName());
+ }
+ catch (InstanceNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+ }
return entry;
}
Modified: branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java 2009-04-08 22:02:28 UTC (rev 87012)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java 2009-04-08 22:06:46 UTC (rev 87013)
@@ -59,6 +59,7 @@
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedOperation;
import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.ManagedOperationMatcher;
import org.jboss.metatype.api.types.MapCompositeMetaType;
import org.jboss.metatype.api.types.MetaType;
import org.jboss.metatype.api.types.SimpleMetaType;
@@ -215,38 +216,10 @@
{
// Get the managed component
ManagedComponent component = getManagementView().getComponent("testCreateQueue", QueueType);
+ assertNotNull("testCreateQueue ManagedComponent", component);
- // The message count property
- ManagedProperty property = component.getProperty("messageCount");
- assertNotNull(property);
- ManagedProperty messageCounter = component.getProperty("messageCounter");
- assertNotNull(messageCounter);
-
- // Send a message
- Queue queue = (Queue) getInitialContext().lookup("testCreateQueue");
- assertNotNull(queue);
- QueueConnectionFactory qCf = (QueueConnectionFactory) getInitialContext().lookup("ConnectionFactory");
- QueueConnection c = qCf.createQueueConnection();
- c.start();
- QueueSession s = c.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
- QueueSender sender = s.createSender(queue);
-
- //
- sender.send(s.createTextMessage("Hey!"));
-
- SimpleValue messageCount = (SimpleValue) property.getValue();
- assertTrue((Integer) (messageCount).getValue() > 0);
- assertEquals(((CompositeValue) messageCounter.getValue()).get("messageCount"), messageCount);
-
- //
- sender.send(s.createTextMessage("Message2"));
-
- SimpleValue messageCount2 = (SimpleValue) property.getValue();
- assertTrue(messageCount2.compareTo(messageCount) > 0);
- assertEquals(((CompositeValue) messageCounter.getValue()).get("messageCount"), messageCount2);
-
- c.stop();
- c.close();
+ // Send a few messages and validate the msg counts
+ sendQueueMsgs("testCreateQueue", component);
}
public void testQueueOperations() throws Exception
@@ -517,6 +490,75 @@
assertNull("queue should be removed" + queue, queue);
}
+ protected void sendQueueMsgs(String jndiName, ManagedComponent component)
+ throws Exception
+ {
+ // The message count property
+ ManagedProperty messageCount = component.getProperty("messageCount");
+ assertNotNull("messageCount", messageCount);
+ ManagedProperty messageCounter = component.getProperty("messageCounter");
+ assertNotNull("messageCounter", messageCounter);
+
+ // Clear any
+ Set<ManagedOperation> ops = component.getOperations();
+ ManagedOperation removeAllMessages = ManagedOperationMatcher.findOperation(ops, "removeAllMessages");
+ assertNotNull("removeAllMessages", removeAllMessages);
+ removeAllMessages.invoke();
+ assertEquals(SimpleValueSupport.wrap(0), messageCount.getValue());
+
+ // Send a message
+ Queue queue = (Queue) getInitialContext().lookup(jndiName);
+ assertNotNull(queue);
+ QueueConnectionFactory qCf = (QueueConnectionFactory) getInitialContext().lookup("ConnectionFactory");
+ QueueConnection c = qCf.createQueueConnection();
+ c.start();
+ QueueSession s = c.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+ QueueSender sender = s.createSender(queue);
+
+ // Message 1
+ sender.send(s.createTextMessage("Hey!"));
+
+ SimpleValue messageCount1 = (SimpleValue) messageCount.getValue();
+ assertTrue((Integer) (messageCount1).getValue() > 0);
+ CompositeValue messageCounterCV = (CompositeValue) messageCounter.getValue();
+ log.info(messageCounterCV);
+ assertEquals(messageCounterCV.get("messageCount"), messageCount1);
+
+ // Message 2
+ sender.send(s.createTextMessage("Message2"));
+
+ SimpleValue messageCount2 = (SimpleValue) messageCount.getValue();
+ assertTrue(messageCount2.compareTo(messageCount1) > 0);
+ messageCounterCV = (CompositeValue) messageCounter.getValue();
+ assertEquals(messageCounterCV.get("messageCount"), messageCount2);
+
+ //
+ ManagedOperation listAllMessages = ManagedOperationMatcher.findOperation(ops, "listAllMessages");
+ assertNotNull("listAllMessages", listAllMessages);
+ MetaValue msgs = listAllMessages.invoke();
+ assertNotNull(msgs);
+ log.info("listAllMessages.MV: "+msgs);
+ assertTrue("msgs is a CollectionValue", msgs instanceof CollectionValue);
+ CollectionValue msgsCV = (CollectionValue) msgs;
+ MetaValue[] msgsMVs = msgsCV.getElements();
+ assertTrue("listAllMessages length > 0", msgsMVs.length > 0);
+ for(MetaValue mv : msgsMVs)
+ {
+ assertTrue(mv instanceof CompositeValue);
+ CompositeValue cv = (CompositeValue) mv;
+ MetaValue JMSMessageID = cv.get("JMSMessageID");
+ log.info(JMSMessageID);
+ assertNotNull(JMSMessageID);
+ MetaValue JMSCorrelationID = cv.get("JMSCorrelationID");
+ log.info(JMSCorrelationID);
+ MetaValue JMSTimestamp = cv.get("JMSTimestamp");
+ log.info(JMSTimestamp);
+ assertNotNull(JMSTimestamp);
+ }
+ c.stop();
+ c.close();
+ }
+
protected ManagedOperation getOperation(ManagedComponent comp, String name, String[] signature)
{
assertNotNull(comp);
More information about the jboss-cvs-commits
mailing list