1 8 9 15 package jfun.yan; 16 17 import jfun.yan.factory.Factory; 18 import jfun.yan.factory.Pool; 19 20 26 final class PooledComponent extends DelegatingComponent { 27 private final Pool pool; 28 Object super_create(final Dependency a) { 29 return super.create(a); 30 } 31 public Object create(final Dependency a) { 32 return pool.getInstance(new Factory(){ 33 public Object create(){ 34 return super_create(a); 35 } 36 }); 37 } 38 private static final String not_pooled = new String ("pool indicator"); 39 public Class verify(Dependency dep) { 40 final Object v = pool.getPooledInstance(not_pooled); 41 if(v==not_pooled){ 42 return super.verify(dep); 43 } 44 else{ 45 return (v==null)?void.class:v.getClass(); 46 } 47 } 48 49 PooledComponent(final Component cc, Pool p) { 50 super(cc); 51 this.pool = p; 52 } 53 } 54 | Popular Tags |