Add constructors to make it possible to backport it to 3.2 without

breaking the api
This commit is contained in:
norman 2011-11-23 13:47:59 +01:00
parent 971a7364f6
commit 946d4be69e

View File

@ -50,11 +50,27 @@ public class ObjectDecoder extends LengthFieldBasedFrameDecoder {
* bytes. If the size of the received object is greater than
* {@code 1048576} bytes, a {@link StreamCorruptedException} will be
* raised.
*
* @deprecated use {@link #ObjectDecoder(ClassResolver)}
*/
@Deprecated
public ObjectDecoder() {
this(1048576);
}
/**
* Creates a new decoder whose maximum object size is {@code 1048576}
* bytes. If the size of the received object is greater than
* {@code 1048576} bytes, a {@link StreamCorruptedException} will be
* raised.
*
* @param classResolver the {@link ClassResolver} to use for this decoder
*/
public ObjectDecoder(ClassResolver classResolver) {
this(1048576, classResolver);
}
/**
* Creates a new decoder with the specified maximum object size.
*
@ -62,7 +78,9 @@ public class ObjectDecoder extends LengthFieldBasedFrameDecoder {
* if the length of the received object is greater
* than this value, {@link StreamCorruptedException}
* will be raised.
* @deprecated use {@link #ObjectDecoder(int, ClassResolver)}
*/
@Deprecated
public ObjectDecoder(int maxObjectSize) {
this(maxObjectSize, ClassResolvers.weakCachingResolver(null));
}
@ -82,6 +100,23 @@ public class ObjectDecoder extends LengthFieldBasedFrameDecoder {
this.classResolver = classResolver;
}
/**
* Create a new decoder with the specified maximum object size and the {@link ClassLoader} wrapped in {@link ClassResolvers#weakCachingResolver(ClassLoader)}
*
*
* @param maxObjectSize the maximum byte length of the serialized object.
* if the length of the received object is greater
* than this value, {@link StreamCorruptedException}
* will be raised.
* @param classLoader the the classloader to use
* @deprecated use {@link #ObjectDecoder(int, ClassResolver)}
*/
@Deprecated
public ObjectDecoder(int maxObjectSize, ClassLoader classLoader) {
this(maxObjectSize, ClassResolvers.weakCachingResolver(classLoader));
}
@Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {