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); }
@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()); }
@Override public Object decode(InputStream in, ClassResolver classResolver) throws Exception { FSTObjectInput fin = conf.getObjectInput(in); Object result = fin.readObject(); in.close(); return result; }
@Override public Object decode(InputStream in, ClassResolver classResolver) throws Exception { HessianInput hi = new HessianInput(in); Object result = hi.readObject(); hi.close(); return result; }
@Override public Object decode(InputStream in, ClassResolver classResolver) throws Exception { ObjectInputStream ois = new ObjectInputStream(in); Object result = ois.readObject(); ois.close(); return result; }
@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; }
public DatagramPacketObjectDecoder(ClassResolver resolver) { delegateDecoder = new ObjectDecoder(resolver); }
public ObjectDecoder(ClassResolver classResolver) { super(classResolver); }
CompactObjectInputStream(InputStream in, ClassResolver classResolver) throws IOException { super(in); this.classResolver = classResolver; }
public GridObjectDecoder(ClassResolver classResolver, GridCodec codec) { this(Integer.MAX_VALUE, classResolver); this.codec = codec; }
public JavaSerializer(ClassResolver resolver) { this.resolver = resolver; }
/** * 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); }
/** * 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; }
/** * 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; }
public Object decode(InputStream in, ClassResolver classResolver) throws Exception;