Save This Page
Home » jboss-5.0.0.CR1-src » org » jboss » mq » [javadoc | source]
    1   /*
    2   * JBoss, Home of Professional Open Source
    3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
    4   * by the @authors tag. See the copyright.txt in the distribution for a
    5   * full listing of individual contributors.
    6   *
    7   * This is free software; you can redistribute it and/or modify it
    8   * under the terms of the GNU Lesser General Public License as
    9   * published by the Free Software Foundation; either version 2.1 of
   10   * the License, or (at your option) any later version.
   11   *
   12   * This software is distributed in the hope that it will be useful,
   13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   15   * Lesser General Public License for more details.
   16   *
   17   * You should have received a copy of the GNU Lesser General Public
   18   * License along with this software; if not, write to the Free
   19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   21   */
   22   package org.jboss.mq;
   23   
   24   import java.io.Serializable;
   25   
   26   import javax.jms.Topic;
   27   import javax.naming.Reference;
   28   import javax.naming.Referenceable;
   29   import javax.naming.StringRefAddr;
   30   
   31   /**
   32    * This class implements javax.jms.Topic
   33    * 
   34    * @author Norbert Lataille (Norbert.Lataille@m4x.org)
   35    * @author Hiram Chirino (Cojonudo14@hotmail.com)
   36    * @author David Maplesden (David.Maplesden@orion.co.nz)
   37    * @author <a href="mailto:adrian@jboss.org">Adrian Brock</a>
   38    * @version $Revision: 37459 $
   39    */
   40   public class SpyTopic extends SpyDestination implements Serializable, Topic, Referenceable
   41   {
   42      // Constants -----------------------------------------------------
   43      
   44      /** The serialVersionUID */
   45      static final long serialVersionUID = -4784950783387129468L;
   46      
   47      // Attributes ----------------------------------------------------
   48      
   49      /** The durableSubscriptionID */
   50      protected DurableSubscriptionID durableSubscriptionID;
   51   
   52      /** added cached toString string for efficiency */
   53      private String toStringStr;
   54      // Static --------------------------------------------------------
   55   
   56      // Constructors --------------------------------------------------
   57      
   58      /**
   59       * Create a new SpyTopic
   60       *
   61       * @param topicName the topic name
   62       */
   63      public SpyTopic(String topicName)
   64      {
   65         super(topicName);
   66         toStringStr = "TOPIC." + name;
   67      }
   68   
   69      /**
   70       * Create a new SpyTopic
   71       *
   72       * @param topic the topic 
   73       * @param clientID the client id
   74       * @param subscriptionName the subscription name
   75       * @param selector the selector
   76       */
   77      public SpyTopic(SpyTopic topic, String clientID, String subscriptionName, String selector)
   78      {
   79         this(topic, new DurableSubscriptionID(clientID, subscriptionName, selector));
   80      }
   81   
   82      /**
   83       * Create a new SpyTopic
   84       *
   85       * @param topic the topic
   86       * @param subid the durable subscription
   87       */
   88      public SpyTopic(SpyTopic topic, DurableSubscriptionID subid)
   89      {
   90         super(topic.getTopicName());
   91         if (subid == null)
   92            toStringStr = "TOPIC." + name;
   93         else
   94            toStringStr = "TOPIC." + name + "." + subid;
   95         this.durableSubscriptionID = subid;
   96      }
   97      
   98      // Public --------------------------------------------------------
   99   
  100      /**
  101       * Get the durable subscription id
  102       * 
  103       * return the durable subscription id
  104       */
  105      public DurableSubscriptionID getDurableSubscriptionID()
  106      {
  107         return durableSubscriptionID;
  108      }
  109      
  110      // Topic implementation ------------------------------------------
  111   
  112      public String getTopicName()
  113      {
  114         return name;
  115      }
  116      
  117      // Referenceable implementation ----------------------------------
  118      public Reference getReference() throws javax.naming.NamingException
  119      {
  120         return new Reference("org.jboss.mq.SpyTopic", new StringRefAddr("name", name),
  121               "org.jboss.mq.referenceable.SpyDestinationObjectFactory", null);
  122      }
  123      
  124      // Object overrides ----------------------------------------------
  125   
  126      public boolean equals(Object obj)
  127      {
  128         if (!(obj instanceof SpyTopic))
  129            return false;
  130         if (obj.hashCode() != hash)
  131            return false;
  132         return ((SpyDestination) obj).name.equals(name);
  133      }
  134      
  135      public String toString()
  136      {
  137         return toStringStr;
  138      }
  139      
  140      // Package protected ---------------------------------------------
  141   
  142      // Protected -----------------------------------------------------
  143   
  144      // Private -------------------------------------------------------
  145   
  146      // Inner classes -------------------------------------------------
  147   }

Save This Page
Home » jboss-5.0.0.CR1-src » org » jboss » mq » [javadoc | source]