camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/5] camel git commit: DefaultClassLoader - Should use applicationContextClassLoader from CamelContext as fallback
Date Tue, 13 Jan 2015 07:00:24 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.14.x 3e48a43c9 -> a21701cfd
  refs/heads/master 8a28aa443 -> 0d827ee76


DefaultClassLoader - Should use applicationContextClassLoader from CamelContext as fallback


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/02148efd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/02148efd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/02148efd

Branch: refs/heads/master
Commit: 02148efd2887681a509ba06bd21dc13177e1ef2b
Parents: 8a28aa4
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Jan 12 19:10:55 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Jan 12 19:29:08 2015 +0100

----------------------------------------------------------------------
 .../apache/camel/impl/DefaultCamelContext.java  |  2 +-
 .../apache/camel/impl/DefaultClassResolver.java | 22 +++++-
 .../org/apache/camel/util/ObjectHelper.java     | 76 +++++++++++++++++---
 .../apache/camel/converter/ConverterTest.java   |  2 +-
 .../org/apache/camel/converter/JaxpTest.java    |  2 +-
 .../camel/converter/StringSourceTest.java       |  2 +-
 .../camel/impl/DefaultClassResolverTest.java    | 24 +++----
 .../camel/core/osgi/OsgiClassResolver.java      |  1 +
 .../camel/core/osgi/OsgiFactoryFinderTest.java  |  2 +-
 .../dozer/CamelToDozerClassResolverAdapter.java |  2 +-
 .../camel/component/jcr/JcrConverterTest.java   |  2 +-
 .../http/HttpServerSharedPipelineFactory.java   |  2 +-
 .../netty/http/NettySharedHttpServerTest.java   |  2 +-
 .../HttpServerSharedInitializerFactory.java     |  2 +-
 .../netty4/http/NettySharedHttpServerTest.java  |  2 +-
 .../camel/language/ognl/MyClassResolver.java    |  6 ++
 .../apache/camel/language/ognl/OgnlTest.java    |  2 +-
 .../test/blueprint/CamelBlueprintHelper.java    |  2 +-
 .../XStreamDataFormatDriverConfigTest.java      |  5 +-
 19 files changed, 118 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
index 6ffb98b..d47452f 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -224,7 +224,7 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
     private final Map<String, FactoryFinder> factories = new HashMap<String, FactoryFinder>();
     private final Map<String, RouteService> routeServices = new LinkedHashMap<String,
RouteService>();
     private final Map<String, RouteService> suspendedRouteServices = new LinkedHashMap<String,
RouteService>();
-    private ClassResolver classResolver = new DefaultClassResolver();
+    private ClassResolver classResolver = new DefaultClassResolver(this);
     private PackageScanClassResolver packageScanClassResolver;
     // we use a capacity of 100 per endpoint, so for the same endpoint we have at most 100
producers in the pool
     // so if we have 6 endpoints in the pool, we can have 6 x 100 producers in total

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/camel-core/src/main/java/org/apache/camel/impl/DefaultClassResolver.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultClassResolver.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultClassResolver.java
index a5b49e2..d4076de 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultClassResolver.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultClassResolver.java
@@ -20,6 +20,7 @@ import java.io.InputStream;
 import java.net.URL;
 import java.util.Enumeration;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.spi.ClassResolver;
 import org.apache.camel.util.CastUtils;
 import org.apache.camel.util.ObjectHelper;
