[jboss-cvs] JBossAS SVN: r104213 - in projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal: impl/remote and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Apr 24 10:35:00 EDT 2010
Author: jesper.pedersen
Date: 2010-04-24 10:35:00 -0400 (Sat, 24 Apr 2010)
New Revision: 104213
Modified:
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/SecurityActions.java
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/SecurityActions.java
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/SecurityActions.java
Log:
Speedup SecurityActions if there isn't a security manager
Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/SecurityActions.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/SecurityActions.java 2010-04-24 13:42:39 UTC (rev 104212)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/SecurityActions.java 2010-04-24 14:35:00 UTC (rev 104213)
@@ -24,7 +24,6 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.util.Properties;
/**
* Privileged Blocks
@@ -45,6 +44,9 @@
*/
static ClassLoader getThreadContextClassLoader()
{
+ if (System.getSecurityManager() == null)
+ return Thread.currentThread().getContextClassLoader();
+
return (ClassLoader)AccessController.doPrivileged(new PrivilegedAction<Object>()
{
public Object run()
@@ -60,29 +62,21 @@
*/
static void setThreadContextClassLoader(final ClassLoader cl)
{
- AccessController.doPrivileged(new PrivilegedAction<Object>()
+ if (System.getSecurityManager() == null)
{
- public Object run()
- {
- Thread.currentThread().setContextClassLoader(cl);
- return null;
- }
- });
- }
-
- /**
- * Get the system properties
- * @return The properties
- */
- static Properties getSystemProperties()
- {
- return (Properties)AccessController.doPrivileged(new PrivilegedAction<Object>()
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ else
{
- public Object run()
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
{
- return System.getProperties();
- }
- });
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ return null;
+ }
+ });
+ }
}
/**
@@ -92,13 +86,20 @@
*/
static String getSystemProperty(final String name)
{
- return (String)AccessController.doPrivileged(new PrivilegedAction<Object>()
+ if (System.getSecurityManager() == null)
{
- public Object run()
+ return System.getProperty(name);
+ }
+ else
+ {
+ return (String)AccessController.doPrivileged(new PrivilegedAction<Object>()
{
- return System.getProperty(name);
- }
- });
+ public Object run()
+ {
+ return System.getProperty(name);
+ }
+ });
+ }
}
/**
@@ -108,13 +109,20 @@
*/
static void setSystemProperty(final String name, final String value)
{
- AccessController.doPrivileged(new PrivilegedAction<Object>()
+ if (System.getSecurityManager() == null)
{
- public Object run()
+ System.setProperty(name, value);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
{
- System.setProperty(name, value);
- return null;
- }
- });
+ public Object run()
+ {
+ System.setProperty(name, value);
+ return null;
+ }
+ });
+ }
}
}
Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/SecurityActions.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/SecurityActions.java 2010-04-24 13:42:39 UTC (rev 104212)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/SecurityActions.java 2010-04-24 14:35:00 UTC (rev 104213)
@@ -44,6 +44,9 @@
*/
static ClassLoader getThreadContextClassLoader()
{
+ if (System.getSecurityManager() == null)
+ return Thread.currentThread().getContextClassLoader();
+
return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
{
public ClassLoader run()
Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/SecurityActions.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/SecurityActions.java 2010-04-24 13:42:39 UTC (rev 104212)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/SecurityActions.java 2010-04-24 14:35:00 UTC (rev 104213)
@@ -22,11 +22,8 @@
package org.jboss.jca.fungal.util;
-import java.net.URL;
-import java.net.URLClassLoader;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.util.Properties;
/**
* Privileged Blocks
@@ -42,98 +39,25 @@
}
/**
- * Get the thread context class loader
- * @return The class loader
- */
- static ClassLoader getThreadContextClassLoader()
- {
- return (ClassLoader)AccessController.doPrivileged(new PrivilegedAction<Object>()
- {
- public Object run()
- {
- return Thread.currentThread().getContextClassLoader();
- }
- });
- }
-
- /**
- * Set the thread context class loader
- * @param cl The class loader
- */
- static void setThreadContextClassLoader(final ClassLoader cl)
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>()
- {
- public Object run()
- {
- Thread.currentThread().setContextClassLoader(cl);
- return null;
- }
- });
- }
-
- /**
- * Get the system properties
- * @return The properties
- */
- static Properties getSystemProperties()
- {
- return (Properties)AccessController.doPrivileged(new PrivilegedAction<Object>()
- {
- public Object run()
- {
- return System.getProperties();
- }
- });
- }
-
- /**
* Get a system property
* @param name The property name
* @return The property value
*/
static String getSystemProperty(final String name)
{
- return (String)AccessController.doPrivileged(new PrivilegedAction<Object>()
+ if (System.getSecurityManager() == null)
{
- public Object run()
- {
- return System.getProperty(name);
- }
- });
- }
-
- /**
- * Set a system property
- * @param name The property name
- * @param value The property value
- */
- static void setSystemProperty(final String name, final String value)
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>()
+ return System.getProperty(name);
+ }
+ else
{
- public Object run()
+ return (String)AccessController.doPrivileged(new PrivilegedAction<Object>()
{
- System.setProperty(name, value);
- return null;
- }
- });
+ public Object run()
+ {
+ return System.getProperty(name);
+ }
+ });
+ }
}
-
- /**
- * Create an URLClassLoader
- * @param urls The urls
- * @param parent The parent class loader
- * @return The class loader
- */
- static URLClassLoader createURLCLassLoader(final URL[] urls, final ClassLoader parent)
- {
- return (URLClassLoader)AccessController.doPrivileged(new PrivilegedAction<Object>()
- {
- public Object run()
- {
- return new URLClassLoader(urls, parent);
- }
- });
- }
}
More information about the jboss-cvs-commits
mailing list