/*****************************************************************************
* Copyright (C) Zephyr Business Solution. All rights reserved. *
* ------------------------------------------------------------------------- *
* The software in this package is published under the terms of the BSD *
* style license a copy of which has been included with this distribution in *
* the LICENSE.txt file. *
*****************************************************************************/
/*
* Created on Jun 8, 2005
*
* Author Ben Yu
* ZBS
*/
package jfun.yan;
import jfun.yan.factory.Factory;
import jfun.yan.factory.Pool;
/**
* Zephyr Business Solution
*
* @author Ben Yu
*
*/
final class PooledComponent extends DelegatingComponent {
private final Pool pool;
Object super_create(final Dependency a) {
return super.create(a);
}
public Object create(final Dependency a) {
return pool.getInstance(new Factory(){
public Object create(){
return super_create(a);
}
});
}
private static final String not_pooled = new String("pool indicator");
public Class verify(Dependency dep) {
final Object v = pool.getPooledInstance(not_pooled);
if(v==not_pooled){
return super.verify(dep);
}
else{
return (v==null)?void.class:v.getClass();
}
}
PooledComponent(final Component cc, Pool p) {
super(cc);
this.pool = p;
}
}