KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > copyobject > ORBStreamObjectCopierImpl


1 /*
2  * @(#)ORBStreamObjectCopierImpl.java 1.8 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.corba.se.impl.copyobject ;
9
10 import java.util.logging.Level JavaDoc;
11 import java.util.logging.Logger JavaDoc;
12
13 import java.io.Serializable JavaDoc;
14 import java.rmi.Remote JavaDoc;
15 import java.rmi.MarshalException JavaDoc;
16
17 import org.omg.CORBA_2_3.portable.InputStream JavaDoc;
18 import org.omg.CORBA_2_3.portable.OutputStream JavaDoc;
19 import org.omg.CORBA.ORB JavaDoc ;
20
21 import com.sun.corba.se.spi.copyobject.ObjectCopier ;
22 import com.sun.corba.se.impl.util.Utility;
23
24 public class ORBStreamObjectCopierImpl implements ObjectCopier {
25
26     public ORBStreamObjectCopierImpl( ORB JavaDoc orb )
27     {
28     this.orb = orb ;
29     }
30
31     public Object JavaDoc copy(Object JavaDoc obj) {
32     if (obj instanceof Remote JavaDoc) {
33             // Yes, so make sure it is connected and converted
34
// to a stub (if needed)...
35
return Utility.autoConnect(obj,orb,true);
36         }
37
38     OutputStream JavaDoc out = (OutputStream JavaDoc)orb.create_output_stream();
39     out.write_value((Serializable JavaDoc)obj);
40     InputStream JavaDoc in = (InputStream JavaDoc)out.create_input_stream();
41     return in.read_value();
42     }
43
44     private ORB JavaDoc orb;
45 }
46
Popular Tags