001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.mq;
023:
024: import java.io.Serializable;
025:
026: import javax.jms.Topic;
027: import javax.naming.Reference;
028: import javax.naming.Referenceable;
029: import javax.naming.StringRefAddr;
030:
031: /**
032: * This class implements javax.jms.Topic
033: *
034: * @author Norbert Lataille (Norbert.Lataille@m4x.org)
035: * @author Hiram Chirino (Cojonudo14@hotmail.com)
036: * @author David Maplesden (David.Maplesden@orion.co.nz)
037: * @author <a href="mailto:adrian@jboss.org">Adrian Brock</a>
038: * @version $Revision: 57198 $
039: */
040: public class SpyTopic extends SpyDestination implements Serializable,
041: Topic, Referenceable {
042: // Constants -----------------------------------------------------
043:
044: /** The serialVersionUID */
045: static final long serialVersionUID = -4784950783387129468L;
046:
047: // Attributes ----------------------------------------------------
048:
049: /** The durableSubscriptionID */
050: protected DurableSubscriptionID durableSubscriptionID;
051:
052: /** added cached toString string for efficiency */
053: private String toStringStr;
054:
055: // Static --------------------------------------------------------
056:
057: // Constructors --------------------------------------------------
058:
059: /**
060: * Create a new SpyTopic
061: *
062: * @param topicName the topic name
063: */
064: public SpyTopic(String topicName) {
065: super (topicName);
066: toStringStr = "TOPIC." + name;
067: }
068:
069: /**
070: * Create a new SpyTopic
071: *
072: * @param topic the topic
073: * @param clientID the client id
074: * @param subscriptionName the subscription name
075: * @param selector the selector
076: */
077: public SpyTopic(SpyTopic topic, String clientID,
078: String subscriptionName, String selector) {
079: this (topic, new DurableSubscriptionID(clientID,
080: subscriptionName, selector));
081: }
082:
083: /**
084: * Create a new SpyTopic
085: *
086: * @param topic the topic
087: * @param subid the durable subscription
088: */
089: public SpyTopic(SpyTopic topic, DurableSubscriptionID subid) {
090: super (topic.getTopicName());
091: if (subid == null)
092: toStringStr = "TOPIC." + name;
093: else
094: toStringStr = "TOPIC." + name + "." + subid;
095: this .durableSubscriptionID = subid;
096: }
097:
098: // Public --------------------------------------------------------
099:
100: /**
101: * Get the durable subscription id
102: *
103: * return the durable subscription id
104: */
105: public DurableSubscriptionID getDurableSubscriptionID() {
106: return durableSubscriptionID;
107: }
108:
109: // Topic implementation ------------------------------------------
110:
111: public String getTopicName() {
112: return name;
113: }
114:
115: // Referenceable implementation ----------------------------------
116: public Reference getReference() throws javax.naming.NamingException {
117: return new Reference(
118: "org.jboss.mq.SpyTopic",
119: new StringRefAddr("name", name),
120: "org.jboss.mq.referenceable.SpyDestinationObjectFactory",
121: null);
122: }
123:
124: // Object overrides ----------------------------------------------
125:
126: public boolean equals(Object obj) {
127: if (!(obj instanceof SpyTopic))
128: return false;
129: if (obj.hashCode() != hash)
130: return false;
131: return ((SpyDestination) obj).name.equals(name);
132: }
133:
134: public String toString() {
135: return toStringStr;
136: }
137:
138: // Package protected ---------------------------------------------
139:
140: // Protected -----------------------------------------------------
141:
142: // Private -------------------------------------------------------
143:
144: // Inner classes -------------------------------------------------
145: }
|