if (regeneratePrototypeCacheP && myPrototype != null && ldm != null) {  TypeIdentificationPG tipg = myPrototype.getTypeIdentificationPG(); String tid = tipg.getTypeIdentification(); if (ldm.isPrototypeCached(tid)) {  Asset putativeProto = ldm.getPrototype(tid); if (putativeProto != myPrototype) { if (log.isInfoEnabled()) { log.info("Deserialization used cached prototype "+putativeProto+ " instead of stored prototype "+myPrototype); }  myPrototype = putativeProto; } else {  } } else {  ldm.cachePrototype(tid, myPrototype); if (log.isDebugEnabled()) { log.debug("Deserialization cached prototype "+myPrototype); } } }
  private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {    ClusterContextTable.ContextState cs = ClusterContextTable.getContextState();    if (cs instanceof ClusterContextTable.MessageContext) {      ClusterContext cc = cs.getClusterContext();      MessageAddress ma = cc.getMessageAddress();      LDMServesPlugin ldm = LDMContextTable.getLDM(ma);      bindToLDM(ldm);      in.defaultReadObject();      myTypeIdentificationPG = (TypeIdentificationPG) in.readObject();      myItemIdentificationPG = (ItemIdentificationPG) in.readObject();      //MessageAddress dest = c.getToAddress();      Object proto = in.readObject();      if (proto != null) {        // in practice, this is always an Asset (or null) nowadays        if (proto instanceof Asset) {          Asset pa = (Asset) proto;          TypeIdentificationPG ptip = pa.getTypeIdentificationPG();          String tid = ptip.getTypeIdentification();          myPrototype = ldm.getPrototype(tid);          // if we found it, we'll just drop what was sent on the floor.          if (myPrototype != null) {            // ok - all done.          } else {            // didn't find it.            // So - add extra (local properties - strange but possible)            ldm.fillProperties(pa);            // cache it so we'll find it next time...            ldm.cachePrototype(tid,pa);            // set it and continue.            myPrototype=pa;          }        } else if (proto instanceof TypeIdentificationPG) {        // proto was sent as only the TIP           TypeIdentificationPG protoTIP = (TypeIdentificationPG) proto;          // get the proto from OUR ldm...          // for now, we just look at the TId of the TIP sent.          String tid = protoTIP.getTypeIdentification();          myPrototype = ldm.getPrototype(tid);          // if no proto found, we're on our own,          // so we'll create a proto with the tid and no other          // props.          if (myPrototype == null) {            PlanningFactory ldmf = (PlanningFactory) ldm.getFactory("planning");            Asset prot = ldmf.createPrototype(Asset.class, tid);            // even though there is no prototype provider, there            // might be property providers that can handle it, so            // we'll expose our new instance to them.            ldm.fillProperties(prot);            // might as well register it, since we're unlikely to get            // a proto provider later.            ldm.cachePrototype(tid,prot);            myPrototype=prot;          } else {          }        } else {          System.err.println("\nWARNING!!! Deserialized an unknown prototype class: "+proto);        }      } else {        myPrototype = null;      }      initRoleSchedule();    } else {      ClusterContext cc = ClusterContextTable.getClusterContext();      if (cc != null) {        MessageAddress ma = cc.getMessageAddress();        LDMServesPlugin ldm = LDMContextTable.getLDM(ma);        bindToLDM(ldm);      }      // plain serialization      in.defaultReadObject();      myTypeIdentificationPG=(TypeIdentificationPG)in.readObject();      myItemIdentificationPG=(ItemIdentificationPG)in.readObject();      myPrototype=(Asset)in.readObject();      if (cc == null) {        System.err.println("Warning! Contextless deserialization of "+this);        Thread.dumpStack();      }      initRoleSchedule();      if (in instanceof org.cougaar.core.persist.PersistenceInputStream) {        Schedule schedule = (Schedule) in.readObject();        ((RoleScheduleImpl)roleschedule).setAvailableSchedule(schedule);      }    }      // End Network serialization  }