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

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

Introduction

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

Prototype

public SerializationException(final String msg, final Throwable cause) 

Source Link

Document

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

Usage

From source file:com.tdclighthouse.prototype.utils.JacksonSerializer.java

@Override
public void serialize(Object source, OutputStream outputStream) {
    try {/*from  ww  w  .j  a va 2  s. com*/
        objectMapper.writeValue(outputStream, source);
    } catch (Exception e) {
        throw new SerializationException(e.getMessage(), e);
    }
}

From source file:com.link_intersystems.lang.ref.AbstractSerializableReference.java

private void writeObject(ObjectOutputStream out) throws IOException {
    if (transientReferent != null) {
        try {//from w  w  w.  java 2s.c  om
            restoreInfo = serialize(transientReferent);
        } catch (SerializationException e) {
            throw e;
        } catch (Exception e) {
            Class<?> transientReferentClass = transientReferent.getClass();
            throw new SerializationException("Unable to serialize object of " + transientReferentClass, e);
        }
    }
    out.defaultWriteObject();
}

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

@Override
protected Constructor<?> deserialize(Serializable restoreInfo) {
    ConstructorSerializationInfo constructorSerializationInfo = (ConstructorSerializationInfo) restoreInfo;
    Class<?> declaringClass = constructorSerializationInfo.getDeclaringClass();
    Class<?>[] parameterTypes = constructorSerializationInfo.getParameterTypes();
    String methodName = constructorSerializationInfo.getMemberName();
    try {/*from  w  w w  .j  a va 2s.co m*/
        Constructor<?> constructor = getConstructor(declaringClass, parameterTypes);
        return constructor;
    } catch (NoSuchMethodException e) {
        throw new SerializationException("Unable to restore method " + methodName + " declared at "
                + declaringClass + " with parameter types " + Arrays.asList(parameterTypes), e);
    }
}

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

@Override
protected Method deserialize(Serializable restoreInfo) {
    MethodSerializationInfo methodSerializationInfo = (MethodSerializationInfo) restoreInfo;
    Class<?> declaringClass = methodSerializationInfo.getDeclaringClass();
    String methodName = methodSerializationInfo.getMemberName();
    Class<?>[] parameterTypes = methodSerializationInfo.getParameterTypes();
    try {//from  w  w  w. j  av a  2  s. c  om
        Method method = getMethod(declaringClass, methodName, parameterTypes);
        return method;
    } catch (NoSuchMethodException e) {
        throw new SerializationException("Unable to restore method " + methodName + " declared at "
                + declaringClass + " with parameter types " + Arrays.asList(parameterTypes), e);
    }
}

From source file:com.link_intersystems.lang.ref.AbstractSerializableReference.java

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();// w w  w  . j  av  a  2s. c  om
    if (restoreInfo != null) {
        try {
            transientReferent = deserialize(restoreInfo);
        } catch (SerializationException e) {
            throw e;
        } catch (Exception e) {
            throw new SerializationException("Unable to deserialize object reference", e);
        }
    }
}

From source file:org.dice_research.topicmodeling.io.stream.DocumentSupplierSerializer.java

public int serialize(DocumentSupplier supplier, File file) throws SerializationException {
    int documentCount = 0;
    FileOutputStream fout = null;
    DataOutputStream dout = null;
    try {/*from   w  w  w .ja  va  2s .  co  m*/
        fout = new FileOutputStream(file);
        dout = new DataOutputStream(fout);
        Document document = supplier.getNextDocument();
        while (document != null) {
            writeDocument(dout, document);
            ++documentCount;
            document = supplier.getNextDocument();
        }
    } catch (Exception e) {
        throw new SerializationException("Got Exception while serializing documents.", e);
    } finally {
        if (dout != null) {
            try {
                dout.close();
            } catch (Exception e) {
            }
        }
        if (fout != null) {
            try {
                fout.close();
            } catch (Exception e) {
            }
        }
    }
    return documentCount;
}