diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/ClassLoaderClassResolver.java b/src/main/java/org/jboss/netty/handler/codec/serialization/ClassLoaderClassResolver.java new file mode 100644 index 0000000000..6c73c81557 --- /dev/null +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/ClassLoaderClassResolver.java @@ -0,0 +1,20 @@ +package org.jboss.netty.handler.codec.serialization; + +class ClassLoaderClassResolver implements ClassResolver { + + private final ClassLoader classLoader; + + ClassLoaderClassResolver(ClassLoader classLoader) { + this.classLoader = classLoader; + } + + @Override + public Class resolve(String className) throws ClassNotFoundException { + try { + return classLoader.loadClass(className); + } catch (ClassNotFoundException e) { + return Class.forName(className, false, classLoader); + } + } + +} diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/ClassResolvers.java b/src/main/java/org/jboss/netty/handler/codec/serialization/ClassResolvers.java index cbc4d1db15..02157c46a9 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/ClassResolvers.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/ClassResolvers.java @@ -12,7 +12,7 @@ public class ClassResolvers { * @return new instance of class resolver */ public static ClassResolver cacheDisabled(ClassLoader classLoader) { - return new ClassloaderClassResolver(defaultClassLoader(classLoader)); + return new ClassLoaderClassResolver(defaultClassLoader(classLoader)); } /** @@ -23,7 +23,7 @@ public class ClassResolvers { * @return new instance of class resolver */ public static ClassResolver weakCachingResolver(ClassLoader classLoader) { - return new CachingClassResolver(new ClassloaderClassResolver(defaultClassLoader(classLoader)), new WeakReferenceMap>(new HashMap>>())); + return new CachingClassResolver(new ClassLoaderClassResolver(defaultClassLoader(classLoader)), new WeakReferenceMap>(new HashMap>>())); } /** @@ -34,7 +34,7 @@ public class ClassResolvers { * @return new instance of class resolver */ public static ClassResolver softCachingResolver(ClassLoader classLoader) { - return new CachingClassResolver(new ClassloaderClassResolver(defaultClassLoader(classLoader)), new SoftReferenceMap>(new HashMap>>())); + return new CachingClassResolver(new ClassLoaderClassResolver(defaultClassLoader(classLoader)), new SoftReferenceMap>(new HashMap>>())); } /** @@ -45,7 +45,7 @@ public class ClassResolvers { * @return new instance of class resolver */ public static ClassResolver weakCachingConcurrentResolver(ClassLoader classLoader) { - return new CachingClassResolver(new ClassloaderClassResolver(defaultClassLoader(classLoader)), new WeakReferenceMap>(new ConcurrentHashMap>>())); + return new CachingClassResolver(new ClassLoaderClassResolver(defaultClassLoader(classLoader)), new WeakReferenceMap>(new ConcurrentHashMap>>())); } /** @@ -56,7 +56,7 @@ public class ClassResolvers { * @return new instance of class resolver */ public static ClassResolver softCachingConcurrentResolver(ClassLoader classLoader) { - return new CachingClassResolver(new ClassloaderClassResolver(defaultClassLoader(classLoader)), new SoftReferenceMap>(new ConcurrentHashMap>>())); + return new CachingClassResolver(new ClassLoaderClassResolver(defaultClassLoader(classLoader)), new SoftReferenceMap>(new ConcurrentHashMap>>())); } static ClassLoader defaultClassLoader(ClassLoader classLoader) { diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/ClassloaderClassResolver.java b/src/main/java/org/jboss/netty/handler/codec/serialization/ClassloaderClassResolver.java index 691b9dd0c9..6c73c81557 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/ClassloaderClassResolver.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/ClassloaderClassResolver.java @@ -1,10 +1,10 @@ package org.jboss.netty.handler.codec.serialization; -class ClassloaderClassResolver implements ClassResolver { +class ClassLoaderClassResolver implements ClassResolver { private final ClassLoader classLoader; - ClassloaderClassResolver(ClassLoader classLoader) { + ClassLoaderClassResolver(ClassLoader classLoader) { this.classLoader = classLoader; }