IOUtilspublic class IOUtils extends Object
Fields Summary |
---|
private static final Logger | _ejbLogger | private static com.sun.ejb.spi.io.J2EEObjectStreamFactory | _streamFactory |
Methods Summary |
---|
public static java.io.ObjectInputStream | createObjectInputStream(java.io.InputStream is, boolean resolveObject, java.lang.ClassLoader loader)
return _streamFactory.createObjectInputStream(is, resolveObject, loader);
| public static java.io.ObjectOutputStream | createObjectOutputStream(java.io.OutputStream os, boolean replaceObject, com.sun.ejb.spi.io.NonSerializableObjectHandler handler)
return _streamFactory.createObjectOutputStream(os, replaceObject,
handler);
| public static final java.lang.Object | deserializeObject(byte[] data, boolean resolveObject, java.lang.ClassLoader classLoader)
Object obj = null;
ByteArrayInputStream bis = null;
ObjectInputStream ois = null;
try {
bis = new ByteArrayInputStream(data);
ois = _streamFactory.createObjectInputStream(bis, resolveObject,
classLoader);
obj = ois.readObject();
} catch (Exception ex) {
_ejbLogger.log(Level.FINE, "Error during deserialization", ex);
throw ex;
} finally {
try { ois.close(); } catch (Exception ex) {
_ejbLogger.log(Level.FINEST, "Error during ois.close()", ex);
}
try { bis.close(); } catch (Exception ex) {
_ejbLogger.log(Level.FINEST, "Error during bis.close()", ex);
}
}
return obj;
| public static final byte[] | serializeObject(java.lang.Object obj, boolean replaceObject)
byte[] data = null;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = null;
try {
oos = _streamFactory.createObjectOutputStream(
bos, replaceObject,
new NonSerializableObjectHandler() {
public Object handleNonSerializableObject(Object obj) {
return obj;
}
});
oos.writeObject(obj);
oos.flush();
data = bos.toByteArray();
} catch (java.io.NotSerializableException notSerEx) {
throw notSerEx;
} catch (Exception th) {
IOException ioEx = new IOException(th.toString());
ioEx.initCause(th);
throw ioEx;
} finally {
if (oos != null) {
try { oos.close(); } catch (Exception ex) {}
}
try { bos.close(); } catch (Exception ex) {}
}
return data;
| public static final void | setJ2EEObjectStreamFactory(com.sun.ejb.spi.io.J2EEObjectStreamFactory factory)
_streamFactory = factory;
|
|