Example usage for org.apache.commons.lang3 SerializationUtils deserialize

List of usage examples for org.apache.commons.lang3 SerializationUtils deserialize

Introduction

In this page you can find the example usage for org.apache.commons.lang3 SerializationUtils deserialize.

Prototype

public static <T> T deserialize(final byte[] objectData) 

Source Link

Document

Deserializes a single Object from an array of bytes.

Usage

From source file:com.francetelecom.clara.cloud.paas.activation.v1.async.listener.amqp.RetryableMessageListener.java

@Override
public void onMessage(Message message) {

    try {// w  ww .  j  a  v  a2s.  com
        log.debug("message received : " + message);
        RetryContext retryContext = new RetryContext(
                (int) message.getMessageProperties().getHeaders().get("retryCount"));
        TaskStatus payload = (TaskStatus) SerializationUtils.deserialize(message.getBody());
        String communicationId = new String(message.getMessageProperties().getCorrelationId());
        taskHandler.onTaskPolled(payload, retryContext, communicationId);
    } catch (Exception ex) {
        log.error("Exception occured during task polling process; details : " + ex);
        throw new RuntimeException(ex);
    }

}

From source file:com.francetelecom.clara.cloud.paas.activation.v1.async.listener.amqp.UnexpectedErrorMessageListener.java

@Override
public void onMessage(Message message) {

    log.debug("message received : " + message);
    TaskStatus payload = (TaskStatus) SerializationUtils.deserialize(message.getBody());
    String communicationId = new String(message.getMessageProperties().getCorrelationId());

    try {//from w  w w  .j a va 2  s  .c om
        log.error("unexpected error occured during task polling process; msg details : " + payload);
    } catch (Exception e) {
        log.error("Exception occured during task polling process; details : " + e);
    }

    MessageProperties props = MessagePropertiesBuilder.newInstance()
            .setContentType(MessageProperties.CONTENT_TYPE_SERIALIZED_OBJECT)
            .setMessageId(UUID.randomUUID().toString()).setCorrelationId(communicationId.getBytes()).build();
    Message error = MessageBuilder
            .withBody(SerializationUtils
                    .serialize(new UnexpectedException("Unexpected error with content: " + payload)))
            .andProperties(props).build();
    amqpErrorTemplate.send(error);

}

From source file:com.dangdang.ddframe.job.cloud.scheduler.mesos.TaskInfoDataTest.java

@Test
public void assertSerializeDataflowJob() {
    TaskInfoData actual = new TaskInfoData(shardingContexts,
            CloudJobConfigurationBuilder.createDataflowCloudJobConfiguration("test_job"));
    assertSerialize((Map) SerializationUtils.deserialize(actual.serialize()));
}

From source file:com.hurence.logisland.classloading.SerializationTest.java

@Test
public void testCustomSerialization() throws Exception {

    BigSerializableClass instance = new BigSerializableClass();
    instance.setStringz(RandomStringUtils.random(1024));
    System.out.println(instance.getStringz());

    MyInterface proxy = PluginProxy.create(instance);
    System.out.println(proxy.getStringz());

    MyInterface serdeser = SerializationUtils.deserialize(SerializationUtils.serialize(proxy));
    System.out.println(serdeser.getStringz());
    BigSerializableClass unwrapped = PluginProxy.unwrap(serdeser);
    System.out.println(unwrapped.getStringz());
    MyInterface rewrapped = PluginProxy.create(unwrapped);
    System.out.println(rewrapped.getStringz());

}

From source file:com.dangdang.ddframe.job.cloud.scheduler.mesos.TaskInfoDataTest.java

@Test
public void assertSerializeScriptJob() {
    TaskInfoData actual = new TaskInfoData(shardingContexts,
            CloudJobConfigurationBuilder.createScriptCloudJobConfiguration("test_job"));
    assertSerialize((Map) SerializationUtils.deserialize(actual.serialize()));
}

From source file:com.romeikat.datamessie.core.base.util.sparsetable.SparseSingleTableTest.java

@Test
public void serializeAndDeserialize() throws Exception {

    final SparseSingleTable<Double, Double, Double> table = new SparseSingleTable<Double, Double, Double>();
    for (int i = 0; i < NUMBER_OF_ITERATIONS; i++) {
        final double rowHeader = Math.random();
        final double columnHeader = Math.random();
        final double value = Math.random();
        table.putValue(rowHeader, columnHeader, value);
    }/*from w  w w.java 2 s . c o  m*/

    final byte[] serializedTable = SerializationUtils.serialize(table);
    @SuppressWarnings("unchecked")
    final SparseSingleTable<Double, Double, Double> deserializedTable = (SparseSingleTable<Double, Double, Double>) SerializationUtils
            .deserialize(serializedTable);

    assertEquals(table, deserializedTable);

}

From source file:it.greenvulcano.util.clazz.BigQueueObject.java

@SuppressWarnings("unchecked")
public T readObject() throws IOException {
    byte[] data = this.bigQueue.dequeue();
    if (data == null)
        return null;
    return (T) SerializationUtils.deserialize(data);
}

From source file:com.romeikat.datamessie.core.base.util.sparsetable.SparseMultiTableTest.java

@Test
public void serializeAndDeserialize() throws Exception {

    final SparseMultiTable<Double, Double, Double> table = new SparseMultiTable<Double, Double, Double>();
    for (int i = 0; i < NUMBER_OF_ITERATIONS; i++) {
        final double rowHeader = Math.random();
        final double columnHeader = Math.random();
        final double value1 = Math.random();
        final double value2 = Math.random();
        table.putValue(rowHeader, columnHeader, value1);
        table.putValue(rowHeader, columnHeader, value2);
    }//  w w  w  .  j  a va  2 s. co m

    final byte[] serializedTable = SerializationUtils.serialize(table);
    @SuppressWarnings("unchecked")
    final SparseMultiTable<Double, Double, Double> deserializedTable = (SparseMultiTable<Double, Double, Double>) SerializationUtils
            .deserialize(serializedTable);

    assertEquals(table, deserializedTable);

}

From source file:com.github.helenusdriver.persistence.Serializer.java

/**
 * {@inheritDoc}/*  www .j  ava2  s  .com*/
 *
 * @author paouelle
 *
 * @see com.github.helenusdriver.persistence.Persister#decode(java.lang.Object)
 */
@Override
public Object decode(byte[] blob) throws IOException {
    return SerializationUtils.deserialize(blob);
}

From source file:com.link_intersystems.lang.reflect.SerializableMethodTest.java

/**
 * Helper method until commons-lang3 fixed the class loader problem. See
 * {@link https://issues.apache.org/jira/browse/LANG-788}.
 */// w w  w .  jav a  2  s  .com
@SuppressWarnings("unchecked")
private static <T extends Serializable> T cloneSerializable(T serializable) {
    T clone = (T) SerializationUtils.deserialize(SerializationUtils.serialize(serializable));
    return clone;
}