KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jtests > providers > admin > AshnaMQAdmin


1 package org.objectweb.jtests.providers.admin;
2
3 import org.objectweb.jtests.jms.admin.Admin;
4 import javax.naming.*;
5 import com.ashnasoft.jms.client.admin.*;
6 import com.ashnasoft.jms.client.*;
7 import javax.jms.Queue JavaDoc;
8 import javax.jms.Topic JavaDoc;
9 import java.util.Properties JavaDoc;
10
11 public class AshnaMQAdmin implements Admin {
12     
13     private String JavaDoc name = "AshnaMQ";
14     private InitialContext ictx = null;
15     private ASAdministrator admin = null;
16
17     public AshnaMQAdmin() {
18         try {
19             Properties JavaDoc props = new Properties JavaDoc();
20             props.setProperty("java.naming.factory.initial", "com.ashnasoft.jms.client.jndi.InitialContextFactoryImpl");
21             props.setProperty("java.naming.factory.host", "localhost");
22             props.setProperty("java.naming.provider.url", "jndi:Ashna://localhost:9090");
23             props.setProperty("java.naming.security.principal","admin");
24             props.setProperty("java.naming.security.credentials","admin");
25             ictx = new InitialContext (props);
26             admin = new ASAdministrator("localhost", 9090, "admin", "admin", false);
27         } catch (Exception JavaDoc e) {
28             e.printStackTrace();
29             System.exit(1);
30         }
31     }
32     
33     public String JavaDoc getName() {
34         return name;
35     }
36     
37     public InitialContext createInitialContext() throws NamingException {
38         return ictx;
39     }
40   
41     public void createQueueConnectionFactory(String JavaDoc qcfName) {
42         try {
43             ASQueueConnectionFactory qcf = new ASQueueConnectionFactory("localhost", 9090, false);
44             ictx.rebind(qcfName, qcf);
45         }
46         catch (Exception JavaDoc e) {
47             e.printStackTrace();
48         }
49     }
50
51     public void createTopicConnectionFactory(String JavaDoc tcfName) {
52         try {
53             ASTopicConnectionFactory tcf = new ASTopicConnectionFactory("localhost", 9090, false);
54             ictx.rebind(tcfName, tcf);
55         }
56         catch (Exception JavaDoc e) {
57             e.printStackTrace();
58         }
59     }
60  
61     public void createQueue(String JavaDoc queueName) {
62         try {
63             admin.createQueue(queueName);
64         }
65         catch (Exception JavaDoc e) {
66             e.printStackTrace();
67         }
68     }
69  
70     public void createTopic(String JavaDoc topicName) {
71         try {
72             admin.createTopic(topicName);
73         }
74         catch (Exception JavaDoc e) {
75             e.printStackTrace();
76         }
77     }
78
79     public void deleteQueue(String JavaDoc queueName) {
80         try {
81             admin.removeQueue(queueName);
82         }
83         catch (Exception JavaDoc e) {
84             e.printStackTrace();
85         }
86     }
87   
88     public void deleteTopic(String JavaDoc topicName) {
89         try {
90             admin.removeTopic(topicName);
91         }
92         catch (Exception JavaDoc e) {
93             e.printStackTrace();
94         }
95     }
96   
97     public void deleteTopicConnectionFactory(String JavaDoc tcfName) {
98         try {
99             ictx.unbind(tcfName);
100         }
101         catch (Exception JavaDoc e) {
102             e.printStackTrace();
103         }
104     }
105
106     public void deleteQueueConnectionFactory(String JavaDoc qcfName) {
107         try {
108             ictx.unbind(qcfName);
109         }
110         catch (Exception JavaDoc e) {
111             e.printStackTrace();
112         }
113     }
114 }
115
Popular Tags