KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > jms > amq > AmqQueue


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.jms.amq;
31
32 import com.caucho.jms.session.MessageConsumerImpl;
33 import com.caucho.jms.session.SessionImpl;
34 import com.caucho.util.L10N;
35
36 import javax.jms.JMSException JavaDoc;
37 import javax.jms.MessageProducer JavaDoc;
38 import javax.jms.Queue JavaDoc;
39 import javax.jms.QueueBrowser JavaDoc;
40 import java.io.IOException JavaDoc;
41 import java.util.logging.Logger JavaDoc;
42
43 /**
44  * An AMQ queue.
45  */

46 public class AmqQueue extends AmqDestination implements Queue JavaDoc {
47   private static final Logger JavaDoc log
48     = Logger.getLogger(AmqQueue.class.getName());
49   private static final L10N L = new L10N(AmqQueue.class);
50
51   private int _id;
52
53   public AmqQueue()
54   {
55   }
56
57   /**
58    * Returns the queue's name.
59    */

60   public String JavaDoc getQueueName()
61   {
62     return getName();
63   }
64
65   /**
66    * Returns the JDBC id for the queue.
67    */

68   public int getId()
69   {
70     return _id;
71   }
72
73   /**
74    * Creates a producer.
75    */

76   public MessageProducer JavaDoc createProducer(SessionImpl session)
77   {
78     return new AmqProducer(session, this);
79   }
80
81   /**
82    * Creates a consumer.
83    */

84   public MessageConsumerImpl createConsumer(SessionImpl session,
85                         String JavaDoc selector,
86                         boolean noWait)
87     throws JMSException JavaDoc
88   {
89     return new AmqQueueConsumer(session, selector, this);
90   }
91
92   /**
93    * Creates a browser.
94    */

95   public QueueBrowser JavaDoc createBrowser(SessionImpl session, String JavaDoc selector)
96     throws JMSException JavaDoc
97   {
98     throw new UnsupportedOperationException JavaDoc();
99   }
100
101   /**
102    * Opens a channel for the queue.
103    */

104   AmqClientChannel openChannel()
105     throws IOException JavaDoc
106   {
107     AmqClient client = getClient();
108
109     AmqClientChannel channel = client.openChannel();
110
111     channel.openQueue(getQueueName());
112
113     return channel;
114   }
115
116   /**
117    * Removes the first message matching the selector.
118    */

119   public void commit(int session)
120     throws JMSException JavaDoc
121   {
122   }
123
124   /**
125    * Returns a printable view of the queue.
126    */

127   public String JavaDoc toString()
128   {
129     return "AmqQueue[" + getName() + "]";
130   }
131 }
132
133
Popular Tags