KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > client > connector > LocalQueue


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2004 - Bull SA
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA.
19  *
20  * Initial developer(s): Frederic Maistre (Bull SA)
21  * Contributor(s): Nicolas Tachker (Bull SA)
22  */

23 package org.objectweb.joram.client.connector;
24
25 import org.objectweb.joram.client.jms.Queue;
26
27
28 /**
29  * The <code>LocalQueue</code> class allows to manage a queue hosted by the
30  * adapter's underlying server.
31  */

32 public class LocalQueue implements LocalQueueMBean
33 {
34   /** Wrapped queue. */
35   private Queue queue;
36
37
38   /**
39    * Constructs a <code>LocalQueue</code> instance.
40    */

41   public LocalQueue(Queue queue)
42   {
43     this.queue = queue;
44   }
45
46
47   public String JavaDoc getAgentId()
48   {
49     try {
50       return queue.getQueueName();
51     }
52     catch (Exception JavaDoc exc) {
53       return null;
54     }
55   }
56
57   public String JavaDoc getJndiName()
58   {
59     return queue.getAdminName();
60   }
61
62   public int getNumberOfPendingMessages()
63   {
64     try {
65       return queue.getPendingMessages();
66     }
67     catch (Exception JavaDoc exc) {
68       return -1;
69     }
70   }
71
72   public int getNumberOfPendingRequests()
73   {
74     try {
75       return queue.getPendingRequests();
76     }
77     catch (Exception JavaDoc exc) {
78       return -1;
79     }
80   }
81
82
83   public void delete() throws Exception JavaDoc
84   {
85     queue.delete();
86     JoramAdapter.unregister(this);
87     JoramAdapter.unbind(queue.getAdminName());
88   }
89 }
90
Popular Tags