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:protocole.Request.java

public static Request unmarshall(byte[] request) {
    // TODO Auto-generated method stub
    return SerializationUtils.deserialize(request);
}

From source file:pt.ieeta.jlay.jlay.agent.DataStream.java

public MessageI getData(String id) {

    String url = GlobalSettings.getHTTPServerRootURL() + "getMessage?id=" + id;
    try {//ww w  .ja va 2  s .  c  o m
        URL obj = new URL(url);
        HttpURLConnection con = (HttpURLConnection) obj.openConnection();

        // optional default is GET
        con.setRequestMethod("GET");

        //add request header
        con.setRequestProperty("User-Agent", USER_AGENT);

        int responseCode = con.getResponseCode();
        System.out.println("\nSending 'GET' request to URL : " + url);
        System.out.println("Response Code : " + responseCode);

        BufferedInputStream in = new BufferedInputStream(con.getInputStream());

        System.out.println("connection lenght ");

        System.out.println(con.getContentLength());

        byte[] r = new byte[con.getContentLength()];
        in.read(r);

        in.close();
        System.out.println(r);
        System.out.println(r.length);
        GeneralMessage g = SerializationUtils.deserialize(r);
        return g;

    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:uk.org.lidalia.sysoutslf4j.integration.CrossClassLoaderTestUtils.java

private static Object moveToCurrentClassLoaderViaSerialization(Serializable objectFromOtherClassLoader) {
    try {/*  w ww.  j  a v a  2s  .  c  om*/
        byte[] objectAsBytes = SerializationUtils.serialize(objectFromOtherClassLoader);
        return SerializationUtils.deserialize(objectAsBytes);
    } catch (Exception e) {
        Exceptions.throwUnchecked(e);
        throw new AssertionError("Unreachable");
    }
}

From source file:uk.q3c.krail.core.guice.uiscope.UIScope.java

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();/* w  w w . j  a  v a 2s.c o  m*/
    cache = new TreeMap<>();
    @SuppressWarnings("unchecked")
    Map<UIKey, Map<GuiceKeyProxy, Serializable>> proxyMap = (Map<UIKey, Map<GuiceKeyProxy, Serializable>>) in
            .readObject();
    for (Map.Entry<UIKey, Map<GuiceKeyProxy, Serializable>> entry : proxyMap.entrySet()) {
        Map<Key<?>, Object> cacheDetail = new HashMap<Key<?>, Object>();
        cache.put(entry.getKey(), cacheDetail);
        Map<GuiceKeyProxy, Serializable> sourceDetail = entry.getValue();
        for (Map.Entry<GuiceKeyProxy, Serializable> sourceDetailEntry : sourceDetail.entrySet()) {
            Object sourceDetailValue = sourceDetailEntry.getValue();
            Key<?> guiceKey = sourceDetailEntry.getKey().getKey();
            if (sourceDetailValue instanceof GuiceKeyProxy) {
                GuiceKeyProxy proxy = (GuiceKeyProxy) sourceDetailValue;
                cacheDetail.put(guiceKey, serializationSupport.getInjector().getInstance(proxy.getKey()));
            } else {
                Object value = SerializationUtils.deserialize((byte[]) sourceDetailEntry.getValue());
                cacheDetail.put(guiceKey, value);
            }

        }
    }
}