@Override public NextAction handleWrite(FilterChainContext context) throws IOException { Connection<?> connection = context.getConnection(); GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer(1024); // Do not need to close Object msg = context.getMessage(); codec.encode(channel, channelBuffer, msg); GrizzlyChannel.removeChannelIfDisconnected(connection); Buffer buffer = connection.getTransport().getMemoryManager().allocate(channelBuffer.readableBytes()); buffer.put(channelBuffer.toByteBuffer()); buffer.flip(); buffer.allowBufferDispose(true); context.setMessage(buffer); } finally { GrizzlyChannel.removeChannelIfDisconnected(connection); } return context.getInvokeAction(); }
@Override public NextAction handleWrite(FilterChainContext context) throws IOException { Connection<?> connection = context.getConnection(); GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler); try { ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer(1024); // Do not need to close Object msg = context.getMessage(); codec.encode(channel, channelBuffer, msg); GrizzlyChannel.removeChannelIfDisconnected(connection); Buffer buffer = connection.getTransport().getMemoryManager().allocate(channelBuffer.readableBytes()); buffer.put(channelBuffer.toByteBuffer()); buffer.flip(); buffer.allowBufferDispose(true); context.setMessage(buffer); } finally { GrizzlyChannel.removeChannelIfDisconnected(connection); } return context.getInvokeAction(); }
@Override public byte[] getBodyPartBytes() { byte[] bytes = contentBytes.get(); if (bytes != null) { return bytes; } final Buffer b = content.getContent(); final int origPos = b.position(); bytes = new byte[b.remaining()]; b.get(bytes); b.flip(); b.position(origPos); contentBytes.compareAndSet(null, bytes); return bytes; }
@Override public Buffer flip() { grizzlyBuffer.flip(); return this; }
@Override public Buffer flip() { grizzlyBuffer.flip(); return this; }
static Buffer copy(final MemoryManager memoryManager, final Buffer buffer) { final Buffer tmpBuf = memoryManager.allocate(buffer.remaining()); tmpBuf.put(buffer); return tmpBuf.flip(); }
static Buffer copy(final MemoryManager memoryManager, final Buffer buffer) { final Buffer tmpBuf = memoryManager.allocate(buffer.remaining()); tmpBuf.put(buffer); return tmpBuf.flip(); }
static Buffer copy(final MemoryManager memoryManager, final Buffer buffer) { final Buffer tmpBuf = memoryManager.allocate(buffer.remaining()); tmpBuf.put(buffer); return tmpBuf.flip(); }
static Buffer copy(final MemoryManager memoryManager, final Buffer buffer) { final Buffer tmpBuf = memoryManager.allocate(buffer.remaining()); tmpBuf.put(buffer); return tmpBuf.flip(); }
static Buffer copy(final MemoryManager memoryManager, final Buffer buffer) { final Buffer tmpBuf = memoryManager.allocate(buffer.remaining()); tmpBuf.put(buffer); return tmpBuf.flip(); }
static Buffer copy(final MemoryManager memoryManager, final Buffer buffer) { final Buffer tmpBuf = memoryManager.allocate(buffer.remaining()); tmpBuf.put(buffer); return tmpBuf.flip(); }
static Buffer copy(final MemoryManager memoryManager, final Buffer buffer) { final Buffer tmpBuf = memoryManager.allocate(buffer.remaining()); tmpBuf.put(buffer); return tmpBuf.flip(); }
static Buffer copy(final MemoryManager memoryManager, final Buffer buffer) { final Buffer tmpBuf = memoryManager.allocate(buffer.remaining()); tmpBuf.put(buffer); return tmpBuf.flip(); }
static Buffer copy(final MemoryManager memoryManager, final Buffer buffer) { final Buffer tmpBuf = memoryManager.allocate(buffer.remaining()); tmpBuf.put(buffer); return tmpBuf.flip(); }
static Buffer copy(final MemoryManager memoryManager, final Buffer buffer) { final Buffer tmpBuf = memoryManager.allocate(buffer.remaining()); tmpBuf.put(buffer); return tmpBuf.flip(); }
static Buffer copy(final MemoryManager memoryManager, final Buffer buffer) { final Buffer tmpBuf = memoryManager.allocate(buffer.remaining()); tmpBuf.put(buffer); return tmpBuf.flip(); }
static Buffer copy(final MemoryManager memoryManager, final Buffer buffer) { final Buffer tmpBuf = memoryManager.allocate(buffer.remaining()); tmpBuf.put(buffer); return tmpBuf.flip(); }
private void sendEndResponse(final FilterChainContext ctx) throws IOException { final Connection connection = ctx.getConnection(); final MemoryManager mm = connection.getTransport().getMemoryManager(); final Buffer buffer = mm.allocate(6); buffer.put((byte) 'A'); buffer.put((byte) 'B'); buffer.putShort((short) 2); buffer.put(AjpConstants.JK_AJP13_END_RESPONSE); buffer.put((byte) 1); buffer.flip(); buffer.allowBufferDispose(true); ctx.write(buffer); }
private void sendEndResponse(final FilterChainContext ctx) throws IOException { final Connection connection = ctx.getConnection(); final MemoryManager mm = connection.getTransport().getMemoryManager(); final Buffer buffer = mm.allocate(6); buffer.put((byte) 'A'); buffer.put((byte) 'B'); buffer.putShort((short) 2); buffer.put(AjpConstants.JK_AJP13_END_RESPONSE); buffer.put((byte) 1); buffer.flip(); buffer.allowBufferDispose(true); ctx.write(buffer); }
private void sendEndResponse(final FilterChainContext ctx) throws IOException { final Connection connection = ctx.getConnection(); final MemoryManager mm = connection.getTransport().getMemoryManager(); final Buffer buffer = mm.allocate(6); buffer.put((byte) 'A'); buffer.put((byte) 'B'); buffer.putShort((short) 2); buffer.put(AjpConstants.JK_AJP13_END_RESPONSE); buffer.put((byte) 1); buffer.flip(); buffer.allowBufferDispose(true); ctx.write(buffer); }