KickJava   Java API By Example, From Geeks To Geeks.

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


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.Topic;
26
27
28 /**
29  * The <code>LocalTopic</code> class allows to manage a topic hosted by the
30  * adapter's underlying server.
31  */

32 public class LocalTopic implements LocalTopicMBean
33 {
34   /** Wrapped topic. */
35   private Topic topic;
36
37
38   /**
39    * Constructs a <code>LocalTopic</code> instance.
40    */

41   public LocalTopic(Topic topic)
42   {
43     this.topic = topic;
44   }
45
46
47   public String JavaDoc getAgentId()
48   {
49     try {
50       return topic.getTopicName();
51     }
52     catch (Exception JavaDoc exc) {
53       return null;
54     }
55   }
56
57   public String JavaDoc getJndiName()
58   {
59     return topic.getAdminName();
60   }
61
62   public int getNumberOfSubscribers()
63   {
64     try {
65       return topic.getSubscriptions();
66     }
67     catch (Exception JavaDoc exc) {
68       return -1;
69     }
70   }
71
72
73   public void delete() throws Exception JavaDoc
74   {
75     topic.delete();
76     JoramAdapter.unregister(this);
77     JoramAdapter.unbind(topic.getAdminName());
78   }
79 }
80
Popular Tags