org.apache.commons.io.input.ClassLoaderObjectInputStream Java Examples
The following examples show how to use
org.apache.commons.io.input.ClassLoaderObjectInputStream.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Utils.java From jstorm with Apache License 2.0 | 6 votes |
/** * Deserialized with ClassLoader */ public static Object javaDeserializeWithCL(byte[] serialized, URLClassLoader loader) { try { ByteArrayInputStream bis = new ByteArrayInputStream(serialized); Object ret; if (loader != null) { ClassLoaderObjectInputStream cis = new ClassLoaderObjectInputStream(loader, bis); ret = cis.readObject(); cis.close(); } else { ObjectInputStream ois = new ObjectInputStream(bis); ret = ois.readObject(); ois.close(); } return ret; } catch (IOException | ClassNotFoundException ioe) { throw new RuntimeException(ioe); } }
Example #2
Source File: ObjectDeserialization.java From Android_Code_Arbiter with GNU Lesser General Public License v3.0 | 5 votes |
public UserEntity deserializeObjectWithInheritance(InputStream receivedFile) throws IOException, ClassNotFoundException { ClassLoaderObjectInputStream in = new ClassLoaderObjectInputStream(getClass().getClassLoader(), receivedFile); try { return (UserEntity) in.readObject(); } finally { in.close(); } }
Example #3
Source File: SerializationUtil.java From streams with Apache License 2.0 | 5 votes |
/** * deserialize byte array as Object. * * <p></p> * BORROwED FROM APACHE STORM PROJECT * * @param serialized byte[] * @return Object */ public static Object deserialize(byte[] serialized) { try { ByteArrayInputStream bis = new ByteArrayInputStream(serialized); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ObjectInputStream ois = new ClassLoaderObjectInputStream(classLoader, bis); Object ret = ois.readObject(); ois.close(); return ret; } catch (IOException | ClassNotFoundException ioe) { throw new RuntimeException(ioe); } }
Example #4
Source File: VoidMessage.java From nd4j with Apache License 2.0 | 5 votes |
static <T extends VoidMessage> T fromBytes(byte[] array) { try { ObjectInputStream in = new ClassLoaderObjectInputStream(Thread.currentThread().getContextClassLoader(), new ByteArrayInputStream(array)); T result = (T) in.readObject(); return result; } catch (Exception e) { throw new RuntimeException(e); } //return SerializationUtils.deserialize(array); }
Example #5
Source File: VoidMessage.java From deeplearning4j with Apache License 2.0 | 5 votes |
static <T extends VoidMessage> T fromBytes(byte[] array) { try { ObjectInputStream in = new ClassLoaderObjectInputStream(Thread.currentThread().getContextClassLoader(), new ByteArrayInputStream(array)); T result = (T) in.readObject(); return result; } catch (Exception e) { throw new RuntimeException(e); } //return SerializationUtils.deserialize(array); }
Example #6
Source File: SerializableSerializer.java From jstorm with Apache License 2.0 | 5 votes |
@Override public Object read(Kryo kryo, Input input, Class c) { int len = input.readInt(); byte[] ser = new byte[len]; input.readBytes(ser); ByteArrayInputStream bis = new ByteArrayInputStream(ser); try { ClassLoaderObjectInputStream ois = new ClassLoaderObjectInputStream(kryo.getClassLoader(), bis); return ois.readObject(); } catch (Exception e) { throw new RuntimeException(e); } }
Example #7
Source File: LogicalPlan.java From Bats with Apache License 2.0 | 4 votes |
public static LogicalPlan read(InputStream is) throws IOException, ClassNotFoundException { return (LogicalPlan)new ClassLoaderObjectInputStream(Thread.currentThread().getContextClassLoader(), is).readObject(); }
Example #8
Source File: LogicalPlan.java From attic-apex-core with Apache License 2.0 | 4 votes |
public static LogicalPlan read(InputStream is) throws IOException, ClassNotFoundException { return (LogicalPlan)new ClassLoaderObjectInputStream(Thread.currentThread().getContextClassLoader(), is).readObject(); }