KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > topicTree > TreeAdmin


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

24 package topicTree;
25
26 import org.objectweb.joram.client.jms.admin.*;
27 import org.objectweb.joram.client.jms.*;
28 import org.objectweb.joram.client.jms.tcp.*;
29
30 /**
31  * Administers an agent server for the topic tree samples.
32  */

33 public class TreeAdmin
34 {
35   public static void main(String JavaDoc[] args) throws Exception JavaDoc
36   {
37     System.out.println();
38     System.out.println("Tree administration...");
39
40     AdminModule.connect("root", "root", 60);
41
42     Topic news = (Topic) Topic.create(0);
43     Topic business = (Topic) Topic.create(0);
44     Topic sports = (Topic) Topic.create(0);
45     Topic tennis = (Topic) Topic.create(0);
46
47     business.setParent(news);
48     sports.setParent(news);
49     tennis.setParent(sports);
50
51     javax.jms.ConnectionFactory JavaDoc cf =
52       TcpConnectionFactory.create("localhost", 16010);
53
54     User user = User.create("anonymous", "anonymous", 0);
55
56     news.setFreeReading();
57     news.setFreeWriting();
58     business.setFreeReading();
59     business.setFreeWriting();
60     sports.setFreeReading();
61     sports.setFreeWriting();
62     tennis.setFreeReading();
63     tennis.setFreeWriting();
64
65     javax.naming.Context JavaDoc jndiCtx = new javax.naming.InitialContext JavaDoc();
66     jndiCtx.bind("news", news);
67     jndiCtx.bind("business", business);
68     jndiCtx.bind("sports", sports);
69     jndiCtx.bind("tennis", tennis);
70     jndiCtx.bind("cf", cf);
71     jndiCtx.close();
72
73     AdminModule.disconnect();
74     System.out.println("Admin closed.");
75   }
76 }
77
Popular Tags