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

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

Introduction

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

Prototype

public static Object deserialize(byte[] objectData) 

Source Link

Document

Deserializes a single Object from an array of bytes.

Usage

From source file:edu.duke.cabig.c3pr.domain.scheduler.runtime.job.CCTSNotificationMessageJob.java

public static void main(String[] args) {
    Vector v = new Vector();
    v.add(new CCTSNotification());
    System.out.println(v);//from w ww.j ava 2  s .  c  om
    byte[] b = SerializationUtils.serialize(v);
    Vector v2 = (Vector) SerializationUtils.deserialize(b);
    System.out.println(v2);
}

From source file:fr.inria.oak.paxquery.pact.operators.unary.NestedAggregationOperator.java

@Override
public void open(Configuration parameters) throws Exception {
    super.open(parameters);

    String aggregationPathEncoded = parameters
            .getString(PACTOperatorsConfiguration.AGGREGATION_PATH_BINARY.toString(), null);
    byte[] aggregationPathBytes = DatatypeConverter.parseBase64Binary(aggregationPathEncoded);
    final int[] aggregationPath = (int[]) SerializationUtils.deserialize(aggregationPathBytes);
    this.aggregationPath = aggregationPath;

    String aggregationTypeEncoded = parameters
            .getString(PACTOperatorsConfiguration.AGGREGATION_TYPE_BINARY.toString(), null);
    byte[] aggregationTypeBytes = DatatypeConverter.parseBase64Binary(aggregationTypeEncoded);
    final AggregationType aggregationType = (AggregationType) SerializationUtils
            .deserialize(aggregationTypeBytes);
    this.aggregationType = aggregationType;

    this.attachDummyColumn = parameters
            .getBoolean(PACTOperatorsConfiguration.ATTACH_DUMMY_COLUMN_BOOLEAN.toString(), false);

}

From source file:com.janrain.backplane2.server.dao.redis.RedisBusDAO.java

@Override
public List<BusConfig2> getAll() throws BackplaneServerException {
    List<BusConfig2> buses = new ArrayList<BusConfig2>();
    List<byte[]> bytesList = Redis.getInstance().lrange(getKey("list"), 0, -1);
    for (byte[] bytes : bytesList) {
        if (bytes != null) {
            buses.add((BusConfig2) SerializationUtils.deserialize(bytes));
        }/* w  w  w  .j  ava 2s  .  c  o  m*/
    }
    return buses;
}

From source file:mitm.application.djigzo.james.EncryptedContainerTest.java

@SuppressWarnings("unchecked")
@Test//www .  j  a v a 2 s.  c om
public void testNull() throws Exception {
    EncryptedContainer<String> container = new EncryptedContainer<String>();

    container.set(null);

    byte[] serialized = SerializationUtils.serialize(container);

    container = (EncryptedContainer<String>) SerializationUtils.deserialize(serialized);

    assertNull(container.get());
}

From source file:dfki.sb.rabbitmqjava.RabbitMQObjectStreamServer.java

private static void processSendAndRecivePackets(QueueingConsumer consumer, Channel channel)
        throws InterruptedException, IOException {
    while (true) {
        QueueingConsumer.Delivery delivery = consumer.nextDelivery();
        BasicProperties props = delivery.getProperties();
        BasicProperties replyProps = new BasicProperties.Builder().correlationId(props.getCorrelationId())
                .build();//from   w ww .  jav a2s  .c  o m
        try {
            byte[] body = delivery.getBody();
            if (body.length == 0) {
                break;
            } else {
                Object obj = SerializationUtils.deserialize(body);
                if (obj instanceof MarketData) {
                    MarketData response = sendMarketData((MarketData) obj);
                    channel.basicPublish("", props.getReplyTo(), replyProps,
                            SerializationUtils.serialize(response));
                } else {
                    QuoteRequest response = sendQuoteRequest((QuoteRequest) obj);
                    channel.basicPublish("", props.getReplyTo(), replyProps,
                            SerializationUtils.serialize(response));
                }
            }
        } catch (IOException e) {
            System.out.println(" [.] " + e.toString());
        } finally {
            channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
        }
    }
}

From source file:com.flexive.tests.embedded.benchmark.StructureBenchmark.java

public void benchStructureSerialization() {
    // benchmark environment serialization for shared/distributed caches

    final FxEnvironment env = CacheAdmin.getEnvironment();
    for (int i = 0; i < 10; i++) {
        SerializationUtils.deserialize(SerializationUtils.serialize(env));
    }//  ww w .jav  a  2 s. c o m

    long start = System.currentTimeMillis();
    final int times = 100;
    for (int i = 0; i < times; i++) {
        SerializationUtils.serialize(env);
    }
    getResultLogger().logTime("serializeEnvironment", start, times, "instance");

    final byte[] serialized = SerializationUtils.serialize(env);
    start = System.currentTimeMillis();
    for (int i = 0; i < times; i++) {
        SerializationUtils.deserialize(serialized);
    }
    getResultLogger().logTime("deserializeEnvironment", start, times, "instance");
    System.out.println("Serialized environment size: " + (serialized.length / 1024) + "kb");
}

