[jboss-remoting-commits] JBoss Remoting SVN: r3828 - remoting2/branches/2.x/src/main/org/jboss/remoting/detection.

jboss-remoting-commits at lists.jboss.org jboss-remoting-commits at lists.jboss.org
Tue Apr 1 23:36:08 EDT 2008


Author: ron.sigal at jboss.com
Date: 2008-04-01 23:36:08 -0400 (Tue, 01 Apr 2008)
New Revision: 3828

Modified:
   remoting2/branches/2.x/src/main/org/jboss/remoting/detection/AbstractDetector.java
Log:
JBREM-934: Put MBeanServer, MBean proxy, and Class.getClassLoader() calls in AccessController.doPrivileged() calls.

Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/detection/AbstractDetector.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/detection/AbstractDetector.java	2008-04-02 03:33:04 UTC (rev 3827)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/detection/AbstractDetector.java	2008-04-02 03:36:08 UTC (rev 3828)
@@ -208,7 +208,13 @@
       }
       else
       {
-         networkRegistry = (NetworkRegistryMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanserver, registryObjectName, NetworkRegistryMBean.class, false);
+         networkRegistry = (NetworkRegistryMBean)AccessController.doPrivileged( new PrivilegedAction()
+         {
+            public Object run()
+            {
+                return MBeanServerInvocationHandler.newProxyInstance(mbeanserver, registryObjectName, NetworkRegistryMBean.class, false);
+            }
+         });
       }
 
       startPinger(getPingerDelay(), getPingerPeriod());
@@ -449,7 +455,7 @@
     *
     * @param detection
     */
-   protected void detect(Detection detection)
+   protected void detect(final Detection detection)
    {
       if (detection != null)
       {
@@ -486,7 +492,15 @@
                   if (networkRegistry != null)
                   {
                      log.debug("detected NEW server: " + detection);
-                     networkRegistry.addServer(detection.getIdentity(), detection.getServerInvokers());
+                 
+                     AccessController.doPrivileged( new PrivilegedAction()
+                     {
+                        public Object run()
+                        {
+                           networkRegistry.addServer(detection.getIdentity(), detection.getServerInvokers());
+                           return null;
+                        }
+                     });
                   }
                }
                else
@@ -501,7 +515,15 @@
                         {
                            log.trace("detected UPDATE for server: " + detection);
                         }
-                        networkRegistry.updateServer(detection.getIdentity(), detection.getServerInvokers());
+                        
+                        AccessController.doPrivileged( new PrivilegedAction()
+                        {
+                           public Object run()
+                           {
+                              networkRegistry.updateServer(detection.getIdentity(), detection.getServerInvokers());
+                              return null;
+                           }
+                        });
                      }
                   }
                }
@@ -536,7 +558,7 @@
              (acceptLocal ? true : (myself.isSameJVM(detection.getIdentity()) == false));
    }
 
-   protected boolean checkInvokerServer(Detection detection, ClassLoader cl)
+   protected boolean checkInvokerServer(final Detection detection, ClassLoader cl)
    {
       boolean ok = false;
       ServerInvokerMetadata[] invokerMetadataArray = detection.getServerInvokers();
@@ -581,8 +603,16 @@
          try
          {
             if(networkRegistry != null)
-            {
-               networkRegistry.removeServer(detection.getIdentity());
+            {  
+               AccessController.doPrivileged( new PrivilegedAction()
+               {
+                  public Object run()
+                  {
+                     networkRegistry.removeServer(detection.getIdentity());
+                     return null;
+                  }
+               });
+               
                log.debug("Removed detection " + detection);
             }
          }
@@ -635,7 +665,13 @@
             {
                return;
             }
-            ClassLoader cl = AbstractDetector.this.getClass().getClassLoader();
+            ClassLoader cl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction()
+            {
+               public Object run()
+               {
+                  return AbstractDetector.class.getClassLoader();
+               }
+            });
             // walk through each detection and see if it needs checking up on ...
             Collection serverCollection = servers.values();
             Server[] serverArray = (Server[])serverCollection.toArray(new Server[serverCollection.size()]);




More information about the jboss-remoting-commits mailing list