POAObjectKeyTemplate.java revision 672:2bb058ce572e
1321807Sbapt/*
2321807Sbapt * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
3321807Sbapt * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4321807Sbapt *
5321807Sbapt * This code is free software; you can redistribute it and/or modify it
6321807Sbapt * under the terms of the GNU General Public License version 2 only, as
7321807Sbapt * published by the Free Software Foundation.  Oracle designates this
8321807Sbapt * particular file as subject to the "Classpath" exception as provided
9321807Sbapt * by Oracle in the LICENSE file that accompanied this code.
10321807Sbapt *
11321807Sbapt * This code is distributed in the hope that it will be useful, but WITHOUT
12321807Sbapt * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13321807Sbapt * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14321807Sbapt * version 2 for more details (a copy is included in the LICENSE file that
15321807Sbapt * accompanied this code).
16321807Sbapt *
17321807Sbapt * You should have received a copy of the GNU General Public License version
18321807Sbapt * 2 along with this work; if not, write to the Free Software Foundation,
19321807Sbapt * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20321807Sbapt *
21321807Sbapt * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22321807Sbapt * or visit www.oracle.com if you need additional information or have any
23321807Sbapt * questions.
24321807Sbapt */
25321807Sbapt
26321807Sbaptpackage com.sun.corba.se.impl.ior;
27321807Sbapt
28321807Sbaptimport java.util.Iterator ;
29321807Sbapt
30321807Sbaptimport org.omg.CORBA_2_3.portable.InputStream ;
31321807Sbaptimport org.omg.CORBA_2_3.portable.OutputStream ;
32321807Sbapt
33321807Sbaptimport org.omg.CORBA.OctetSeqHolder ;
34321807Sbapt
35321807Sbaptimport com.sun.corba.se.spi.activation.POANameHelper ;
36321807Sbapt
37321807Sbaptimport com.sun.corba.se.spi.orb.ORB ;
38321807Sbaptimport com.sun.corba.se.spi.orb.ORBVersion ;
39321807Sbaptimport com.sun.corba.se.spi.orb.ORBVersionFactory ;
40321807Sbapt
41321807Sbaptimport com.sun.corba.se.spi.ior.ObjectAdapterId ;
42321807Sbapt
43321807Sbaptimport com.sun.corba.se.impl.ior.ObjectKeyFactoryImpl ;
44321807Sbapt
45321807Sbaptpublic final class POAObjectKeyTemplate extends NewObjectKeyTemplateBase
46321807Sbapt{
47321807Sbapt    /** This constructor reads the template ONLY from the stream.
48321807Sbapt    */
49321807Sbapt    public POAObjectKeyTemplate( ORB orb, int magic, int scid, InputStream is )
50321807Sbapt    {
51321807Sbapt        super( orb, magic, scid, is.read_long(), is.read_string(),
52321807Sbapt            new ObjectAdapterIdArray( POANameHelper.read( is ) ) ) ;
53321807Sbapt
54321807Sbapt        setORBVersion( is ) ;
55321807Sbapt    }
56321807Sbapt
57321807Sbapt    /** This constructor reads a complete ObjectKey (template and Id)
58321807Sbapt    * from the stream.
59321807Sbapt    */
60321807Sbapt    public POAObjectKeyTemplate( ORB orb, int magic, int scid, InputStream is,
61321807Sbapt        OctetSeqHolder osh )
62321807Sbapt    {
63321807Sbapt        super( orb, magic, scid, is.read_long(), is.read_string(),
64321807Sbapt            new ObjectAdapterIdArray( POANameHelper.read( is ) ) ) ;
65321807Sbapt
66321807Sbapt        osh.value = readObjectKey( is ) ;
67321807Sbapt
68321807Sbapt        setORBVersion( is ) ;
69321807Sbapt    }
70321807Sbapt
71321807Sbapt    public POAObjectKeyTemplate( ORB orb, int scid, int serverid, String orbid,
72321807Sbapt        ObjectAdapterId objectAdapterId)
73321807Sbapt    {
74321807Sbapt        super( orb, ObjectKeyFactoryImpl.JAVAMAGIC_NEWER, scid, serverid, orbid,
75321807Sbapt            objectAdapterId ) ;
76321807Sbapt
77321807Sbapt        setORBVersion( ORBVersionFactory.getORBVersion() ) ;
78321807Sbapt    }
79321807Sbapt
80321807Sbapt    public void writeTemplate(OutputStream os)
81321807Sbapt    {
82321807Sbapt        os.write_long( getMagic() ) ;
83321807Sbapt        os.write_long( getSubcontractId() ) ;
84321807Sbapt        os.write_long( getServerId() ) ;
85321807Sbapt        os.write_string( getORBId() ) ;
86321807Sbapt        getObjectAdapterId().write( os ) ;
87321807Sbapt    }
88321807Sbapt}
89321807Sbapt