i try to design a Connection pool by Dynamic Proxy. when the pool user invoke conn.close() method,with Dynamic Proxy,the Connection pool can just recycle the Connection instead of close the Connection.
the pool user call:
to get a Proxy Connection Object,and finish some SQL operation,and then he invoke the Connection pool set the inUse flag of this conneciton object into false,in this way, the pool can return the free Connection judge by the inUse flag which is false; if the flag is false,the Proxy hold up all the method,an the user can not use this connection anymore;
now there is another user,he call:
if unfortunately,the object conn2 refer to is the same as conn1 refer to. the pool set the flag into true,and the proxy cancel hold up the method invocation. then the problem occur,in this time,the refer variable 'conn1' can use the connection object again! so,who can i break the refer between refer conn1 and the connection object? or some other way I can do in the Proxy class? thank you!