Coverage Report - org.apache.tapestry.record.PropertyPersistenceStrategySourceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
PropertyPersistenceStrategySourceImpl
0%
0/32
0%
0/10
2
 
 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.record;
 16  
 
 17  
 import java.util.ArrayList;
 18  
 import java.util.Collection;
 19  
 import java.util.HashMap;
 20  
 import java.util.Iterator;
 21  
 import java.util.List;
 22  
 import java.util.Map;
 23  
 
 24  
 import org.apache.hivemind.ApplicationRuntimeException;
 25  
 import org.apache.tapestry.engine.ServiceEncoding;
 26  
 
 27  
 /**
 28  
  * Implementation of the
 29  
  * <code>tapestry.persist.PropertyPersistenceStrategySource</code> service.
 30  
  * Allows access to other services, that implement the
 31  
  * {@link org.apache.tapestry.record.PropertyPersistenceStrategy} interface.
 32  
  * 
 33  
  * @author Howard M. Lewis Ship
 34  
  * @since 4.0
 35  
  */
 36  0
 public class PropertyPersistenceStrategySourceImpl implements
 37  
         PropertyPersistenceStrategySource
 38  
 {
 39  
 
 40  
     // Set from tapestry.props.PersistenceStrategy
 41  
     private List _contributions;
 42  
 
 43  0
     private Map _strategies = new HashMap();
 44  
 
 45  
     public void initializeService()
 46  
     {
 47  0
         Iterator i = _contributions.iterator();
 48  0
         while(i.hasNext())
 49  
         {
 50  0
             PropertyPersistenceStrategyContribution c = (PropertyPersistenceStrategyContribution) i
 51  
                     .next();
 52  
 
 53  0
             _strategies.put(c.getName(), c.getStrategy());
 54  0
         }
 55  0
     }
 56  
 
 57  
     public PropertyPersistenceStrategy getStrategy(String name)
 58  
     {
 59  0
         if (!_strategies.containsKey(name))
 60  0
             throw new ApplicationRuntimeException(RecordMessages
 61  
                     .unknownPersistenceStrategy(name));
 62  
 
 63  0
         return (PropertyPersistenceStrategy) _strategies.get(name);
 64  
     }
 65  
 
 66  
     public Collection getAllStoredChanges(String pageName)
 67  
     {
 68  0
         Collection result = new ArrayList();
 69  
 
 70  0
         Iterator i = _strategies.values().iterator();
 71  
 
 72  0
         while(i.hasNext())
 73  
         {
 74  0
             PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i
 75  
                     .next();
 76  
 
 77  0
             result.addAll(s.getStoredChanges(pageName));
 78  0
         }
 79  
 
 80  0
         return result;
 81  
     }
 82  
 
 83  
     public void discardAllStoredChanged(String pageName)
 84  
     {
 85  0
         Iterator i = _strategies.values().iterator();
 86  
 
 87  0
         while(i.hasNext())
 88  
         {
 89  0
             PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i
 90  
                     .next();
 91  
 
 92  0
             s.discardStoredChanges(pageName);
 93  0
         }
 94  0
     }
 95  
 
 96  
     public void addParametersForPersistentProperties(ServiceEncoding encoding,
 97  
             boolean post)
 98  
     {
 99  0
         Iterator i = _strategies.values().iterator();
 100  
 
 101  0
         while(i.hasNext())
 102  
         {
 103  0
             PropertyPersistenceStrategy s = (PropertyPersistenceStrategy) i
 104  
                     .next();
 105  
 
 106  0
             s.addParametersForPersistentProperties(encoding, post);
 107  0
         }
 108  0
     }
 109  
 
 110  
     public void setContributions(List contributions)
 111  
     {
 112  0
         _contributions = contributions;
 113  0
     }
 114  
 }