Java 类io.netty.handler.codec.serialization.ClassResolver 实例源码

项目:darks-grid    文件:CodecFactory.java   
public static ChannelHandler createDecoder(ClassResolver classResolver)
{
    CodecConfig codecConfig = GridRuntime.config().getNetworkConfig().getCodecConfig();
    String type = DEFAULT_CODEC;
    Class<? extends GridCodec> codecClass = null;
    if (codecConfig.getType() != null)
    {
        type = codecConfig.getType().toLowerCase();
        codecClass = codecConfig.getCodecClass();
    }
    if (NETTY_CODEC.equals(type))
    {
        return new ObjectDecoder(Integer.MAX_VALUE, classResolver);
    }
    if (codecMap.containsKey(type) && codecClass == null)
    {
        codecClass = codecMap.get(type);
    }
    if (codecClass == null)
        throw new GridException("Cannot find codec " + type);
    GridCodec codec = ReflectUtils.newInstance(codecClass);
    codec.initialize(codecConfig.getParameters());
    return new GridObjectDecoder(classResolver, codec);
}
项目:MercuryTrade    文件:ClientChannelInitializer.java   
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
    socketChannel.pipeline().addLast(new ObjectEncoder());
    ClassLoader classLoader = this.getClass().getClassLoader();
    ClassResolver classResolver = ClassResolvers.weakCachingResolver(classLoader);
    socketChannel.pipeline().addLast(new ObjectDecoder(classResolver));
    socketChannel.pipeline().addLast(new ClientHandler());
}
项目:darks-grid    文件:FSTCodec.java   
@Override
public Object decode(InputStream in, ClassResolver classResolver) throws Exception
{
    FSTObjectInput fin = conf.getObjectInput(in);
    Object result = fin.readObject();
    in.close();
    return result;
}
项目:darks-grid    文件:HessianCodec.java   
@Override
public Object decode(InputStream in, ClassResolver classResolver) throws Exception
{
    HessianInput hi = new HessianInput(in);
    Object result = hi.readObject();
    hi.close();
    return result;
}
项目:darks-grid    文件:GenericCodec.java   
@Override
public Object decode(InputStream in, ClassResolver classResolver) throws Exception
{
    ObjectInputStream ois = new ObjectInputStream(in);
    Object result = ois.readObject();
    ois.close();
    return result;
}
项目:darks-grid    文件:KryoCodec.java   
@Override
public Object decode(InputStream in, ClassResolver classResolver) throws Exception
{
    Kryo kryo = getKryo();
    Input input = new Input(in);
    Object ret = kryo.readClassAndObject(input);
    input.close();
    return ret;
}
项目:Camel    文件:DatagramPacketObjectDecoder.java   
public DatagramPacketObjectDecoder(ClassResolver resolver) {
    delegateDecoder = new ObjectDecoder(resolver);
}
项目:Camel    文件:ObjectDecoder.java   
public ObjectDecoder(ClassResolver classResolver) {
    super(classResolver);
}
项目:jetstream    文件:StreamMessageDecoder.java   
CompactObjectInputStream(InputStream in, ClassResolver classResolver) throws IOException {
    super(in);
    this.classResolver = classResolver;
}
项目:darks-grid    文件:GridObjectDecoder.java   
public GridObjectDecoder(ClassResolver classResolver, GridCodec codec)
{
    this(Integer.MAX_VALUE, classResolver);
    this.codec = codec;
}
项目:kompics    文件:JavaSerializer.java   
public JavaSerializer(ClassResolver resolver) {
    this.resolver = resolver;
}
项目:kompics    文件:JavaSerializer.java   
CompactObjectInputStream(InputStream in, ClassResolver classResolver) throws IOException {
    super(in);
    this.classResolver = classResolver;
}
项目:jetstream    文件:StreamMessageDecoder.java   
/**
 * 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.
 */
public StreamMessageDecoder(ClassResolver classResolver) {
    this(classResolver, 1048576);
}
项目:jetstream    文件:StreamMessageDecoder.java   
/**
 * Creates a new decoder with the specified maximum object size.
 * 
 * @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.
 */
public StreamMessageDecoder(ClassResolver classResolver, int maxObjectSize) {
    super(maxObjectSize, 0, 4, 0, 4);
    this.classResolver = classResolver;
}
项目:darks-grid    文件:GridObjectDecoder.java   
/**
 * Creates a new decoder with the specified maximum object size.
 *
 * @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 classResolver    the {@link ClassResolver} which will load the class
 *                       of the serialized object
 */
public GridObjectDecoder(int maxObjectSize, ClassResolver classResolver) {
    super(maxObjectSize, 0, 4, 0, 4);
    this.classResolver = classResolver;
}
项目:darks-grid    文件:GridCodec.java   
public Object decode(InputStream in, ClassResolver classResolver) throws Exception;