001 /** 002 * 003 * Copyright 2004 Protique Ltd 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 019 package org.activemq.message; 020 021 import javax.jms.Destination; 022 import javax.jms.Topic; 023 024 import org.activemq.management.JMSDestinationStats; 025 import org.activemq.management.JMSTopicStatsImpl; 026 027 028 /** 029 * A <CODE>Topic</CODE> object encapsulates a provider-specific topic name. 030 * It is the way a client specifies the identity of a topic to JMS API methods. 031 * For those methods that use a <CODE>Destination</CODE> as a parameter, a 032 * <CODE>Topic</CODE> object may used as an argument . For 033 * example, a Topic can be used to create a <CODE>MessageConsumer</CODE> 034 * and a <CODE>MessageProducer</CODE> 035 * by calling: 036 * <UL> 037 * <LI> <CODE>Session.CreateConsumer(Destination destination)</CODE> 038 * <LI> <CODE>Session.CreateProducer(Destination destination)</CODE> 039 * <p/> 040 * </UL> 041 * <p/> 042 * <P>Many publish/subscribe (pub/sub) providers group topics into hierarchies 043 * and provide various options for subscribing to parts of the hierarchy. The 044 * JMS API places no restriction on what a <CODE>Topic</CODE> object 045 * represents. It may be a leaf in a topic hierarchy, or it may be a larger 046 * part of the hierarchy. 047 * <p/> 048 * <P>The organization of topics and the granularity of subscriptions to 049 * them is an important part of a pub/sub application's architecture. The JMS 050 * API 051 * does not specify a policy for how this should be done. If an application 052 * takes advantage of a provider-specific topic-grouping mechanism, it 053 * should document this. If the application is installed using a different 054 * provider, it is the job of the administrator to construct an equivalent 055 * topic architecture and create equivalent <CODE>Topic</CODE> objects. 056 * 057 * @see javax.jms.Session#createConsumer(javax.jms.Destination) 058 * @see javax.jms.Session#createProducer(javax.jms.Destination) 059 * @see javax.jms.TopicSession#createTopic(String) 060 */ 061 062 public class ActiveMQTopic extends ActiveMQDestination implements Topic { 063 064 private static final long serialVersionUID = -4243052759456351987L; 065 066 /** 067 * Default constructor for an ActiveMQTopic Destination 068 */ 069 public ActiveMQTopic() { 070 super(); 071 } 072 073 /** 074 * Construct a named ActiveMQTopic Destination 075 * 076 * @param name 077 */ 078 079 public ActiveMQTopic(String name) { 080 super(name); 081 } 082 083 /** 084 * Gets the name of this Topic. 085 * <p/> 086 * <P>Clients that depend upon the name are not portable. 087 * 088 * @return the Topic name 089 */ 090 091 public String getTopicName() { 092 return super.getPhysicalName(); 093 } 094 095 /** 096 * @return Returns the Destination type 097 */ 098 099 public int getDestinationType() { 100 return ACTIVEMQ_TOPIC; 101 } 102 103 protected Destination createDestination(String name) { 104 return new ActiveMQTopic(name); 105 } 106 107 protected JMSDestinationStats createDestinationStats() { 108 return new JMSTopicStatsImpl(); 109 } 110 111 }