Hi Roland, I'm sorry I didn't see your email earlier or I could have saved you some headaches. Sounds like you've figured it out though. Your description of the weak references, etc below is spot on and quite well written. As you have discovered, most of the complexity of the MTHCM comes from the support for handling GCed connections. This part of the MTHCM was added after the original design was completed, so there is likely a better/simpler way to achieve the same results. Please let me know if there is anything I can add/explain.
Mike On 1/20/07, Roland Weber <[EMAIL PROTECTED]> wrote:
Good news, some inspiring music on mind-shaking volume helped me solve the riddle of the MTHCM, and with a good night's sleep I'm ready to tackle the code. I even dimly remember the discussions about the garbage collection thing. The reason for the weak references is that an application may allocate a connection and then just forget about it without releasing it. Since the manager does not maintain a hard reference to the connection, it will be GCed and the vanishing weak reference tells the manager(s) that a connection has been lost. Without the connection object, it's hard to tell _which_ manager issued the connection that was lost, hence there is a second map from the weak references to the responsible managers. I guess this strategy was introduced before the wrappers that are being handed out nowadays. With the wrappers in place, we can manage the connections in the traditional way and instead keep a weak reference to the _wrapper_. When the wrapper is GCed, the connection can be reclaimed. That way, connections will never be cleaned up by the GC (except when the whole connection manager is GCed) and we don't have to rely on finalizers being called in order to release for example native resources associated with the connection. Another missing puzzle piece is the route tracking that is implemented in the old connection class by means of a HostConfiguration and tunnelCreated flag. The new interfaces have been defined bottom-up, so they don't have this feature which is required by the manager. It's not possible to map a managed connection to an operated connection by a simple adapter without adding route tracking. I'll need an extra class here, and that is the place where I can fit the subclassing I mentioned earlier. I'll get started right away... cheers, Roland --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
