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

J2EEObjectStreamFactoryImpl

public class J2EEObjectStreamFactoryImpl extends Object implements com.sun.ejb.spi.io.J2EEObjectStreamFactory
A Factory class for creating EJBObject input/output Stream
author
Mahesh Kannan

Fields Summary
private static final Logger
_ejbLogger
Constructors Summary
public J2EEObjectStreamFactoryImpl()


      
    
Methods Summary
public java.io.ObjectInputStreamcreateObjectInputStream(java.io.InputStream is, boolean resolveObject, java.lang.ClassLoader loader)
Obtain an ObjectInputStream that allows de-serialization of a graph of objects.

throws
IOException when the de-serialziation fails
return
an ObjectInputStream that can be used to deserialize objects

        ObjectInputStream ois = null;
        if ( loader != null ) {
            // Need privileged block here because EJBObjectInputStream
            // does enableResolveObject
            if(System.getSecurityManager() == null) {
                ois = new EJBObjectInputStream(is, loader, resolveObject);
            } else {
                try {
                    ois = (ObjectInputStream)AccessController.doPrivileged(
                            new PrivilegedExceptionAction() {
                        public java.lang.Object run()
                        throws Exception {
                            return new EJBObjectInputStream(
                                    is, loader, resolveObject);
                        }
                    });
                } catch ( PrivilegedActionException ex ) {
                    throw (IOException) ex.getException();
                }
            }
        } else {
            ois = new ObjectInputStream(is);
        }

        return ois;
    
public java.io.ObjectOutputStreamcreateObjectOutputStream(java.io.OutputStream os, boolean replaceObject, com.sun.ejb.spi.io.NonSerializableObjectHandler handler)
Obtain an ObjectOutputStream that allows serialization of a graph of objects. The objects can be plain Serializable objects or can be converted into Serializable objects using the handler

throws
IOException when the serialziation fails
return
an ObjectOutputStream that can be used to serialize objects

        // Need privileged block here because EJBObjectOutputStream
        // does enableReplaceObject
        ObjectOutputStream oos = null;
        if(System.getSecurityManager() == null) {
            oos = new EJBObjectOutputStream(os, replaceObject, handler);
        } else {
            try {
                oos = (ObjectOutputStream)AccessController.doPrivileged(
                        new PrivilegedExceptionAction() {
                    public java.lang.Object run()
                    throws Exception {
                        return new EJBObjectOutputStream(
                                os, replaceObject, handler);
                    }
                });
            } catch ( PrivilegedActionException ex ) {
                throw (IOException) ex.getException();
            }
        }
        return oos;