Clover coverage report - Code Coverage for tapestry release 4.0-beta-2
Coverage timestamp: Sat Jul 9 2005 22:02:17 EDT
file stats: LOC: 75   Methods: 5
NCLOC: 36   Classes: 1
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
EngineManagerImpl.java 100% 100% 100% 100%
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.Locale;
 18   
 19    import org.apache.tapestry.IEngine;
 20    import org.apache.tapestry.services.EngineFactory;
 21    import org.apache.tapestry.services.EngineManager;
 22    import org.apache.tapestry.services.RequestLocaleManager;
 23    import org.apache.tapestry.services.ObjectPool;
 24   
 25    /**
 26    * Implementation of service {@link org.apache.tapestry.services.EngineManager}.
 27    * Service point tapestry.request.EngineManager.
 28    *
 29    * @author Howard Lewis Ship
 30    * @since 4.0
 31    */
 32    public class EngineManagerImpl implements EngineManager
 33    {
 34    private ObjectPool _enginePool;
 35   
 36    private EngineFactory _engineFactory;
 37   
 38    private RequestLocaleManager _localeManager;
 39   
 40  134 public IEngine getEngineInstance()
 41    {
 42  134 Locale locale = _localeManager.extractLocaleForCurrentRequest();
 43   
 44  134 IEngine result = (IEngine) _enginePool.get(locale);
 45   
 46    // This happens when either the pool is empty, or when a session exists
 47    // but the engine has not been stored into it (which should never happen, and
 48    // probably indicates an error in the framework or the application).
 49   
 50  134 if (result == null)
 51  50 result = _engineFactory.constructNewEngineInstance(locale);
 52   
 53  134 return result;
 54    }
 55   
 56  133 public void storeEngineInstance(IEngine engine)
 57    {
 58  133 _enginePool.store(engine.getLocale(), engine);
 59    }
 60   
 61  42 public void setEngineFactory(EngineFactory factory)
 62    {
 63  42 _engineFactory = factory;
 64    }
 65   
 66  44 public void setEnginePool(ObjectPool pool)
 67    {
 68  44 _enginePool = pool;
 69    }
 70   
 71  43 public void setLocaleManager(RequestLocaleManager manager)
 72    {
 73  43 _localeManager = manager;
 74    }
 75    }