Search in sources :

Example 1 with MarshallerFactory

use of org.jboss.marshalling.MarshallerFactory in project jdepth by Crab2died.

the class MarshallingCodeCFactory method buildDecoder.

public static MarshallingDecoder buildDecoder() {
    MarshallerFactory factory = Marshalling.getProvidedMarshallerFactory("serial");
    MarshallingConfiguration configuration = new MarshallingConfiguration();
    configuration.setVersion(5);
    UnmarshallerProvider provider = new DefaultUnmarshallerProvider(factory, configuration);
    return new MarshallingDecoder(provider, 1024);
}
Also used : MarshallerFactory(org.jboss.marshalling.MarshallerFactory) MarshallingConfiguration(org.jboss.marshalling.MarshallingConfiguration)

Example 2 with MarshallerFactory

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

the class AbstractCompatibleMarshallingDecoderTest method testFragmentedUnmarshalling.

@Test
public void testFragmentedUnmarshalling() throws IOException {
    MarshallerFactory marshallerFactory = createMarshallerFactory();
    MarshallingConfiguration configuration = createMarshallingConfig();
    EmbeddedChannel ch = new EmbeddedChannel(createDecoder(Integer.MAX_VALUE));
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
    marshaller.start(Marshalling.createByteOutput(bout));
    marshaller.writeObject(testObject);
    marshaller.finish();
    marshaller.close();
    byte[] testBytes = bout.toByteArray();
    ByteBuf buffer = input(testBytes);
    ByteBuf slice = buffer.readRetainedSlice(2);
    ch.writeInbound(slice);
    ch.writeInbound(buffer);
    assertTrue(ch.finish());
    String unmarshalled = ch.readInbound();
    assertEquals(testObject, unmarshalled);
    assertNull(ch.readInbound());
}
Also used : MarshallerFactory(org.jboss.marshalling.MarshallerFactory) Marshaller(org.jboss.marshalling.Marshaller) MarshallingConfiguration(org.jboss.marshalling.MarshallingConfiguration) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.jupiter.api.Test)

Example 3 with MarshallerFactory

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

the class AbstractCompatibleMarshallingDecoderTest method testTooBigObject.

@Test
public void testTooBigObject() throws IOException {
    MarshallerFactory marshallerFactory = createMarshallerFactory();
    MarshallingConfiguration configuration = createMarshallingConfig();
    ChannelHandler mDecoder = createDecoder(4);
    EmbeddedChannel ch = new EmbeddedChannel(mDecoder);
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    Marshaller marshaller = marshallerFactory.createMarshaller(configuration);
    marshaller.start(Marshalling.createByteOutput(bout));
    marshaller.writeObject(testObject);
    marshaller.finish();
    marshaller.close();
    byte[] testBytes = bout.toByteArray();
    onTooBigFrame(ch, input(testBytes));
}
Also used : MarshallerFactory(org.jboss.marshalling.MarshallerFactory) Marshaller(org.jboss.marshalling.Marshaller) MarshallingConfiguration(org.jboss.marshalling.MarshallingConfiguration) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) ChannelHandler(io.netty.channel.ChannelHandler) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Example 4 with MarshallerFactory

use of org.jboss.marshalling.MarshallerFactory in project jvm-serializers by eishay.

the class JBossMarshalling method register.

public static void register(final TestGroups groups) {
    MarshallerFactory riverFactory = new RiverMarshallerFactory();
    groups.media.add(JavaBuiltIn.mediaTransformer, new MarshallingSerializer<MediaContent>(MediaContent.class, "jboss-marshalling-river", riverFactory, false, false), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.ZERO_KNOWLEDGE, "full graph zero knowledge"));
    groups.media.add(JavaBuiltIn.mediaTransformer, new MarshallingSerializer<MediaContent>(MediaContent.class, "jboss-marshalling-river-manual", riverFactory, false, true), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.MANUAL_OPT, "full graph with manual optimizations"));
    groups.media.add(JavaBuiltIn.mediaTransformer, new MarshallingSerializer<MediaContent>(MediaContent.class, "jboss-marshalling-river-ct", riverFactory, true, false), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.CLASSES_KNOWN, "full graph with preregistered classes"));
    groups.media.add(JavaBuiltIn.mediaTransformer, new MarshallingSerializer<MediaContent>(MediaContent.class, "jboss-marshalling-river-ct-manual", riverFactory, true, true), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.MANUAL_OPT, "full graph preregistered classes, manual optimization"));
    groups.media.add(JavaBuiltIn.mediaTransformer, new MarshallingSerializer<MediaContent>(MediaContent.class, "jboss-marshalling-serial", new SerialMarshallerFactory(), false, false), new SerFeatures(SerFormat.BINARY, SerGraph.FULL_GRAPH, SerClass.ZERO_KNOWLEDGE, ""));
}
Also used : MarshallerFactory(org.jboss.marshalling.MarshallerFactory) RiverMarshallerFactory(org.jboss.marshalling.river.RiverMarshallerFactory) SerialMarshallerFactory(org.jboss.marshalling.serial.SerialMarshallerFactory) SerialMarshallerFactory(org.jboss.marshalling.serial.SerialMarshallerFactory) MediaContent(data.media.MediaContent) RiverMarshallerFactory(org.jboss.marshalling.river.RiverMarshallerFactory)

Example 5 with MarshallerFactory

use of org.jboss.marshalling.MarshallerFactory in project jdepth by Crab2died.

the class MarshallingCodeCFactory method buildEncoder.

public static MarshallingEncoder buildEncoder() {
    MarshallerFactory factory = Marshalling.getProvidedMarshallerFactory("serial");
    MarshallingConfiguration configuration = new MarshallingConfiguration();
    configuration.setVersion(5);
    MarshallerProvider provider = new DefaultMarshallerProvider(factory, configuration);
    return new MarshallingEncoder(provider);
}
Also used : MarshallerFactory(org.jboss.marshalling.MarshallerFactory) MarshallingConfiguration(org.jboss.marshalling.MarshallingConfiguration)

Aggregations

MarshallerFactory (org.jboss.marshalling.MarshallerFactory)7 MarshallingConfiguration (org.jboss.marshalling.MarshallingConfiguration)6 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)4 Test (org.junit.jupiter.api.Test)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Marshaller (org.jboss.marshalling.Marshaller)3 ByteBuf (io.netty.buffer.ByteBuf)2 MediaContent (data.media.MediaContent)1 ChannelHandler (io.netty.channel.ChannelHandler)1 Unmarshaller (org.jboss.marshalling.Unmarshaller)1 RiverMarshallerFactory (org.jboss.marshalling.river.RiverMarshallerFactory)1 SerialMarshallerFactory (org.jboss.marshalling.serial.SerialMarshallerFactory)1