diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/CachingClassResolver.java b/src/main/java/org/jboss/netty/handler/codec/serialization/CachingClassResolver.java index 4c7f0abfdd..14ed39b4d6 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/CachingClassResolver.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/CachingClassResolver.java @@ -1,3 +1,18 @@ +/* + * Copyright 2011 Red Hat, Inc. + * + * Red Hat licenses this file to you under the Apache License, version 2.0 + * (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ package org.jboss.netty.handler.codec.serialization; import java.util.Map; 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..e5fa684ddb --- /dev/null +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/ClassLoaderClassResolver.java @@ -0,0 +1,39 @@ +/* + * Copyright 2011 Red Hat, Inc. + * + * Red Hat licenses this file to you under the Apache License, version 2.0 + * (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package org.jboss.netty.handler.codec.serialization; + +class ClassLoaderClassResolver implements ClassResolver { + + private final ClassLoader classLoader; + + ClassLoaderClassResolver(ClassLoader classLoader) { + this.classLoader = classLoader; + } + + + /* + * (non-Javadoc) + * @see org.jboss.netty.handler.codec.serialization.ClassResolver#resolve(java.lang.String) + */ + 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/ClassResolver.java b/src/main/java/org/jboss/netty/handler/codec/serialization/ClassResolver.java index 73958e1108..4340a746a2 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/ClassResolver.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/ClassResolver.java @@ -1,6 +1,20 @@ +/* + * Copyright 2011 Red Hat, Inc. + * + * Red Hat licenses this file to you under the Apache License, version 2.0 + * (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ package org.jboss.netty.handler.codec.serialization; - /** * please use {@link ClassResolvers} as instance factory */ 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..4bb22794e8 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 @@ -1,3 +1,18 @@ +/* + * Copyright 2011 Red Hat, Inc. + * + * Red Hat licenses this file to you under the Apache License, version 2.0 + * (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ package org.jboss.netty.handler.codec.serialization; import java.lang.ref.Reference; @@ -12,7 +27,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 +38,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 +49,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 +60,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 +71,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 22aa346721..e5fa684ddb 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,25 @@ +/* + * Copyright 2011 Red Hat, Inc. + * + * Red Hat licenses this file to you under the Apache License, version 2.0 + * (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ 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; } diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/ReferenceMap.java b/src/main/java/org/jboss/netty/handler/codec/serialization/ReferenceMap.java index 7103a6c516..155d146b7e 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/ReferenceMap.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/ReferenceMap.java @@ -1,3 +1,18 @@ +/* + * Copyright 2011 Red Hat, Inc. + * + * Red Hat licenses this file to you under the Apache License, version 2.0 + * (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ package org.jboss.netty.handler.codec.serialization; import java.lang.ref.Reference; diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/SoftReferenceMap.java b/src/main/java/org/jboss/netty/handler/codec/serialization/SoftReferenceMap.java index 7bf82e02da..b8c53a0808 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/SoftReferenceMap.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/SoftReferenceMap.java @@ -1,3 +1,18 @@ +/* + * Copyright 2011 Red Hat, Inc. + * + * Red Hat licenses this file to you under the Apache License, version 2.0 + * (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ package org.jboss.netty.handler.codec.serialization; import java.lang.ref.Reference; diff --git a/src/main/java/org/jboss/netty/handler/codec/serialization/WeakReferenceMap.java b/src/main/java/org/jboss/netty/handler/codec/serialization/WeakReferenceMap.java index 9217baac0c..7f404a2a1b 100644 --- a/src/main/java/org/jboss/netty/handler/codec/serialization/WeakReferenceMap.java +++ b/src/main/java/org/jboss/netty/handler/codec/serialization/WeakReferenceMap.java @@ -1,3 +1,18 @@ +/* + * Copyright 2011 Red Hat, Inc. + * + * Red Hat licenses this file to you under the Apache License, version 2.0 + * (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ package org.jboss.netty.handler.codec.serialization; import java.lang.ref.Reference;