KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > jmx > browser > model > connector > RemotingConnectionService


1 /*
2
3  * EJTools, the Enterprise Java Tools
4
5  *
6
7  * Distributable under LGPL license.
8
9  * See terms of license at www.gnu.org.
10
11  */

12
13 package org.ejtools.jmx.browser.model.connector;
14
15
16
17 import java.util.Hashtable JavaDoc;
18
19
20
21 import javax.management.MBeanServer JavaDoc;
22
23 import javax.management.MBeanServerConnection JavaDoc;
24
25 import javax.management.remote.JMXConnector JavaDoc;
26
27 import javax.management.remote.JMXConnectorFactory JavaDoc;
28
29 import javax.management.remote.JMXServiceURL JavaDoc;
30
31 import javax.naming.Context JavaDoc;
32
33
34
35 import org.ejtools.jmx.MBeanServerProxy;
36
37 import org.ejtools.jmx.browser.model.service.ConnectionMetaData;
38
39
40
41
42
43 /**
44
45  * @author letiembl
46
47  * @created 4 septembre 2002
48
49  * @version $Revision: 1.1 $
50
51  */

52
53 public class RemotingConnectionService extends AbstractConnectionService
54
55 {
56
57    /** Description of the Field */
58
59    protected JMXConnector JavaDoc connector = null;
60
61
62
63
64
65    /** */
66
67    public void disconnect()
68
69    {
70
71       super.disconnect();
72
73       try
74
75       {
76
77          this.connector.close();
78
79       }
80
81       catch (Exception JavaDoc e)
82
83       {
84
85          // Do nothing
86

87       }
88
89       this.setConnected(false);
90
91    }
92
93
94
95
96
97    /**
98
99     * @exception Exception Description of the Exception
100
101     */

102
103    protected void createMBeanServer()
104
105       throws Exception JavaDoc
106
107    {
108
109       System.setProperty("jmx.serial.form", "1.2");
110
111
112
113       Hashtable JavaDoc props = new Hashtable JavaDoc();
114
115       props.put(Context.INITIAL_CONTEXT_FACTORY, this.profile.getProperty(ConnectionMetaData.FACTORY));
116
117       props.put(Context.URL_PKG_PREFIXES, this.profile.getProperty(ConnectionMetaData.PACKAGES));
118
119       props.put(Context.PROVIDER_URL, this.profile.getProperty(ConnectionMetaData.URL));
120
121       props.put(Context.SECURITY_PRINCIPAL, this.profile.getProperty(ConnectionMetaData.PRINCIPAL));
122
123       props.put(Context.SECURITY_CREDENTIALS, this.profile.getProperty(ConnectionMetaData.CREDENTIALS));
124
125
126
127 JMXServiceURL JavaDoc url = new JMXServiceURL JavaDoc(this.profile.getProperty(ConnectionMetaData.SERVICE));
128
129 this.connector = JMXConnectorFactory.connect(url, props);
130
131 MBeanServerConnection JavaDoc connection = connector.getMBeanServerConnection();
132
133
134
135       MBeanServer JavaDoc mbeanServer = MBeanServerProxy.createMBeanProxy(connection);
136
137       this.setMBeanServer(mbeanServer);
138
139    }
140
141 }
142
143
Popular Tags