[jboss-cvs] JBossAS SVN: r72446 - trunk/system-jmx/src/main/org/jboss/system.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Apr 18 10:43:08 EDT 2008


Author: adrian at jboss.org
Date: 2008-04-18 10:43:08 -0400 (Fri, 18 Apr 2008)
New Revision: 72446

Added:
   trunk/system-jmx/src/main/org/jboss/system/SecurityActions.java
Log:
Missed commit

Added: trunk/system-jmx/src/main/org/jboss/system/SecurityActions.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/SecurityActions.java	                        (rev 0)
+++ trunk/system-jmx/src/main/org/jboss/system/SecurityActions.java	2008-04-18 14:43:08 UTC (rev 72446)
@@ -0,0 +1,81 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.system;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * SecurityActions.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+class SecurityActions
+{
+   
+   private static ClassLoader setContextClassLoaderInternal(final ClassLoader classLoader)
+   {
+      ClassLoader result = Thread.currentThread().getContextClassLoader();
+      if (classLoader != null)
+         Thread.currentThread().setContextClassLoader(classLoader);
+      return result;
+   }
+   
+   static ClassLoader setContextClassLoader(final ClassLoader classLoader)
+   {
+      if (System.getSecurityManager() == null)
+      {
+         return setContextClassLoaderInternal(classLoader);
+      }
+      else
+      {
+         return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+         {
+             public ClassLoader run()
+             {
+                return setContextClassLoaderInternal(classLoader);
+             }
+         });
+      }
+   }
+
+   static void resetContextClassLoader(final ClassLoader classLoader)
+   {
+      if (System.getSecurityManager() == null)
+      {
+         Thread.currentThread().setContextClassLoader(classLoader);
+      }
+      else
+      {
+         AccessController.doPrivileged(new PrivilegedAction<Object>()
+         {
+             public Object run()
+             {
+                Thread.currentThread().setContextClassLoader(classLoader);
+                return null;
+             }
+         });
+      }
+   }
+
+}




More information about the jboss-cvs-commits mailing list