1 /* 2 * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.corba.se.impl.ior; 27 28 import org.omg.CORBA.OctetSeqHolder ; 29 30 import org.omg.CORBA_2_3.portable.InputStream ; 31 import org.omg.CORBA_2_3.portable.OutputStream ; 32 33 import com.sun.corba.se.spi.ior.ObjectId ; 34 import com.sun.corba.se.spi.ior.ObjectKeyFactory ; 35 36 import com.sun.corba.se.spi.orb.ORB ; 37 import com.sun.corba.se.spi.orb.ORBVersion ; 38 import com.sun.corba.se.spi.orb.ORBVersionFactory ; 39 40 import com.sun.corba.se.impl.ior.ObjectKeyFactoryImpl ; 41 42 import com.sun.corba.se.impl.encoding.CDRInputStream ; 43 44 /** 45 * Handles object keys created by JDK ORBs from before JDK 1.4.0. 46 */ 47 public final class OldJIDLObjectKeyTemplate extends OldObjectKeyTemplateBase 48 { 49 /** 50 * JDK 1.3.1 FCS did not include a version byte at the end of 51 * its object keys. JDK 1.3.1_01 included the byte with the 52 * value 1. Anything below 1 is considered an invalid value. 53 */ 54 public static final byte NULL_PATCH_VERSION = 0; 55 56 byte patchVersion = OldJIDLObjectKeyTemplate.NULL_PATCH_VERSION; 57 58 public OldJIDLObjectKeyTemplate( ORB orb, int magic, int scid, 59 InputStream is, OctetSeqHolder osh ) 60 { 61 this( orb, magic, scid, is ); 62 63 osh.value = readObjectKey( is ) ; 64 65 /** 66 * Beginning with JDK 1.3.1_01, a byte was placed at the end of 67 * the object key with a value indicating the patch version. 68 * JDK 1.3.1_01 had the value 1. If other patches are necessary 69 * which involve ORB versioning changes, they should increment 70 * the patch version. 71 * 72 * Note that if we see a value greater than 1 in this code, we 73 * will treat it as if we're talking to the most recent ORB version. 74 * 75 * WARNING: This code is sensitive to changes in CDRInputStream 76 * getPosition. It assumes that the CDRInputStream is an 77 * encapsulation whose position can be compared to the object 78 * key array length. 79 */ 80 if (magic == ObjectKeyFactoryImpl.JAVAMAGIC_NEW && 81 osh.value.length > ((CDRInputStream)is).getPosition()) { 82 83 patchVersion = is.read_octet(); 84 85 if (patchVersion == ObjectKeyFactoryImpl.JDK1_3_1_01_PATCH_LEVEL) 86 setORBVersion(ORBVersionFactory.getJDK1_3_1_01()); 87 else if (patchVersion > ObjectKeyFactoryImpl.JDK1_3_1_01_PATCH_LEVEL) 88 setORBVersion(ORBVersionFactory.getORBVersion()); 89 else 90 throw wrapper.invalidJdk131PatchLevel( new Integer( patchVersion ) ) ; 91 } 92 } 93 94 95 public OldJIDLObjectKeyTemplate( ORB orb, int magic, int scid, int serverid) 96 { 97 super( orb, magic, scid, serverid, JIDL_ORB_ID, JIDL_OAID ) ; 98 } 99 100 public OldJIDLObjectKeyTemplate(ORB orb, int magic, int scid, InputStream is) 101 { 102 this( orb, magic, scid, is.read_long() ) ; 103 } 104 105 protected void writeTemplate( OutputStream os ) 106 { 107 os.write_long( getMagic() ) ; 108 os.write_long( getSubcontractId() ) ; 109 os.write_long( getServerId() ) ; 110 } 111 112 public void write(ObjectId objectId, OutputStream os) 113 { 114 super.write(objectId, os); 115 116 if (patchVersion != OldJIDLObjectKeyTemplate.NULL_PATCH_VERSION) 117 os.write_octet( patchVersion ) ; 118 } 119 }