KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > deadMQueue > DMQAdmin


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2004 - Bull SA
4  * Copyright (C) 2001 - 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):
24  */

25 package deadMQueue;
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 an agent server for the deadMQueue samples.
33  */

34 public class DMQAdmin
35 {
36   public static void main(String JavaDoc[] args) throws Exception JavaDoc
37   {
38     System.out.println();
39     System.out.println("DMQ administration...");
40
41     AdminModule.connect("root", "root", 60);
42
43     Queue queue = (Queue) Queue.create(0);
44     Topic topic = (Topic) Topic.create(0);
45
46     DeadMQueue userDmq = (DeadMQueue) DeadMQueue.create(0);
47     DeadMQueue destDmq = (DeadMQueue) DeadMQueue.create(0);
48
49     User ano = User.create("anonymous", "anonymous", 0);
50     User dmq = User.create("dmq", "dmq", 0);
51
52     javax.jms.ConnectionFactory JavaDoc cnxFact =
53       TcpConnectionFactory.create("localhost", 16010);
54
55     ano.setDMQ(userDmq);
56     queue.setDMQ(destDmq);
57     topic.setDMQ(destDmq);
58
59     ano.setThreshold(2);
60     queue.setThreshold(2);
61
62     queue.setFreeReading();
63     queue.setFreeWriting();
64     topic.setFreeReading();
65     topic.setFreeWriting();
66     userDmq.setReader(dmq);
67     userDmq.setWriter(dmq);
68     destDmq.setReader(dmq);
69     destDmq.setWriter(dmq);
70
71     javax.naming.Context JavaDoc jndiCtx = new javax.naming.InitialContext JavaDoc();
72     jndiCtx.bind("queue", queue);
73     jndiCtx.bind("topic", topic);
74     jndiCtx.bind("userDmq", userDmq);
75     jndiCtx.bind("destDmq", destDmq);
76     jndiCtx.bind("cnxFact", cnxFact);
77     jndiCtx.close();
78
79     AdminModule.disconnect();
80     System.out.println("Admin closed.");
81   }
82 }
83
Free Books   Free Magazines  
Popular Tags