Search in sources :

Example 16 with Marshaller

use of org.jboss.marshalling.Marshaller in project netty by netty.

the class MarshallingEncoder method encode.

@Override
protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
    Marshaller marshaller = provider.getMarshaller(ctx);
    int lengthPos = out.writerIndex();
    out.writeBytes(LENGTH_PLACEHOLDER);
    ChannelBufferByteOutput output = new ChannelBufferByteOutput(out);
    marshaller.start(output);
    marshaller.writeObject(msg);
    marshaller.finish();
    marshaller.close();
    out.setInt(lengthPos, out.writerIndex() - lengthPos - 4);
}
Also used : Marshaller(org.jboss.marshalling.Marshaller)

Aggregations

Marshaller (org.jboss.marshalling.Marshaller)16 ByteArrayOutputStream (java.io.ByteArrayOutputStream)11 OutputStreamByteOutput (org.jboss.marshalling.OutputStreamByteOutput)6 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)3 IOException (java.io.IOException)3 MarshallerFactory (org.jboss.marshalling.MarshallerFactory)3 MarshallingConfiguration (org.jboss.marshalling.MarshallingConfiguration)3 Test (org.junit.jupiter.api.Test)3 DataOutputStream (java.io.DataOutputStream)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 SimpleDataOutput (org.jboss.marshalling.SimpleDataOutput)2 StartException (org.jboss.msc.service.StartException)2 ByteBuf (io.netty.buffer.ByteBuf)1 ChannelHandler (io.netty.channel.ChannelHandler)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InvalidClassException (java.io.InvalidClassException)1 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1