View Javadoc

1   /*** 
2    * 
3    * Copyright 2004 Protique Ltd
4    * 
5    * Licensed under the Apache License, Version 2.0 (the "License"); 
6    * you may not use this file except in compliance with the License. 
7    * You may obtain a copy of the License at 
8    * 
9    * http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, 
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14   * See the License for the specific language governing permissions and 
15   * limitations under the License. 
16   * 
17   **/
18  
19  package org.codehaus.activemq.message;
20  
21  import org.codehaus.activemq.management.JMSDestinationStats;
22  import org.codehaus.activemq.management.JMSTopicStatsImpl;
23  
24  import javax.jms.Destination;
25  import javax.jms.Topic;
26  
27  
28  /***
29   * A <CODE>Topic</CODE> object encapsulates a provider-specific topic name.
30   * It is the way a client specifies the identity of a topic to JMS API methods.
31   * For those methods that use a <CODE>Destination</CODE> as a parameter, a
32   * <CODE>Topic</CODE> object may used as an argument . For
33   * example, a Topic can be used to create a <CODE>MessageConsumer</CODE>
34   * and a <CODE>MessageProducer</CODE>
35   * by calling:
36   * <UL>
37   * <LI> <CODE>Session.CreateConsumer(Destination destination)</CODE>
38   * <LI> <CODE>Session.CreateProducer(Destination destination)</CODE>
39   * <p/>
40   * </UL>
41   * <p/>
42   * <P>Many publish/subscribe (pub/sub) providers group topics into hierarchies
43   * and provide various options for subscribing to parts of the hierarchy. The
44   * JMS API places no restriction on what a <CODE>Topic</CODE> object
45   * represents. It may be a leaf in a topic hierarchy, or it may be a larger
46   * part of the hierarchy.
47   * <p/>
48   * <P>The organization of topics and the granularity of subscriptions to
49   * them is an important part of a pub/sub application's architecture. The JMS
50   * API
51   * does not specify a policy for how this should be done. If an application
52   * takes advantage of a provider-specific topic-grouping mechanism, it
53   * should document this. If the application is installed using a different
54   * provider, it is the job of the administrator to construct an equivalent
55   * topic architecture and create equivalent <CODE>Topic</CODE> objects.
56   *
57   * @see javax.jms.Session#createConsumer(javax.jms.Destination)
58   * @see javax.jms.Session#createProducer(javax.jms.Destination)
59   * @see javax.jms.TopicSession#createTopic(String)
60   */
61  
62  public class ActiveMQTopic extends ActiveMQDestination implements Topic {
63  
64  
65      /***
66       * Default constructor for an ActiveMQTopic Destination
67       */
68      public ActiveMQTopic() {
69          super();
70      }
71  
72      /***
73       * Construct a named ActiveMQTopic Destination
74       *
75       * @param name
76       */
77  
78      public ActiveMQTopic(String name) {
79          super(name);
80      }
81  
82      /***
83       * Gets the name of this Topic.
84       * <p/>
85       * <P>Clients that depend upon the name are not portable.
86       *
87       * @return the Topic name
88       */
89  
90      public String getTopicName() {
91          return super.getPhysicalName();
92      }
93  
94      /***
95       * @return Returns the Destination type
96       */
97  
98      public int getDestinationType() {
99          return ACTIVEMQ_TOPIC;
100     }
101 
102     protected Destination createDestination(String name) {
103         return new ActiveMQTopic(name);
104     }
105 
106     protected JMSDestinationStats createDestinationStats() {
107         return new JMSTopicStatsImpl();
108     }
109 
110 }