* The Package uses PackageCompilationData to hold a reference to the generated bytecode; which must be restored before any Rules.
* A custom ObjectInputStream, able to resolve classes against the bytecode in the PackageCompilationData, is used to restore the Rules.
*/
public void readExternal(final ObjectInput stream) throws IOException,
ClassNotFoundException {
DroolsObjectInput droolsStream = null;
boolean isDrools = stream instanceof DroolsObjectInputStream;
ByteArrayInputStream bytes = null;
boolean wasDrools = stream.readBoolean();
if( wasDrools && !isDrools) {
throw new IllegalArgumentException("The knowledge base was serialized using a DroolsObjectOutputStream. A DroolsObjectInputStream is required for deserialization.");
}
if ( wasDrools ) {
droolsStream = (DroolsObjectInput) stream;
} else {
bytes = new ByteArrayInputStream( (byte[]) stream.readObject() );
droolsStream = new DroolsObjectInputStream( bytes );
}
super.readExternal( droolsStream );
this.reteooBuilder = (ReteooBuilder) droolsStream.readObject();
this.reteooBuilder.setRuleBase( this );
this.rete = (Rete) droolsStream.readObject();
if( !wasDrools ) {
droolsStream.close();
}
}