KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ubermq > jms > server > admin > RemoteAdminProxy


1 package com.ubermq.jms.server.admin;
2
3 import com.ubermq.jms.common.routing.*;
4 import java.rmi.*;
5 import java.rmi.server.*;
6 import java.util.*;
7
8 /**
9  * Creates a remote administrative proxy that
10  * delegates incoming remote requests to a local
11  * implementation of the <code>MessageServerAdmin</code>
12  * interface.
13  */

14 public class RemoteAdminProxy
15     extends UnicastRemoteObject
16     implements MessageServerAdmin
17 {
18     private MessageServerAdmin delegate;
19
20     public RemoteAdminProxy(MessageServerAdmin a)
21         throws RemoteException
22     {
23         super();
24         this.delegate = a;
25     }
26
27     /**
28      * Returns the name of the server.
29      * @return a description of the server
30      */

31     public String JavaDoc getServerName() throws java.rmi.RemoteException JavaDoc
32     {
33         return delegate.getServerName();
34     }
35
36     /**
37      * Returns a collection of all connections to the server.
38      * @return a Collection of ConnectionAdmin objects.
39      * @see com.ubermq.jms.server.admin.ConnectionAdmin
40      */

41     public Collection getConnections() throws java.rmi.RemoteException JavaDoc
42     {
43         Collection c = delegate.getConnections();
44         ArrayList ret = new ArrayList();
45
46         Iterator iter = c.iterator();
47         while (iter.hasNext())
48         {
49             ConnectionAdmin admin = (ConnectionAdmin)iter.next();
50             ret.add(new RemoteConnectionAdminProxy(admin));
51         }
52
53         return ret;
54     }
55
56     /**
57      * Returns a collection of all active durable subscriptions
58      * registered on the server.<P>
59      *
60      * @return a Collection of DurableSubscriptionAdmin objects.
61      * @see com.ubermq.jms.server.admin.DurableSubscriptionAdmin
62      */

63     public Collection getPersistentConsumers() throws RemoteException
64     {
65         Collection c = delegate.getPersistentConsumers();
66         ArrayList ret = new ArrayList();
67
68         Iterator iter = c.iterator();
69         while (iter.hasNext())
70         {
71             PersistentConsumerAdmin admin = (PersistentConsumerAdmin)iter.next();
72             ret.add(new RemotePersistentConsumerAdminProxy(admin));
73         }
74
75         return ret;
76     }
77
78     /**
79      * Closes the administrative interface and releases all resources.
80      */

81     public void close() throws java.rmi.RemoteException JavaDoc
82     {
83         delegate.close();
84     }
85
86     /**
87      * Returns an object containing a snapshot of router
88      * statistical information. This includes number of routes,
89      * a full subscription table, uptime, and overall throughput
90      * statistics.
91      */

92     public IRouterStatistics getRouterStatistics()
93         throws java.rmi.RemoteException JavaDoc
94     {
95         IRouterStatistics r = delegate.getRouterStatistics();
96         return new MyStatsHolder(r);
97     }
98
99     private static class MyStatsHolder
100         implements IRouterStatistics, java.io.Serializable JavaDoc
101     {
102         private int in, out, dropped;
103         private java.util.Date JavaDoc startTime;
104         private String JavaDoc description;
105
106         public static final long serialVersionUID = 1l;
107
108         MyStatsHolder(IRouterStatistics s)
109         {
110             this.in = s.getMessagesIn();
111             this.out = s.getMessagesOut();
112             this.dropped = s.getMessagesDropped();
113             this.startTime = s.getStartTime();
114             this.description = s.getStatisticsAsText();
115         }
116
117         /**
118          * Returns the number of messages published but sent to zero
119          * subscribers (i.e. dropped).
120          */

121         public int getMessagesDropped()
122         {
123             return dropped;
124         }
125
126         /**
127          * Returns the number of messages published to the router.
128          */

129         public int getMessagesIn()
130         {
131             return in;
132         }
133
134         /**
135          * Returns a friendly description of our router statistics.
136          * @return a formatted textual description of the stats.
137          */

138         public String JavaDoc getStatisticsAsText()
139         {
140             return description;
141         }
142
143         /**
144          * Indicates whether the router is active.
145          * @return true if the router is active.
146          */

147         public boolean isRunning()
148         {
149             return true;
150         }
151
152         /**
153          * Returns the date that the router was created.
154          */

155         public java.util.Date JavaDoc getStartTime()
156         {
157             return startTime;
158         }
159
160         /**
161          * Returns the number of messages delivered via this router.
162          */

163         public int getMessagesOut()
164         {
165             return out;
166         }
167
168         /**
169          * Indicates a message was received.
170          */

171         public void messageIn()
172         {
173         }
174
175         /**
176          * Indicates that a message was sent.
177          */

178         public void messageOut()
179         {
180         }
181
182         /**
183          * Indicates that a message was dropped.
184          */

185         public void messageDropped()
186         {
187         }
188     }
189
190 }
191
Popular Tags