Search in sources :

Example 1 with ArtifactClassLoaderObjectInputStream

use of org.mule.runtime.module.artifact.api.serializer.ArtifactClassLoaderObjectInputStream in project mule by mulesoft.

the class CustomJavaSerializationProtocol method doDeserialize.

/**
 * {@inheritDoc}
 */
@Override
protected <T> T doDeserialize(InputStream inputStream, ClassLoader classLoader) throws Exception {
    checkArgument(inputStream != null, "Cannot deserialize a null stream");
    checkArgument(classLoader != null, "Cannot deserialize with a null classloader");
    try (ObjectInputStream in = new ArtifactClassLoaderObjectInputStream(classLoaderRepository, inputStream)) {
        Object obj = in.readObject();
        return (T) obj;
    } catch (Exception ex) {
        throw new SerializationException("Cannot deserialize object", ex);
    }
}
Also used : SerializationException(org.mule.runtime.api.serialization.SerializationException) ArtifactClassLoaderObjectInputStream(org.mule.runtime.module.artifact.api.serializer.ArtifactClassLoaderObjectInputStream) IOException(java.io.IOException) SerializationException(org.mule.runtime.api.serialization.SerializationException) ObjectInputStream(java.io.ObjectInputStream) ArtifactClassLoaderObjectInputStream(org.mule.runtime.module.artifact.api.serializer.ArtifactClassLoaderObjectInputStream)

Aggregations

IOException (java.io.IOException)1 ObjectInputStream (java.io.ObjectInputStream)1 SerializationException (org.mule.runtime.api.serialization.SerializationException)1 ArtifactClassLoaderObjectInputStream (org.mule.runtime.module.artifact.api.serializer.ArtifactClassLoaderObjectInputStream)1