!7 sclass ORef { S globalID = aGlobalID(); WeakReference ref; new Set forMachines; long created = now(), lastAccessed; } module ObjectReferences > DynObjectTable { transient Map byGlobalID = synchroMap(); transient Map byObject = weakIdentityHashMap(); start { dontPersist(); itemToMap = func(ORef r) -> Map { O o = getWeakRef(r.ref); ret litorderedmap( "Global ID" := r.globalID, "Type" := o == null ? "gone" : className(o), "Last Accessed" := formatLocalDateWithSeconds(r.lastAccessed), "For Machines" := joinWithComma(r.forMachines)); }; } O _getReloadData() { ret data; } void _setReloadData(L data) { addAll(this.data, map(data, func(O o) -> ORef { shallowCloneToClass(ORef, o) })); } // API // returns global ID S addReferencedObject(O object, S forMachine) { ORef r; bool isNew; { lock lock; r = byObject.get(object); isNew = r == null; if (isNew) { r = new ORef; r.ref = weakRef(object); byGlobalID.put(r.globalID, r); byObject.put(object, r); } r.lastAccessed = now(); r.forMachines.add(forMachine); } if (isNew) add(r); ret r.globalID; } O getReferencedObject(S globalID) { ORef r = byGlobalID.get(globalID); ret r == null ? null : r.ref!; } }