KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > chat > ChatAdmin


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2001 - 2004 ScalAgent Distributed Technologies
4  * Copyright (C) 2004 - Bull SA
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): Jose Carlos Waeny
23  * Contributor(s): Frederic Maistre (INRIA)
24  * ScalAgent Distributed Technologies
25  */

26 package chat;
27
28 import org.objectweb.joram.client.jms.admin.*;
29 import org.objectweb.joram.client.jms.*;
30 import org.objectweb.joram.client.jms.tcp.*;
31
32 /**
33  * Launching JORAM administration:
34  * connecting to JORAM server, creating chat agents and creating chat topic
35  *
36  * @author JC Waeny
37  * @email jc@waeny.2y.net
38  * @version 1.0
39  */

40 public class ChatAdmin
41 {
42   public static void main(String JavaDoc args[]) throws Exception JavaDoc
43   {
44     System.out.println();
45     System.out.println("Chat administration phase... ");
46
47     // Connecting to JORAM server:
48
AdminModule.connect("root", "root", 60);
49
50     // Creating the JMS administered objects:
51
javax.jms.ConnectionFactory JavaDoc connFactory =
52       TcpConnectionFactory.create("localhost", 16010);
53
54     Topic topic = (Topic) Topic.create(0);
55
56     // Creating an access for user anonymous:
57
User user = User.create("anonymous", "anonymous", 0);
58
59     // Setting free access to the topic:
60
topic.setFreeReading();
61     topic.setFreeWriting();
62
63     // Binding objects in JNDI:
64
javax.naming.Context JavaDoc jndiCtx = new javax.naming.InitialContext JavaDoc();
65     jndiCtx.bind("factoryChat", connFactory);
66     jndiCtx.bind("topicChat", topic);
67     jndiCtx.close();
68     
69     AdminModule.disconnect();
70     System.out.println("Admin closed.");
71   }
72 }
73
Popular Tags