Author: ron.sigal(a)jboss.com
Date: 2008-04-01 23:44:36 -0400 (Tue, 01 Apr 2008)
New Revision: 3831
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/detection/util/DetectorUtil.java
Log:
JBREM-934: Put MBeanServerFactory.createMBeanServer() and MBeanServer.registerMBean()
calls in AccessController.doPrivileged() calls.
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/detection/util/DetectorUtil.java
===================================================================
---
remoting2/branches/2.x/src/main/org/jboss/remoting/detection/util/DetectorUtil.java 2008-04-02
03:41:43 UTC (rev 3830)
+++
remoting2/branches/2.x/src/main/org/jboss/remoting/detection/util/DetectorUtil.java 2008-04-02
03:44:36 UTC (rev 3831)
@@ -21,6 +21,10 @@
*/
package org.jboss.remoting.detection.util;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
@@ -101,10 +105,40 @@
System.setProperty("jboss.identity",
String.valueOf(System.currentTimeMillis()));
- MBeanServer server = MBeanServerFactory.createMBeanServer();
+ MBeanServer server = null;
+ try
+ {
+ server = (MBeanServer) AccessController.doPrivileged( new
PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return MBeanServerFactory.createMBeanServer();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
- NetworkRegistry registry = NetworkRegistry.getInstance();
- server.registerMBean(registry, new
ObjectName("remoting:type=NetworkRegistry"));
+ final MBeanServer finalServer = server;
+ final NetworkRegistry registry = NetworkRegistry.getInstance();
+
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ finalServer.registerMBean(registry, new
ObjectName("remoting:type=NetworkRegistry"));
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
InvokerLocator locator = new InvokerLocator("socket://localhost");
//ClassLoader clsLoader = Thread.currentThread().getContextClassLoader();
@@ -113,10 +147,26 @@
//server.registerMBean(invokerSvr, objName);
//invokerSvr.start();
- Connector connector = new Connector();
+ final Connector connector = new Connector();
connector.setInvokerLocator(locator.getLocatorURI());
- ObjectName obj = new
ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol());
- server.registerMBean(connector, obj);
+ final ObjectName obj = new
ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol());
+
+ try
+ {
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ finalServer.registerMBean(connector, obj);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+
//connector.create();
connector.start();
@@ -140,8 +190,26 @@
detector = jdet;
objName = new ObjectName("remoting:type=Detector,transport=jndi");
}
-
- server.registerMBean(detector, objName);
+
+ try
+ {
+ final Detector finalDetector = detector;
+ final ObjectName finalObjName = objName;
+
+ AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ finalServer.registerMBean(finalDetector, finalObjName);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (Exception) e.getCause();
+ }
+
detector.start();
System.err.println("Starting Detector");
Show replies by date