Clover coverage report - Code Coverage for tapestry release 4.0-alpha-3
Coverage timestamp: Mon May 16 2005 09:05:49 EDT
file stats: LOC: 72   Methods: 3
NCLOC: 32   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
ObjectPoolImpl.java 100% 90% 66.7% 88.2%
coverage coverage
 1   
 // Copyright 2004, 2005 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.tapestry.services.impl;
 16   
 
 17   
 import java.util.HashMap;
 18   
 import java.util.LinkedList;
 19   
 import java.util.List;
 20   
 import java.util.Map;
 21   
 
 22   
 import org.apache.tapestry.event.ResetEventListener;
 23   
 import org.apache.tapestry.services.ObjectPool;
 24   
 
 25   
 /**
 26   
  * Implementation of the {@link org.apache.tapestry.services.ObjectPool} interface.
 27   
  * 
 28   
  * <p>
 29   
  * This ia a minimal implementation, one that has no concept of automatically removing
 30   
  * unused pooled objects. Eventually, it will also register for notifications about
 31   
  * general cache cleaning.
 32   
  *
 33   
  * @author Howard Lewis Ship
 34   
  * @since 4.0
 35   
  */
 36   
 public class ObjectPoolImpl implements ObjectPool, ResetEventListener
 37   
 {
 38   
     /**
 39   
      * Pool of Lists (of pooled objects), keyed on arbitrary key.
 40   
      */
 41   
     private Map _pool = new HashMap();
 42   
 
 43  376
     public synchronized Object get(Object key)
 44   
     {
 45  376
         List pooled = (List) _pool.get(key);
 46   
 
 47  376
         if (pooled == null || pooled.isEmpty())
 48  197
             return null;
 49   
 
 50  179
         return pooled.remove(0);
 51   
     }
 52   
 
 53  363
     public synchronized void store(Object key, Object value)
 54   
     {
 55  363
         List pooled = (List) _pool.get(key);
 56   
 
 57  363
         if (pooled == null)
 58   
         {
 59  179
             pooled = new LinkedList();
 60  179
             _pool.put(key, pooled);
 61   
         }
 62   
 
 63  363
         pooled.add(value);
 64   
     }
 65   
 
 66  0
     public synchronized void resetEventDidOccur()
 67   
     {
 68  0
         _pool.clear();
 69   
     }
 70   
 
 71   
 }
 72