KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > client > tools > admin > AdminController


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

22 package org.objectweb.joram.client.tools.admin;
23
24 import java.util.Hashtable JavaDoc;
25 import java.util.Iterator JavaDoc;
26 import java.util.List JavaDoc;
27 import java.util.Enumeration JavaDoc;
28 import java.net.ConnectException JavaDoc;
29 import javax.naming.*;
30 import javax.swing.*;
31 import java.awt.event.*;
32 import javax.swing.tree.*;
33 import javax.jms.*;
34
35 import org.objectweb.joram.client.jms.admin.*;
36 import org.objectweb.joram.client.jms.tcp.*;
37 import org.objectweb.joram.client.jms.Queue;
38 import org.objectweb.joram.client.jms.Topic;
39 import org.objectweb.joram.client.jms.Destination;
40
41 import org.objectweb.util.monolog.api.*;
42
43 public class AdminController
44 {
45   private boolean adminConnected = false;
46   private String JavaDoc adminConnectionStr = "Not connected";
47
48   private ControllerEventListener gui;
49
50   private DefaultTreeModel adminTreeModel;
51   private PlatformTreeNode adminRoot;
52   
53   private DefaultTreeModel jndiTreeModel;
54   private MutableTreeNode jndiRoot;
55
56   private String JavaDoc namedCtx = "";
57   private Context ctx = null;
58
59   private boolean jndiConnected = false;
60
61   public static final String JavaDoc DEFAULT_ADMIN_HOST = "localhost";
62   public static final String JavaDoc DEFAULT_ADMIN_PORT = "16010";
63   
64   public static final String JavaDoc PROP_JNDI_FACTORY = "java.naming.factory.initial";
65   public static final String JavaDoc PROP_JNDI_HOST = "java.naming.factory.host";
66   public static final String JavaDoc PROP_JNDI_PORT = "java.naming.factory.port";
67   
68   public static final String JavaDoc DEFAULT_JNDI_FACTORY = "fr.dyade.aaa.jndi2.client.NamingContextFactory";
69   public static final String JavaDoc DEFAULT_JNDI_HOST = "localhost";
70   public static final String JavaDoc DEFAULT_JNDI_PORT = "16400";
71
72   private static final String JavaDoc STR_ADMIN_DISCONNECTED = "Disconnected";
73   private static final String JavaDoc STR_JNDI_DISCONNECTED = "Disconnected";
74
75   public AdminController()
76   {
77     adminRoot = new PlatformTreeNode(this, STR_ADMIN_DISCONNECTED);
78     adminTreeModel = new DefaultTreeModel(adminRoot, true);
79
80     jndiRoot = new DefaultMutableTreeNode(STR_JNDI_DISCONNECTED);
81     jndiTreeModel = new DefaultTreeModel(jndiRoot, true);
82   }
83
84   public void setControllerEventListener(ControllerEventListener l)
85   {
86     this.gui = l;
87   }
88
89   protected DefaultTreeModel getAdminTreeModel() { return adminTreeModel; }
90   
91   protected DefaultTreeModel getJndiTreeModel() { return jndiTreeModel; }
92
93   public void connectJndi(String JavaDoc host, int port, String JavaDoc ctxName) throws NamingException
94   {
95     namedCtx = ctxName;
96     
97     Hashtable JavaDoc env = new Hashtable JavaDoc();
98     env.put(PROP_JNDI_FACTORY,
99             System.getProperty(PROP_JNDI_FACTORY) != null ? System.getProperty(PROP_JNDI_FACTORY) : DEFAULT_JNDI_FACTORY);
100     env.put(PROP_JNDI_HOST, host);
101     env.put(PROP_JNDI_PORT, Integer.toString(port));
102     
103     ctx = new InitialContext(env);
104     jndiConnected = true;
105     if (ctxName != null) {
106       ctx = (Context)ctx.lookup(ctxName);
107     }
108     jndiRoot.setUserObject((ctxName == null || ctxName.length() == 0) ? "Root Context" : ctxName);
109     jndiTreeModel.nodeChanged(jndiRoot);
110     refreshJndiData();
111   }
112
113   public void refreshJndiData() throws NamingException
114   {
115     cleanupJndiTree();
116  
117     for (NamingEnumeration e = ctx.list(""); e.hasMore();) {
118       NameClassPair pair = (NameClassPair) e.next();
119       JndiTreeNode node = new JndiTreeNode(this, ctx, pair.getName());
120       insertJndiNode(node);
121     }
122   }
123
124   public void disconnectJndi() throws NamingException
125   {
126     ctx.close();
127
128     jndiRoot.setUserObject(STR_JNDI_DISCONNECTED);
129     jndiTreeModel.nodeChanged(jndiRoot);
130     cleanupJndiTree();
131
132     ctx = null;
133     jndiConnected = false;
134   }
135
136   public JndiTreeNode findJndiNodeByName(String JavaDoc name)
137   {
138     int i;
139     for (i = 0; i < jndiRoot.getChildCount(); i++) {
140       JndiTreeNode curr = (JndiTreeNode) jndiRoot.getChildAt(i);
141       if (name.equals(curr.getName()))
142         return curr;
143     }
144
145     return null;
146   }
147
148   public void connectAdmin(final String JavaDoc host,
149                            final int port,
150                            final String JavaDoc user,
151                            final String JavaDoc passwd)
152     throws Exception JavaDoc {
153     try {
154       disconnectAdmin();
155     }
156     catch (Exception JavaDoc exc) {}
157
158     AdminModule.connect(host, port, user, passwd, 4);
159     adminConnected = true;
160     adminConnectionStr = "//" + host + ":" + port;
161     adminRoot.setUserObject("Active Config");
162     adminTreeModel.nodeChanged(adminRoot);
163
164     AdminTool.invokeLater(new CommandWorker() {
165         public void run() throws Exception JavaDoc {
166           refreshAdminData();
167           gui.adminControllerEvent(
168             new ControllerEvent(ControllerEvent.ADMIN_CONNECTED));
169         }
170       });
171   }
172
173   /**
174    * First refreshing step. Doesn't block.
175    */

176   private void refreshAdminData1(ServerTreeNode serverTreeNode)
177     throws ConnectException JavaDoc, AdminException {
178     if (Log.logger.isLoggable(BasicLevel.DEBUG))
179       Log.logger.log(BasicLevel.DEBUG,
180                      "AdminController.refreshAdminData(" +
181                      serverTreeNode + ')');
182     String JavaDoc[] domainNames = AdminModule.getDomainNames(
183       serverTreeNode.getServerId());
184     TreeNode parentTreeNode = serverTreeNode.getParent();
185     String JavaDoc parentDomainName = null;
186     if (parentTreeNode instanceof DomainTreeNode) {
187       DomainTreeNode dtn = (DomainTreeNode)parentTreeNode;
188       parentDomainName = dtn.getDomainName();
189     }
190     for (int i = 0; i < domainNames.length; i++) {
191       if (! domainNames[i].equals(parentDomainName)) {
192         DomainTreeNode dtn =
193           new DomainTreeNode(this, domainNames[i]);
194         adminTreeModel.insertNodeInto(
195           dtn,
196           serverTreeNode.getDomainRoot(),
197           serverTreeNode.getDomainRoot().getChildCount());
198         
199         Server[] servers = AdminModule.getServers(domainNames[i]);
200         for (int j = 0; j < servers.length; j++) {
201           if (servers[j].getId() !=
202               serverTreeNode.getServerId()) {
203             ServerTreeNode stn =
204               new ServerTreeNode(this, servers[j]);
205             adminTreeModel.insertNodeInto(
206               stn, dtn,
207               dtn.getChildCount());
208             refreshAdminData1(stn);
209           }
210         }
211       }
212     }
213   }
214
215   void updateDestinations(int serverId,
216                           MutableTreeNode destinationRoot)
217     throws ConnectException JavaDoc, AdminException {
218     List JavaDoc destList = AdminModule.getDestinations(serverId);
219     for (Iterator JavaDoc i = destList.iterator(); i.hasNext();) {
220       Destination dest = (Destination) i.next();
221       DestinationTreeNode destNode;
222       if (dest instanceof Topic) {
223         destNode = new TopicTreeNode(this, (Topic)dest);
224       } else if (dest instanceof Queue) {
225         destNode = new QueueTreeNode(this, (Queue)dest);
226       } else if (dest instanceof TemporaryQueue) {
227         destNode = new TopicTreeNode(this, (Topic)dest);
228       } else if (dest instanceof TemporaryTopic) {
229         destNode = new QueueTreeNode(this, (Queue)dest);
230       } else {
231         destNode = new DestinationTreeNode(this, dest);
232       }
233       adminTreeModel.insertNodeInto(
234         destNode,
235         destinationRoot,
236         destinationRoot.getChildCount());
237     }
238   }
239
240   void updateUsers(int serverId,
241                    MutableTreeNode userRoot)
242     throws ConnectException JavaDoc, AdminException {
243     List JavaDoc userList = AdminModule.getUsers(serverId);
244     for (Iterator JavaDoc i = userList.iterator(); i.hasNext();) {
245       User user = (User) i.next();
246       UserTreeNode userNode = new UserTreeNode(this, user);
247       adminTreeModel.insertNodeInto(
248         userNode,
249         userRoot,
250         userRoot.getChildCount());
251     }
252   }
253
254   /**
255    * Second refreshing step. May block.
256    */

257   private void refreshAdminData2(ServerTreeNode serverTreeNode)
258     throws ConnectException JavaDoc, AdminException {
259     if (Log.logger.isLoggable(BasicLevel.DEBUG))
260       Log.logger.log(BasicLevel.DEBUG,
261                      "AdminController.refreshAdminData(" +
262                      serverTreeNode + ')');
263     List JavaDoc destList;
264     List JavaDoc userList;
265     try {
266       updateDestinations(
267         serverTreeNode.getServerId(),
268         serverTreeNode.getDestinationRoot());
269       updateUsers(
270         serverTreeNode.getServerId(),
271         serverTreeNode.getUserRoot());
272     } catch (AdminException exc) {
273       if (Log.logger.isLoggable(BasicLevel.WARN))
274         Log.logger.log(BasicLevel.WARN, "", exc);
275       return;
276     } catch (ConnectException JavaDoc ce) {
277       if (Log.logger.isLoggable(BasicLevel.WARN))
278         Log.logger.log(BasicLevel.WARN, "", ce);
279       return;
280     }
281
282     Enumeration JavaDoc e = serverTreeNode.getDomainRoot().children();
283     while (e.hasMoreElements()) {
284       DomainTreeNode dtn = (DomainTreeNode)e.nextElement();
285       Enumeration JavaDoc e2 = dtn.children();
286       while (e2.hasMoreElements()) {
287         ServerTreeNode stn = (ServerTreeNode)e2.nextElement();
288         refreshAdminData2(stn);
289       }
290     }
291   }
292
293   public void refreshAdminData()
294     throws ConnectException JavaDoc, AdminException {
295     if (Log.logger.isLoggable(BasicLevel.DEBUG))
296       Log.logger.log(BasicLevel.DEBUG,
297                      "AdminController.refreshAdminData()");
298     cleanupAdminTree();
299
300     // Get the local server id
301
Server localServer = AdminModule.getLocalServer();
302     ServerTreeNode localServerNode =
303       new ServerTreeNode(
304         this,
305         localServer);
306     adminTreeModel.insertNodeInto(
307       localServerNode, adminRoot,
308       adminRoot.getChildCount());
309     
310     // Recursively browse the servers configuration
311
refreshAdminData1(localServerNode);
312     refreshAdminData2(localServerNode);
313   }
314
315   public void disconnectAdmin() throws Exception JavaDoc {
316     if (adminConnected) {
317       AdminModule.disconnect();
318     }
319
320     adminRoot.setUserObject(STR_ADMIN_DISCONNECTED);
321     adminTreeModel.nodeChanged(adminRoot);
322     cleanupAdminTree();
323
324     adminConnected = false;
325     adminConnectionStr = "Not connected";
326     gui.adminControllerEvent(new ControllerEvent(ControllerEvent.ADMIN_DISCONNECTED));
327   }
328   
329   public void stopServer(ServerTreeNode stn) throws Exception JavaDoc {
330     AdminModule.stopServer(stn.getServerId());
331   }
332
333   public void deleteServer(ServerTreeNode stn) throws Exception JavaDoc {
334     AdminModule.removeServer(stn.getServerId());
335     adminTreeModel.removeNodeFromParent(stn);
336   }
337
338   public void deleteDomain(DomainTreeNode dtn) throws Exception JavaDoc {
339     AdminModule.removeDomain(dtn.getDomainName());
340     adminTreeModel.removeNodeFromParent(dtn);
341   }
342
343   public void createConnectionFactory(String JavaDoc host, int port,
344     String JavaDoc name, String JavaDoc type) throws Exception JavaDoc
345   {
346     try
347     {
348       if (ctx.lookup(name) != null)
349         throw new Exception JavaDoc("Name already bound in JNDI context");
350     }
351     catch (NameNotFoundException exc) {}
352
353     Object JavaDoc factory = null;
354
355     if ("CF".equals(type))
356       factory = TcpConnectionFactory.create(host, port);
357     if ("QCF".equals(type))
358       factory = QueueTcpConnectionFactory.create(host, port);
359     if ("TCF".equals(type))
360       factory = TopicTcpConnectionFactory.create(host, port);
361     if ("XCF".equals(type))
362       factory = XATcpConnectionFactory.create(host, port);
363     if ("XQCF".equals(type))
364       factory = XAQueueTcpConnectionFactory.create(host, port);
365     if ("XTCF".equals(type))
366       factory = XATopicTcpConnectionFactory.create(host, port);
367
368     ctx.bind(name, factory);
369
370     JndiTreeNode node = new JndiTreeNode(this, ctx, new Binding(name, factory));
371     insertJndiNode(node);
372   }
373
374   public void createDestination(ServerTreeNode serverNode, String JavaDoc name, String JavaDoc type) throws Exception JavaDoc
375   {
376     try
377     {
378       if (ctx.lookup(name) != null)
379         throw new Exception JavaDoc("Name already bound in JNDI context");
380     }
381     catch (NameNotFoundException exc) {}
382
383     Destination dest = null;
384
385     if ("Q".equals(type))
386       dest = org.objectweb.joram.client.jms.Queue.create(
387           serverNode.getServerId(), name);
388     if ("T".equals(type))
389       dest = org.objectweb.joram.client.jms.Topic.create(
390           serverNode.getServerId(), name);
391     if ("DMQ".equals(type))
392       dest = org.objectweb.joram.client.jms.admin.DeadMQueue.create(
393           serverNode.getServerId(), name);
394
395     ctx.bind(name, dest);
396
397     JndiTreeNode node = new JndiTreeNode(this, ctx, new Binding(name, dest));
398     insertJndiNode(node);
399
400     DestinationTreeNode destNode = new DestinationTreeNode(this, dest);
401     adminTreeModel.insertNodeInto(destNode, serverNode.getDestinationRoot(),
402                                   serverNode.getDestinationRoot().getChildCount());
403   }
404
405   public void deleteObject(JndiTreeNode node) throws Exception JavaDoc
406   {
407     String JavaDoc name = node.getName();
408     Object JavaDoc obj = ctx.lookup(name);
409
410     try
411     {
412       org.objectweb.joram.client.jms.Destination dest =
413         (org.objectweb.joram.client.jms.Destination) obj;
414       dest.delete();
415
416       DestinationTreeNode dtn = findDestinationNode(adminRoot, dest);
417       if (dtn != null)
418         adminTreeModel.removeNodeFromParent(findDestinationNode(adminRoot, dest));
419     }
420     catch (ClassCastException JavaDoc cce) {}
421
422     ctx.unbind(name);
423
424     jndiTreeModel.removeNodeFromParent(node);
425   }
426
427   public void createUser(ServerTreeNode serverNode, String JavaDoc name, String JavaDoc passwd)
428     throws Exception JavaDoc {
429     User user = User.create(name, passwd, serverNode.getServerId());
430     UserTreeNode userNode = new UserTreeNode(this, user);
431     adminTreeModel.insertNodeInto(userNode,
432                                   serverNode.getUserRoot(),
433                                   serverNode.getUserRoot().getChildCount());
434   }
435
436   public void createDomain(ServerTreeNode serverNode, String JavaDoc domainName, int port)
437     throws Exception JavaDoc {
438     AdminModule.addDomain(domainName, (short)serverNode.getServerId(), port);
439     DomainTreeNode dtn = new DomainTreeNode(this, domainName);
440     adminTreeModel.insertNodeInto(dtn,
441                                   serverNode.getDomainRoot(),
442                                   serverNode.getDomainRoot().getChildCount());
443   }
444
445   public void updateUser(UserTreeNode userNode, String JavaDoc name, String JavaDoc passwd)
446     throws Exception JavaDoc {
447     userNode.getUser().update(name, passwd);
448     adminTreeModel.nodeChanged(userNode);
449   }
450
451   public void deleteUser(UserTreeNode node)
452     throws Exception JavaDoc {
453     node.getUser().delete();
454     adminTreeModel.removeNodeFromParent(node);
455   }
456
457   public void deleteMessage(MessageTreeNode msgTn)
458     throws Exception JavaDoc {
459     DefaultMutableTreeNode parentTn =
460       (DefaultMutableTreeNode)msgTn.getParent();
461     if (parentTn instanceof SubscriptionTreeNode) {
462       SubscriptionTreeNode subTn =
463         (SubscriptionTreeNode)parentTn;
464       SubscriptionRootTreeNode subRootTn =
465         (SubscriptionRootTreeNode)subTn.getParent();
466       UserTreeNode userTn =
467         (UserTreeNode)subRootTn.getParent();
468       ServerTreeNode serverTn = userTn.getParentServerTreeNode();
469       userTn.getUser().deleteMessage(
470         subTn.getSubscription().getName(),
471         msgTn.getMessageId());
472     } else {
473       MessageRootTreeNode msgRootTn =
474         (MessageRootTreeNode)parentTn;
475       QueueTreeNode queueTreeNode =
476         (QueueTreeNode)msgRootTn.getParent();
477       queueTreeNode.getQueue().deleteMessage(
478         msgTn.getMessageId());
479     }
480     adminTreeModel.removeNodeFromParent(msgTn);
481   }
482
483   public void clearSubscription(SubscriptionTreeNode subTn)
484     throws Exception JavaDoc {
485     SubscriptionRootTreeNode subRootTn =
486       (SubscriptionRootTreeNode)subTn.getParent();
487     UserTreeNode userTn = (UserTreeNode)subRootTn.getParent();
488     ServerTreeNode serverTn = userTn.getParentServerTreeNode();
489     userTn.getUser().clearSubscription(
490       subTn.getSubscription().getName());
491     while(subTn.getChildCount() > 0) {
492       MessageTreeNode msgTn = (MessageTreeNode)subTn.getChildAt(0);
493       adminTreeModel.removeNodeFromParent(msgTn);
494     }
495   }
496
497   public void clearQueue(QueueTreeNode queueTn) throws Exception JavaDoc {
498     queueTn.getQueue().clear();
499     MessageRootTreeNode msgRootTn = queueTn.getMessageRootTreeNode();
500     while(msgRootTn.getChildCount() > 0) {
501       MessageTreeNode msgTn = (MessageTreeNode)msgRootTn.getChildAt(0);
502       adminTreeModel.removeNodeFromParent(msgTn);
503     }
504   }
505
506   public int getPendingMessages(Queue q) throws Exception JavaDoc
507   {
508     return ((org.objectweb.joram.client.jms.Queue) q).getPendingMessages();
509   }
510
511   public int getPendingRequests(Queue q) throws Exception JavaDoc
512   {
513     return ((org.objectweb.joram.client.jms.Queue) q).getPendingRequests();
514   }
515
516   public int getSubscriptions(Topic t) throws Exception JavaDoc
517   {
518     return ((org.objectweb.joram.client.jms.Topic) t).getSubscriptions();
519   }
520
521   public int getDefaultThreshold(int serverId) throws Exception JavaDoc
522   {
523     return AdminModule.getDefaultThreshold(serverId);
524   }
525
526   public void setDefaultThreshold(int serverId, int threshold) throws Exception JavaDoc
527   {
528     AdminModule.setDefaultThreshold(serverId, threshold);
529   }
530
531   public DeadMQueue getDefaultDMQ(int serverId) throws Exception JavaDoc
532   {
533     return AdminModule.getDefaultDMQ(serverId);
534   }
535
536   public void setDefaultDMQ(int serverId, DeadMQueue dmq) throws Exception JavaDoc
537   {
538     AdminModule.setDefaultDMQ(serverId, dmq);
539   }
540
541   public void unsetDefaultThreshold(int serverId) throws Exception JavaDoc
542   {
543     AdminModule.setDefaultThreshold(serverId, -1);
544   }
545
546   public void unsetDefaultDMQ(int serverId) throws Exception JavaDoc
547   {
548     AdminModule.setDefaultDMQ(serverId, null);
549   }
550
551   public int getUserThreshold(User user) throws Exception JavaDoc
552   {
553     return user.getThreshold();
554   }
555
556   public void setUserThreshold(User user, int threshold) throws Exception JavaDoc
557   {
558     user.setThreshold(threshold);
559   }
560
561   public DeadMQueue getUserDMQ(User user) throws Exception JavaDoc
562   {
563     return user.getDMQ();
564   }
565
566   public void setUserDMQ(User user, DeadMQueue dmq) throws Exception JavaDoc
567   {
568     user.setDMQ(dmq);
569   }
570
571   public void unsetUserThreshold(User user) throws Exception JavaDoc
572   {
573     user.setThreshold(-1);
574   }
575
576   public void unsetUserDMQ(User user) throws Exception JavaDoc
577   {
578     user.setDMQ(null);
579   }
580
581   public int getQueueThreshold(Queue queue) throws Exception JavaDoc
582   {
583     return ((org.objectweb.joram.client.jms.Queue) queue).getThreshold();
584   }
585
586   public void setQueueThreshold(Queue queue, int threshold) throws Exception JavaDoc
587   {
588     ((org.objectweb.joram.client.jms.Queue) queue).setThreshold(threshold);
589   }
590
591   public DeadMQueue getDestinationDMQ(Destination dest) throws Exception JavaDoc
592   {
593     return ((org.objectweb.joram.client.jms.Destination) dest).getDMQ();
594   }
595
596   public void setDestinationDMQ(Destination dest, DeadMQueue dmq) throws Exception JavaDoc
597   {
598     ((org.objectweb.joram.client.jms.Destination) dest).setDMQ(dmq);
599   }
600
601   public void unsetQueueThreshold(Queue queue) throws Exception JavaDoc
602   {
603     ((org.objectweb.joram.client.jms.Queue) queue).setThreshold(-1);
604   }
605
606   public void unsetDestinationDMQ(Destination dest) throws Exception JavaDoc
607   {
608     ((org.objectweb.joram.client.jms.Destination) dest).setDMQ(null);
609   }
610
611   public boolean isFreelyReadable(Destination dest) throws Exception JavaDoc
612   {
613     return ((org.objectweb.joram.client.jms.Destination) dest).isFreelyReadable();
614   }
615
616   public boolean isFreelyWritable(Destination dest) throws Exception JavaDoc
617   {
618     return ((org.objectweb.joram.client.jms.Destination) dest).isFreelyWriteable();
619   }
620
621   public void setFreeReading(Destination dest) throws Exception JavaDoc
622   {
623     ((org.objectweb.joram.client.jms.Destination) dest).setFreeReading();
624   }
625
626   public void setFreeWriting(Destination dest) throws Exception JavaDoc
627   {
628     ((org.objectweb.joram.client.jms.Destination) dest).setFreeWriting();
629   }
630
631   public void unsetFreeReading(Destination dest) throws Exception JavaDoc
632   {
633     ((org.objectweb.joram.client.jms.Destination) dest).unsetFreeReading();
634   }
635
636   public void unsetFreeWriting(Destination dest) throws Exception JavaDoc
637   {
638     ((org.objectweb.joram.client.jms.Destination) dest).unsetFreeWriting();
639   }
640
641   public List JavaDoc getAuthorizedReaders(Destination dest) throws Exception JavaDoc
642   {
643     return ((org.objectweb.joram.client.jms.Destination) dest).getReaders();
644   }
645
646   public List JavaDoc getAuthorizedWriters(Destination dest) throws Exception JavaDoc
647   {
648     return ((org.objectweb.joram.client.jms.Destination) dest).getWriters();
649   }
650
651   public void setReader(User user, Destination dest) throws Exception JavaDoc
652   {
653     ((org.objectweb.joram.client.jms.Destination) dest).setReader(user);
654   }
655
656   public void setWriter(User user, Destination dest) throws Exception JavaDoc
657   {
658     ((org.objectweb.joram.client.jms.Destination) dest).setWriter(user);
659   }
660
661   public void unsetReader(User user, Destination dest) throws Exception JavaDoc
662   {
663     ((org.objectweb.joram.client.jms.Destination) dest).unsetReader(user);
664   }
665
666   public void unsetWriter(User user, Destination dest) throws Exception JavaDoc
667   {
668     ((org.objectweb.joram.client.jms.Destination) dest).unsetWriter(user);
669   }
670
671   public String JavaDoc getAdminConnectionStatus() { return adminConnectionStr; }
672
673   public boolean isAdminConnected() { return adminConnected; }
674
675   public boolean isJndiConnected() { return jndiConnected; }
676
677   private void cleanupAdminTree()
678   {
679     while (adminRoot.getChildCount() > 0)
680       adminTreeModel.removeNodeFromParent((MutableTreeNode) adminRoot.getChildAt(0));
681   }
682   
683   private void cleanupJndiTree()
684   {
685     while (jndiRoot.getChildCount() > 0)
686       jndiTreeModel.removeNodeFromParent((MutableTreeNode) jndiRoot.getChildAt(0));
687   }
688
689   private void insertJndiNode(JndiTreeNode n)
690   {
691     int i;
692     for (i = 0; i < jndiRoot.getChildCount(); i++) {
693       JndiTreeNode curr = (JndiTreeNode) jndiRoot.getChildAt(i);
694       if (n.getName().compareTo(curr.getName()) < 0)
695         break;
696     }
697
698     jndiTreeModel.insertNodeInto(n, jndiRoot, i);
699   }
700
701     private DestinationTreeNode findDestinationNode(TreeNode from, Destination dest) {
702         for (int i = 0; i < from.getChildCount(); i++) {
703             TreeNode current = from.getChildAt(i);
704             try {
705                 DestinationTreeNode dtn = (DestinationTreeNode) current;
706                 if (dtn.getDestination().equals(dest))
707                     return dtn;
708             }
709             catch (ClassCastException JavaDoc exc) {
710                 if (current.getChildCount() > 0)
711                     return findDestinationNode(current, dest);
712             }
713         }
714
715         return null;
716     }
717
718     protected String JavaDoc findDestinationJndiName(Destination dest) {
719         for (int i = 0; i < jndiRoot.getChildCount(); i++) {
720             JndiTreeNode current = (JndiTreeNode) jndiRoot.getChildAt(i);
721             Object JavaDoc obj = current.getObject();
722             if (obj instanceof Destination && ((Destination) obj).equals(dest))
723                 return current.getName();
724         }
725
726         return null;
727     }
728
729   protected void notifyListener(ControllerEvent e)
730   {
731     if (gui != null)
732       gui.adminControllerEvent(e);
733   }
734
735   
736 }
737
Popular Tags