NewObjectKeyTemplateBase.java revision 608:7e06bf1dcb09
1200483Srwatson/*
2200483Srwatson * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
3200483Srwatson * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4200483Srwatson *
5200483Srwatson * This code is free software; you can redistribute it and/or modify it
6200483Srwatson * under the terms of the GNU General Public License version 2 only, as
7200483Srwatson * published by the Free Software Foundation.  Oracle designates this
8200483Srwatson * particular file as subject to the "Classpath" exception as provided
9200483Srwatson * by Oracle in the LICENSE file that accompanied this code.
10200483Srwatson *
11200483Srwatson * This code is distributed in the hope that it will be useful, but WITHOUT
12200483Srwatson * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13200483Srwatson * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14200483Srwatson * version 2 for more details (a copy is included in the LICENSE file that
15200483Srwatson * accompanied this code).
16200483Srwatson *
17200483Srwatson * You should have received a copy of the GNU General Public License version
18200483Srwatson * 2 along with this work; if not, write to the Free Software Foundation,
19200483Srwatson * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20200483Srwatson *
21200483Srwatson * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22200483Srwatson * or visit www.oracle.com if you need additional information or have any
23200483Srwatson * questions.
24200483Srwatson */
25200483Srwatson
26200483Srwatsonpackage com.sun.corba.se.impl.ior;
27200483Srwatson
28200483Srwatsonimport java.io.IOException ;
29200483Srwatson
30200483Srwatsonimport org.omg.CORBA_2_3.portable.InputStream ;
31200483Srwatsonimport org.omg.CORBA_2_3.portable.OutputStream ;
32200483Srwatson
33200483Srwatsonimport com.sun.corba.se.spi.ior.ObjectId ;
34200483Srwatsonimport com.sun.corba.se.spi.ior.ObjectAdapterId ;
35200483Srwatsonimport com.sun.corba.se.spi.ior.ObjectKeyFactory ;
36200483Srwatson
37200483Srwatsonimport com.sun.corba.se.spi.ior.iiop.GIOPVersion ;
38200483Srwatson
39200483Srwatsonimport com.sun.corba.se.spi.orb.ORB ;
40200483Srwatsonimport com.sun.corba.se.spi.orb.ORBVersion ;
41200483Srwatsonimport com.sun.corba.se.spi.orb.ORBVersionFactory ;
42200483Srwatson
43200483Srwatsonimport com.sun.corba.se.impl.ior.ObjectKeyFactoryImpl ;
44200483Srwatson
45200483Srwatsonpublic abstract class NewObjectKeyTemplateBase extends ObjectKeyTemplateBase
46200483Srwatson{
47200483Srwatson    public NewObjectKeyTemplateBase( ORB orb, int magic, int scid, int serverid,
48200483Srwatson        String orbid, ObjectAdapterId oaid )
49200483Srwatson    {
50200483Srwatson        super( orb, magic, scid, serverid, orbid, oaid ) ;
51200483Srwatson        // subclass must set the version, since we don't have the object key here.
52200483Srwatson
53200483Srwatson        if (magic != ObjectKeyFactoryImpl.JAVAMAGIC_NEWER)
54200483Srwatson            throw wrapper.badMagic( new Integer( magic ) ) ;
55200483Srwatson    }
56200483Srwatson
57200483Srwatson    public void write(ObjectId objectId, OutputStream os)
58200483Srwatson    {
59200483Srwatson        super.write( objectId, os ) ;
60200483Srwatson        getORBVersion().write( os ) ;
61200483Srwatson    }
62200483Srwatson
63200483Srwatson    public void write(OutputStream os)
64200483Srwatson    {
65200483Srwatson        super.write( os ) ;
66200483Srwatson        getORBVersion().write( os ) ;
67200483Srwatson    }
68200483Srwatson
69200483Srwatson    protected void setORBVersion( InputStream is )
70200483Srwatson    {
71200483Srwatson        ORBVersion version = ORBVersionFactory.create( is ) ;
72200483Srwatson        setORBVersion( version ) ;
73200483Srwatson    }
74200483Srwatson}
75200483Srwatson