KickJava   Java API By Example, From Geeks To Geeks.

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


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.Destination;
26 import org.objectweb.joram.client.jms.Queue;
27 import org.objectweb.joram.client.jms.Topic;
28 import org.objectweb.joram.client.jms.admin.AdminModule;
29
30 import java.util.Iterator JavaDoc;
31 import java.util.List JavaDoc;
32 import java.util.Vector JavaDoc;
33
34
35 /**
36  * The <code>RemoteServer</code> class allows to handle remote JORAM servers.
37  */

38 public class RemoteServer implements RemoteServerMBean
39 {
40   /** Remote server identifier. */
41   private short id;
42
43
44   /** Constructs a <code>RemoteServer</code> instance. */
45   public RemoteServer(short id)
46   {
47     this.id = id;
48   }
49
50
51   public String JavaDoc getRemoteServerId()
52   {
53     return "" + id;
54   }
55
56
57   public List JavaDoc retrieveRemoteQueuesNames() throws Exception JavaDoc
58   {
59     List JavaDoc list = AdminModule.getDestinations(id);
60     Iterator JavaDoc it = list.iterator();
61     Destination dest;
62     Vector JavaDoc names = new Vector JavaDoc();
63     while (it.hasNext()) {
64       dest = (Destination) it.next();
65       if (dest instanceof Queue)
66         names.add(dest.getAdminName());
67     }
68     return names;
69   }
70
71   public List JavaDoc retrieveRemoteTopicsNames() throws Exception JavaDoc
72   {
73     List JavaDoc list = AdminModule.getDestinations(id);
74     Iterator JavaDoc it = list.iterator();
75     Destination dest;
76     Vector JavaDoc names = new Vector JavaDoc();
77     while (it.hasNext()) {
78       dest = (Destination) it.next();
79       if (dest instanceof Topic)
80         names.add(dest.getAdminName());
81     }
82     return names;
83   }
84 }
85
Popular Tags