@Override public InputStream asInputStream() { return new ByteBufInputStream(this.byteBuf); }
@Override public InputStream asInputStream(boolean releaseOnClose) { return new ByteBufInputStream(this.byteBuf, releaseOnClose); }
@Override public InputStream asInputStream(boolean releaseOnClose) { return new ByteBufInputStream(this.byteBuf, releaseOnClose); }
@Override public Object decode(ByteBuf buf, State state) throws IOException { if (valueClass != null) { return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), valueClass); } if (valueTypeReference != null) { return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), valueTypeReference); } return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), Object.class); } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { if (valueClass != null) { return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), valueClass); } if (valueTypeReference != null) { return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), valueTypeReference); } return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), Object.class); } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), Object.class); } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { if (valueClass != null) { return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), valueClass); } return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), valueTypeReference); } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { if (keyClass != null) { return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), keyClass); } return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), keyTypeReference); } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { if (valueClass != null) { return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), valueClass); } return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), valueTypeReference); } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), Object.class); } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { if (keyClass != null) { return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), keyClass); } return mapObjectMapper.readValue((InputStream)new ByteBufInputStream(buf), keyTypeReference); } };
public Netty4ClientHttpResponse(ChannelHandlerContext context, FullHttpResponse nettyResponse) { Assert.notNull(context, "ChannelHandlerContext must not be null"); Assert.notNull(nettyResponse, "FullHttpResponse must not be null"); this.context = context; this.nettyResponse = nettyResponse; this.body = new ByteBufInputStream(this.nettyResponse.content()); this.nettyResponse.retain(); }
@Override protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception { ByteBuf frame = (ByteBuf) super.decode(ctx, in); if (frame == null) { return null; } ObjectInputStream ois = new CompactObjectInputStream(new ByteBufInputStream(frame, true), classResolver); try { return ois.readObject(); } finally { ois.close(); } } }
@Override protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception { ByteBuf frame = (ByteBuf) super.decode(ctx, in); if (frame == null) { return null; } ObjectInputStream ois = new CompactObjectInputStream(new ByteBufInputStream(frame, true), classResolver); try { return ois.readObject(); } finally { ois.close(); } } }
public Netty4ClientHttpResponse(ChannelHandlerContext context, FullHttpResponse nettyResponse) { Assert.notNull(context, "ChannelHandlerContext must not be null"); Assert.notNull(nettyResponse, "FullHttpResponse must not be null"); this.context = context; this.nettyResponse = nettyResponse; this.body = new ByteBufInputStream(this.nettyResponse.content()); this.nettyResponse.retain(); }
/** * Decode a given JSON buffer to a POJO of the given class type. * @param buf the JSON buffer. * @param type the type to map to. * @param <T> the generic type. * @return an instance of T * @throws DecodeException when there is a parsing or invalid mapping. */ public static <T> T decodeValue(Buffer buf, TypeReference<T> type) throws DecodeException { try { return mapper.readValue(new ByteBufInputStream(buf.getByteBuf()), type); } catch (Exception e) { throw new DecodeException("Failed to decode:" + e.getMessage(), e); } }
/** * Decode a given JSON buffer to a POJO of the given class type. * @param buf the JSON buffer. * @param clazz the class to map to. * @param <T> the generic type. * @return an instance of T * @throws DecodeException when there is a parsing or invalid mapping. */ public static <T> T decodeValue(Buffer buf, Class<T> clazz) throws DecodeException { try { return mapper.readValue((InputStream) new ByteBufInputStream(buf.getByteBuf()), clazz); } catch (Exception e) { throw new DecodeException("Failed to decode:" + e.getMessage(), e); } }
@Override public Object decode(ByteBuf buf, State state) throws IOException { try { ByteBufInputStream in = new ByteBufInputStream(buf); FSTObjectInput inputStream = config.getObjectInput(in); return inputStream.readObject(); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e); } } };
@Override public Object decode(ByteBuf buf, State state) throws IOException { try { ByteBufInputStream in = new ByteBufInputStream(buf); FSTObjectInput inputStream = config.getObjectInput(in); return inputStream.readObject(); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e); } } };
@Override protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception { final int length = in.readableBytes(); InputStream bbIn = null; ByteBufOutputStream bbOut = null; try { bbIn = new ByteBufInputStream(in); bbOut = new ByteBufOutputStream(out); bbOut.writeByte(properties); bbOut.writeInt(littleEndianDictionarySize); bbOut.writeLong(Long.reverseBytes(length)); encoder.code(bbIn, bbOut, -1, -1, null); } finally { if (bbIn != null) { bbIn.close(); } if (bbOut != null) { bbOut.close(); } } }