1 7 package com.inversoft.verge.mvc.controller.form; 8 9 10 import java.util.Collections ; 11 import java.util.HashMap ; 12 import java.util.Map ; 13 14 import com.inversoft.beans.BeanException; 15 import com.inversoft.verge.mvc.controller.BeanHandle; 16 import com.inversoft.verge.mvc.controller.WebBeanHandle; 17 import com.inversoft.verge.util.WebBean; 18 19 20 33 public class FormWebBeanHandle extends WebBeanHandle { 34 35 40 private final static Class [] HANDLE_PARAMS = {FormAction.class}; 41 42 47 static final boolean CACHING = true; 48 49 52 static Map cache = new HashMap (); 53 54 55 59 60 71 private static BeanHandle getBeanHandle(String handleName, Class beanClass) 72 throws BeanException { 73 74 if (!CACHING) { 76 return new BeanHandle(handleName, beanClass, HANDLE_PARAMS); 77 } 78 79 Map propMap = null; 81 synchronized (cache) { 82 propMap = (Map ) cache.get(beanClass); 83 if (propMap == null) { 84 propMap = Collections.synchronizedMap(new HashMap ()); 85 cache.put(beanClass, propMap); 86 } 87 } 88 89 BeanHandle bh = null; 91 synchronized (propMap) { 92 bh = (BeanHandle) propMap.get(handleName); 93 if (bh == null) { 94 bh = new BeanHandle(handleName, beanClass, HANDLE_PARAMS); 95 propMap.put(handleName, bh); 96 } 97 } 98 99 return bh; 100 } 101 102 103 118 public FormWebBeanHandle(String id, String handle, int scope, String className) 119 throws BeanException { 120 super(id, handle, scope, className); 121 } 122 123 137 public FormWebBeanHandle(String definition, int scope, String className) 138 throws BeanException { 139 super(definition, scope, className); 140 } 141 142 156 public FormWebBeanHandle(String definition, int scope, Class klass) 157 throws BeanException { 158 super(definition, scope, klass); 159 } 160 161 172 public FormWebBeanHandle(WebBean webBean, String handle) throws BeanException { 173 super(webBean, handle); 174 } 175 176 177 183 public Class [] getHandleParams() { 184 return HANDLE_PARAMS; 185 } 186 187 195 protected BeanHandle findBeanHandle(String handleName, Class beanClass) 196 throws BeanException { 197 return FormWebBeanHandle.getBeanHandle(handleName, beanClass); 198 } 199 } | Popular Tags |