public void readExternal ( ObjectInput in ) throws IOException , ClassNotFoundException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) Tr . entry ( tc , "readExternal" ) ; try { // read magic short magic = in . readShort ( ) ; short majorVersion = in . readShort ( ) ; short minorVersion = in . readShort ( ) ; if ( ! ( magic == EXTERNAL_MAGIC ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "Magic Number absent, trying default Java deserialization" ) ; throw new IOException ( "Bean ID externalized stream format error" ) ; } else if ( ! ( majorVersion == MAJOR_VERSION ) || ! ( minorVersion == MINOR_VERSION ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , "BeanID Version mismatch" , new Object [ ] { new Short ( majorVersion ) , new Short ( minorVersion ) } ) ; throw new IOException ( "BeanID version mismatch" ) ; } // read the interface type (HOME or REMOTE) byte ifType = in . readByte ( ) ; if ( ifType == IF_HOME ) { _isHome = true ; } else { _isHome = false ; } //89554 // read the bean name byte [ ] j2eeNameBytes = readExternalJ2EEName ( in ) ; // read the serialized primary key pkey = readExternalPKey ( in , j2eeNameBytes ) ; // TAKE CARE! We don't have a container reference so can't // restore transient fields. // This is ok as long // as rest of container restores BeanIds using the deserialise // method. Since readExternal // is a new addition // this can be no different to the behaviour that would have been // observed when using // the default serialization. } finally { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) Tr . exit ( tc , "readExternal" ) ; } }
readExternal is called by Java serialization when readObject is called on an ObjectInputStream for an object of class BeanId . It must read the values in the same sequence and with the same types as written by writeExternal .