Exemplo n.º 1
0
 /**
  * Destroys all instances in the stack and clears the stack.
  *
  * @param key key passed to factory when destroying instances
  * @param stack stack to destroy
  */
 private void destroyStack(K key, java.util.Stack <V> stack)
 {
     lock (this)
     {
         if (null == stack)
         {
             return;
         }
         else
         {
             if (null != _factory)
             {
                 java.util.Iterator <V> it = stack.iterator();
                 while (it.hasNext())
                 {
                     try
                     {
                         _factory.destroyObject(key, it.next());
                     }
                     catch (Exception e)
                     {
                         // ignore error, keep destroying the rest
                     }
                 }
             }
             _totIdle -= stack.size();
             _activeCount.remove(key);
             stack.clear();
         }
     }
 }
Exemplo n.º 2
0
        /**
         * Returns a string representation of this StackKeyedObjectPool, including
         * the number of pools, the keys and the size of each keyed pool.
         *
         * @return Keys and pool sizes
         */

        public override String ToString()
        {
            lock (this)
            {
                java.lang.StringBuffer buf = new java.lang.StringBuffer();
                buf.append(this.getClass().getName());
                buf.append(" contains ").append(_pools.size()).append(" distinct pools: ");
                java.util.Iterator <K> it = _pools.keySet().iterator();
                while (it.hasNext())
                {
                    K key = it.next();
                    buf.append(" |").append(key).append("|=");
                    java.util.Stack <V> s = _pools.get(key);
                    buf.append(s.size());
                }
                return(buf.toString());
            }
        }