KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > ior > OldPOAObjectKeyTemplate


1 /*
2  * @(#)OldPOAObjectKeyTemplate.java 1.9 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.ior;
9
10 import org.omg.CORBA.INTERNAL JavaDoc ;
11 import org.omg.CORBA.OctetSeqHolder JavaDoc ;
12
13 import org.omg.CORBA_2_3.portable.InputStream JavaDoc ;
14 import org.omg.CORBA_2_3.portable.OutputStream JavaDoc ;
15
16 import com.sun.corba.se.spi.orb.ORB ;
17 import com.sun.corba.se.spi.orb.ORBVersion ;
18 import com.sun.corba.se.spi.orb.ORBVersionFactory ;
19
20 import com.sun.corba.se.impl.ior.ObjectKeyFactoryImpl ;
21
22 /**
23  * @author Ken Cavanaugh
24  */

25 public final class OldPOAObjectKeyTemplate extends OldObjectKeyTemplateBase
26 {
27     /** This constructor reads the template ONLY from the stream
28     */

29     public OldPOAObjectKeyTemplate( ORB orb, int magic, int scid, InputStream JavaDoc is )
30     {
31     this( orb, magic, scid, is.read_long(), is.read_long(), is.read_long() ) ;
32     }
33     
34     /** This constructor reads a complete ObjectKey (template and Id)
35     * from the stream.
36     */

37     public OldPOAObjectKeyTemplate( ORB orb, int magic, int scid, InputStream JavaDoc is,
38     OctetSeqHolder JavaDoc osh )
39     {
40     this( orb, magic, scid, is ) ;
41     osh.value = readObjectKey( is ) ;
42     }
43     
44     public OldPOAObjectKeyTemplate( ORB orb, int magic, int scid, int serverid,
45     int orbid, int poaid)
46     {
47     super( orb, magic, scid, serverid,
48         Integer.toString( orbid ),
49         new ObjectAdapterIdNumber( poaid ) ) ;
50     }
51     
52     public void writeTemplate(OutputStream JavaDoc os)
53     {
54     os.write_long( getMagic() ) ;
55     os.write_long( getSubcontractId() ) ;
56     os.write_long( getServerId() ) ;
57
58     int orbid = Integer.parseInt( getORBId() ) ;
59     os.write_long( orbid ) ;
60
61     ObjectAdapterIdNumber oaid = (ObjectAdapterIdNumber)(getObjectAdapterId()) ;
62     int poaid = oaid.getOldPOAId() ;
63     os.write_long( poaid ) ;
64     }
65  
66     public ORBVersion getORBVersion()
67     {
68     if (getMagic() == ObjectKeyFactoryImpl.JAVAMAGIC_OLD)
69         return ORBVersionFactory.getOLD() ;
70     else if (getMagic() == ObjectKeyFactoryImpl.JAVAMAGIC_NEW)
71         return ORBVersionFactory.getNEW() ;
72     else
73         throw new INTERNAL JavaDoc() ;
74     }
75 }
76
77
Popular Tags