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 org.activemq.management.JMSDestinationStats;
022    import org.activemq.management.JMSQueueStatsImpl;
023    
024    import javax.jms.Destination;
025    import javax.jms.Queue;
026    
027    
028    /**
029     * A <CODE>Queue</CODE> object encapsulates a provider-specific queue name.
030     * It is the way a client specifies the identity of a queue to JMS API methods.
031     * For those methods that use a <CODE>Destination</CODE> as a parameter, a
032     * <CODE>Queue</CODE> object used as an argument. For example, a queue can
033     * be used  to create a <CODE>MessageConsumer</CODE> and a
034     * <CODE>MessageProducer</CODE>  by calling:
035     * <UL>
036     * <LI> <CODE>Session.CreateConsumer(Destination destination)</CODE>
037     * <LI> <CODE>Session.CreateProducer(Destination destination)</CODE>
038     * <p/>
039     * </UL>
040     * <p/>
041     * <P>The actual length of time messages are held by a queue and the
042     * consequences of resource overflow are not defined by the JMS API.
043     *
044     * @see javax.jms.Session#createConsumer(javax.jms.Destination)
045     * @see javax.jms.Session#createProducer(javax.jms.Destination)
046     * @see javax.jms.Session#createQueue(String)
047     * @see javax.jms.QueueSession#createQueue(String)
048     */
049    
050    public class ActiveMQQueue extends ActiveMQDestination implements Queue {
051    
052        private static final long serialVersionUID = -8153802971552885826L;
053    
054        /**
055         * Default constructor for an ActiveMQQueue Destination
056         */
057        public ActiveMQQueue() {
058            super();
059        }
060    
061        /**
062         * Construct a named ActiveMQQueue Destination
063         *
064         * @param name
065         */
066    
067        public ActiveMQQueue(String name) {
068            super(name);
069        }
070    
071        /**
072         * Gets the name of this queue.
073         * <p/>
074         * <P>Clients that depend upon the name are not portable.
075         *
076         * @return the queue name
077         */
078    
079        public String getQueueName() {
080            return super.getPhysicalName();
081        }
082    
083        /**
084         * @return Returns the Destination type
085         */
086    
087        public int getDestinationType() {
088            return ACTIVEMQ_QUEUE;
089        }
090        
091        /**
092         * Returns true if a Topic Destination
093         *
094         * @return true/false
095         */
096    
097        public boolean isTopic() {
098            return false;
099        }
100    
101        /**
102         * Returns true if a Queue Destination
103         *
104         * @return true/false
105         */
106        public boolean isQueue() {
107            return true;
108        }
109    
110        protected Destination createDestination(String name) {
111            return new ActiveMQQueue(name);
112        }
113    
114        protected JMSDestinationStats createDestinationStats() {
115            return new JMSQueueStatsImpl();
116        }
117    
118    }