KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.objectweb.jtests.providers.admin;
2
3 import org.objectweb.jtests.jms.admin.Admin;
4
5 import javax.naming.*;
6 import javax.jms.Queue JavaDoc;
7 import javax.jms.Topic JavaDoc;
8 import java.util.*;
9 import java.io.*;
10 import com.pramati.services.jms.spi.admin.JMSServerMBean;
11 import com.pramati.util.naming.BindNamesAndDefaultParamValues;
12
13 /**
14  * This wrapper has been provided for Joram's open source Test suite by Pramati Technologies.
15  * The wrapper is used by the Test framework to create and destroy administered objects
16  * <b>queues,topics and connection factories</b><br>
17  * Pramati Message Server's Adminstration is based on JMX : Java Management Extension framework;
18  * Each adminstrable object is bound in the MBean server<br>
19  *
20  * In this class the main JMSServerMBean is being used for creating and deleting the Administered
21  * objects.
22  *
23  * @see com.pramai.services.jms.spi.admin.JMSServerMBean
24  *
25  * @author Rajdeep Dua : mailto rajdeep@pramati.com
26  */

27 public class PramatiAdmin implements Admin {
28   
29     private String JavaDoc name = "PRAMATI";
30     InitialContext ictx = null;
31     JMSServerMBean jmsServerMBean = null;
32     /**
33      * Initialises the wrapper by looking up in the Pramati Message Server's naming service for
34      * the JMSServerMBean.
35      */

36     public PramatiAdmin() {
37     try {
38         Properties props = new Properties();
39         props.setProperty("java.naming.factory.initial",
40                   "com.pramati.naming.client.PramatiClientContextFactory");
41         //Please change the IP and port according to the configuration ,2099 is the
42
//default naming service port for Standalone JMSServer,for Embedded JMSServer in
43
//Pramati's Application server it is 9191
44
props.setProperty("java.naming.provider.url", "http://localhost:2099");
45         ictx = new InitialContext (props);
46         jmsServerMBean = (JMSServerMBean)ictx.lookup(BindNamesAndDefaultParamValues.JMS_SERVER_MBEAN);
47     }catch (Exception JavaDoc e) {
48         e.printStackTrace();
49     }
50     }
51
52     public String JavaDoc getName() {
53     return name;
54     }
55
56     public InitialContext createInitialContext() throws NamingException {
57     return ictx;
58     }
59   
60     public void createQueueConnectionFactory(String JavaDoc name) {
61     try {
62         jmsServerMBean.createQueueConnectionFactory(name);
63     } catch (Exception JavaDoc e) {
64         e.printStackTrace();
65     }
66     }
67   
68     public void createTopicConnectionFactory(String JavaDoc name) {
69     try {
70         jmsServerMBean.createTopicConnectionFactory(name);
71     } catch (Exception JavaDoc e) {
72         e.printStackTrace();
73     }
74     }
75  
76     public void createQueue(String JavaDoc name) {
77     try {
78         jmsServerMBean.createQueue(name);
79     } catch (Exception JavaDoc e) {
80         e.printStackTrace();
81     }
82     }
83   
84     public void createTopic(String JavaDoc name) {
85     try {
86         jmsServerMBean.createTopic(name);
87     } catch (Exception JavaDoc e) {
88         e.printStackTrace();
89     }
90     }
91
92     public void deleteQueue(String JavaDoc name) {
93     try {
94         jmsServerMBean.deleteQueue(name);
95     } catch (Exception JavaDoc e) {
96         e.printStackTrace();
97     }
98     }
99  
100     public void deleteTopic(String JavaDoc name) {
101     try {
102         jmsServerMBean.deleteTopic(name);
103     } catch (Exception JavaDoc e) {
104         e.printStackTrace();
105     }
106     }
107
108     public void deleteTopicConnectionFactory(String JavaDoc name) {
109     try {
110         jmsServerMBean.deleteTopicConnectionFactory(name);
111     } catch (Exception JavaDoc e) {
112         e.printStackTrace();
113     }
114     }
115
116     public void deleteQueueConnectionFactory(String JavaDoc name) {
117     try {
118         jmsServerMBean.deleteQueueConnectionFactory(name);
119     } catch (Exception JavaDoc e) {
120         e.printStackTrace();
121     }
122     }
123 }
124
Popular Tags