Hi Edin,

Edin Ahmetagic wrote on Wednesday, June 29, 2005 12:10 PM:

> Hi,
> I think it would be nice if I could force the client, to
> return the borrowed objects to the pool. As I see other guys think so
> too. nice :) 
> 
> I´ve mentioned that it would be an approach to have an
> interface that have to be implemnted by the objects that are
> "polable". But this could be a problem. What to do, if the
> objects that have to be pooled are not modifiable, so that
> they can't implement an interface? Hmm, there have to be an other
> approach to solve this. Any ideas?

you might have a look at the HEAD version of ProxyToys 
(http://proxytoys.codehaus.org). The current version 0.1 does obviously contain 
neither docs nor a solution to the pool problem, but you might build the head 
version yourself. The ProxyToys source can be checkout out anonymously from the 
Subversion repository:

svn co svn://svn.proxytoys.codehaus.org/proxytoys/scm/trunk/proxytoys

or browse it:
http://svn.proxytoys.codehaus.org/

The Javadoc for the pool component is quite complete and look at the unit tests 
for detailed usage.

Basic idea is to decorate all elements in the pool with a proxy and an 
additional interface. Using the interface, you can manually return the element 
to the pool. Otherwise the element returns automatically if the garbage 
collector finalizes the proxy ;-)

In combination with CGLIB you can also proxy non-final classes. Additionally 
you might create an own interface, that has "compatible methods" to the pooled 
objects. Note: The pool implementation is very basic by intension, you will 
have to extend the implementation if you want the pool to create elements on 
demand, etc.

 ... and yes, I am working on a new release, but first the docs and website 
have to be ready :)

- Jörg

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to