cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1401235 - in /cxf/trunk: api/src/main/java/org/apache/cxf/common/classloader/ integration/jca/src/main/java/org/apache/cxf/jca/core/classloader/ maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ maven-plugins/corba/sr...
Date Tue, 23 Oct 2012 10:09:31 GMT
Author: coheigea
Date: Tue Oct 23 10:09:31 2012
New Revision: 1401235

URL: http://svn.apache.org/viewvc?rev=1401235&view=rev
Log:
Wrapping new ClassLoader instantiation in AccessController.doPrivileged

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
    cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/core/classloader/PlugInClassLoader.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
    cxf/trunk/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/WSDLToIDLPlugin.java
    cxf/trunk/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
    cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/AnnotationUtil.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java?rev=1401235&r1=1401234&r2=1401235&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java Tue
Oct 23 10:09:31 2012
@@ -22,6 +22,7 @@ package org.apache.cxf.common.classloade
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.net.URLClassLoader;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ArrayList;
@@ -59,6 +60,21 @@ public final class ClassLoaderUtils {
         });
     }
     
+    public static ClassLoader getURLClassLoader(
+        final URL[] urls, final ClassLoader parent
+    ) {
+        return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+            public ClassLoader run() {
+                return new URLClassLoader(urls, parent);
+            }
+        });
+    }
+
+    public static ClassLoader getURLClassLoader(
+        final List<URL> urlList, final ClassLoader parent
+    ) {
+        return getURLClassLoader(urlList.toArray(new URL[urlList.size()]), parent);
+    }
     
     /**
      * Load a given resource. <p/> This method will try to load the resource

Modified: cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/core/classloader/PlugInClassLoader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/core/classloader/PlugInClassLoader.java?rev=1401235&r1=1401234&r2=1401235&view=diff
==============================================================================
--- cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/core/classloader/PlugInClassLoader.java
(original)
+++ cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/core/classloader/PlugInClassLoader.java
Tue Oct 23 10:09:31 2012
@@ -47,9 +47,9 @@ public class PlugInClassLoader extends S
     private String jarUrls[] = new String[0];
     private final ProtectionDomain protectionDomain;
     
-    private ClassLoader ploader;
+    private final ClassLoader ploader;
 
-    public PlugInClassLoader(ClassLoader p) throws IOException {        
+    public PlugInClassLoader(final ClassLoader p) throws IOException {        
         super(new FireWallClassLoader(p, 
                                       getFilterList(p, FILTERS_PROPS_FILE),
                                       getFilterList(p, NEFILTERS_PROPS_FILE)));

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java?rev=1401235&r1=1401234&r2=1401235&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
Tue Oct 23 10:09:31 2012
@@ -23,7 +23,6 @@ import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
-import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
@@ -31,6 +30,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.logging.Log;
@@ -99,8 +99,7 @@ public class ClassLoaderSwitcher {
         }
 
         origContextClassloader = Thread.currentThread().getContextClassLoader();
-        URLClassLoader loader = new URLClassLoader(urlList.toArray(new URL[urlList.size()]),
-                                                   origContextClassloader);
+        ClassLoader loader = ClassLoaderUtils.getURLClassLoader(urlList, origContextClassloader);
         String newCp = buf.toString();
 
         log.debug("Classpath: " + urlList.toString());

Modified: cxf/trunk/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/WSDLToIDLPlugin.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/WSDLToIDLPlugin.java?rev=1401235&r1=1401234&r2=1401235&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/WSDLToIDLPlugin.java
(original)
+++ cxf/trunk/maven-plugins/corba/src/main/java/org/apache/cxf/maven_plugin/corba/maven/plugins/WSDLToIDLPlugin.java
Tue Oct 23 10:09:31 2012
@@ -21,7 +21,6 @@ package org.apache.cxf.maven_plugin.corb
 import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -29,6 +28,7 @@ import java.util.Map;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.tools.corba.WSDLToIDL;
 
@@ -107,8 +107,7 @@ public class WSDLToIDLPlugin extends Abs
         }
         
         ClassLoader origContext = Thread.currentThread().getContextClassLoader();
-        URLClassLoader loader = new URLClassLoader(urlList.toArray(new URL[urlList.size()]),
-                                                   origContext);
+        ClassLoader loader = ClassLoaderUtils.getURLClassLoader(urlList, origContext);
         String newCp = buf.toString();
 
         //with some VM's, creating an XML parser (which we will do to parse wsdls)

Modified: cxf/trunk/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java?rev=1401235&r1=1401234&r2=1401235&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
(original)
+++ cxf/trunk/maven-plugins/java2ws-plugin/src/main/java/org/apache/cxf/maven_plugin/ClassLoaderSwitcher.java
Tue Oct 23 10:09:31 2012
@@ -22,12 +22,12 @@ package org.apache.cxf.maven_plugin;
 import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.logging.Log;
@@ -92,8 +92,7 @@ public class ClassLoaderSwitcher {
         }
 
         origContextClassloader = Thread.currentThread().getContextClassLoader();
-        URLClassLoader loader = new URLClassLoader(urlList.toArray(new URL[urlList.size()]),
-                                                   origContextClassloader);
+        ClassLoader loader = ClassLoaderUtils.getURLClassLoader(urlList, origContextClassloader);
         String newCp = buf.toString();
 
         log.debug("Classpath: " + urlList.toString());

Modified: cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java?rev=1401235&r1=1401234&r2=1401235&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java
(original)
+++ cxf/trunk/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java
Tue Oct 23 10:09:31 2012
@@ -23,7 +23,6 @@ import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
-import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
@@ -31,6 +30,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.logging.Log;
@@ -101,8 +101,7 @@ public class ClassLoaderSwitcher {
         }
 
         origContextClassloader = Thread.currentThread().getContextClassLoader();
-        URLClassLoader loader = new URLClassLoader(urlList.toArray(new URL[urlList.size()]),
-                                                   origContextClassloader);
+        ClassLoader loader = ClassLoaderUtils.getURLClassLoader(urlList, origContextClassloader);
         String newCp = buf.toString();
 
         log.debug("Classpath: " + urlList.toString());

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java?rev=1401235&r1=1401234&r2=1401235&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/blueprint/BlueprintBus.java Tue Oct
23 10:09:31 2012
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.bus.blueprint;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 import org.apache.cxf.bus.extension.ExtensionManagerBus;
 import org.apache.cxf.configuration.ConfiguredBeanLocator;
@@ -58,11 +60,16 @@ public class BlueprintBus extends Extens
         }
     }
     
-    public void setBundleContext(BundleContext c) {
+    public void setBundleContext(final BundleContext c) {
         context = c;
-        super.setExtension(new BundleDelegatingClassLoader(c.getBundle(), 
-                                                           this.getClass().getClassLoader()),
-                           ClassLoader.class);
+        ClassLoader bundleClassLoader =
+            AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+                public ClassLoader run() {
+                    return new BundleDelegatingClassLoader(c.getBundle(), 
+                                                           this.getClass().getClassLoader());
+                }
+            });
+        super.setExtension(bundleClassLoader, ClassLoader.class);
         super.setExtension(c, BundleContext.class);
     }
     public void setBlueprintContainer(BlueprintContainer con) {

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java?rev=1401235&r1=1401234&r2=1401235&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
(original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
Tue Oct 23 10:09:31 2012
@@ -368,13 +368,14 @@ public class DynamicClientFactory {
             LOG.log(Level.SEVERE , new Message("COULD_NOT_COMPILE_SRC", LOG, wsdlUrl).toString());
         }
         FileUtils.removeDir(src);
-        URLClassLoader cl;
+        URL[] urls = null;
         try {
-            cl = new URLClassLoader(new URL[] {classes.toURI().toURL()}, classLoader);
+            urls = new URL[] {classes.toURI().toURL()};
         } catch (MalformedURLException mue) {
             throw new IllegalStateException("Internal error; a directory returns a malformed
URL: "
                                             + mue.getMessage(), mue);
         }
+        ClassLoader cl = ClassLoaderUtils.getURLClassLoader(urls, classLoader);
 
         JAXBContext context;
         Map<String, Object> contextProperties = jaxbContextProperties;

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java?rev=1401235&r1=1401234&r2=1401235&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
Tue Oct 23 10:09:31 2012
@@ -641,7 +641,7 @@ public class JettyHTTPServerEngine
                 // Regardless the port has to equal the one
                 // we are configured for.
                 assert porto == port;
-                assert hosto == host;
+                assert hosto == null ? host == null : hosto.equals(host);
                 if (hosto != null) {
                     result.setHost(hosto);
                 }

Modified: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/AnnotationUtil.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/AnnotationUtil.java?rev=1401235&r1=1401234&r2=1401235&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/AnnotationUtil.java (original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/AnnotationUtil.java Tue
Oct 23 10:09:31 2012
@@ -31,6 +31,7 @@ import java.util.logging.Logger;
 import javax.jws.WebParam;
 import javax.jws.WebResult;
 
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.URIParserUtil;
@@ -70,11 +71,11 @@ public final class AnnotationUtil {
 
     public static synchronized URLClassLoader getClassLoader(ClassLoader parent) {
         URL[] urls = URIParserUtil.pathToURLs(getClassPath());
-        return new URLClassLoader(urls, parent);
+        return (URLClassLoader)ClassLoaderUtils.getURLClassLoader(urls, parent);
     }
 
     private static ClassLoader newLoader(URL[] urls, ClassLoader parent) {
-        return new URLClassLoader(urls, parent);
+        return ClassLoaderUtils.getURLClassLoader(urls, parent);
     }
     public static synchronized Class<?> loadClass(String className, ClassLoader parent)
{
         Class<?> clazz = null;



Mime
View raw message