From source file:fr.inria.oak.paxquery.pact.operators.unary.PostAggregationOperator.java

@Override
public void open(Configuration parameters) throws Exception {
    super.open(parameters);

    this.aggregationColumn = parameters
            .getInteger(PACTOperatorsConfiguration.POST_AGGREGATION_COLUMN_INT.toString(), -1);

    String aggregationTypeEncoded = parameters
            .getString(PACTOperatorsConfiguration.AGGREGATION_TYPE_BINARY.toString(), null);
    byte[] aggregationTypeBytes = DatatypeConverter.parseBase64Binary(aggregationTypeEncoded);
    final AggregationType aggregationType = (AggregationType) SerializationUtils
            .deserialize(aggregationTypeBytes);
    this.aggregationType = aggregationType;

    this.nestedColumn = parameters.getInteger(PACTOperatorsConfiguration.NESTED_RECORDS_COLUMN_INT.toString(),
            -1);//from   www.  ja  va 2s  . c o m

    this.excludeNestedField = parameters
            .getBoolean(PACTOperatorsConfiguration.EXCLUDE_NESTED_FIELD_BOOLEAN.toString(), false);
}

From source file:at.gv.egovernment.moa.id.storage.DBExceptionStoreImpl.java

public Throwable fetchException(String id) {

    try {// w  ww  .j a  va2 s .  co m
        Logger.debug("Fetch Exception with ID " + id);

        ExceptionStore ex = searchInDatabase(id);

        Object data = SerializationUtils.deserialize(ex.getException());
        if (data instanceof Throwable)
            return (Throwable) data;

        else {
            Logger.warn("Exeption is not of classtype Throwable");
            return null;
        }

    } catch (MOADatabaseException e) {
        Logger.info("No Exception found with ID=" + id);
        return null;

    } catch (Exception e) {
        Logger.warn("Exception can not deserialized from Database.", e);
        return null;
    }

}

From source file:com.cloudera.science.quince.VCFToGA4GHVariantFn.java

@Override
public void initialize() {
    converter = new VariantContext2VariantConverter();
    variantConverterContext = new VariantConverterContext();

    byte[] variantHeaders = Base64.decodeBase64(getConfiguration().get(VARIANT_HEADERS));
    VCFHeader[] headers = (VCFHeader[]) SerializationUtils.deserialize(variantHeaders);

    for (VCFHeader header : headers) {
        VariantSet vs = new VariantSet();
        vs.setId(header.getMetaDataLine(VARIANT_SET_ID).getValue());
        vs.setDatasetId(getConfiguration().get(SAMPLE_GROUP)); // dataset = sample group
        VCFHeaderLine reference = header.getMetaDataLine("reference");
        vs.setReferenceSetId(reference == null ? "unknown" : reference.getValue());

        Genotype2CallSet gtConverter = new Genotype2CallSet();
        for (String genotypeSample : header.getGenotypeSamples()) {
            CallSet cs = gtConverter.forward(genotypeSample);
            cs.getVariantSetIds().add(vs.getId());
            // it's OK if there are duplicate sample names from different headers since the
            // only information we require for conversion is the name itself so there's no
            // scope for conflict
            variantConverterContext.getCallSetMap().put(cs.getName(), cs);
        }//w  w w . j a v  a  2 s. c  o  m
    }
    converter.setContext(variantConverterContext);
}

From source file:com.uuweaver.ucore.amqp.core.Message.java

private String getBodyContentAsString() {
    if (body == null) {
        return null;
    }/* ww  w  .  java  2s . c  om*/
    try {
        String contentType = (messageProperties != null) ? messageProperties.getContentType() : null;
        if (MessageProperties.CONTENT_TYPE_SERIALIZED_OBJECT.equals(contentType)) {
            return SerializationUtils.deserialize(body).toString();
        }
        if (MessageProperties.CONTENT_TYPE_TEXT_PLAIN.equals(contentType)) {
            return new String(body, ENCODING);
        }
        if (MessageProperties.CONTENT_TYPE_JSON.equals(contentType)) {
            return new String(body, ENCODING);
        }
    } catch (Exception e) {
        // ignore
    }
    return body.toString() + "(byte[" + body.length + "])"; // Comes out as '[B@....b' (so harmless)
}