FileDocCategorySizeDatePackage
IOUtils.javaAPI DocGlassfish v2 API5355Fri May 04 22:32:56 BST 2007com.sun.ejb.base.io

IOUtils

public class IOUtils extends Object

Fields Summary
private static final Logger
_ejbLogger
private static com.sun.ejb.spi.io.J2EEObjectStreamFactory
_streamFactory
Constructors Summary
Methods Summary
public static java.io.ObjectInputStreamcreateObjectInputStream(java.io.InputStream is, boolean resolveObject, java.lang.ClassLoader loader)

	return _streamFactory.createObjectInputStream(is, resolveObject, loader);
    
public static java.io.ObjectOutputStreamcreateObjectOutputStream(java.io.OutputStream os, boolean replaceObject, com.sun.ejb.spi.io.NonSerializableObjectHandler handler)

	return _streamFactory.createObjectOutputStream(os, replaceObject,
		handler);
    
public static final java.lang.ObjectdeserializeObject(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 voidsetJ2EEObjectStreamFactory(com.sun.ejb.spi.io.J2EEObjectStreamFactory factory)


        
              
    
        _streamFactory = factory;