KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.objectweb.jtests.providers.admin;
2
3 import org.objectweb.jtests.jms.admin.Admin;
4 import javax.naming.*;
5 import fiorano.jms.runtime.admin.*;
6 import fiorano.jms.md.*;
7 import javax.jms.Queue JavaDoc;
8 import javax.jms.Topic JavaDoc;
9 import java.util.Properties JavaDoc;
10
11 public class FioranoMQAdmin implements Admin {
12     
13     private String JavaDoc name = "FioranoMQ";
14     private InitialContext ictx = null;
15     private MQAdminService adminService = null;
16
17     public FioranoMQAdmin() {
18     try {
19         Properties JavaDoc props = new Properties JavaDoc();
20         props.setProperty("java.naming.factory.initial", "fiorano.jms.runtime.naming.FioranoInitialContextFactory");
21         props.setProperty("java.naming.factory.host", "localhost");
22         props.setProperty("java.naming.provider.url", "http://localhost:1856");
23         props.setProperty("java.naming.security.principal","anonymous");
24         props.setProperty("java.naming.security.credentials","anonymous");
25         ictx = new InitialContext (props);
26         MQAdminConnectionFactory acf = (MQAdminConnectionFactory) ictx.lookup ("primaryACF");
27         MQAdminConnection ac = acf.createMQAdminConnection ("admin", "passwd");
28         adminService = ac.getMQAdminService();
29     } catch (Exception JavaDoc e) {
30         e.printStackTrace();
31         System.exit(1);
32     }
33     }
34     
35     public String JavaDoc getName() {
36     return name;
37     }
38     
39     public InitialContext createInitialContext() throws NamingException {
40     return ictx;
41     }
42   
43     public void createQueueConnectionFactory(String JavaDoc qcfName) {
44     try {
45         QueueConnectionFactoryMetaData factoryMetaData = new QueueConnectionFactoryMetaData();
46         factoryMetaData.setName(qcfName);
47         factoryMetaData.setDescription ("Queue Connection Factory");
48         factoryMetaData.setConnectURL ("http://localhost:1856");
49         adminService.createQueueConnectionFactory (factoryMetaData);
50     } catch (Exception JavaDoc e) {
51         e.printStackTrace();
52     }
53     }
54
55     public void createTopicConnectionFactory(String JavaDoc tcfName) {
56     try {
57         TopicConnectionFactoryMetaData factoryMetaData = new TopicConnectionFactoryMetaData();
58         factoryMetaData.setName(tcfName);
59         factoryMetaData.setDescription ("Topic Connection Factory");
60         factoryMetaData.setConnectURL ("http://localhost:1856");
61         adminService.createTopicConnectionFactory (factoryMetaData);
62     } catch (Exception JavaDoc e) {
63         e.printStackTrace();
64     }
65     }
66  
67     public void createQueue(String JavaDoc queueName) {
68     try {
69         QueueMetaData queueMetaData = new QueueMetaData();
70         queueMetaData.setName(queueName);
71         adminService.createQueue(queueMetaData);
72     } catch (Exception JavaDoc e) {
73         e.printStackTrace();
74     }
75     }
76  
77     public void createTopic(String JavaDoc topicName) {
78     try {
79         TopicMetaData topicMetaData1 = new TopicMetaData();
80         topicMetaData1.setName(topicName);
81         adminService.createTopic(topicMetaData1);
82     } catch (Exception JavaDoc e) {
83         e.printStackTrace();
84     }
85     }
86
87     public void deleteQueue(String JavaDoc queueName) {
88     try {
89         adminService.deleteQueue(queueName);
90     } catch (Exception JavaDoc e) {
91         e.printStackTrace();
92     }
93     }
94   
95     public void deleteTopic(String JavaDoc topicName) {
96     try {
97         adminService.deleteTopic(topicName);
98     } catch (Exception JavaDoc e) {
99         e.printStackTrace();
100     }
101     }
102   
103     public void deleteTopicConnectionFactory(String JavaDoc tcfName) {
104     try {
105         adminService.deleteTopicConnectionFactory(tcfName);
106     } catch (Exception JavaDoc e) {
107         e.printStackTrace();
108     }
109     }
110
111     public void deleteQueueConnectionFactory(String JavaDoc qcfName) {
112     try {
113         adminService.deleteQueueConnectionFactory(qcfName);
114     } catch (Exception JavaDoc e) {
115         e.printStackTrace();
116     }
117     }
118 }
119
Popular Tags