⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 overview-summary.html

📁 优秀的文档,可以学习java之用 0006728337 00000 n 0006728424 00000 n 0006728600 00000 n
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.5.0_06) on Sun Apr 02 20:52:32 EDT 2006 --><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><TITLE>Overview (Commons Pool 1.3 API)</TITLE><META NAME="keywords" CONTENT="Overview, Commons Pool 1.3 API"><LINK REL ="stylesheet" TYPE="text/css" HREF="stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){    parent.document.title="Overview (Commons Pool 1.3 API)";}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Overview</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <FONT CLASS="NavBarFont1">Package</FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <FONT CLASS="NavBarFont1">Use</FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;PREV&nbsp;&nbsp;NEXT</FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="index.html?overview-summary.html" target="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="overview-summary.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;&nbsp;<SCRIPT type="text/javascript">  <!--  if(window==top) {    document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');  }  //--></SCRIPT><NOSCRIPT>  <A HREF="allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><CENTER><H1>Commons Pool 1.3 API</H1></CENTER>
         Generic Object pooling API with several implementations.<P><B>See:</B><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="#overview_description"><B>Description</B></A><P><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Packages</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD WIDTH="20%"><B><A HREF="org/apache/commons/pool/package-summary.html">org.apache.commons.pool</A></B></TD><TD>
         Object pooling API.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD WIDTH="20%"><B><A HREF="org/apache/commons/pool/impl/package-summary.html">org.apache.commons.pool.impl</A></B></TD><TD>
         Object pooling API implementations.</TD></TR></TABLE><P>&nbsp;<A NAME="overview_description"><!-- --></A><P><p>
         Generic Object pooling API with several implementations.
      </p>
      <p>
         The <code>org.apache.commons.pool</code> package defines a simple 
         interface for a pool of object instances, and a handful of base 
         classes that may be useful when creating pool implementations.
         The api supports pooling of unique objects which can be requested
         via a key as well as pools where all objects are equivalent.
      </p>
      <p>
         The <code>org.apache.commons.pool.impl</code> package contains
         several pool implementations.  
         <A HREF="org/apache/commons/pool/impl/StackObjectPool.html" title="class in org.apache.commons.pool.impl"><CODE>StackObjectPool</CODE></A>
         is useful for supporting reuse of a limited number of instances while
         allowing new instances to be created as needed to support high demand.
         <A HREF="org/apache/commons/pool/impl/GenericObjectPool.html" title="class in org.apache.commons.pool.impl"><CODE>
         GenericObjectPool</CODE></A> has many configuration options and can support
         a limited set of objects such as would be useful in a database
         connection pool.
         <A HREF="org/apache/commons/pool/impl/SoftReferenceObjectPool.html" title="class in org.apache.commons.pool.impl"><CODE>
         SoftReferenceObjectPool</CODE></A> has no limit on the number of objects in the
         pool, but garbage collector can remove idle objects from the pool as
         needed.  There are also keyed versions of the first two.
      </p>
      <p>
         Here is a simple example of pooling <code>HashMap</code>'s.  First 
         create an <A HREF="org/apache/commons/pool/ObjectPoolFactory.html" title="interface in org.apache.commons.pool"><CODE>
         ObjectPoolFactory</CODE></A>
      </p>
<pre>
    public class HashMapFactory 
        extends <A HREF="org/apache/commons/pool/BasePoolableObjectFactory.html" title="class in org.apache.commons.pool"><CODE>BasePoolableObjectFactory</CODE></A>
    {
        /**
         * Creates an instance that can be returned by the pool.
         * @return an instance that can be returned by the pool.
         */
        public Object makeObject() 
            throws Exception
        {
            return new HashMap();
        }
        
        /**
         * Uninitialize an instance to be returned to the pool.
         * @param obj the instance to be passivated
         */
        public void passivateObject(Object obj) 
            throws Exception
        {
            Map map = (Map)obj;
            map.clear();
        }
    }
</pre>
      <p>
         A class that makes frequent use of a Map could then use a pool
         as shown below:
      </p>
<pre>
    public class Foo
    {
        private <A HREF="org/apache/commons/pool/ObjectPool.html" title="interface in org.apache.commons.pool"><CODE>ObjectPool</CODE></A> pool;
        public Foo()
        {
            <A HREF="org/apache/commons/pool/PoolableObjectFactory.html" title="interface in org.apache.commons.pool"><CODE>PoolableObjectFactory</CODE></A> factory = new HashMapFactory();
            pool = new StackObjectPool(factory, 1000);
        }

        public doSomething()
        {
            ...
            Map map = null;
            try
            {
                map = (Map)pool.borrowObject();
                // use map
                ...
            }
            finally
            {
                if (map != null)
                {
                    pool.returnObject(map);
                }
            }
            ...
        }
    }
</pre>

<p>
The above example shows how one would use an 
<A HREF="org/apache/commons/pool/ObjectPool.html" title="interface in org.apache.commons.pool"><CODE>ObjectPool</CODE></A>.  The other supplied 
implementations or another special purpose pool would be used similarly.
</p><P><P><HR><!-- ======= START OF BOTTOM NAVBAR ====== --><A NAME="navbar_bottom"><!-- --></A><A HREF="#skip-navbar_bottom" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Overview</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <FONT CLASS="NavBarFont1">Package</FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <FONT CLASS="NavBarFont1">Class</FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <FONT CLASS="NavBarFont1">Use</FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="overview-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;PREV&nbsp;&nbsp;NEXT</FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="index.html?overview-summary.html" target="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="overview-summary.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;&nbsp;<SCRIPT type="text/javascript">  <!--  if(window==top) {    document.writeln('<A HREF="allclasses-noframe.html"><B>All Classes</B></A>');  }  //--></SCRIPT><NOSCRIPT>  <A HREF="allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR></TABLE><A NAME="skip-navbar_bottom"></A><!-- ======== END OF BOTTOM NAVBAR ======= --><HR>Copyright &copy; 2001-2006 The Apache Software Foundation. All Rights Reserved.</BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -