KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > jmx > browser > model > service > ConnectionServiceProvider


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.service;
14
15
16
17 import java.beans.beancontext.BeanContextServices JavaDoc;
18
19 import java.util.Iterator JavaDoc;
20
21 import java.util.Vector JavaDoc;
22
23
24
25 import org.apache.log4j.Logger;
26
27 import org.ejtools.beans.beancontext.CustomBeanContextServiceProvider;
28
29 import org.ejtools.jmx.browser.model.connector.LocalConnectionService;
30
31 import org.ejtools.util.service.Profile;
32
33
34
35 /**
36
37  * Description of the Class
38
39  *
40
41  * @author <a HREF="mailto:letiemble@users.sourceforge.net">Laurent Etiemble</a>
42
43  * @created 13 décembre 2001
44
45  * @version $Revision: 1.6 $
46
47  * @todo Javadoc to complete
48
49  */

50
51 public class ConnectionServiceProvider extends CustomBeanContextServiceProvider
52
53 {
54
55    /** Description of the Field */
56
57    protected ConnectionService service = null;
58
59    /** Description of the Field */
60
61    private static Logger logger = Logger.getLogger(ConnectionServiceProvider.class);
62
63
64
65
66
67    /** Constructor for the ConnectionServiceProvider object */
68
69    public ConnectionServiceProvider()
70
71    {
72
73       this.setup(new LocalConnectionService());
74
75    }
76
77
78
79
80
81    /**
82
83     * Constructor for the ConnectionServiceProvider object
84
85     *
86
87     * @param metadata Description of the Parameter
88
89     * @param loader Description of the Parameter
90
91     */

92
93    public ConnectionServiceProvider(Profile metadata)
94
95    {
96
97       // Create the connection service from metadatas
98

99       String JavaDoc clazz = metadata.getProperty(ConnectionMetaData.CLASS_NAME);
100
101       if (clazz != null)
102
103       {
104
105          try
106
107          {
108
109             ConnectionService service = (ConnectionService) Thread.currentThread().getContextClassLoader().loadClass(clazz).newInstance();
110
111             this.setup(service);
112
113          }
114
115          catch (ClassNotFoundException JavaDoc cnfe)
116
117          {
118
119             logger.error(cnfe.getMessage(), cnfe);
120
121          }
122
123          catch (IllegalAccessException JavaDoc iae)
124
125          {
126
127             logger.error(iae.getMessage(), iae);
128
129          }
130
131          catch (Exception JavaDoc e)
132
133          {
134
135             logger.error(e.getMessage(), e);
136
137          }
138
139       }
140
141       else
142
143       {
144
145          logger.error("Class provided is null");
146
147       }
148
149    }
150
151
152
153
154
155    /**
156
157     * Getter for the currentServiceSelectors attribute
158
159     *
160
161     * @param bcs Description of the Parameter
162
163     * @param serviceClass Description of the Parameter
164
165     * @return The currentServiceSelectors value
166
167     */

168
169    public Iterator JavaDoc getCurrentServiceSelectors(BeanContextServices JavaDoc bcs, java.lang.Class JavaDoc serviceClass)
170
171    {
172
173       return (new Vector JavaDoc()).iterator();
174
175    }
176
177
178
179
180
181    /**
182
183     * Getter for the service attribute
184
185     *
186
187     * @param bcs Description of the Parameter
188
189     * @param requestor Description of the Parameter
190
191     * @param serviceClass Description of the Parameter
192
193     * @param serviceSelector Description of the Parameter
194
195     * @return The service value
196
197     */

198
199    public Object JavaDoc getService(BeanContextServices JavaDoc bcs, java.lang.Object JavaDoc requestor, java.lang.Class JavaDoc serviceClass, java.lang.Object JavaDoc serviceSelector)
200
201    {
202
203       return this.service;
204
205    }
206
207
208
209
210
211    /**
212
213     * Description of the Method
214
215     *
216
217     * @param bcs Description of the Parameter
218
219     * @param requestor Description of the Parameter
220
221     * @param service Description of the Parameter
222
223     */

224
225    public void releaseService(BeanContextServices JavaDoc bcs, java.lang.Object JavaDoc requestor, java.lang.Object JavaDoc service) { }
226
227
228
229
230
231    /**
232
233     * @return The serviceClass value
234
235     */

236
237    protected Class JavaDoc[] getServiceClass()
238
239    {
240
241       return new Class JavaDoc[]{ConnectionService.class};
242
243    }
244
245
246
247
248
249    /**
250
251     * Description of the Method
252
253     *
254
255     * @param service Description of the Parameter
256
257     */

258
259    private void setup(ConnectionService service)
260
261    {
262
263       this.service = service;
264
265    }
266
267 }
268
269
Popular Tags