use of org.apache.camel.util.CamelObjectInputStream in project camel by apache.
the class HttpHelper method deserializeJavaObjectFromStream.
/**
* Deserializes the input stream to a Java object
*
* @param is input stream for the Java object
* @param context the camel context which could help us to apply the customer classloader
* @return the java object, or <tt>null</tt> if input stream was <tt>null</tt>
* @throws ClassNotFoundException is thrown if class not found
* @throws IOException can be thrown
*/
public static Object deserializeJavaObjectFromStream(InputStream is, CamelContext context) throws ClassNotFoundException, IOException {
if (is == null) {
return null;
}
Object answer = null;
ObjectInputStream ois = new CamelObjectInputStream(is, context);
try {
answer = ois.readObject();
} finally {
IOHelper.close(ois);
}
return answer;
}
Aggregations