1 64 65 package com.jcorporate.expresso.core.controller; 66 67 import com.jcorporate.expresso.core.misc.StringUtil; 68 import org.apache.oro.util.CacheLRU; 69 70 71 78 public class DefaultControllerFactory 79 implements ControllerFactory { 80 81 85 protected CacheLRU controllerCache = new CacheLRU(20); 86 87 90 public DefaultControllerFactory() { 91 } 92 93 94 97 public synchronized Controller getController(String className) 98 throws ControllerException { 99 return getController("", className); 100 } 101 102 106 public synchronized Controller getController(String moduleName, String className) 107 throws ControllerException { 108 Controller c = (Controller) controllerCache.getElement(className); 109 110 if (c == null) { 111 c = Controller.instantiate(className); 112 controllerCache.addElement(className, c); 113 } 114 115 return c; 116 } 117 118 122 public synchronized Controller getController(ControllerRequest request) 123 throws ControllerException { 124 String s = request.getParameter(Controller.CONTROLLER_PARAM_KEY); 125 StringUtil.assertNotBlank(s, 126 "You must define your controller " + 127 "parameter in your controller request"); 128 129 return getController(s); 130 } 131 } 132 | Popular Tags |