Search in sources :

Example 1 with BufferOutputStream

use of org.glassfish.grizzly.utils.BufferOutputStream in project openmq by eclipse-ee4j.

the class GrizzlyMQPacketFilter method handleWrite.

@Override
public NextAction handleWrite(final FilterChainContext ctx) throws IOException {
    final Packet packet = ctx.getMessage();
    final MemoryManager mm = ctx.getConnection().getTransport().getMemoryManager();
    BufferOutputStream bos = null;
    try {
        bos = new BufferOutputStream(mm);
        packet.writePacket(bos);
        bos.close();
        Buffer buf = bos.getBuffer();
        buf.trim();
        buf.allowBufferDispose(true);
        if (buf.isComposite()) {
            ((CompositeBuffer) buf).allowInternalBuffersDispose(true);
        }
        ctx.setMessage(buf);
        return ctx.getInvokeAction();
    } finally {
        if (bos != null) {
            bos.close();
        }
    }
}
Also used : Buffer(org.glassfish.grizzly.Buffer) CompositeBuffer(org.glassfish.grizzly.memory.CompositeBuffer) Packet(com.sun.messaging.jmq.io.Packet) CompositeBuffer(org.glassfish.grizzly.memory.CompositeBuffer) BufferOutputStream(org.glassfish.grizzly.utils.BufferOutputStream) MemoryManager(org.glassfish.grizzly.memory.MemoryManager)

Aggregations

Packet (com.sun.messaging.jmq.io.Packet)1 Buffer (org.glassfish.grizzly.Buffer)1 CompositeBuffer (org.glassfish.grizzly.memory.CompositeBuffer)1 MemoryManager (org.glassfish.grizzly.memory.MemoryManager)1 BufferOutputStream (org.glassfish.grizzly.utils.BufferOutputStream)1