// The lazy man's method of registering a VM bus listener // You only need to keep a reference around but not to close() anything // OTOH you depend on the GC for cleaning up your listener // structures which is not so good sclass WeakRefVMBusListener extends WeakReference implements IF2 { Set listeners; // where we were added *(Set *listeners, O listener) { super(listener); } *(Set *listeners, IVF2 listener) { super(listener); } public O get(S msg, O arg) { O listener = get(); if (listener == null) { ifdef WeakRefVMBusListener_debug print WeakRefVMBusListener_debug("Removing VM bus listener"); endifdef remove(listeners, this); null; } ret callF(listener, msg, arg); } }