KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ubermq > jms > client > impl > LocalQueue


1 package com.ubermq.jms.client.impl;
2
3 import com.ubermq.jms.client.*;
4 import com.ubermq.kernel.overflow.*;
5 import javax.jms.*;
6
7 /**
8  * An implementation of an UberMQ queue destination. <P>
9  *
10  */

11 public final class LocalQueue
12     extends LocalDestination
13     implements java.io.Serializable JavaDoc,
14     javax.jms.Queue JavaDoc,
15     javax.jms.TemporaryQueue JavaDoc
16 {
17     public static final long serialVersionUID = 1L;
18
19     private transient Session s;
20     private String JavaDoc name;
21
22     public LocalQueue(Session s, String JavaDoc name)
23     {
24         this.s = s;
25         this.name = name;
26     }
27
28     public LocalQueue(String JavaDoc name)
29     {
30         this.s = null;
31         this.name = name;
32     }
33
34     /** Gets the name of this queue.
35      *
36      * <P>Clients that depend upon the name are not portable.
37      *
38      * @return the queue name
39      */

40     public String JavaDoc getQueueName()
41     {
42         return name;
43     }
44
45     /**
46      * Deletes this temporary queue. If there are existing receivers
47      * still using it, a <CODE>JMSException</CODE> will be thrown.
48      *
49      * @exception JMSException if the JMS provider fails to delete the
50      * temporary queue due to some internal error.
51      */

52     public void delete() throws JMSException
53     {
54         try
55         {
56             if (s == null)
57                 throw new javax.jms.IllegalStateException JavaDoc("not temporary");
58
59             if (!s.conn.getClientProcessor().controlSequence(s.conn.factories.controlFactory().queueDelete(name),
60                                                         new DropIncoming()))
61                 throw new JMSException("The queue is still in use.");
62         }
63         catch (java.io.IOException JavaDoc e) {
64             throw new JMSIOException(e);
65         }
66     }
67
68     /**
69      * Returns the UberMQ topic name that is used internally.
70      */

71     public String JavaDoc getInternalTopicName()
72     {
73         return QUEUE_TOPIC_PREFIX + name;
74     }
75
76     public String JavaDoc toString()
77     {
78         return name;
79     }
80 }
81
82
Popular Tags