58a59,62 > import java.io.IOException; > import java.io.ObjectInputStream; > import java.io.ObjectOutputStream; > import java.io.Serializable; 82c86 < public class DataContext implements QueryEngine { --- > public class DataContext implements QueryEngine, Serializable{ 85c89 < protected QueryEngine parent; --- > protected transient QueryEngine parent; //Will not be directly serialized - see read/writeObject for details 1093c1097 < class RelationshipDataSource implements ToManyListDataSource { --- > class RelationshipDataSource implements ToManyListDataSource, Serializable { 1107a1112,1149 > > private void writeObject(ObjectOutputStream out) throws IOException { > //If the "parent" of this datacontext is a DataDomain, then just write the > // name of it. Then when deser happens, we can get back the DataDomain by name, > // from the shared configuration (which will either load it if need be, or return > // an existing one. > out.defaultWriteObject(); > if(this.parent instanceof DataDomain) { > DataDomain domain=(DataDomain) this.parent; > out.writeObject(domain.getName()); > } else { > out.writeObject(this.parent); //Hope that whatever this.parent is, that it is Serializable > } > } > > private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { > boolean failed=false; > in.defaultReadObject(); > Object value=in.readObject(); > if(value instanceof QueryEngine) { > //Must be a real QueryEngine object - use it > this.parent=(QueryEngine)value; > } else if (value instanceof String) { > //Must be the name of a DataDomain - use it > this.parent=Configuration.getSharedConfig().getDomain((String)value); > if(this.parent==null) { > failed=true; > } > } else { > failed=true; > } > if(failed) { > throw new IOException("Parent attribute of DataContext was neither a QueryEngine nor " + > "the name of a valid DataDomain:"+value); > } > > } >