[Mulgara-dev] ConnectionFactory updates

Paul Gearon gearon at ieee.org
Wed May 21 00:19:11 UTC 2008


On Tue, May 20, 2008 at 4:56 PM, Alex Hall <alexhall at revelytix.com> wrote:
<snip/>
> I have also overridden the finalize method on the Connection in order to
> try and reclaim Sessions from Connections that have been abandoned but
> not closed by the client.  Also, there is a new Connection.dispose()
> method which will allow the client to explicitly close the underlying
> Session, in which case it will not be re-used by the factory.

Seems reasonable. It makes me wonder if we want to somehow tell if
Sessions are closed, and not let the Factory reclaim them in that
event. e.g. When the factory goes to insert it in the cache is does a
Session.isClosed() on it first. Maybe that's overkill though.

> Since the Connection now needs a reference to the factory that created
> it, I changed the access level on the SessionConnection constructor from
> public to default access.  The SessionConnection can no longer be
> created directly by clients; all access should go through the
> ConnectionFactory class.  If anybody thinks this will be a problem, let
> me know so we can work on an alternate implementation.

No, it sounds good to me.

> Note that while the ConnectionFactory class is synchronized for
> concurrent access by multiple clients, the same is not true for the
> Connections that it returns.  Clients are responsible for managing
> Connections and restricting their access to a single thread.  Also, it
> is possible for a client to get a reference to the Session that backs a
> Connection, close the Connection so the Session is re-used, and continue
> executing operations on the Session.  Closing that loophole would
> require a wrapper around the Session and I considered that to be overkill.

I agree.

This is great work. Thank you Alex! :-)

Paul



More information about the Mulgara-dev mailing list