@@ -29,12 +30,27 @@ import org.apache.camel.util.ObjectHelper;
  */
 public class DefaultClassResolver implements ClassResolver {
 
+    private final ClassLoader loader;
+
+    public DefaultClassResolver(CamelContext camelContext) {
+        this.loader = camelContext != null ? camelContext.getApplicationContextClassLoader()
: null;
+    }
+
     public Class<?> resolveClass(String name) {
-        return loadClass(name, DefaultClassResolver.class.getClassLoader());
+        Class<?> answer = loadClass(name, DefaultClassResolver.class.getClassLoader());
+        if (answer == null && loader != null) {
+            // fallback and use application context class loader
+            answer = loadClass(name, loader);
+        }
+        return answer;
     }
 
     public <T> Class<T> resolveClass(String name, Class<T> type) {
         Class<T> answer = CastUtils.cast(loadClass(name, DefaultClassResolver.class.getClassLoader()));
+        if (answer == null && loader != null) {
+            // fallback and use application context class loader
+            answer = CastUtils.cast(loadClass(name, loader));
+        }
         return answer;
     }
 
@@ -81,12 +97,12 @@ public class DefaultClassResolver implements ClassResolver {
 
     public InputStream loadResourceAsStream(String uri) {
         ObjectHelper.notEmpty(uri, "uri");
-        return ObjectHelper.loadResourceAsStream(uri);
+        return ObjectHelper.loadResourceAsStream(uri, loader);
     }
 
     public URL loadResourceAsURL(String uri) {
         ObjectHelper.notEmpty(uri, "uri");
-        return ObjectHelper.loadResourceAsURL(uri);
+        return ObjectHelper.loadResourceAsURL(uri, loader);
     }
 
     public Enumeration<URL> loadResourcesAsURL(String uri) {

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java b/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
index 1e2ebfe..edcf519 100644
--- a/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
@@ -981,12 +981,29 @@ public final class ObjectHelper {
      * @return the stream or null if it could not be loaded
      */
     public static InputStream loadResourceAsStream(String name) {
+        return loadResourceAsStream(name, null);
+    }
+
+    /**
+     * Attempts to load the given resource as a stream using the thread context
+     * class loader or the class loader used to load this class
+     *
+     * @param name the name of the resource to load
+     * @param loader optional classloader to attempt first
+     * @return the stream or null if it could not be loaded
+     */
+    public static InputStream loadResourceAsStream(String name, ClassLoader loader) {
         InputStream in = null;
 
         String resolvedName = resolveUriPath(name);
-        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
-        if (contextClassLoader != null) {
-            in = contextClassLoader.getResourceAsStream(resolvedName);
+        if (loader != null) {
+            in = loader.getResourceAsStream(resolvedName);
+        }
+        if (in == null) {
+            ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+            if (contextClassLoader != null) {
+                in = contextClassLoader.getResourceAsStream(resolvedName);
+            }
         }
         if (in == null) {
             in = ObjectHelper.class.getClassLoader().getResourceAsStream(resolvedName);
@@ -1006,12 +1023,29 @@ public final class ObjectHelper {
      * @return the stream or null if it could not be loaded
      */
     public static URL loadResourceAsURL(String name) {
+        return loadResourceAsURL(name, null);
+    }
+
+    /**
+     * Attempts to load the given resource as a stream using the thread context
+     * class loader or the class loader used to load this class
+     *
+     * @param name the name of the resource to load
+     * @param loader optional classloader to attempt first
+     * @return the stream or null if it could not be loaded
+     */
+    public static URL loadResourceAsURL(String name, ClassLoader loader) {
         URL url = null;
 
         String resolvedName = resolveUriPath(name);
-        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
-        if (contextClassLoader != null) {
-            url = contextClassLoader.getResource(resolvedName);
+        if (loader != null) {
+            url = loader.getResource(resolvedName);
+        }
+        if (url == null) {
+            ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+            if (contextClassLoader != null) {
+                url = contextClassLoader.getResource(resolvedName);
+            }
         }
         if (url == null) {
             url = ObjectHelper.class.getClassLoader().getResource(resolvedName);
@@ -1031,16 +1065,38 @@ public final class ObjectHelper {
      * @return the URLs for the resources or null if it could not be loaded
      */
     public static Enumeration<URL> loadResourcesAsURL(String packageName) {
+        return loadResourcesAsURL(packageName, null);
+    }
+
+    /**
+     * Attempts to load the given resources from the given package name using the thread
context
+     * class loader or the class loader used to load this class
+     *
+     * @param packageName the name of the package to load its resources
+     * @param loader optional classloader to attempt first
+     * @return the URLs for the resources or null if it could not be loaded
+     */
+    public static Enumeration<URL> loadResourcesAsURL(String packageName, ClassLoader
loader) {
         Enumeration<URL> url = null;
 
-        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
-        if (contextClassLoader != null) {
+        if (loader != null) {
             try {
-                url = contextClassLoader.getResources(packageName);
+                url = loader.getResources(packageName);
             } catch (IOException e) {
                 // ignore
             }
         }
+
+        if (url == null) {
+            ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+            if (contextClassLoader != null) {
+                try {
+                    url = contextClassLoader.getResources(packageName);
+                } catch (IOException e) {
+                    // ignore
+                }
+            }
+        }
         if (url == null) {
             try {
                 url = ObjectHelper.class.getClassLoader().getResources(packageName);
@@ -1051,7 +1107,7 @@ public final class ObjectHelper {
 
         return url;
     }
-    
+
     /**
      * Helper operation used to remove relative path notation from 
      * resources.  Most critical for resources on the Classpath

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/camel-core/src/test/java/org/apache/camel/converter/ConverterTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/converter/ConverterTest.java b/camel-core/src/test/java/org/apache/camel/converter/ConverterTest.java
index 9a294cb..8d0c678 100644
--- a/camel-core/src/test/java/org/apache/camel/converter/ConverterTest.java
+++ b/camel-core/src/test/java/org/apache/camel/converter/ConverterTest.java
@@ -52,7 +52,7 @@ public class ConverterTest extends TestCase {
     private static final Logger LOG = LoggerFactory.getLogger(ConverterTest.class);
 
     protected TypeConverter converter = new DefaultTypeConverter(new DefaultPackageScanClassResolver(),
-            new ReflectionInjector(), new DefaultFactoryFinderResolver().resolveDefaultFactoryFinder(new
DefaultClassResolver()));
+            new ReflectionInjector(), new DefaultFactoryFinderResolver().resolveDefaultFactoryFinder(new
DefaultClassResolver(null)));
 
     public static class IntegerPropertyEditor extends PropertyEditorSupport {
         public void setAsText(String text) throws IllegalArgumentException {

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/camel-core/src/test/java/org/apache/camel/converter/JaxpTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/converter/JaxpTest.java b/camel-core/src/test/java/org/apache/camel/converter/JaxpTest.java
index 0638b39..01b8da1 100644
--- a/camel-core/src/test/java/org/apache/camel/converter/JaxpTest.java
+++ b/camel-core/src/test/java/org/apache/camel/converter/JaxpTest.java
@@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory;
 public class JaxpTest extends TestCase {
     private static final Logger LOG = LoggerFactory.getLogger(JaxpTest.class);
     protected TypeConverter converter = new DefaultTypeConverter(new DefaultPackageScanClassResolver(),
-            new ReflectionInjector(), new DefaultFactoryFinderResolver().resolveDefaultFactoryFinder(new
DefaultClassResolver()));
+            new ReflectionInjector(), new DefaultFactoryFinderResolver().resolveDefaultFactoryFinder(new
DefaultClassResolver(null)));
 
     @Override
     protected void setUp() throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/camel-core/src/test/java/org/apache/camel/converter/StringSourceTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/converter/StringSourceTest.java b/camel-core/src/test/java/org/apache/camel/converter/StringSourceTest.java
index 1e310ea..632bf4b 100644
--- a/camel-core/src/test/java/org/apache/camel/converter/StringSourceTest.java
+++ b/camel-core/src/test/java/org/apache/camel/converter/StringSourceTest.java
@@ -37,7 +37,7 @@ import org.apache.camel.util.ServiceHelper;
  */
 public class StringSourceTest extends TestCase {
     protected TypeConverter converter = new DefaultTypeConverter(new DefaultPackageScanClassResolver(),
-            new ReflectionInjector(), new DefaultFactoryFinderResolver().resolveDefaultFactoryFinder(new
DefaultClassResolver()));
+            new ReflectionInjector(), new DefaultFactoryFinderResolver().resolveDefaultFactoryFinder(new
DefaultClassResolver(null)));
     protected String expectedBody = "<hello>world!</hello>";
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/camel-core/src/test/java/org/apache/camel/impl/DefaultClassResolverTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/DefaultClassResolverTest.java
b/camel-core/src/test/java/org/apache/camel/impl/DefaultClassResolverTest.java
index d73aa58..fc2f9c4 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/DefaultClassResolverTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/DefaultClassResolverTest.java
@@ -27,43 +27,43 @@ import junit.framework.TestCase;
 public class DefaultClassResolverTest extends TestCase {
 
     public void testResolveClass() {
-        DefaultClassResolver resolver = new DefaultClassResolver();
+        DefaultClassResolver resolver = new DefaultClassResolver(null);
         Class<?> clazz = resolver.resolveClass("java.lang.Integer");
         assertNotNull(clazz);
     }
 
     public void testResolveClassType() {
-        DefaultClassResolver resolver = new DefaultClassResolver();
+        DefaultClassResolver resolver = new DefaultClassResolver(null);
         Class<Integer> clazz = resolver.resolveClass("java.lang.Integer", Integer.class);
         assertNotNull(clazz);
     }
 
     public void testResolveClassClassLoader() {
-        DefaultClassResolver resolver = new DefaultClassResolver();
+        DefaultClassResolver resolver = new DefaultClassResolver(null);
         Class<?> clazz = resolver.resolveClass("java.lang.Integer", DefaultClassResolverTest.class.getClassLoader());
         assertNotNull(clazz);
     }
 
     public void testResolveClassClassLoaderType() {
-        DefaultClassResolver resolver = new DefaultClassResolver();
+        DefaultClassResolver resolver = new DefaultClassResolver(null);
         Class<Integer> clazz = resolver.resolveClass("java.lang.Integer", Integer.class,
DefaultClassResolverTest.class.getClassLoader());
         assertNotNull(clazz);
     }
 
     public void testResolveMandatoryClass() throws Exception {
-        DefaultClassResolver resolver = new DefaultClassResolver();
+        DefaultClassResolver resolver = new DefaultClassResolver(null);
         Class<?> clazz = resolver.resolveMandatoryClass("java.lang.Integer");
         assertNotNull(clazz);
     }
 
     public void testResolveMandatoryClassType()throws Exception {
-        DefaultClassResolver resolver = new DefaultClassResolver();
+        DefaultClassResolver resolver = new DefaultClassResolver(null);
         Class<Integer> clazz = resolver.resolveMandatoryClass("java.lang.Integer",
Integer.class);
         assertNotNull(clazz);
     }
 
     public void testResolveMandatorySimpleClassType()throws Exception {
-        DefaultClassResolver resolver = new DefaultClassResolver();
+        DefaultClassResolver resolver = new DefaultClassResolver(null);
 
         Class<Byte> clazz = resolver.resolveMandatoryClass("Byte", Byte.class);
         assertNotNull(clazz);
@@ -97,19 +97,19 @@ public class DefaultClassResolverTest extends TestCase {
     }
 
     public void testResolveMandatoryClassClassLoader() throws Exception {
-        DefaultClassResolver resolver = new DefaultClassResolver();
+        DefaultClassResolver resolver = new DefaultClassResolver(null);
         Class<?> clazz = resolver.resolveMandatoryClass("java.lang.Integer", DefaultClassResolverTest.class.getClassLoader());
         assertNotNull(clazz);
     }
 
     public void testResolveMandatoryClassClassLoaderType() throws Exception {
-        DefaultClassResolver resolver = new DefaultClassResolver();
+        DefaultClassResolver resolver = new DefaultClassResolver(null);
         Class<Integer> clazz = resolver.resolveMandatoryClass("java.lang.Integer",
Integer.class, DefaultClassResolverTest.class.getClassLoader());
         assertNotNull(clazz);
     }
 
     public void testResolveMandatoryClassNotFound()  {
-        DefaultClassResolver resolver = new DefaultClassResolver();
+        DefaultClassResolver resolver = new DefaultClassResolver(null);
         try {
             resolver.resolveMandatoryClass("com.FooBar");
             fail("Should thrown an exception");
@@ -119,13 +119,13 @@ public class DefaultClassResolverTest extends TestCase {
     }
 
     public void testLoadResourceAsUri() {
-        DefaultClassResolver resolver = new DefaultClassResolver();
+        DefaultClassResolver resolver = new DefaultClassResolver(null);
         URL url = resolver.loadResourceAsURL("log4j.properties");
         assertNotNull(url);
     }
 
     public void testLoadResourceAsStream() {
-        DefaultClassResolver resolver = new DefaultClassResolver();
+        DefaultClassResolver resolver = new DefaultClassResolver(null);
         InputStream is = resolver.loadResourceAsStream("log4j.properties");
         assertNotNull(is);
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiClassResolver.java
----------------------------------------------------------------------
diff --git a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiClassResolver.java
b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiClassResolver.java
index 59abb3c..2e07458 100644
--- a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiClassResolver.java
+++ b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiClassResolver.java
@@ -40,6 +40,7 @@ public class OsgiClassResolver extends DefaultClassResolver {
     private final BundleContext bundleContext;
 
     public OsgiClassResolver(CamelContext camelContext, BundleContext context) {
+        super(camelContext);
         this.camelContext = camelContext;
         this.bundleContext = context;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/components/camel-core-osgi/src/test/java/org/apache/camel/core/osgi/OsgiFactoryFinderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-core-osgi/src/test/java/org/apache/camel/core/osgi/OsgiFactoryFinderTest.java
b/components/camel-core-osgi/src/test/java/org/apache/camel/core/osgi/OsgiFactoryFinderTest.java
index f53e29e..a6197ff 100644
--- a/components/camel-core-osgi/src/test/java/org/apache/camel/core/osgi/OsgiFactoryFinderTest.java
+++ b/components/camel-core-osgi/src/test/java/org/apache/camel/core/osgi/OsgiFactoryFinderTest.java
@@ -26,7 +26,7 @@ public class OsgiFactoryFinderTest extends CamelOsgiTestSupport {
 
     @Test
     public void testFindClass() throws Exception {
-        OsgiFactoryFinder finder = new OsgiFactoryFinder(getBundleContext(), new DefaultClassResolver(),
"META-INF/services/org/apache/camel/component/");
+        OsgiFactoryFinder finder = new OsgiFactoryFinder(getBundleContext(), new DefaultClassResolver(null),
"META-INF/services/org/apache/camel/component/");
         Class<?> clazz = finder.findClass("file_test", "strategy.factory.");
         assertNotNull("We should get the file strategy factory here", clazz);
         

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/components/camel-dozer/src/main/java/org/apache/camel/converter/dozer/CamelToDozerClassResolverAdapter.java
----------------------------------------------------------------------
diff --git a/components/camel-dozer/src/main/java/org/apache/camel/converter/dozer/CamelToDozerClassResolverAdapter.java
b/components/camel-dozer/src/main/java/org/apache/camel/converter/dozer/CamelToDozerClassResolverAdapter.java
index ad913d1..611a4bb 100644
--- a/components/camel-dozer/src/main/java/org/apache/camel/converter/dozer/CamelToDozerClassResolverAdapter.java
+++ b/components/camel-dozer/src/main/java/org/apache/camel/converter/dozer/CamelToDozerClassResolverAdapter.java
@@ -29,7 +29,7 @@ public final class CamelToDozerClassResolverAdapter implements DozerClassLoader
 
     public CamelToDozerClassResolverAdapter() {
         // must have a default nor-arg constructor to allow Dozer to work with OSGi
-        classResolver = new DefaultClassResolver();
+        classResolver = new DefaultClassResolver(null);
     }
 
     public CamelToDozerClassResolverAdapter(CamelContext camelContext) {

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrConverterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrConverterTest.java
b/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrConverterTest.java
index 1298e3c..a4ce7b4 100644
--- a/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrConverterTest.java
+++ b/components/camel-jcr/src/test/java/org/apache/camel/component/jcr/JcrConverterTest.java
@@ -45,7 +45,7 @@ public class JcrConverterTest extends Assert {
     @Before
     public void init() throws Exception {
         converter = new DefaultTypeConverter(new DefaultPackageScanClassResolver(),
-                new ReflectionInjector(), new DefaultFactoryFinderResolver().resolveDefaultFactoryFinder(new
DefaultClassResolver()));
+                new ReflectionInjector(), new DefaultFactoryFinderResolver().resolveDefaultFactoryFinder(new
DefaultClassResolver(null)));
         ServiceHelper.startService(converter);
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
index f9b4cd0..2f9eefb 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
@@ -53,7 +53,7 @@ public class HttpServerSharedPipelineFactory extends HttpServerPipelineFactory
{
         this.configuration = configuration;
         this.channelFactory = channelFactory;
         // fallback and use default resolver
-        this.classResolver = classResolver != null ? classResolver : new DefaultClassResolver();
+        this.classResolver = classResolver != null ? classResolver : new DefaultClassResolver(null);
 
         try {
             this.sslContext = createSSLContext();

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettySharedHttpServerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettySharedHttpServerTest.java
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettySharedHttpServerTest.java
index faa6aee..38c3046 100644
--- a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettySharedHttpServerTest.java
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettySharedHttpServerTest.java
@@ -28,7 +28,7 @@ public class NettySharedHttpServerTest extends BaseNettyTest {
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         nettySharedHttpServer = new DefaultNettySharedHttpServer();
-        nettySharedHttpServer.setClassResolver(new DefaultClassResolver());
+        nettySharedHttpServer.setClassResolver(new DefaultClassResolver(context));
 
         NettySharedHttpServerBootstrapConfiguration configuration = new NettySharedHttpServerBootstrapConfiguration();
         configuration.setPort(getPort());

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
index 3ed4397..930dc2d 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
@@ -53,7 +53,7 @@ public class HttpServerSharedInitializerFactory extends HttpServerInitializerFac
         this.configuration = configuration;
         this.channelFactory = channelFactory;
         // fallback and use default resolver
-        this.classResolver = classResolver != null ? classResolver : new DefaultClassResolver();
+        this.classResolver = classResolver != null ? classResolver : new DefaultClassResolver(null);
 
         try {
             this.sslContext = createSSLContext();

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettySharedHttpServerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettySharedHttpServerTest.java
b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettySharedHttpServerTest.java
index de659a7..0c33612 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettySharedHttpServerTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettySharedHttpServerTest.java
@@ -28,7 +28,7 @@ public class NettySharedHttpServerTest extends BaseNettyTest {
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         nettySharedHttpServer = new DefaultNettySharedHttpServer();
-        nettySharedHttpServer.setClassResolver(new DefaultClassResolver());
+        nettySharedHttpServer.setClassResolver(new DefaultClassResolver(context));
 
         NettySharedHttpServerBootstrapConfiguration configuration = new NettySharedHttpServerBootstrapConfiguration();
         configuration.setPort(getPort());

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/components/camel-ognl/src/test/java/org/apache/camel/language/ognl/MyClassResolver.java
----------------------------------------------------------------------
diff --git a/components/camel-ognl/src/test/java/org/apache/camel/language/ognl/MyClassResolver.java
b/components/camel-ognl/src/test/java/org/apache/camel/language/ognl/MyClassResolver.java
index 5aff767..6791474 100644
--- a/components/camel-ognl/src/test/java/org/apache/camel/language/ognl/MyClassResolver.java
+++ b/components/camel-ognl/src/test/java/org/apache/camel/language/ognl/MyClassResolver.java
@@ -16,9 +16,15 @@
  */
 package org.apache.camel.language.ognl;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.impl.DefaultClassResolver;
 
 public class MyClassResolver extends DefaultClassResolver {
+
+    public MyClassResolver(CamelContext camelContext) {
+        super(camelContext);
+    }
+
     public Class<?> resolveClass(String name) {
         if (name.equals("org.apache.camel.language.ognl.Animal1")) {
             name = "org.apache.camel.language.ognl.Animal";

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/components/camel-ognl/src/test/java/org/apache/camel/language/ognl/OgnlTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ognl/src/test/java/org/apache/camel/language/ognl/OgnlTest.java
b/components/camel-ognl/src/test/java/org/apache/camel/language/ognl/OgnlTest.java
index e0fb612..b2dbb51 100644
--- a/components/camel-ognl/src/test/java/org/apache/camel/language/ognl/OgnlTest.java
+++ b/components/camel-ognl/src/test/java/org/apache/camel/language/ognl/OgnlTest.java
@@ -44,7 +44,7 @@ public class OgnlTest extends LanguageTestSupport {
             assertTrue("We should get the ClassNotFoundException", ex.getMessage().indexOf("ClassNotFoundException")
> 0);
         }
         // setup the class resolver to load the right class for us
-        exchange.getContext().setClassResolver(new MyClassResolver());
+        exchange.getContext().setClassResolver(new MyClassResolver(context));
         assertExpression("@org.apache.camel.language.ognl.Animal1@getClassName()", "Animal");
     }
     @Test

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
index 0c14be6..d8a1b4a 100644
--- a/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
+++ b/components/camel-test-blueprint/src/main/java/org/apache/camel/test/blueprint/CamelBlueprintHelper.java
@@ -76,7 +76,7 @@ public final class CamelBlueprintHelper {
     public static final String BUNDLE_FILTER = "(Bundle-SymbolicName=*)";
     public static final String BUNDLE_VERSION = "1.0.0";
     private static final Logger LOG = LoggerFactory.getLogger(CamelBlueprintHelper.class);
-    private static final ClassResolver RESOLVER = new DefaultClassResolver();
+    private static final ClassResolver RESOLVER = new DefaultClassResolver(null);
 
     private CamelBlueprintHelper() {
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/02148efd/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatDriverConfigTest.java
----------------------------------------------------------------------
diff --git a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatDriverConfigTest.java
b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatDriverConfigTest.java
index 6c02b7b..6b15a73 100644
--- a/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatDriverConfigTest.java
+++ b/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamDataFormatDriverConfigTest.java
@@ -32,13 +32,10 @@ public class XStreamDataFormatDriverConfigTest extends CamelTestSupport
{
         XStreamDataFormat xStreamDataFormat = new XStreamDataFormat();
         xStreamDataFormat.setXstreamDriver(new JsonHierarchicalStreamDriver());
 
-        XStream xStream = xStreamDataFormat.createXStream(new DefaultClassResolver());
+        XStream xStream = xStreamDataFormat.createXStream(new DefaultClassResolver(context));
         String marshalledOrder = xStream.toXML(purchaseOrder);
 
         assertEquals("{", marshalledOrder.substring(0, 1));
     }
-    
-    
-    
 
 }


Mime
View raw message