Example usage for org.apache.commons.lang SerializationException SerializationException

List of usage examples for org.apache.commons.lang SerializationException SerializationException

Introduction

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

Prototype

public SerializationException(String msg, Throwable cause) 

Source Link

Document

Constructs a new SerializationException with specified detail message and nested Throwable.

Usage

From source file:com.hundsun.jresplus.web.nosession.cookie.HessianZipSerializer.java

public static byte[] encode(Object object) throws SerializationException {
    if (object == null) {
        return null;
    }//from  w ww  . j  ava2  s. c  o m
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    Deflater def = new Deflater(Deflater.BEST_COMPRESSION, false);
    DeflaterOutputStream dos = new DeflaterOutputStream(baos, def);

    Hessian2Output ho = null;

    try {
        ho = new Hessian2Output(dos);
        ho.writeObject(object);
    } catch (Exception e) {
        throw new SerializationException("Failed to encode date", e);
    } finally {
        if (ho != null) {
            try {
                ho.close();
            } catch (IOException e) {
            }
        }
        try {
            dos.close();
        } catch (IOException e) {
        }

        def.end();
    }

    return baos.toByteArray();
}

From source file:com.hundsun.jresplus.web.nosession.cookie.HessianZipSerializer.java

public static Object decode(byte[] encodedValue) throws SerializationException {
    ByteArrayInputStream bais = new ByteArrayInputStream(encodedValue);
    Inflater inf = new Inflater(false);
    InflaterInputStream iis = new InflaterInputStream(bais, inf);
    Hessian2Input hi = null;//from  w w  w.j  a  v  a2  s  . c  om
    try {
        hi = new Hessian2Input(iis);
        return hi.readObject();
    } catch (Exception e) {
        throw new SerializationException("Failed to parse data", e);
    } finally {
        if (hi != null) {
            try {
                hi.close();
            } catch (IOException e) {
            }
        }
        try {
            iis.close();
        } catch (IOException e) {
        }
        inf.end();
    }
}

From source file:com.moz.fiji.mapreduce.kvstore.lib.InMemoryMapKeyValueStore.java

@Override
public void storeToConf(KeyValueStoreConfiguration conf) throws IOException {
    try {//from   ww w  .  j  a  va  2 s  . c  o  m
        conf.set(CONF_MAP, Base64.encodeBase64String(SerializationUtils.serialize(mMap)));
    } catch (SerializationException se) {
        // Throw a more helpful error message for the user.
        throw new SerializationException(
                "InMemoryKeyValueStore requires that its keys and values are Serializable", se);
    }
}

From source file:org.apache.streams.data.MoreoverXmlActivitySerializer.java

private Article deserializeMoreover(String serialized) {
    try {/* w ww.  j av  a 2  s  .  c o  m*/
        Unmarshaller unmarshaller = articleContext.createUnmarshaller();
        return (Article) unmarshaller.unmarshal(new StringReader(serialized));
    } catch (JAXBException e) {
        throw new SerializationException("Unable to deserialize Moreover data", e);
    }
}

From source file:org.apache.streams.data.MoreoverXmlActivitySerializer.java

private ArticlesResponse deserializeMoreoverResponse(String serialized) {
    try {//www  .  j  av a  2 s.  c  o m
        Unmarshaller unmarshaller = articlesContext.createUnmarshaller();
        return ((JAXBElement<ArticlesResponse>) unmarshaller.unmarshal(new StringReader(serialized)))
                .getValue();
    } catch (JAXBException e) {
        throw new SerializationException("Unable to deserialize Moreover data", e);
    }
}

From source file:org.apache.streams.moreover.MoreoverXmlActivitySerializer.java

private Article deserializeMoreover(String serialized) {
    try {//from ww w.  j ava  2  s  .co m
        Unmarshaller unmarshaller = articleContext.createUnmarshaller();
        return (Article) unmarshaller.unmarshal(new StringReader(serialized));
    } catch (JAXBException ex) {
        throw new SerializationException("Unable to deserialize Moreover data", ex);
    }
}

From source file:org.apache.streams.moreover.MoreoverXmlActivitySerializer.java

private ArticlesResponse deserializeMoreoverResponse(String serialized) {
    try {/*w w w .  ja  v a  2s .c o  m*/
        Unmarshaller unmarshaller = articlesContext.createUnmarshaller();
        return ((JAXBElement<ArticlesResponse>) unmarshaller.unmarshal(new StringReader(serialized)))
                .getValue();
    } catch (JAXBException ex) {
        throw new SerializationException("Unable to deserialize Moreover data", ex);
    }
}