User: mnf999  
  Date: 01/12/19 11:52:59

  Modified:    src/main/org/jboss/mq/server JBossMQService.java
  Log:
  Use the right calls on the controller
  
  Revision  Changes    Path
  1.10      +126 -109  jbossmq/src/main/org/jboss/mq/server/JBossMQService.java
  
  Index: JBossMQService.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/JBossMQService.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JBossMQService.java       2001/11/12 06:36:49     1.9
  +++ JBossMQService.java       2001/12/19 19:52:57     1.10
  @@ -1,9 +1,9 @@
   /*
  - * JBoss, the OpenSource J2EE webOS
  - *
  - * Distributable under LGPL license.
  - * See terms of license at gnu.org.
  - */
  +* JBoss, the OpenSource J2EE webOS
  +*
  +* Distributable under LGPL license.
  +* See terms of license at gnu.org.
  +*/
   package org.jboss.mq.server;
   
   
  @@ -19,75 +19,75 @@
   import org.jboss.system.ServiceMBeanSupport;
   
   /**
  - *  JMX MBean implementation for JBossMQ.
  - *
  - * @author     Vincent Sheffer ([EMAIL PROTECTED])
  - * @author     <a href="mailto:[EMAIL PROTECTED]";>Juha Lindfors</a>
  - * @author     <a href="[EMAIL PROTECTED]">Hiram Chirino</a>
  - * @see        JBossMQ subproject
  - * @version    $Revision: 1.9 $
  - */
  +*  JMX MBean implementation for JBossMQ.
  +*
  +* @author     Vincent Sheffer ([EMAIL PROTECTED])
  +* @author     <a href="mailto:[EMAIL PROTECTED]";>Juha Lindfors</a>
  +* @author     <a href="[EMAIL PROTECTED]">Hiram Chirino</a>
  +* @see        JBossMQ subproject
  +* @version    $Revision: 1.10 $
  +*/
   public class JBossMQService extends ServiceMBeanSupport implements 
