commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Juozas Baliuka" <bali...@centras.lt>
Subject Re: [DBCP] Please let us start to improve the connection pool
Date Mon, 24 Mar 2003 19:06:47 GMT



<snip>
> At least, i do not understand why this should be more elegant, if it works
> EVERY application has to read the docs, and implement this. This is like
> "cut and paste" in an OO design, isnt it?

It is because there are a lot of "good" ways to handle this, I think they
are out of DBCP scope.
TrancationManager in container handles this stuff and I think user must
handle it himself if Connection pool is used "out of box".

>
> Mario
>
> > class MySafeConnection implements InvokationHandler{
> >
> >   Connection connection;
> >   WeakReference owner;
> >
> >    MySafeConnection(Connection connection){
> >      this.connection = connection;
> >      owner = new WeakReference( Thread.currentThread() );
> >   }
> >
> >  Object invoke(Object obj, Method method, Object args[] ) throw
Throwable{
> >
> >     if(  owner.get() == Thread.currentThread()   ){
> >         method.invoke( connection, args );
> >      }else{
> >         throw new IllegalStateExeption();
> >    }
> >
> >  }
> >
> >  static Connection decorate(Connection connection){
> >
> >     return
> >
(Connection)Proxy.newProxyInstance(connection.getClass().getClassLoader(),
> >                                     new Class[] {Connection.class}, new
> > MySafeConnection(connection));
> >
> >   }
> >
> > }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message