[jboss-cvs] JBossAS SVN: r90349 - in trunk: messaging/src/main/org/jboss/jms/server/destination and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 17 14:39:22 EDT 2009


Author: scott.stark at jboss.org
Date: 2009-06-17 14:39:22 -0400 (Wed, 17 Jun 2009)
New Revision: 90349

Added:
   trunk/messaging/src/main/org/jboss/jms/server/ServerPeerMO.java
   trunk/messaging/src/main/org/jboss/jms/server/ServerPeerMODefinition.java
Modified:
   trunk/messaging/src/main/org/jboss/jms/server/destination/MessageListMapper.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
Log:
JBAS-6784, add a ServerPeer managed ojbect mapping
JBAS-7024, use a CompositeValueSupport rather than a MapCompositeValueSupport


Copied: trunk/messaging/src/main/org/jboss/jms/server/ServerPeerMO.java (from rev 90301, branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/ServerPeerMO.java)
===================================================================
--- trunk/messaging/src/main/org/jboss/jms/server/ServerPeerMO.java	                        (rev 0)
+++ trunk/messaging/src/main/org/jboss/jms/server/ServerPeerMO.java	2009-06-17 18:39:22 UTC (rev 90349)
@@ -0,0 +1,456 @@
+/*
+ * 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;
+
+import java.util.List;
+
+import javax.management.ObjectName;
+
+import org.jboss.jms.server.destination.StringObjectNameMetaMapper;
+import org.jboss.managed.api.ManagedOperation.Impact;
+import org.jboss.managed.api.annotation.ActivationPolicy;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.jboss.messaging.util.Version;
+import org.jboss.metatype.api.annotations.MetaMapping;
+
+/**
+ * Empty class to provide the management metadata for JBoss Messaging
+ * org.jboss.jms.server.ServerPeer, when deployed in AS5.
+ * 
+ * @see {@linkplain org.jboss.jms.server.ServerPeer}
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+ at ManagementObject(
+      name="jboss.messaging:service=ServerPeer",
+      componentType = @ManagementComponent(type = "JMS", subtype = "ServerPeer"),
+      properties = ManagementProperties.ALL,
+      isRuntime = true)
+public class ServerPeerMO
+{
+   @ManagementProperty(use={ViewUse.CONFIGURATION},
+         description="The persistence manager name",
+         includeInTemplate=true, mandatory=true, readOnly=false)
+   @MetaMapping(StringObjectNameMetaMapper.class)
+   public ObjectName getPersistenceManager()
+   {
+      return null;
+   }
+   public void setPersistenceManager(ObjectName on)
+   {
+   }
+
+   @ManagementProperty(use={ViewUse.CONFIGURATION},
+         description="The post office name",
+         includeInTemplate=true, mandatory=true, readOnly=false)
+   @MetaMapping(StringObjectNameMetaMapper.class)
+   public ObjectName getPostOffice()
+   {
+      return null;
+   }
+   public void setPostOffice(ObjectName on)
+   {
+   }
+
+   @ManagementProperty(use={ViewUse.CONFIGURATION},
+         description="The user manager name",
+         includeInTemplate=true, mandatory=true, readOnly=false)
+   @MetaMapping(StringObjectNameMetaMapper.class)
+   public ObjectName getJmsUserManager()
+   {
+      return null;
+   }
+   public void setJMSUserManager(ObjectName on)
+   {
+   }
+
+   @ManagementProperty(use={ViewUse.CONFIGURATION},
+         description="The default DLQ on the server peer",
+         includeInTemplate=true,
+         activationPolicy=ActivationPolicy.DEPLOYMENT_RESTART)
+   @MetaMapping(StringObjectNameMetaMapper.class)
+   public ObjectName getDefaultDLQ()
+   {
+      return null;
+   }
+   public void setDefaultDLQ(ObjectName on)
+   {
+   }
+
+   @ManagementProperty(use={ViewUse.CONFIGURATION},
+         description="The default expiry queue on the server peer",
+         includeInTemplate=true, mandatory=true, readOnly=false)
+   @MetaMapping(StringObjectNameMetaMapper.class)
+   public ObjectName getDefaultExpiryQueue()
+   {
+      return null;
+   }
+   public void setDefaultExpiryQueue(ObjectName on)
+   {
+   }
+
+   //read only JMX attributes
+
+   @ManagementProperty(use={ViewUse.RUNTIME},
+         includeInTemplate=false, mandatory=false, readOnly=true)
+   public String getJMSVersion()
+   {
+      return null;
+   }
+
+   @ManagementProperty(use={ViewUse.RUNTIME},
+         includeInTemplate=false, mandatory=false, readOnly=true)
+   public int getJMSMajorVersion()
+   {
+      return 0;
+   }
+   @ManagementProperty(use={ViewUse.RUNTIME},
+         includeInTemplate=false, mandatory=false, readOnly=true)
+   public int getJMSMinorVersion()
+   {
+      return 0;
+   }
+   @ManagementProperty(use={ViewUse.RUNTIME},
+         includeInTemplate=false, mandatory=false, readOnly=true)
+   public String getJMSProviderName()
+   {
+      return null;
+   }
+   @ManagementProperty(use={ViewUse.RUNTIME},
+         includeInTemplate=false, mandatory=false, readOnly=true)
+   public String getProviderVersion()
+   {
+      return null;
+   }
+   @ManagementProperty(use={ViewUse.RUNTIME},
+         includeInTemplate=false, mandatory=false, readOnly=true)
+
+   public int getProviderMajorVersion()
+   {
+      return 0;
+   }
+   @ManagementProperty(use={ViewUse.RUNTIME},
+         includeInTemplate=false, mandatory=false, readOnly=true)
+
+   public int getProviderMinorVersion()
+   {
+      return 0;
+   }
+
+   //Read - write attributes
+
+   public void setSecurityDomain(String securityDomain) throws Exception
+   {
+   }
+   public String getSecurityDomain()
+   {
+      return null;
+   }
+
+   public long getFailoverStartTimeout()
+   {
+      return 0;
+   }
+
+   public void setFailoverStartTimeout(long timeout)
+   {
+   }
+
+   public long getFailoverCompleteTimeout()
+   {
+      return 0;
+   }
+
+   public void setFailoverCompleteTimeout(long timeout)
+   {
+   }
+
+   public int getDefaultMaxDeliveryAttempts()
+   {
+      return 0;
+   }
+
+   public void setDefaultMaxDeliveryAttempts(int attempts)
+   {
+   }
+
+   public long getMessageCounterSamplePeriod()
+   {
+      return 0;
+   }
+
+   public void setMessageCounterSamplePeriod(long newPeriod)
+   {
+
+   }
+
+   public long getDefaultRedeliveryDelay()
+   {
+      return 0;
+   }
+
+   public void setDefaultRedeliveryDelay(long delay)
+   {
+   }
+
+   public int getDefaultMessageCounterHistoryDayLimit()
+   {
+      return 0;
+   }
+
+   public void setDefaultMessageCounterHistoryDayLimit(int limit)
+   {
+   }
+
+   @ManagementProperty(use={ViewUse.CONFIGURATION},
+         includeInTemplate=false,
+         activationPolicy=ActivationPolicy.COMPONENT_RESTART)
+   public String getClusterPullConnectionFactoryName()
+   {
+      return null;
+   }
+   public void setClusterPullConnectionFactoryName(String name)
+   {
+   }
+
+   public boolean isUseXAForMessagePull()
+   {
+      return false;
+   }
+   @ManagementProperty(use={ViewUse.CONFIGURATION},
+         includeInTemplate=false,
+         activationPolicy=ActivationPolicy.COMPONENT_RESTART)
+   public void setUseXAForMessagePull(boolean useXA) throws Exception
+   {
+   }
+
+   public boolean isDefaultPreserveOrdering()
+   {
+      return false;
+   }
+   @ManagementProperty(use={ViewUse.CONFIGURATION},
+         includeInTemplate=false,
+         activationPolicy=ActivationPolicy.COMPONENT_RESTART)
+   public void setDefaultPreserveOrdering(boolean preserve) throws Exception
+   {
+   }
+
+   public long getRecoverDeliveriesTimeout()
+   {
+      return 0;
+   }
+   public void setRecoverDeliveriesTimeout(long timeout)
+   {
+   }
+
+   @ManagementProperty(use={ViewUse.CONFIGURATION},
+         includeInTemplate=false,
+         activationPolicy=ActivationPolicy.COMPONENT_RESTART)
+   public void setServerPeerID(int serverPeerID)
+   {
+   }
+   public int getServerPeerID()
+   {
+      return 0;
+   }
+
+   public String getDefaultQueueJNDIContext()
+   {
+      return null;
+   }
+   @ManagementProperty(use={ViewUse.CONFIGURATION},
+         includeInTemplate=false,
+         activationPolicy=ActivationPolicy.COMPONENT_RESTART)
+   public void setDefaultQueueJNDIContext(String defaultQueueJNDIContext)
+   {
+   }
+
+   public String getDefaultTopicJNDIContext()
+   {
+      return null;
+   }
+
+   public void setDefaultTopicJNDIContext(String defaultTopicJNDIContext)
+   {
+   }
+
+   public void setSuckerPassword(String password)
+   {
+
+   }
+
+   public void setStrictTck(boolean strictTck)
+   {
+   }
+
+   public boolean isStrictTck()
+   {
+      return false;
+   }
+   
+   
+   public void setEnableMessageCounters(boolean enable) 
+   {
+
+   }
+   
+   public boolean isEnableMessageCounters()
+   {
+      return false;
+   }      
+   
+   public void enableMessageCounters()
+   {
+      setEnableMessageCounters(true);
+   }
+
+   public void disableMessageCounters()
+   {
+      setEnableMessageCounters(false);
+   }
+
+   // JMX Operations -------------------------------------------------------------------------------
+
+   @ManagementOperation(impact = Impact.ReadWrite)
+   public String deployQueue(String name, String jndiName) throws Exception
+   {
+      return null;
+   }
+   @ManagementOperation(impact = Impact.ReadWrite)
+   public String deployQueue(String name, String jndiName, int fullSize, int pageSize, int downCacheSize) throws Exception
+   {
+      return null;
+   }
+   @ManagementOperation(impact = Impact.ReadWrite)
+   public boolean destroyQueue(String name) throws Exception
+   {
+      return false;
+   }
+   @ManagementOperation(impact = Impact.ReadWrite)
+   public boolean undeployQueue(String name) throws Exception
+   {
+      return false;
+   }
+   @ManagementOperation(impact = Impact.ReadWrite)
+   public String deployTopic(String name, String jndiName) throws Exception
+   {
+      return null;
+   }
+   @ManagementOperation(impact = Impact.ReadWrite)
+   public String deployTopic(String name, String jndiName, int fullSize, int pageSize, int downCacheSize) throws Exception
+   {
+      return null;
+   }
+   @ManagementOperation(impact = Impact.ReadWrite)
+   public boolean destroyTopic(String name) throws Exception
+   {
+      return false;
+   }
+   @ManagementOperation(impact = Impact.ReadWrite)
+   public boolean undeployTopic(String name) throws Exception
+   {
+      return false;
+   }
+   @ManagementOperation(impact = Impact.ReadOnly)
+   public List getMessageCounters() throws Exception
+   {
+      return null;
+   }
+   @ManagementOperation(impact = Impact.ReadOnly)
+   public List getMessageStatistics() throws Exception
+   {
+      return null;
+   }
+   @ManagementOperation(impact = Impact.ReadOnly)
+   public String listMessageCountersAsHTML() throws Exception
+   {
+      return null;
+   }
+   @ManagementOperation(impact = Impact.ReadWrite)
+   public void resetAllMessageCounters()
+   {
+   }
+   @ManagementOperation(impact = Impact.ReadWrite)
+   public void resetAllMessageCounterHistories()
+   {
+   }
+   @ManagementOperation(impact = Impact.ReadOnly)
+   public String showPreparedTransactionsAsHTML()
+   {
+      return null;
+   }
+   @ManagementOperation(impact = Impact.ReadOnly)
+   public String showActiveClientsAsHTML() throws Exception
+   {
+      return null;
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   @ManagementOperation(impact = Impact.ReadWrite)
+   public void resetAllSuckers()
+   {
+   }
+
+   public Version getVersion()
+   {
+      return null;
+   }
+
+   public boolean isSupportsFailover()
+   {
+      return false;
+   }
+   @ManagementProperty(use={ViewUse.CONFIGURATION},
+         includeInTemplate=false,
+         activationPolicy=ActivationPolicy.COMPONENT_RESTART)
+   public void setSupportsFailover(boolean supportsFailover) throws Exception
+   {
+   }
+
+   public String getServerAopConfig()
+   {
+      return null;
+   }
+    @ManagementProperty(use={ViewUse.CONFIGURATION},
+          includeInTemplate=false,
+          activationPolicy=ActivationPolicy.COMPONENT_RESTART)
+   public void setServerAopConfig(String serverAopConfig)
+   {
+   }
+
+   public String getClientAopConfig()
+   {
+      return null;
+   }
+   @ManagementProperty(use={ViewUse.CONFIGURATION},
+         includeInTemplate=false,
+         activationPolicy=ActivationPolicy.COMPONENT_RESTART)
+   public void setClientAopConfig(String clientAopConfig)
+   {
+   }
+}

Copied: trunk/messaging/src/main/org/jboss/jms/server/ServerPeerMODefinition.java (from rev 90301, branches/Branch_5_x/messaging/src/main/org/jboss/jms/server/ServerPeerMODefinition.java)
===================================================================
--- trunk/messaging/src/main/org/jboss/jms/server/ServerPeerMODefinition.java	                        (rev 0)
+++ trunk/messaging/src/main/org/jboss/jms/server/ServerPeerMODefinition.java	2009-06-17 18:39:22 UTC (rev 90349)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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;
+
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.factory.ManagedObjectFactory;
+import org.jboss.managed.api.factory.ManagedObjectDefinition;
+import org.jboss.managed.spi.factory.ManagedObjectBuilder;
+import org.jboss.metadata.spi.MetaData;
+
+/**
+ * A ManagedObjectBuilder that maps the ServerPeer class to the ServerPeerMO
+ * for its ManagedObject skeleton.
+ *
+ * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ServerPeerMODefinition extends ManagedObjectDefinition
+{
+   private static Logger log = Logger.getLogger(ServerPeerMODefinition.class);
+
+   public ServerPeerMODefinition(ManagedObjectFactory factory)
+   {
+      super(ServerPeer.class, new ServerPeerMOBuilder(factory));
+   }
+
+   private static class ServerPeerMOBuilder implements ManagedObjectBuilder
+   {
+      private ManagedObjectFactory factory;
+
+      private ServerPeerMOBuilder(ManagedObjectFactory factory)
+      {
+         this.factory = factory;
+      }
+
+      /**
+       * Create a ManagedObject from QueueService to QueueServiceMO.
+       *
+       * @param clazz - the mbean class to create the ManagedObject for
+       * @param metaData - the MDR MetaData view
+       */
+      public ManagedObject buildManagedObject(Class<?> clazz, MetaData metaData)
+      {
+         ManagedObjectFactory mof = getMOFactory();
+         log.debug("Creating QueueServiceMO template for: " + clazz);
+         return mof.createManagedObject(ServerPeerMO.class, metaData);
+      }
+
+      /**
+       * Get MO factory.
+       *
+       * @return the MO factory
+       */
+      protected ManagedObjectFactory getMOFactory()
+      {
+         if (factory == null)
+            factory = ManagedObjectFactory.getInstance();
+
+         return factory;
+      }
+   }
+}