JBossMQServiceMBean
   {
      private static final String SERVICE_CONTROLLER_NAME = 
"JBOSS-SYSTEM:spine=ServiceController";
      public String jndiBindLocation = "java:/JBossMQServer";
      // Attributes ----------------------------------------------------
  -
  +   
      private ObjectName mqService;
  -
  +   
      private JMSServer jmsServer;
  -
  +   
      private ObjectName persistenceManager;
  -
  +   
      private ObjectName stateManager;
  -
  -
  +   
  +   
      public JBossMQService() 
      {
      }
  -
  +   
      public ObjectName preRegister(MBeanServer server, ObjectName name)
  -      throws Exception
  +   throws Exception
      {
         mqService = super.preRegister(server, name);
         return mqService;
      }
  -
  -
  +   
  +   
      /**
  -    *  Gets the Name attribute of the JBossMQService object
  -    *
  -    * @return    The Name value
  -    */
  +   *  Gets the Name attribute of the JBossMQService object
  +   *
  +   * @return    The Name value
  +   */
      public String getName()
      {
         return "JBossMQ";
      }
  -
  +   
      /**
  -    *  Gets the JMSServer attribute of the JBossMQService object
  -    *
  -    * @return    The JMSServer value
  -    */
  +   *  Gets the JMSServer attribute of the JBossMQService object
  +   *
  +   * @return    The JMSServer value
  +   */
      public JMSServer getJMSServer()
      {
         return jmsServer;
      }
  -
      
  +   
      /**
  -    * Get the value of PersistenceManager.
  -    * @return value of PersistenceManager.
  -    */
  +   * Get the value of PersistenceManager.
  +   * @return value of PersistenceManager.
  +   */
      public ObjectName getPersistenceManager() 
      {
         return persistenceManager;
      }
      
      /**
  -    * Set the value of PersistenceManager.
  -    * @param v  Value to assign to PersistenceManager.
  -    */
  +   * Set the value of PersistenceManager.
  +   * @param v  Value to assign to PersistenceManager.
  +   */
      public void setPersistenceManager(ObjectName objectName) 
      {
         this.persistenceManager = objectName;
  @@ -95,154 +95,171 @@
      
      
      /**
  -    * Get the value of StateManager.
  -    * @return value of StateManager.
  -    */
  +   * Get the value of StateManager.
  +   * @return value of StateManager.
  +   */
      public ObjectName getStateManager() 
      {
         return stateManager;
      }
      
      /**
  -    * Set the value of StateManager.
  -    * @param v  Value to assign to StateManager.
  -    */
  +   * Set the value of StateManager.
  +   * @param v  Value to assign to StateManager.
  +   */
      public void setStateManager(ObjectName  objectName) 
      {
         this.stateManager = objectName;
      }
      
      /**
  -    *  #Description of the Method
  -    *
  -    * @param  name           Description of Parameter
  -    * @exception  Exception  Description of Exception
  -    */
  +   *  #Description of the Method
  +   *
  +   * @param  name           Description of Parameter
  +   * @exception  Exception  Description of Exception
  +   */
      public void createQueue(String name) throws Exception
      {
  -
  +      
         try
         {
  -
  +         
            ObjectName queue = getQueueObjectName(name);
            getServer().createMBean("org.jboss.mq.server.QueueManager", queue);
            getServer().setAttribute(queue, new Attribute("JBossMQService", 
mqService));
            //getServer().invoke(queue, "start", new Object[]{}, new String[]{});
  +         
  +         // create the service
            getServer().invoke(getServiceControllerName(),
  -                            "registerAndStartService",
  -                            new Object[] {queue, null},
  -                            new String[] {"javax.management.ObjectName", 
"java.lang.String"});
  -
  +            "create",
  +            new Object[] {queue},
  +            new String[] {"javax.management.ObjectName"});
  +         
  +         // start the service
  +         getServer().invoke(getServiceControllerName(),
  +            "start",
  +            new Object[] {queue},
  +            new String[] {"javax.management.ObjectName"});
  +      
         }
         catch (Exception e)
         {
            log.warn("Could not create the destination: ", e);
            throw e;
         }
  -
  +   
      }
  -
  +   
      // Administration calls
      /**
  -    *  #Description of the Method
  -    *
  -    * @param  name           Description of Parameter
  -    * @exception  Exception  Description of Exception
  -    */
  +   *  #Description of the Method
  +   *
  +   * @param  name           Description of Parameter
  +   * @exception  Exception  Description of Exception
  +   */
      public void createTopic(String name) throws Exception
      {
         try
         {
  -
  +         
            ObjectName topic= getTopicObjectName(name);
            getServer().createMBean("org.jboss.mq.server.TopicManager", topic);
            getServer().setAttribute(topic, new Attribute("JBossMQService", 
mqService));
            //getServer().invoke(topic, "start", new Object[]{}, new String[]{});
  +         
  +         // create the topic
            getServer().invoke(getServiceControllerName(),
  -                            "registerAndStartService",
  -                            new Object[] {topic, null},
  -                            new String[] {"javax.management.ObjectName", 
"java.lang.String"});
  +            "create",
  +            new Object[] {topic},
  +            new String[] {"javax.management.ObjectName"});
   
  +      
  +         // create the topic
  +         getServer().invoke(getServiceControllerName(),
  +            "start",
  +            new Object[] {topic},
  +            new String[] {"javax.management.ObjectName"});
   
  +      
         }
         catch (Exception e)
         {
            log.warn("Could not create the destination: ", e);
            throw e;
         }
  -
  -
  +   
  +   
      }
  -
  +   
      /**
  -    *  #Description of the Method
  -    *
  -    * @param  name           Description of Parameter
  -    * @exception  Exception  Description of Exception
  -    */
  +   *  #Description of the Method
  +   *
  +   * @param  name           Description of Parameter
  +   * @exception  Exception  Description of Exception
  +   */
      public void destroyQueue(String name) throws Exception
      {
         try
         {
  -
  +         
            ObjectName queue = getQueueObjectName(name);
            getServer().invoke(getServiceControllerName(),
  -                            "undeploy",
  -                            new Object[] {queue},
  -                            new String[] {"javax.management.ObjectName"});
  -
  +            "undeploy",
  +            new Object[] {queue},
  +            new String[] {"javax.management.ObjectName"});
  +         
            //getServer().invoke(queue, "stop", new Object[]{}, new String[]{});
            //getServer().unregisterMBean(queue);
  -
  +      
         }
         catch (Exception e)
         {
            log.warn("Could not destroy the destination: ", e);
            throw e;
         }
  -
  -
  +   
  +   
      }
  -
  +   
      /**
  -    *  #Description of the Method
  -    *
  -    * @param  name           Description of Parameter
  -    * @exception  Exception  Description of Exception
  -    */
  +   *  #Description of the Method
  +   *
  +   * @param  name           Description of Parameter
  +   * @exception  Exception  Description of Exception
  +   */
      public void destroyTopic(String name) throws Exception
      {
         try
         {
  -
  +         
            ObjectName topic = getTopicObjectName(name);
            //getServer().invoke(topic, "stop", new Object[]{}, new String[]{});
            //getServer().unregisterMBean(topic);
            getServer().invoke(getServiceControllerName(),
  -                            "undeploy",
  -                            new Object[] {topic},
  -                            new String[] {"javax.management.ObjectName"});
  -
  +            "undeploy",
  +            new Object[] {topic},
  +            new String[] {"javax.management.ObjectName"});
  +      
         }
         catch (Exception e)
         {
            log.warn("Could not destroy the destination: ", e);
            throw e;
         }
  -
  -
  +   
  +   
      }
  -
  -
  +   
  +   
      protected void startService() throws Exception
      {
         try 
         {
  -
  +         
            PersistenceManager pm = (PersistenceManager)
  -            getServer().invoke(persistenceManager, "getInstance", 
  -                               new Object[] {},
  -                               new String[] {});
  +         getServer().invoke(persistenceManager, "getInstance", 
  +            new Object[] {},
  +            new String[] {});
            JMSServer.initServer();//yucky kludge!
            jmsServer = JMSServer.getInstance();
            jmsServer.setPersistenceManager(pm);
  @@ -253,9 +270,9 @@
         try 
         {
            StateManager sm = (StateManager)
  -            getServer().invoke(stateManager, "getInstance", 
  -                               new Object[] {},
  -                               new String[] {});
  +         getServer().invoke(stateManager, "getInstance", 
  +            new Object[] {},
  +            new String[] {});
            jmsServer.setStateManager(sm);
         } catch (Exception e) 
         {
  @@ -263,22 +280,22 @@
         } // end of try-catch
         jmsServer.startServer();
      }
  -
  +   
      protected void stopService()
      {
         jmsServer.stopServer();
      }
  -
  +   
      private ObjectName getTopicObjectName(String name) throws 
MalformedObjectNameException
      {
         return new ObjectName(mqService.getDomain() + ":service=Topic,name=" + name);
      }
  -
  +   
      private ObjectName getQueueObjectName(String name) throws 
MalformedObjectNameException
      {
         return new ObjectName(mqService.getDomain() + ":service=Queue,name=" + name);
      }
  -
  +   
      private ObjectName getServiceControllerName() throws Exception
      {
         return new ObjectName(SERVICE_CONTROLLER_NAME);
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to