Clover coverage report - Code Coverage for tapestry release 3.1-alpha-1
Coverage timestamp: Mon Feb 21 2005 09:16:14 EST
file stats: LOC: 96   Methods: 7
NCLOC: 51   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
ApplicationStateManagerImpl.java 100% 87.5% 85.7% 88.9%
coverage coverage
 1   
 // Copyright 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.engine.state;
 16   
 
 17   
 import java.util.HashMap;
 18   
 import java.util.Iterator;
 19   
 import java.util.Map;
 20   
 
 21   
 import org.apache.hivemind.ApplicationRuntimeException;
 22   
 import org.apache.hivemind.PoolManageable;
 23   
 
 24   
 /**
 25   
  * This implementation expects to be pooled.
 26   
  * 
 27   
  * @author Howard M. Lewis Ship
 28   
  * @since 3.1
 29   
  */
 30   
 public class ApplicationStateManagerImpl implements ApplicationStateManager, PoolManageable
 31   
 {
 32   
 
 33   
     /**
 34   
      * Keyed on application static object name, value is the current state object.
 35   
      */
 36   
 
 37   
     private Map _stateObjects = new HashMap();
 38   
 
 39   
     private StateObjectManagerRegistry _registry;
 40   
 
 41  185
     public void activateService()
 42   
     {
 43   
     }
 44   
 
 45  186
     public void passivateService()
 46   
     {
 47  186
         _stateObjects.clear();
 48   
     }
 49   
 
 50  2
     public boolean exists(String objectName)
 51   
     {
 52  2
         return _stateObjects.containsKey(objectName) || _registry.get(objectName).exists();
 53   
     }
 54   
 
 55  9
     public Object get(String objectName)
 56   
     {
 57  9
         Object result = _stateObjects.get(objectName);
 58   
 
 59  9
         if (result == null)
 60   
         {
 61  8
             result = _registry.get(objectName).get();
 62   
 
 63  7
             _stateObjects.put(objectName, result);
 64   
         }
 65   
 
 66  8
         return result;
 67   
     }
 68   
 
 69  0
     public void store(String objectName, Object stateObject)
 70   
     {
 71  0
         _registry.get(objectName).store(stateObject);
 72   
 
 73  0
         _stateObjects.put(objectName, stateObject);
 74   
     }
 75   
 
 76  186
     public void flush()
 77   
     {
 78  186
         Iterator i = _stateObjects.entrySet().iterator();
 79  186
         while (i.hasNext())
 80   
         {
 81  4
             Map.Entry e = (Map.Entry) i.next();
 82   
 
 83  4
             String objectName = (String) e.getKey();
 84  4
             Object stateObject = e.getValue();
 85   
 
 86   
             // Slight bending of law-of-demeter
 87   
 
 88  4
             _registry.get(objectName).store(stateObject);
 89   
         }
 90   
     }
 91   
 
 92  56
     public void setRegistry(StateObjectManagerRegistry registry)
 93   
     {
 94  56
         _registry = registry;
 95   
     }
 96   
 }