Modified: trunk/messaging/src/main/org/jboss/jms/server/destination/MessageListMapper.java
===================================================================
--- trunk/messaging/src/main/org/jboss/jms/server/destination/MessageListMapper.java	2009-06-17 17:45:42 UTC (rev 90348)
+++ trunk/messaging/src/main/org/jboss/jms/server/destination/MessageListMapper.java	2009-06-17 18:39:22 UTC (rev 90349)
@@ -34,7 +34,7 @@
 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.CompositeValueSupport;
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.SimpleValueSupport;
 import org.jboss.metatype.spi.values.MetaMapper;
@@ -64,7 +64,7 @@
       };
       MetaType[] itemTypes = {
             SimpleMetaType.STRING,
-            SimpleMetaType.LONG,
+            SimpleMetaType.LONG_PRIMITIVE,
             SimpleMetaType.STRING
       };
       MSG_TYPE = new ImmutableCompositeMetaType("javax.jms.Message", "JMS Message",
@@ -82,10 +82,10 @@
          {
             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()));
+               CompositeValueSupport cvs = new CompositeValueSupport(MSG_TYPE);
+               cvs.set("JMSCorrelationID", SimpleValueSupport.wrap(m.getJMSCorrelationID()));
+               cvs.set("JMSTimestamp", SimpleValueSupport.wrap(m.getJMSTimestamp()));
+               cvs.set("JMSMessageID", SimpleValueSupport.wrap(m.getJMSMessageID()));
                tmp.add(cvs);
             }
             catch(Exception e)

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java	2009-06-17 17:45:42 UTC (rev 90348)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/JmsDestinationUnitTestCase.java	2009-06-17 18:39:22 UTC (rev 90349)
@@ -304,6 +304,24 @@
       
    }
 
