Search in sources :

Example 1 with MarshallingConfiguration

use of org.jboss.marshalling.MarshallingConfiguration in project wildfly by wildfly.

the class SimpleMarshallingContext method isMarshallable.

@Override
public boolean isMarshallable(Object object) {
    if (object == null)
        return true;
    MarshallingConfiguration configuration = this.repository.getMarshallingConfiguration(this.repository.getCurrentMarshallingVersion());
    try {
        ObjectTable table = configuration.getObjectTable();
        if ((table != null) && table.getObjectWriter(object) != null)
            return true;
        ClassExternalizerFactory factory = configuration.getClassExternalizerFactory();
        if ((factory != null) && (factory.getExternalizer(object.getClass()) != null))
            return true;
        SerializabilityChecker checker = configuration.getSerializabilityChecker();
        return ((checker == null) ? SerializabilityChecker.DEFAULT : checker).isSerializable(object.getClass());
    } catch (IOException e) {
        return false;
    }
}
Also used : ClassExternalizerFactory(org.jboss.marshalling.ClassExternalizerFactory) MarshallingConfiguration(org.jboss.marshalling.MarshallingConfiguration) ObjectTable(org.jboss.marshalling.ObjectTable) IOException(java.io.IOException) SerializabilityChecker(org.jboss.marshalling.SerializabilityChecker)

Example 2 with MarshallingConfiguration

use of org.jboss.marshalling.MarshallingConfiguration 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 3 with MarshallingConfiguration

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

the class RiverCompatibleMarshallingDecoderTest method createMarshallingConfig.

@Override
protected MarshallingConfiguration createMarshallingConfig() {
    // Create a configuration
    final MarshallingConfiguration configuration = new MarshallingConfiguration();
    configuration.setVersion(3);
    return configuration;
}
Also used : MarshallingConfiguration(org.jboss.marshalling.MarshallingConfiguration)

Example 4 with MarshallingConfiguration

use of org.jboss.marshalling.MarshallingConfiguration 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 5 with MarshallingConfiguration

use of org.jboss.marshalling.MarshallingConfiguration 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)

Aggregations

MarshallingConfiguration (org.jboss.marshalling.MarshallingConfiguration)17 MarshallerFactory (org.jboss.marshalling.MarshallerFactory)6 RiverMarshallerFactory (org.jboss.marshalling.river.RiverMarshallerFactory)5 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 Test (org.junit.jupiter.api.Test)4 IOException (java.io.IOException)3 Marshaller (org.jboss.marshalling.Marshaller)3 ByteBuf (io.netty.buffer.ByteBuf)2 ClassExternalizerFactory (org.jboss.marshalling.ClassExternalizerFactory)2 ObjectTable (org.jboss.marshalling.ObjectTable)2 SerializabilityChecker (org.jboss.marshalling.SerializabilityChecker)2 ZeroPortPolicy (com.sun.corba.se.spi.extension.ZeroPortPolicy)1 ChannelHandler (io.netty.channel.ChannelHandler)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 InvalidClassException (java.io.InvalidClassException)1 ArrayList (java.util.ArrayList)1 TransactionManager (javax.transaction.TransactionManager)1 EJBComponent (org.jboss.as.ejb3.component.EJBComponent)1