in src/java/org/apache/fulcrum/pool/PoolBuffer.java [79:126]
public <T> T poll(Object[] params, String[] signature, FactoryService factoryService) throws PoolException
{
T instance = pool.poll();
if (instance != null)
{
if (arrayCtorRecyclable)
{
((ArrayCtorRecyclable) instance).recycle(params);
} else if (instance instanceof Recyclable) {
try
{
if (signature != null && signature.length > 0)
{
/* Get the recycle method from the cache. */
Method recycle = getRecycle(signature);
if (recycle == null)
{
synchronized (this) {
/* Make a synchronized recheck. */
recycle = getRecycle(signature);
if (recycle == null)
{
Class<? extends Object> clazz = instance.getClass();
recycle = clazz.getMethod("recycle",
factoryService.getSignature(clazz, params, signature));
@SuppressWarnings("unchecked")
ArrayList<Recycler> cache = recyclers != null
? (ArrayList<Recycler>) recyclers.clone()
: new ArrayList<Recycler>();
cache.add(new Recycler(recycle, signature));
recyclers = cache;
}
}
}
recycle.invoke(instance, params);
} else {
((Recyclable) instance).recycle();
}
}
catch (Exception x)
{
throw new PoolException("Recycling failed for " + instance.getClass().getName(), x);
}
}
}
return instance;
}