+   /**
+    * JBAS-6939
+    * @throws Exception
+    */
+   public void testQueueRunState() throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      ManagedComponent queue = mgtView.getComponent("testCreateQueue", QueueType);
+      assertNotNull(queue);
+      assertEquals("running", RunState.RUNNING, queue.getRunState());
+      ManagedOperation stop = getOperation(queue, "stop", new String[0]);
+      stop.invoke(new MetaValue[0]);
+      
+      mgtView.reload();
+      queue = mgtView.getComponent("testCreateQueue", QueueType);
+      log.info("runtstate: " + queue.getRunState());
+   }
+
    public void testRemoveQueue() throws Exception
    {
       removeDeployment("testCreateQueue-service.xml");
@@ -392,6 +410,20 @@
       }
    }
    
+   public void testServerPeer() throws Exception
+   {
+      ManagementView mgtView = getManagementView();
+      ComponentType type = new ComponentType("JMS", "ServerPeer");
+      ManagedComponent component = mgtView.getComponent("jboss.messaging:service=ServerPeer", type);
+      assertNotNull(component);
+      
+      log.info("Properties: "+component.getProperties().keySet());
+      
+      ManagedOperation o = getOperation(component, "listMessageCountersAsHTML", new String[0]);
+      MetaValue v = o.invoke(new MetaValue[0]);
+      assertNotNull("null operation return value", v);
+      log.debug("result" + v);
+   }
 
    public void testTopicMetrics() throws Exception
    {




More information about the jboss-cvs-commits mailing list