~ubuntu-branches/ubuntu/oneiric/libjboss-remoting-java/oneiric

« back to all changes in this revision

Viewing changes to src/main/org/jboss/remoting/transporter/TransporterServer.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: package-import@ubuntu.com-20110909140103-hqokx61534tas9rg
Tags: 2.5.3.SP1-1
* Newer but not newest upstream release. Do not build samples.
* Change debian/watch to upstream's svn repo.
* Add patch to fix compile error caused by tomcat update.
  (Closes: #628303)
* Switch to source format 3.0.
* Switch to debhelper level 7.
* Remove useless Depends.
* Update Standards-Version: 3.9.2.
* Update README.source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* JBoss, Home of Professional Open Source
 
3
* Copyright 2005, JBoss Inc., and individual contributors as indicated
 
4
* by the @authors tag. See the copyright.txt in the distribution for a
 
5
* full listing of individual contributors.
 
6
*
 
7
* This is free software; you can redistribute it and/or modify it
 
8
* under the terms of the GNU Lesser General Public License as
 
9
* published by the Free Software Foundation; either version 2.1 of
 
10
* the License, or (at your option) any later version.
 
11
*
 
12
* This software is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
15
* Lesser General Public License for more details.
 
16
*
 
17
* You should have received a copy of the GNU Lesser General Public
 
18
* License along with this software; if not, write to the Free
 
19
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 
20
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 
21
*/
 
22
 
 
23
package org.jboss.remoting.transporter;
 
24
 
 
25
import org.jboss.remoting.InvokerLocator;
 
26
import org.jboss.remoting.ServerInvocationHandler;
 
27
import org.jboss.remoting.detection.multicast.MulticastDetector;
 
28
import org.jboss.remoting.transport.Connector;
 
29
import org.jboss.remoting.util.SecurityUtility;
 
30
import org.w3c.dom.Element;
 
31
 
 
32
import javax.management.MBeanServer;
 
33
import javax.management.MBeanServerFactory;
 
34
 
 
35
import java.security.AccessController;
 
36
import java.security.PrivilegedActionException;
 
37
import java.security.PrivilegedExceptionAction;
 
38
import java.util.ArrayList;
 
39
import java.util.List;
 
40
import java.util.Map;
 
41
 
 
42
/**
 
43
 * The remoting server to expose the target POJO.  This should be called on as a factory via
 
44
 * static methods.
 
45
 *
 
46
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
 
47
 */
 
48
public class TransporterServer
 
49
{
 
50
   private Connector connector = null;
 
51
 
 
52
   /**
 
53
    * Creates a remoting server using the provided locator and subsytem and creating a TransporterHandler which
 
54
    * takes the specified target object.
 
55
    *
 
56
    * @param locator
 
57
    * @param target
 
58
    * @param subsystem
 
59
    * @throws Exception
 
60
    */
 
61
   public TransporterServer(InvokerLocator locator, Object target, String subsystem) throws Exception
 
62
   {
 
63
      connector = getConnector(locator, null, null);
 
64
      ServerInvocationHandler handler = new TransporterHandler(target);
 
65
      if (subsystem != null)
 
66
      {
 
67
         connector.addInvocationHandler(subsystem.toUpperCase(), handler);
 
68
      }
 
69
      else
 
70
      {
 
71
         addInterfaceSubsystems(connector, handler, target);
 
72
      }
 
73
   }
 
74
 
 
75
   /**
 
76
    * Creates a remoting server using the provided locator and subsytem and creating a TransporterHandler which
 
77
    * takes the specified target object.
 
78
    *
 
79
    * @param xmlConfig
 
80
    * @param target
 
81
    * @param subsystem
 
82
    * @throws Exception
 
83
    */
 
84
   public TransporterServer(Element xmlConfig, Object target, String subsystem) throws Exception
 
85
   {
 
86
      connector = getConnector(null, null, xmlConfig);
 
87
      ServerInvocationHandler handler = new TransporterHandler(target);
 
88
      if (subsystem != null)
 
89
      {
 
90
         connector.addInvocationHandler(subsystem.toUpperCase(), handler);
 
91
      }
 
92
      else
 
93
      {
 
94
         addInterfaceSubsystems(connector, handler, target);
 
95
      }
 
96
   }
 
97
 
 
98
   /**
 
99
    * Creates a remoting server using the provided locator and subsytem and creating a TransporterHandler which
 
100
    * takes the specified target object.
 
101
    *
 
102
    * @param locator
 
103
    * @param target
 
104
    * @param subsystem
 
105
    * @param config    - configuration data for Connector
 
106
    * @throws Exception
 
107
    */
 
108
   public TransporterServer(InvokerLocator locator, Object target, String subsystem, Map config) throws Exception
 
109
   {
 
110
      connector = getConnector(locator, config, null);
 
111
      ServerInvocationHandler handler = new TransporterHandler(target);
 
112
      if (subsystem != null)
 
113
      {
 
114
         connector.addInvocationHandler(subsystem.toUpperCase(), handler);
 
115
      }
 
116
      else
 
117
      {
 
118
         addInterfaceSubsystems(connector, handler, target);
 
119
      }
 
120
   }
 
121
 
 
122
   private void addInterfaceSubsystems(Connector connector, ServerInvocationHandler handler, Object target) throws Exception
 
123
   {
 
124
      Class targetClass = target.getClass();
 
125
 
 
126
      //first have to build list of interface names
 
127
      List interfaceNames = new ArrayList();
 
128
      populateInterfaceNames(interfaceNames, targetClass);
 
129
 
 
130
      for (int i = 0; i < interfaceNames.size(); i++)
 
131
      {
 
132
         String interfaceClassName = (String) interfaceNames.get(i);
 
133
         connector.addInvocationHandler(interfaceClassName.toUpperCase(), handler);
 
134
      }
 
135
   }
 
136
 
 
137
   private void populateInterfaceNames(List interfaceNames, Class targetClass)
 
138
   {
 
139
      Class[] interfaces = targetClass.getInterfaces();
 
140
      if (interfaces != null)
 
141
      {
 
142
         for (int x = 0; x < interfaces.length; x++)
 
143
         {
 
144
            interfaceNames.add(interfaces[x].getName());
 
145
            populateInterfaceNames(interfaceNames, interfaces[x]);
 
146
         }
 
147
      }
 
148
   }
 
149
 
 
150
   /**
 
151
    * Returns the connector that this transporter server will use.  Subclasses are free to override this method in order
 
152
    * to create a more customized connector.
 
153
    *
 
154
    * @param locator
 
155
    * @param config    configuration data for connector
 
156
    * @param xmlConfig configuration data for connector (in xml form)
 
157
    * @return the connector to be used by this transporter server
 
158
    * @throws Exception
 
159
    */
 
160
   protected Connector getConnector(InvokerLocator locator, Map config, Element xmlConfig)
 
161
         throws Exception
 
162
   {
 
163
      Connector c = new Connector(locator, config);
 
164
      if (xmlConfig != null)
 
165
      {
 
166
         c.setConfiguration(xmlConfig);
 
167
      }
 
168
      c.create();
 
169
 
 
170
      return c;
 
171
   }
 
172
 
 
173
   /**
 
174
    * Adds a transporter handler to receive remote invocations on the target object passed.
 
175
    *
 
176
    * @param target         the target implementation to call on
 
177
    * @param proxyclassname the fully qualified classname of the interface that clients will use to call on
 
178
    */
 
179
   public void addHandler(Object target, String proxyclassname) throws Exception
 
180
   {
 
181
      if (connector != null)
 
182
      {
 
183
         connector.addInvocationHandler(proxyclassname, new TransporterHandler(target));
 
184
      }
 
185
      else
 
186
      {
 
187
         throw new Exception("Can not add handler to transporter server as has not be initialized yet.");
 
188
      }
 
189
   }
 
190
 
 
191
   /**
 
192
    * Starts the remoting server.  This is called automatically upon any of the static createTransporterServer() methods.
 
193
    *
 
194
    * @throws Exception
 
195
    */
 
196
   public void start() throws Exception
 
197
   {
 
198
      connector.start();
 
199
   }
 
200
 
 
201
   /**
 
202
    * Stops the remoting server.  This must be called when no longer want to expose the target POJO for remote
 
203
    * method calls.
 
204
    */
 
205
   public void stop()
 
206
   {
 
207
      connector.stop();
 
208
   }
 
209
 
 
210
   /**
 
211
    * Creates a MBeanServer and MulticastDetector to start publishing detection messages so
 
212
    * other detectors will be aware this server is available.
 
213
    *
 
214
    * @throws Exception
 
215
    */
 
216
   private static void setupDetector() throws Exception
 
217
   {
 
218
      InternalTransporterServices services = InternalTransporterServices.getInstance();
 
219
 
 
220
      // if no one has setup our internal services yet, let's do it now
 
221
      if (!services.isSetup())
 
222
      {
 
223
         // we need an MBeanServer to store our network registry and multicast detector services
 
224
         MBeanServer server = createMBeanServer();
 
225
 
 
226
         // multicast detector will detect new network registries that come online
 
227
         MulticastDetector detector = new MulticastDetector();
 
228
         services.setup(server, detector, null, null, null, true, false);
 
229
         detector.start();
 
230
      }
 
231
      else if (services.getDetector() == null)
 
232
      {
 
233
         // the internal services singleton is already setup, make sure it has a detector because we need it
 
234
         MulticastDetector detector = new MulticastDetector();
 
235
         services.assignDetector(detector, null, true);
 
236
         detector.start();
 
237
      }
 
238
 
 
239
      return;
 
240
   }
 
241
 
 
242
   /**
 
243
    * Creates a remoting server based on given locator.  Will convert any remote invocation requests into
 
244
    * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started)
 
245
    * instance.
 
246
    *
 
247
    * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server
 
248
    * ready to receive requests.
 
249
    *
 
250
    * @param locator     - specifies what transport, host and port binding, etc. to use by the remoting server.
 
251
    * @param target      - the target POJO to receive the method call upon getting remote invocation requests.
 
252
    * @param subsystem   - the name under which to register the handler within the remoting server.  <b>This must be
 
253
    *                    the fully qualified name of the interface for clients to use a the remote proxy to the target POJO.  Otherwise,
 
254
    *                    clustering will not work, as this is the value used to identifiy remote POJOs on the client side.</b>  If not clustered,
 
255
    *                    this is not as critical, and simply use the fully qualified class name of the POJO if desired.
 
256
    * @param isClustered - true indicates that would like this server to be considered available for
 
257
    *                    failover from clients calling on the same interface as exposed by the subsystem value.  False will only allow
 
258
    *                    those client that explicitly targeting this server to make calls on it.
 
259
    * @return TransporterServer.  Note, it will already be started upon return.
 
260
    * @throws Exception
 
261
    */
 
262
   public static TransporterServer createTransporterServer(InvokerLocator locator, Object target,
 
263
                                                           String subsystem, boolean isClustered) throws Exception
 
264
   {
 
265
      return createTransporterServer(locator, target, subsystem, null, isClustered);
 
266
   }
 
267
 
 
268
   /**
 
269
    * Creates a remoting server based on given locator.  Will convert any remote invocation requests into
 
270
    * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started)
 
271
    * instance.
 
272
    *
 
273
    * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server
 
274
    * ready to receive requests.
 
275
    *
 
276
    * @param locator     - specifies what transport, host and port binding, etc. to use by the remoting server.
 
277
    * @param target      - the target POJO to receive the method call upon getting remote invocation requests.
 
278
    * @param subsystem   - the name under which to register the handler within the remoting server.  <b>This must be
 
279
    *                    the fully qualified name of the interface for clients to use a the remote proxy to the target POJO.  Otherwise,
 
280
    *                    clustering will not work, as this is the value used to identifiy remote POJOs on the client side.</b>  If not clustered,
 
281
    *                    this is not as critical, and simply use the fully qualified class name of the POJO if desired.
 
282
    * @param config      - the configuration to be used in setting up the Connector.
 
283
    * @param isClustered - true indicates that would like this server to be considered available for
 
284
    *                    failover from clients calling on the same interface as exposed by the subsystem value.  False will only allow
 
285
    *                    those client that explicitly targeting this server to make calls on it.
 
286
    * @return TransporterServer.  Note, it will already be started upon return.
 
287
    * @throws Exception
 
288
    */
 
289
   public static TransporterServer createTransporterServer(InvokerLocator locator, Object target,
 
290
                                                           String subsystem, Map config, boolean isClustered) throws Exception
 
291
   {
 
292
      if (isClustered && (InternalTransporterServices.getInstance().getDetector() == null))
 
293
      {
 
294
         setupDetector();
 
295
      }
 
296
 
 
297
      TransporterServer server = new TransporterServer(locator, target, subsystem, config);
 
298
      server.start();
 
299
      return server;
 
300
   }
 
301
 
 
302
   /**
 
303
    * Creates a remoting server based on given locator.  Will convert any remote invocation requests into
 
304
    * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started)
 
305
    * instance.
 
306
    *
 
307
    * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server
 
308
    * ready to receive requests.
 
309
    *
 
310
    * @param locatorURI  - specifies what transport, host and port binding, etc. to use by the remoting server.
 
311
    * @param target      - the target POJO to receive the method call upon getting remote invocation requests.
 
312
    * @param subsystem   - the name under which to register the handler within the remoting server.  <b>This must be
 
313
    *                    the fully qualified name of the interface for clients to use a the remote proxy to the target POJO.  Otherwise,
 
314
    *                    clustering will not work, as this is the value used to identifiy remote POJOs on the client side.</b>  If not clustered,
 
315
    *                    this is not as critical, and simply use the fully qualified class name of the POJO if desired.
 
316
    * @param isClustered - true indicates that would like this server to be considered available for
 
317
    *                    failover from clients calling on the same interface as exposed by the subsystem value.  False will only allow
 
318
    *                    those client that explicitly targeting this server to make calls on it.
 
319
    * @return TransporterServer.  Note, it will already be started upon return.
 
320
    * @throws Exception
 
321
    */
 
322
   public static TransporterServer createTransporterServer(String locatorURI, Object target,
 
323
                                                           String subsystem, boolean isClustered) throws Exception
 
324
   {
 
325
      return createTransporterServer(new InvokerLocator(locatorURI), target, subsystem, null, isClustered);
 
326
   }
 
327
 
 
328
   /**
 
329
    * Creates a remoting server based on given locator.  Will convert any remote invocation requests into
 
330
    * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started)
 
331
    * instance.
 
332
    *
 
333
    * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server
 
334
    * ready to receive requests.
 
335
    *
 
336
    * @param locatorURI  - specifies what transport, host and port binding, etc. to use by the remoting server.
 
337
    * @param target      - the target POJO to receive the method call upon getting remote invocation requests.
 
338
    * @param subsystem   - the name under which to register the handler within the remoting server.  <b>This must be
 
339
    *                    the fully qualified name of the interface for clients to use a the remote proxy to the target POJO.  Otherwise,
 
340
    *                    clustering will not work, as this is the value used to identifiy remote POJOs on the client side.</b>  If not clustered,
 
341
    *                    this is not as critical, and simply use the fully qualified class name of the POJO if desired.
 
342
    * @param config      - the configuration data for the Connector.
 
343
    * @param isClustered - true indicates that would like this server to be considered available for
 
344
    *                    failover from clients calling on the same interface as exposed by the subsystem value.  False will only allow
 
345
    *                    those client that explicitly targeting this server to make calls on it.
 
346
    * @return TransporterServer.  Note, it will already be started upon return.
 
347
    * @throws Exception
 
348
    */
 
349
   public static TransporterServer createTransporterServer(String locatorURI, Object target,
 
350
                                                           String subsystem, Map config, boolean isClustered) throws Exception
 
351
   {
 
352
      return createTransporterServer(new InvokerLocator(locatorURI), target, subsystem, config, isClustered);
 
353
   }
 
354
 
 
355
   /**
 
356
    * Creates a remoting server based on given locator.  Will convert any remote invocation requests into
 
357
    * method calls on the given target object.  Note: the TransporterServer instance returned will be a live (started)
 
358
    * instance.
 
359
    *
 
360
    * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server
 
361
    * ready to receive requests.
 
362
    *
 
363
    * @param xmlconfig   - specifies config for Connector
 
364
    * @param target      - the target POJO to receive the method call upon getting remote invocation requests.
 
365
    * @param subsystem   - the name under which to register the handler within the remoting server.  <b>This must be
 
366
    *                    the fully qualified name of the interface for clients to use a the remote proxy to the target POJO.  Otherwise,
 
367
    *                    clustering will not work, as this is the value used to identifiy remote POJOs on the client side.</b>  If not clustered,
 
368
    *                    this is not as critical, and simply use the fully qualified class name of the POJO if desired.
 
369
    * @param isClustered - true indicates that would like this server to be considered available for
 
370
    *                    failover from clients calling on the same interface as exposed by the subsystem value.  False will only allow
 
371
    *                    those client that explicitly targeting this server to make calls on it.
 
372
    * @return TransporterServer.  Note, it will already be started upon return.
 
373
    * @throws Exception
 
374
    */
 
375
   public static TransporterServer createTransporterServer(Element xmlconfig, Object target,
 
376
                                                           String subsystem, boolean isClustered) throws Exception
 
377
   {
 
378
      if (isClustered && (InternalTransporterServices.getInstance().getDetector() == null))
 
379
      {
 
380
         setupDetector();
 
381
      }
 
382
 
 
383
      TransporterServer server = new TransporterServer(xmlconfig, target, subsystem);
 
384
      server.start();
 
385
      return server;
 
386
   }
 
387
 
 
388
   /**
 
389
    * Creates a remoting server based on given locator.  Will convert any remote invocation requests into
 
390
    * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started)
 
391
    * instance.
 
392
    *
 
393
    * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server
 
394
    * ready to receive requests.
 
395
    *
 
396
    * @param locator   - specifies what transport, host and port binding, etc. to use by the remoting server.
 
397
    * @param target    - the target POJO to receive the method call upon getting remote invocation requests.
 
398
    * @param subsystem - the name under which to register the handler within the remoting server.  Can
 
399
    *                  simply use the fully qualified class name of the POJO if desired.
 
400
    * @return TransporterServer.  Note, it will already be started upon return.
 
401
    * @throws Exception
 
402
    */
 
403
   public static TransporterServer createTransporterServer(InvokerLocator locator, Object target, String subsystem) throws Exception
 
404
   {
 
405
      return createTransporterServer(locator, target, subsystem, false);
 
406
   }
 
407
 
 
408
   /**
 
409
    * Creates a remoting server based on given locator.  Will convert any remote invocation requests into
 
410
    * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started)
 
411
    * instance.
 
412
    *
 
413
    * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server
 
414
    * ready to receive requests.
 
415
    *
 
416
    * @param locator - specifies what transport, host and port binding, etc. to use by the remoting server.
 
417
    * @param target  - the target POJO to receive the method call upon getting remote invocation requests.
 
418
    * @return TransporterServer.  Note, it will already be started upon return.
 
419
    * @throws Exception
 
420
    */
 
421
   public static TransporterServer createTransporterServer(InvokerLocator locator, Object target) throws Exception
 
422
   {
 
423
      return createTransporterServer(locator, target, false);
 
424
   }
 
425
 
 
426
   /**
 
427
    * Creates a remoting server based on given locator.  Will convert any remote invocation requests into
 
428
    * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started)
 
429
    * instance.
 
430
    *
 
431
    * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server
 
432
    * ready to receive requests.
 
433
    *
 
434
    * @param locator     - specifies what transport, host and port binding, etc. to use by the remoting server.
 
435
    * @param target      - the target POJO to receive the method call upon getting remote invocation requests.
 
436
    * @param isClustered - indicates if want automatic failover on calls to remote servers.
 
437
    * @return TransporterServer.  Note, it will already be started upon return.
 
438
    * @throws Exception
 
439
    */
 
440
   public static TransporterServer createTransporterServer(InvokerLocator locator, Object target, boolean isClustered) throws Exception
 
441
   {
 
442
      if (isClustered && (InternalTransporterServices.getInstance().getDetector() == null))
 
443
      {
 
444
         setupDetector();
 
445
      }
 
446
 
 
447
      TransporterServer server = new TransporterServer(locator, target, null, null);
 
448
      server.start();
 
449
      return server;
 
450
 
 
451
   }
 
452
 
 
453
   /**
 
454
    * Creates a remoting server based on given locator.  Will convert any remote invocation requests into
 
455
    * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started)
 
456
    * instance.
 
457
    *
 
458
    * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server
 
459
    * ready to receive requests.
 
460
    *
 
461
    * @param locator - specifies what transport, host and port binding, etc. to use by the remoting server.
 
462
    * @param target  - the target POJO to receive the method call upon getting remote invocation requests.
 
463
    * @return TransporterServer.  Note, it will already be started upon return.
 
464
    * @throws Exception
 
465
    */
 
466
   public static TransporterServer createTransporterServer(String locator, Object target) throws Exception
 
467
   {
 
468
      return createTransporterServer(new InvokerLocator(locator), target, false);
 
469
   }
 
470
 
 
471
   /**
 
472
    * Creates a remoting server based on given locator.  Will convert any remote invocation requests into
 
473
    * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started)
 
474
    * instance.
 
475
    *
 
476
    * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server
 
477
    * ready to receive requests.
 
478
    *
 
479
    * @param locator     - specifies what transport, host and port binding, etc. to use by the remoting server.
 
480
    * @param target      - the target POJO to receive the method call upon getting remote invocation requests.
 
481
    * @param isClustered - indicates if want automatic failover on calls to remote servers.
 
482
    * @return TransporterServer.  Note, it will already be started upon return.
 
483
    * @throws Exception
 
484
    */
 
485
   public static TransporterServer createTransporterServer(String locator, Object target, boolean isClustered) throws Exception
 
486
   {
 
487
      return createTransporterServer(new InvokerLocator(locator), target, isClustered);
 
488
   }
 
489
 
 
490
   /**
 
491
    * Creates a remoting server based on given locator.  Will convert any remote invocation requests into
 
492
    * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started)
 
493
    * instance.
 
494
    *
 
495
    * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server
 
496
    * ready to receive requests.
 
497
    *
 
498
    * @param locatorURI - specifies what transport, host and port binding, etc. to use by the remoting server.
 
499
    * @param target     - the target POJO to receive the method call upon getting remote invocation requests.
 
500
    * @param subsystem  - the name under which to register the handler within the remoting server.  Can
 
501
    *                   simply use the fully qualified class name of the POJO if desired.
 
502
    * @return TransporterServer.  Note, it will already be started upon return.
 
503
    * @throws Exception
 
504
    */
 
505
   public static TransporterServer createTransporterServer(String locatorURI, Object target, String subsystem) throws Exception
 
506
   {
 
507
      return createTransporterServer(new InvokerLocator(locatorURI), target, subsystem, false);
 
508
   }
 
509
 
 
510
   static private MBeanServer createMBeanServer() throws Exception
 
511
   {
 
512
      if (SecurityUtility.skipAccessControl())
 
513
      {
 
514
         return MBeanServerFactory.createMBeanServer();
 
515
      }
 
516
      
 
517
      try
 
518
      {
 
519
         return (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction()
 
520
         {
 
521
            public Object run() throws Exception
 
522
            {
 
523
               return MBeanServerFactory.createMBeanServer();
 
524
            }
 
525
         });
 
526
      }
 
527
      catch (PrivilegedActionException e)
 
528
      {
 
529
         throw (Exception) e.getCause();
 
530
      }   
 
531
   }
 
532
}
 
 
b'\\ No newline at end of file'