Coverage Report - org.apache.tapestry.engine.state.SOMRegistryImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
SOMRegistryImpl
0%
0/30
0%
0/6
1.667
 
 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.ErrorLog;
 23  
 
 24  
 /**
 25  
  * @author Howard M. Lewis Ship
 26  
  * @since 4.0
 27  
  */
 28  0
 public class SOMRegistryImpl implements StateObjectManagerRegistry
 29  
 {
 30  
 
 31  
     private ErrorLog _errorLog;
 32  
 
 33  
     private Map _factoryContributions;
 34  
 
 35  
     private Map _applicationContributions;
 36  
 
 37  
     private Map _persistenceManagers;
 38  
 
 39  0
     private Map _objectManagers = new HashMap();
 40  
 
 41  
     public void initializeService()
 42  
     {
 43  0
         Map contributions = new HashMap();
 44  0
         contributions.putAll(_factoryContributions);
 45  
         // Overwrite any duplicates with the application contributions
 46  0
         contributions.putAll(_applicationContributions);
 47  
 
 48  0
         Iterator i = contributions.values().iterator();
 49  0
         while(i.hasNext())
 50  
         {
 51  0
             StateObjectContribution c = (StateObjectContribution) i.next();
 52  
 
 53  0
             String objectName = c.getName();
 54  0
             String scope = c.getScope();
 55  
 
 56  0
             StateObjectPersistenceManager pm = (StateObjectPersistenceManager) _persistenceManagers
 57  
                     .get(scope);
 58  
 
 59  0
             if (pm == null)
 60  
             {
 61  0
                 _errorLog.error(StateMessages.unknownScope(objectName, scope),
 62  
                         c.getLocation(), null);
 63  0
                 continue;
 64  
             }
 65  
 
 66  0
             StateObjectManager manager = new StateObjectManagerImpl(objectName,
 67  
                     c.getFactory(), pm);
 68  
 
 69  0
             _objectManagers.put(objectName, manager);
 70  
 
 71  0
         }
 72  0
     }
 73  
 
 74  
     public StateObjectManager get(String objectName)
 75  
     {
 76  0
         StateObjectManager manager = (StateObjectManager) _objectManagers
 77  
                 .get(objectName);
 78  
 
 79  0
         if (manager == null)
 80  0
             throw new ApplicationRuntimeException(StateMessages
 81  
                     .unknownStateObjectName(objectName));
 82  
 
 83  0
         return manager;
 84  
     }
 85  
 
 86  
     public void setApplicationContributions(Map applicationContributions)
 87  
     {
 88  0
         _applicationContributions = applicationContributions;
 89  0
     }
 90  
 
 91  
     public void setErrorLog(ErrorLog errorLog)
 92  
     {
 93  0
         _errorLog = errorLog;
 94  0
     }
 95  
 
 96  
     public void setFactoryContributions(Map factoryContributions)
 97  
     {
 98  0
         _factoryContributions = factoryContributions;
 99  0
     }
 100  
 
 101  
     public void setPersistenceManagers(Map persistenceManagers)
 102  
     {
 103  0
         _persistenceManagers = persistenceManagers;
 104  0
     }
 105  
 }