1 /***************************************************************************** 2 * Copyright (C) Zephyr Business Solution. All rights reserved. * 3 * ------------------------------------------------------------------------- * 4 * The software in this package is published under the terms of the BSD * 5 * style license a copy of which has been included with this distribution in * 6 * the LICENSE.txt file. * 7 *****************************************************************************/ 8 9 /* 10 * Created on Jun 8, 2005 11 * 12 * Author Ben Yu 13 * ZBS 14 */ 15 package jfun.yan.factory; 16 17 /** 18 * Represents a pooling strategy for certain object instance. 19 * <p> 20 * Zephyr Business Solution 21 * 22 * @author Ben Yu 23 * 24 */ 25 public interface Pool<T> extends java.io.Serializable{ 26 /** 27 * Apply the pooling strategy and return an instance 28 * from either the pool or the factory. 29 * @param factory the factory to create the object instance. 30 * @return the object instance. 31 */ 32 T getInstance(Factory<T> factory); 33 34 /** 35 * Get the instance that's already pooled. 36 * @param def the default value to return if there's no pooled instance. 37 * @return the pooled instance or the default object. 38 */ 39 T getPooledInstance(T def); 40 41 /** 42 * Is this pool currently having something in cache? 43 */ 44 boolean isPooled(); 45 } 46