User: lqd     
  Date: 02/01/31 05:14:42

  Modified:    src/main/org/jboss/mq/server Tag: Branch_2_4
                        QueueManager.java
  Log:
  - re-setup logger to use the Queue's name in logging output
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.2   +43 -16    jbossmq/src/main/org/jboss/mq/server/QueueManager.java
  
  Index: QueueManager.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/QueueManager.java,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- QueueManager.java 2001/08/23 03:57:12     1.2.2.1
  +++ QueueManager.java 2002/01/31 13:14:41     1.2.2.2
  @@ -21,6 +21,7 @@
   
   import org.jboss.mq.*;
   import org.jboss.util.ServiceMBeanSupport;
  +import org.jboss.logging.Logger;
   
   /**
    *  This class is a message queue which is stored (hashed by Destination) on the
  @@ -29,36 +30,43 @@
    * @author     Norbert Lataille ([EMAIL PROTECTED])
    * @author     Hiram Chirino ([EMAIL PROTECTED])
    * @created    August 16, 2001
  - * @version    $Revision: 1.2.2.1 $
  + * @version    $Revision: 1.2.2.2 $
    */
  -public class QueueManager extends org.jboss.util.ServiceMBeanSupport implements 
QueueManagerMBean {
  +public class QueueManager
  +   extends org.jboss.util.ServiceMBeanSupport
  +   implements QueueManagerMBean
  +{
      JMSQueue         destination;
      SpyQueue         queue;
      String           queueName;
   
  -   public String getName() {
  +   public String getName()
  +   {
         return "JBossMQQueue";
      }
   
      /**
  -    *  Insert the method's description here. Creation date: (7/1/2001 11:30:33
  -    *  AM)
  +    * Get the name of the Queue
       *
       * @return    java.lang.String
       */
  -   public java.lang.String getQueueName() {
  +   public java.lang.String getQueueName()
  +   {
         return queueName;
      }
   
      public int getQueueDepth()
  -      throws Exception {
  +      throws Exception
  +   {
         return destination.queue.messages.size();
      }
   
      public void initService()
  -      throws Exception {
  +      throws Exception
  +   {
   
  -      if ( queueName == null || queueName.length() == 0 ) {
  +      if ( queueName == null || queueName.length() == 0 )
  +      {
            throw new Exception( "QueueName was not set" );
         }
   
  @@ -67,20 +75,30 @@
         queue = new SpyQueue( queueName );
         destination = new JMSQueue( queue, null, server );
   
  -      server.addDestination( queue, destination );
  +      try
  +      {
  +         server.addDestination( queue, destination );
  +         // server.getPersistenceManager().restoreQueue( destination, queue );
  +      } catch ( JMSException e )
  +      {
  +         log.warn( "Couldn't add queue: " + e.getMessage() );
  +      }
   
  -   }
   
  +   }
   
      public void startService()
  -      throws Exception {
  +      throws Exception
  +   {
   
         //Get an InitialContext
         InitialContext ctx = new InitialContext();
         javax.naming.Context subctx;
  -      try {
  +      try
  +      {
            subctx = ( javax.naming.Context )ctx.lookup( "queue" );
  -      } catch ( javax.naming.NamingException e ) {
  +      } catch ( javax.naming.NamingException e )
  +      {
            subctx = ctx.createSubcontext( "queue" );
         }
         subctx.rebind( queueName, queue );
  @@ -88,11 +106,20 @@
      }
   
      protected ObjectName getObjectName( MBeanServer server, ObjectName name )
  -      throws javax.management.MalformedObjectNameException {
  +      throws javax.management.MalformedObjectNameException
  +   {
         queueName = name.getKeyProperty( "name" );
  -      if ( queueName == null || queueName.length() == 0 ) {
  +      if ( queueName == null || queueName.length() == 0 )
  +      {
            throw new MalformedObjectNameException( "Property 'name' not provided" );
         }
  +
  +      //  re-setup the logger with a more descriptive name
  +      log = Logger.getLogger(getClass().getName() + "#" + queueName);
  +
         return name;
      }
   }
  +/*
  +vim:tabstop=3:expandtab:shiftwidth=3
  +*/
  
  
  

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

Reply via email to