FileDocCategorySizeDatePackage
JavaStreamObjectCopierImpl.javaAPI DocJava SE 5 API1596Fri Aug 26 14:54:18 BST 2005com.sun.corba.se.impl.copyobject

JavaStreamObjectCopierImpl

public class JavaStreamObjectCopierImpl extends Object implements com.sun.corba.se.spi.copyobject.ObjectCopier

Fields Summary
private org.omg.CORBA.ORB
orb
Constructors Summary
public JavaStreamObjectCopierImpl(org.omg.CORBA.ORB orb)

	this.orb = orb ;
    
Methods Summary
public java.lang.Objectcopy(java.lang.Object obj)

	if (obj instanceof Remote) {
            // Yes, so make sure it is connected and converted
            // to a stub (if needed)...
            return Utility.autoConnect(obj,orb,true);
        }

	try {
	    ByteArrayOutputStream os = new ByteArrayOutputStream( 10000 ) ;
	    ObjectOutputStream oos = new ObjectOutputStream( os ) ;
	    oos.writeObject( obj ) ;

	    byte[] arr = os.toByteArray() ;
	    InputStream is = new ByteArrayInputStream( arr ) ;
	    ObjectInputStream ois = new ObjectInputStream( is ) ;

	    return ois.readObject();
	} catch (Exception exc) {
	    System.out.println( "Failed with exception:" + exc ) ;
	    return null ;
	}