KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dotcom > DotcomAdmin


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 dotcom;
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 /**
33  * Launching JORAM administration:
34  * connecting to JORAM server, creating customer agents, creating topic
35  * and creating queues.
36  */

37 public class DotcomAdmin
38 {
39   public static void main(String JavaDoc args[]) throws Exception JavaDoc
40   {
41     System.out.println();
42     System.out.println("Dotcom administration...");
43
44     // connecting to JORAM server
45
AdminModule.connect("root", "root", 60);
46         
47     // setting users
48
User web = User.create("web", "web", 0);
49     User billing = User.create("billing", "billing", 0);
50     User inventory = User.create("inventory", "inventory", 0);
51     User customer = User.create("customer", "customer", 0);
52     User control = User.create("control", "control", 0);
53     User delivery = User.create("delivery", "delivery", 0);
54
55     // Creating the administered objects:
56
javax.jms.QueueConnectionFactory JavaDoc qcf =
57       QueueTcpConnectionFactory.create("localhost", 16010);
58     javax.jms.TopicConnectionFactory JavaDoc tcf =
59       TopicTcpConnectionFactory.create("localhost", 16010);
60
61     Topic tOrders = (Topic) Topic.create(0);
62     Queue qItems = (Queue) Queue.create(0);
63     Queue qCheck = (Queue) Queue.create(0);
64     Queue qChecked = (Queue) Queue.create(0);
65     Queue qBills = (Queue) Queue.create(0);
66     Queue qDelivery = (Queue) Queue.create(0);
67
68     // Setting access permissions:
69
tOrders.setWriter(web);
70     tOrders.setReader(billing);
71     tOrders.setReader(inventory);
72     tOrders.setReader(customer);
73     qCheck.setWriter(billing);
74     qCheck.setReader(control);
75     qChecked.setWriter(control);
76     qChecked.setReader(billing);
77     qBills.setWriter(billing);
78     qBills.setReader(customer);
79     qItems.setWriter(inventory);
80     qItems.setReader(customer);
81     qDelivery.setWriter(customer);
82     qDelivery.setReader(delivery);
83
84     // Binding objects in JNDI:
85
javax.naming.Context JavaDoc jndiCtx = new javax.naming.InitialContext JavaDoc();
86     jndiCtx.bind("qcf", qcf);
87     jndiCtx.bind("tcf", tcf);
88     jndiCtx.bind("tOrders", tOrders);
89     jndiCtx.bind("qItems", qItems);
90     jndiCtx.bind("qCheck", qCheck);
91     jndiCtx.bind("qChecked", qChecked);
92     jndiCtx.bind("qBills", qBills);
93     jndiCtx.bind("qDelivery", qDelivery);
94     jndiCtx.close();
95
96     AdminModule.disconnect();
97     System.out.println("Admin closed.");
98   }
99 }
100
Popular Tags