1 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 32 public class EngineManagerImpl implements EngineManager 33 { 34 private ObjectPool _enginePool; 35 36 private EngineFactory _engineFactory; 37 38 private RequestLocaleManager _localeManager; 39 40 public IEngine getEngineInstance() 41 { 42 Locale locale = _localeManager.extractLocaleForCurrentRequest(); 43 44 IEngine result = (IEngine) _enginePool.get(locale); 45 46 50 if (result == null) 51 result = _engineFactory.constructNewEngineInstance(locale); 52 53 return result; 54 } 55 56 public void storeEngineInstance(IEngine engine) 57 { 58 _enginePool.store(engine.getLocale(), engine); 59 } 60 61 public void setEngineFactory(EngineFactory factory) 62 { 63 _engineFactory = factory; 64 } 65 66 public void setEnginePool(ObjectPool pool) 67 { 68 _enginePool = pool; 69 } 70 71 public void setLocaleManager(RequestLocaleManager manager) 72 { 73 _localeManager = manager; 74 } 75 } | Popular Tags |