/* JFox, the OpenSource J2EE Application Server
 *
 * Copyright (C) 2002 huihoo.org
 * Distributable under GNU LGPL license
 * See the GNU Lesser General Public License for more details.
 */

package org.huihoo.jfox.pool;

/**
 * 
 * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
 */


public interface IndexedObjectPool {
  /**
   * retrieve Object from object pool with the key
   * 如果这个 key 还不存在,就新建该 key ,并返回和该 key 关联的对象
   * @return
   */
  PoolableObject retrieveObject(Object key) throws Exception ;

  /**
   * restore the retrived object to object pool
   * @return true if success, false if failed
   */
  boolean restoreObject(Object key,PoolableObject obj);

  /**
   * remove a poolable object from the pool
   * @param key
   * @return
   */
  boolean removeObject(Object key);
  /**
   * Clears any objects sitting idle in the pool, releasing any associated resources
   */
  void clear();

  /**
   * get the factory use to create new instances
   */
  ObjectFactory getObjectFactory();

  /**
   * get the count of working object
   * @return
   */
  int getWorking();

  /**
   * get the count of rest object
   * @return
   */
  int getRest();
}