}
public void writeExternal(ObjectOutput out) throws IOException {
boolean isDrools = out instanceof DroolsObjectOutputStream;
DroolsObjectOutputStream droolsStream;
ByteArrayOutputStream bytes;
if ( isDrools ) {
bytes = null;
droolsStream = (DroolsObjectOutputStream) out;
} else {
bytes = new ByteArrayOutputStream();
droolsStream = new DroolsObjectOutputStream( bytes );
}
droolsStream.writeObject( rules );
droolsStream.writeObject( namedWindows );
droolsStream.writeObject( idGenerator );
if ( !isDrools ) {
droolsStream.flush();
droolsStream.close();
bytes.close();
out.writeInt( bytes.size() );
out.writeObject( bytes.toByteArray() );
}
}