当前位置: 首页>>代码示例>>Java>>正文


Java ClassLoaderObjectInputStream类代码示例

本文整理汇总了Java中org.apache.commons.io.input.ClassLoaderObjectInputStream的典型用法代码示例。如果您正苦于以下问题:Java ClassLoaderObjectInputStream类的具体用法?Java ClassLoaderObjectInputStream怎么用?Java ClassLoaderObjectInputStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClassLoaderObjectInputStream类属于org.apache.commons.io.input包,在下文中一共展示了ClassLoaderObjectInputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserialize

import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入依赖的package包/类
public static Object deserialize(byte[] serialized, URLClassLoader loader) {
	try {
		ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
		Object ret = null;
		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 ioe) {
		throw new RuntimeException(ioe);
	} catch (ClassNotFoundException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:22,代码来源:Utils.java

示例2: javaDeserializeWithCL

import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入依赖的package包/类
/**
 * Deserialized with ClassLoader
 * 
 * @param serialized
 * @param loader
 * @return
 */
public static Object javaDeserializeWithCL(byte[] serialized, URLClassLoader loader) {
    try {
        ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
        Object ret = null;
        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 ioe) {
        throw new RuntimeException(ioe);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:28,代码来源:Utils.java

示例3: loadGameHistory

import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入依赖的package包/类
/**
 * Loads a saved game from the device's memory
 * @return saved match if found, else returns null
 */
public static PygmyGame loadGameHistory(String path) {
	File file = new File(path);
	PygmyGame game = null;

	if (file.exists()) {
		try {
			ClassLoaderObjectInputStream ois = new ClassLoaderObjectInputStream(
					PygmyLoader.getClassLoader(), new FileInputStream(file));
			game = (PygmyGame) ois.readObject();
			ois.close();
		} catch (Exception e) { 
			e.printStackTrace();
		}
	}
	return game;
}
 
开发者ID:elyas-bhy,项目名称:pygmy,代码行数:21,代码来源:Utils.java

示例4: javaDeserializeWithCL

import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:alibaba,项目名称:jstorm,代码行数:22,代码来源:Utils.java

示例5: restoreWrappedObject

import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入依赖的package包/类
private void restoreWrappedObject() {
	try {
		if(modelObject_ == null) {
			// Then this must be a new request
			installFacesListener();
			
			ByteArrayInputStream bis = new ByteArrayInputStream(serializedModel_);
			FacesContext facesContext = FacesContext.getCurrentInstance();
			ClassLoaderObjectInputStream ois = new ClassLoaderObjectInputStream(facesContext.getContextClassLoader(), bis);
			modelObject_ = (ModelObject)ois.readObject();
			ois.close();
			bis.close();
			serializedModel_ = null;
		}
	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:jesse-gallagher,项目名称:XPages-Scaffolding,代码行数:19,代码来源:ModelDataContainer.java

示例6: deserializeObjectWithInheritance

import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入依赖的package包/类
public UserEntity deserializeObjectWithInheritance(InputStream receivedFile) throws IOException, ClassNotFoundException {
    ClassLoaderObjectInputStream in = new ClassLoaderObjectInputStream(getClass().getClassLoader(), receivedFile);
    try {
        return (UserEntity) in.readObject();
    }
    finally {
        in.close();
    }
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:10,代码来源:ObjectDeserialization.java

示例7: read

import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入依赖的package包/类
@SuppressWarnings("resource")
@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);
	}
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:16,代码来源:SerializableSerializer.java

示例8: read

import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入依赖的package包/类
@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);
	}
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:15,代码来源:SerializableSerializer.java

示例9: read

import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:14,代码来源:SerializableSerializer.java

示例10: readWrite

import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
public static <T> T readWrite(T t) throws Exception {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    try {
        oos.writeObject(t);
    } finally {
        oos.close();
    }
    return (T)new ClassLoaderObjectInputStream(t.getClass().getClassLoader(), new ByteArrayInputStream(bos.toByteArray())).readObject();
}
 
开发者ID:maxifier,项目名称:mxcache,代码行数:12,代码来源:InstrumentationTestHelper.java

示例11: fromBytes

import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入依赖的package包/类
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);
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:13,代码来源:VoidMessage.java

示例12: bytesToObject

import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入依赖的package包/类
public static <T extends Serializable> T bytesToObject(final Class<T> clazz, final byte[] value) {
    if (null == value || value.length <= 0) {
        return null;
    }
    try {
        final ByteArrayInputStream bytes = new ByteArrayInputStream(value);
        final ObjectInputStream input = new ClassLoaderObjectInputStream(clazz.getClassLoader(), bytes);
        final Object instance = input.readObject();
        IOUtils.closeQuietly(input);
        return clazz.cast(instance);
    } catch (final Exception e) {
        logger.warn("Unable to deserialize value [" + value + "] of type [" + clazz + "].", e);
        return null;
    }
}
 
开发者ID:trajar,项目名称:normandra,代码行数:16,代码来源:DataUtils.java

示例13: read

import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入依赖的package包/类
public static LogicalPlan read(InputStream is) throws IOException, ClassNotFoundException
{
  return (LogicalPlan)new ClassLoaderObjectInputStream(Thread.currentThread().getContextClassLoader(), is).readObject();
}
 
开发者ID:apache,项目名称:apex-core,代码行数:5,代码来源:LogicalPlan.java

示例14: deserialize

import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入依赖的package包/类
private Object deserialize(byte[] serializedOriginal, ClassLoader targetLoader) throws ClassNotFoundException, IOException {
    ByteArrayInputStream byteStream = new ByteArrayInputStream(serializedOriginal);
    ClassLoaderObjectInputStream objectStream = new ClassLoaderObjectInputStream(targetLoader, byteStream);
    return objectStream.readObject();
}
 
开发者ID:csm,项目名称:java-sandbox,代码行数:6,代码来源:SerializationCloningStrategy.java

示例15: cloneObjectUsingClassLoader

import org.apache.commons.io.input.ClassLoaderObjectInputStream; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * @throws ClassCastException if the given <code>original</code> object is not {@link Serializable}
 * @throws SerializationException if serialization fails
 * @throws IOException if input fails during deserialization
 * @throws ClassNotFoundException if the <code>targetClassLoader</code> cannot find a required class
 */
public Object cloneObjectUsingClassLoader(Object original, ClassLoader targetClassLoader)
		throws ClassCastException, SerializationException, IOException, ClassNotFoundException {
	Assert.areNotNull(original, targetClassLoader);
	byte[] serializedOriginal = SerializationUtils.serialize((Serializable) original);
	return new ClassLoaderObjectInputStream(targetClassLoader, new ByteArrayInputStream(serializedOriginal)).readObject();
}
 
开发者ID:fmunch,项目名称:transloader,代码行数:15,代码来源:SerializationCloningStrategy.java


注:本文中的org.apache.commons.io.input.ClassLoaderObjectInputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。