KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mail > MailAdmin


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

23 package mail;
24
25 import org.objectweb.joram.client.jms.admin.*;
26 import org.objectweb.joram.client.jms.*;
27 import org.objectweb.joram.client.jms.tcp.*;
28 import org.objectweb.joram.client.jms.Queue;
29
30 import java.io.*;
31 import java.util.Properties JavaDoc;
32
33 public class MailAdmin {
34   public static void main(String JavaDoc[] args) throws Exception JavaDoc {
35     System.out.println("mail administration...");
36
37     AdminModule.connect("root", "root", 60);
38     Properties JavaDoc prop = new Properties JavaDoc();
39     prop.load(new FileInputStream("pop.properties"));
40  
41     Queue queue = Queue.create(0, null,
42                                "com.scalagent.joram.mom.dest.mail.JavaMailQueue",prop);
43
44     prop = new Properties JavaDoc();
45     prop.load(new FileInputStream("smtp.properties"));
46     Topic topic = Topic.create(0,null,
47                                "com.scalagent.joram.mom.dest.mail.JavaMailTopic",prop);
48
49     javax.jms.ConnectionFactory JavaDoc cf = TcpConnectionFactory.create("localhost", 16010);
50
51     User user = User.create("anonymous", "anonymous", 0);
52
53     queue.setFreeReading();
54     queue.setFreeWriting();
55
56     topic.setFreeReading();
57     topic.setFreeWriting();
58
59     javax.naming.Context JavaDoc jndiCtx = new javax.naming.InitialContext JavaDoc();
60     jndiCtx.bind("cf", cf);
61     jndiCtx.bind("mailQueue", queue);
62     jndiCtx.bind("mailTopic", topic);
63     jndiCtx.close();
64
65     AdminModule.disconnect();
66     System.out.println("Admin closed, ready to send/recv mail.");
67   }
68 }
69
Popular Tags