KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > archi > ArchiAdmin


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2003 - 2004 Bull SA
4  * Copyright (C) 2001 - 2004 ScalAgent Distributed Technologies
5  * Copyright (C) 1996 - 2000 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 archi;
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 two agent servers for the archi samples.
33  */

34 public class ArchiAdmin
35 {
36   public static void main(String JavaDoc args[]) throws Exception JavaDoc
37   {
38     System.out.println();
39     System.out.println("Archi administration...");
40
41     // Connecting the administrator:
42
AdminModule.connect("root", "root", 60);
43
44     // Creating access for user anonymous on servers 0 and 2:
45
User user0 = User.create("anonymous", "anonymous", 0);
46     User user2 = User.create("anonymous", "anonymous", 2);
47
48     // Creating the destinations on server 1:
49
Queue queue = (Queue) Queue.create(1);
50     Topic topic = (Topic) Topic.create(1);
51
52     // Setting free access to the destinations:
53
queue.setFreeReading();
54     topic.setFreeReading();
55     queue.setFreeWriting();
56     topic.setFreeWriting();
57
58     // Creating the connection factories for connecting to the servers 0 and 2:
59
javax.jms.ConnectionFactory JavaDoc cf0 =
60       TcpConnectionFactory.create("localhost", 16010);
61     javax.jms.ConnectionFactory JavaDoc cf2 =
62       TcpConnectionFactory.create("localhost", 16012);
63
64     // Binding the objects in JNDI:
65
javax.naming.Context JavaDoc jndiCtx = new javax.naming.InitialContext JavaDoc();
66     jndiCtx.bind("queue", queue);
67     jndiCtx.bind("topic", topic);
68     jndiCtx.bind("cf0", cf0);
69     jndiCtx.bind("cf2", cf2);
70     jndiCtx.close();
71
72     AdminModule.disconnect();
73     System.out.println("Admin closed.");
74   }
75 }
76
Popular Tags