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.splicemachine.derby.stream.output.PipelineWriterBuilder.java

public static PipelineWriterBuilder getHTableWriterBuilderFromBase64String(String base64String)
        throws IOException {
    if (base64String == null)
        throw new IOException("tableScanner base64 String is null");
    return (PipelineWriterBuilder) SerializationUtils.deserialize(Base64.decodeBase64(base64String));
}

From source file:com.kecso.socket.ServerSocketControl.java

@Override
public void run() {
    DatagramSocket sock = null;/*from w  w  w  .j  ava  2  s .  c o  m*/

    try {
        sock = new DatagramSocket(8888);
        sock.setSoTimeout(1000);

        byte[] buffer = new byte[65536];
        DatagramPacket incoming = new DatagramPacket(buffer, buffer.length);

        while (!Thread.currentThread().isInterrupted()) {
            try {
                sock.receive(incoming);
                byte[] data = incoming.getData();
                this.udpMessage = SerializationUtils.deserialize(data);

                byte[] response = SerializationUtils.serialize(
                        this.output != null
                                ? new UdpResponse((float) output.getSpeed(), (float) output.getVerticalSpeed(),
                                        (float) output.getAltitude(), (float) output.getRpm())
                                : null);
                DatagramPacket dp = new DatagramPacket(response, response.length, incoming.getAddress(),
                        incoming.getPort());
                sock.send(dp);
            } catch (SocketTimeoutException e) {
            }
        }
    } catch (Exception e) {
        System.err.println("IOException " + e);
    } finally {
        if (sock != null) {
            sock.close();
        }

    }
}

From source file:kafka.examples.common.serialization.CustomDeserializer.java

@SuppressWarnings("unchecked")
@Override/*from w w  w  .  ja  v  a2s  .  c om*/
public T deserialize(String topic, byte[] objectData) {
    return (objectData == null) ? null : (T) SerializationUtils.deserialize(objectData);
}

From source file:com.FalcoLabs.Fido.api.datastore.serializers.BinarySerializer.java

@SuppressWarnings("unchecked")
public T fromByteBuffer(ByteBuffer byteBuffer) {
    byte[] bytes = new byte[byteBuffer.remaining()];
    byteBuffer.get(bytes);/*  ww  w . j  a va  2  s.c  o  m*/
    Object obj = SerializationUtils.deserialize(bytes);
    return (T) obj;
}

From source file:com.textocat.textokit.commons.wfstore.SharedDefaultWordformStore.java

@SuppressWarnings("unchecked")
@Override//from ww w .j  a  v a  2s  . co m
public void load(DataResource dr) throws ResourceInitializationException {
    DefaultWordformStore<TagType> ws;
    try {
        ws = (DefaultWordformStore<TagType>) SerializationUtils
                .deserialize(new BufferedInputStream(dr.getInputStream()));
    } catch (IOException e) {
        throw new ResourceInitializationException(e);
    }
    this.strKeyMap = ws.strKeyMap;
    this.metadataMap = ws.metadataMap;
}

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

@Override
public void onMessage(Message message) {

    try {/*from   ww  w . ja  va2s . c  o m*/
        log.debug("message received : " + message);
        TaskStatus payload = (TaskStatus) SerializationUtils.deserialize(message.getBody());
        String communicationId = new String(message.getMessageProperties().getCorrelationId());
        taskHandler.onTaskComplete(payload, 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.ErrorMessageListener.java

@Override
public void onMessage(Message message) {

    try {/*ww w  .  j a  v a2s. co  m*/
        log.debug("unxepected error occured during task polling process");
        Throwable error = (Throwable) SerializationUtils.deserialize(message.getBody());
        String communicationId = new String(message.getMessageProperties().getCorrelationId());
        taskHandler.onTaskFailure(error, communicationId);
    } catch (Exception ex) {
        log.error("Exception occured during task polling process; details : " + ex);
        throw new RuntimeException(ex);
    }

}

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

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

From source file:com.splicemachine.compactions.CompactionRecordReader.java

@Override
public void initialize(InputSplit split, TaskAttemptContext context) {
    String fileString = conf.get(MRConstants.COMPACTION_FILES);
    files = SerializationUtils.deserialize(Base64.decodeBase64(fileString));
    currentKey = new Integer(0);
}

From source file:de.kaiserpfalzEdv.commons.encoding.EncodingHelper.java

/**
 * Decodes the Object stream into an object.
 *
 * @param objectString the BASE64 encoded string containing a serialized object.
 * @return the object itself.//from w  w w  .  j  av a 2  s  .  c o m
 * @throws EncodingException If an {@link IOException} or
 *                           {@link ClassNotFoundException} was thrown.
 */
public static Object decode(final String objectString) {
    LOG.trace("Trying to decode string: {}", objectString);
    checkArgument(isNotBlank(objectString), "Can't decode NULL or empty String!");

    Object out = SerializationUtils.deserialize(Base64.getDecoder().decode(objectString));

    LOG.debug("Decoded BASE64 encoded object from string. Now returning object.");
    return out;
}