KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cluster > topic > ClusterAdmin


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

25 package cluster.topic;
26
27 import org.objectweb.joram.client.jms.admin.*;
28 import org.objectweb.joram.client.jms.*;
29 import org.objectweb.joram.client.jms.tcp.*;
30
31 /**
32  * Administers three agent servers for the cluster of topics sample.
33  */

34 public class ClusterAdmin
35 {
36   public static void main(String JavaDoc[] args) throws Exception JavaDoc
37   {
38     System.out.println();
39     System.out.println("Cluster of topics administration...");
40
41     AdminModule.connect("root", "root", 60);
42
43     User user00 = User.create("publisher00", "publisher00", 0);
44     User user10 = User.create("subscriber10", "subscriber10", 1);
45     User user20 = User.create("subscriber20", "subscriber20", 2);
46     User user21 = User.create("subscriber21", "subscriber21", 2);
47
48     javax.jms.ConnectionFactory JavaDoc cf0 =
49       TcpConnectionFactory.create("localhost", 16010);
50     javax.jms.ConnectionFactory JavaDoc cf1 =
51       TcpConnectionFactory.create("localhost", 16011);
52     javax.jms.ConnectionFactory JavaDoc cf2 =
53       TcpConnectionFactory.create("localhost", 16012);
54
55     Topic top0 = (Topic) Topic.create(0);
56     Topic top1 = (Topic) Topic.create(1);
57     Topic top2 = (Topic) Topic.create(2);
58
59     top0.setFreeReading();
60     top1.setFreeReading();
61     top2.setFreeReading();
62     top0.setFreeWriting();
63     top1.setFreeWriting();
64     top2.setFreeWriting();
65
66     top0.addClusteredTopic(top1);
67     top0.addClusteredTopic(top2);
68     
69     javax.naming.Context JavaDoc jndiCtx = new javax.naming.InitialContext JavaDoc();
70     jndiCtx.bind("cf0", cf0);
71     jndiCtx.bind("cf1", cf1);
72     jndiCtx.bind("cf2", cf2);
73     jndiCtx.bind("top0", top0);
74     jndiCtx.bind("top1", top1);
75     jndiCtx.bind("top2", top2);
76     jndiCtx.close();
77     
78     AdminModule.disconnect();
79     System.out.println("Admin closed.");
80   }
81 }
82
Popular Tags