User: dbudworth
  Date: 01/11/29 15:10:09

  Modified:    src/main/org/jboss/mq/server QueueManager.java
                        QueueManagerMBean.java TopicManager.java
                        TopicManagerMBean.java
  Log:
  Added JNDI name property.
  
  Defaults to [topic|queue]/[topicname|queuename]
  
  It doesn't enforce topics or queues to be listed under topic/* | queue/*, so that 
may need to be changed (I don't know if that's a requirement, but testing seemed to 
work out ok).
  
  Revision  Changes    Path
  1.7       +39 -14    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- QueueManager.java 2001/11/28 00:55:29     1.6
  +++ QueueManager.java 2001/11/29 23:10:09     1.7
  @@ -29,13 +29,16 @@
    *
    * @author     Norbert Lataille ([EMAIL PROTECTED])
    * @author     <a href="[EMAIL PROTECTED]">Hiram Chirino</a>
  - * @version    $Revision: 1.6 $
  + * @version    $Revision: 1.7 $
    */
   public class QueueManager extends ServiceMBeanSupport implements QueueManagerMBean
   {
      JMSQueue destination;
      SpyQueue queue;
      String queueName;
  +   String jndiName;
  +   boolean jndiBound = false;
  +   
      private ObjectName jbossMQService;
   
      /**
  @@ -111,19 +114,10 @@
         server.addDestination(queue, destination);
         //server.getPersistenceManager().initQueue(destination);
         server.getPersistenceManager().restoreQueue(destination, queue);
  -      //Get an InitialContext
  -      InitialContext ctx = new InitialContext();
  -      javax.naming.Context subctx;
  -      try
  -      {
  -         subctx = (javax.naming.Context)ctx.lookup("queue");
  -      }
  -      catch (javax.naming.NamingException e)
  -      {
  -         subctx = ctx.createSubcontext("queue");
  -      }
  -      Util.rebind(subctx,queueName,queue);
  -
  +      if (jndiName == null)
  +         setJNDIName("queue/"+queueName);
  +      else
  +         setJNDIName(jndiName); //in config phase, all we did was store the name, 
and not actually bind
      }
   
      protected void stopService()
  @@ -139,5 +133,36 @@
            throw new MalformedObjectNameException("Property 'name' not provided");
         }
         return name;
  +   }
  +
  +  /**
  +    * Sets the JNDI name for this queue
  +    * @param name Name to bind this queue to in the JNDI tree
  +    */
  +   public synchronized void setJNDIName(String name) throws Exception{
  +      if (queue == null){ //nothing to bind yet, startService will recall us
  +         jndiName = name;
  +         return;
  +      }
  +      if (name == null)
  +         throw new InvalidAttributeValueException("Queue JNDI names can't be null");
  +      InitialContext ic  = new InitialContext();
  +      if (jndiName != null && jndiBound){
  +         Util.unbind(ic,jndiName); //Remove old jndi name
  +         jndiName = null;
  +         jndiBound = false;
  +      }
  +      Util.rebind(ic,name,queue);
  +      jndiName = name;
  +      jndiBound = true;
  +      log.info("Bound queue '"+queueName+"' to JNDI name '"+jndiName+"'");
  +   }
  +
  +   /**
  +    * Gets the JNDI name use by this queue
  +    * @return  The JNDI name currently in use
  +    */
  +   public String getJNDIName(){
  +      return jndiName;
      }
   }
  
  
  
  1.6       +13 -1     jbossmq/src/main/org/jboss/mq/server/QueueManagerMBean.java
  
  Index: QueueManagerMBean.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/QueueManagerMBean.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- QueueManagerMBean.java    2001/11/10 21:38:05     1.5
  +++ QueueManagerMBean.java    2001/11/29 23:10:09     1.6
  @@ -15,7 +15,7 @@
    * @author     <a href="[EMAIL PROTECTED]">Hiram Chirino</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>david jencks</a>
    * @see        <related>
  - * @version    $Revision: 1.5 $
  + * @version    $Revision: 1.6 $
    */
   public interface QueueManagerMBean
          extends ServiceMBean
  @@ -46,4 +46,16 @@
       * @param v  Value to assign to JBossMQService.
       */
      void setJBossMQService(ObjectName  jbossMQService); 
  +
  +   /**
  +    * Sets the JNDI name for this queue
  +    * @param name Name to bind this queue to in the JNDI tree
  +    */
  +   void setJNDIName(String name) throws Exception;
  +
  +   /**
  +    * Gets the JNDI name use by this queue
  +    * @return  The JNDI name currently in use
  +    */
  +   String getJNDIName();
   }
  
  
  
  1.7       +40 -13    jbossmq/src/main/org/jboss/mq/server/TopicManager.java
  
  Index: TopicManager.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/TopicManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TopicManager.java 2001/11/28 00:55:29     1.6
  +++ TopicManager.java 2001/11/29 23:10:09     1.7
  @@ -30,7 +30,7 @@
    *
    * @author     Norbert Lataille ([EMAIL PROTECTED])
    * @author     <a href="[EMAIL PROTECTED]">Hiram Chirino</a>
  - * @version    $Revision: 1.6 $
  + * @version    $Revision: 1.7 $
    */
   public class TopicManager
          extends ServiceMBeanSupport
  @@ -40,6 +40,8 @@
      JMSTopic destination;
      SpyTopic topic;
      String topicName;
  +   String jndiName;
  +   boolean jndiBound = false;
      private ObjectName jbossMQService;
   
      /**
  @@ -114,18 +116,11 @@
         
         //server.getPersistenceManager().restoreQueue(destination, topic);
         //server.getPersistenceManager().initQueue(destination);
  -      //Get an InitialContext
  -      InitialContext ctx = new InitialContext();
  -      javax.naming.Context subctx;
  -      try
  -      {
  -         subctx = (javax.naming.Context)ctx.lookup("topic");
  -      }
  -      catch (javax.naming.NamingException e)
  -      {
  -         subctx = ctx.createSubcontext("topic");
  -      }
  -      Util.rebind(subctx,topicName,topic);
  +
  +      if (jndiName == null)
  +         setJNDIName("topic/"+topicName);
  +      else
  +         setJNDIName(jndiName); //In config phase, we only stored the name, and 
didn't actually bind it
      }
   
      protected void stopService()
  @@ -142,4 +137,36 @@
         }
         return name;
      }
  +   
  +   /**
  +    * Sets the JNDI name for this topic
  +    * @param name Name to bind this topic to in the JNDI tree
  +    */
  +   public synchronized void setJNDIName(String name) throws Exception{
  +      if (topic == null){ //nothing to bind yet, startService will recall us
  +         jndiName = name;
  +         return;
  +      }
  +      if (name == null)
  +         throw new InvalidAttributeValueException("Topic JNDI names can't be null");
  +      InitialContext ic  = new InitialContext();
  +      if (jndiName != null && jndiBound){
  +         Util.unbind(ic,jndiName); //Remove old jndi name
  +         jndiName = null;
  +         jndiBound = false;
  +      }
  +      Util.rebind(ic,name,topic);
  +      jndiName = name;
  +      jndiBound = true;
  +      log.info("Bound topic '"+topicName+"' to JNDI name '"+jndiName+"'");
  +   }
  +
  +   /**
  +    * Gets the JNDI name use by this topic
  +    * @return  The JNDI name currently in use
  +    */
  +   public String getJNDIName(){
  +      return jndiName;
  +   }
  +
   }
  
  
  
  1.6       +14 -1     jbossmq/src/main/org/jboss/mq/server/TopicManagerMBean.java
  
  Index: TopicManagerMBean.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jbossmq/src/main/org/jboss/mq/server/TopicManagerMBean.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TopicManagerMBean.java    2001/11/10 21:38:05     1.5
  +++ TopicManagerMBean.java    2001/11/29 23:10:09     1.6
  @@ -14,7 +14,7 @@
    *
    * @author     <a href="[EMAIL PROTECTED]">Hiram Chirino</a>
    * @see        <related>
  - * @version    $Revision: 1.5 $
  + * @version    $Revision: 1.6 $
    */
   public interface TopicManagerMBean
          extends ServiceMBean
  @@ -38,4 +38,17 @@
       * @param v  Value to assign to JBossMQService.
       */
      void setJBossMQService(ObjectName  jbossMQService); 
  +
  +    /**
  +    * Sets the JNDI name for this topic
  +    * @param name Name to bind this topic to in the JNDI tree
  +    */
  +   void setJNDIName(String name) throws Exception;
  +
  +   /**
  +    * Gets the JNDI name use by this topic
  +    * @return  The JNDI name currently in use
  +    */
  +   String getJNDIName();
  +
   }
  
  
  

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

Reply via email to