1 7 package com.inversoft.verge.mvc.controller.form.config; 8 9 10 import java.lang.reflect.Method ; 11 12 import com.inversoft.util.ReflectionTools; 13 import com.inversoft.verge.mvc.config.BaseConfig; 14 import com.inversoft.verge.mvc.controller.WebBeanHandle; 15 16 17 24 public class ActionConfig extends BaseConfig { 25 26 private WebBeanHandle handle; 27 private String handleRID; 28 private boolean repository; 29 private boolean modelEnabled = true; 30 private boolean validationEnabled = true; 31 private boolean longTxnEnabled = false; 32 private String longTxnStartURL; 33 private String longTxnEndURL; 34 private String longTxnCategory; 35 private Method preHandle; 36 private Method postHandle; 37 38 39 43 private ActionConfig(String name, boolean modelEnabled, 44 boolean validationEnabled, boolean longTxnEnabled, 45 String longTxnStartURL, String longTxnEndURL, String longTxnCategory) { 46 super(name); 47 48 this.modelEnabled = modelEnabled; 49 this.validationEnabled = validationEnabled; 50 this.longTxnEnabled = longTxnEnabled; 51 this.longTxnStartURL = longTxnStartURL; 52 this.longTxnEndURL = longTxnEndURL; 53 this.longTxnCategory = longTxnCategory; 54 } 55 56 60 public ActionConfig(String name, WebBeanHandle handle, boolean modelEnabled, 61 boolean validationEnabled, boolean longTxnEnabled, 62 String longTxnStartURL, String longTxnEndURL, String longTxnCategory) { 63 this(name, modelEnabled, validationEnabled, longTxnEnabled, 64 longTxnStartURL, longTxnEndURL, longTxnCategory); 65 66 assert (handle != null) : "handle == null"; 67 this.handle = handle; 68 setupMethods(); 69 } 70 71 79 public ActionConfig(String name, String handleRID, boolean modelEnabled, 80 boolean validationEnabled, boolean longTxnEnabled, 81 String longTxnStartURL, String longTxnEndURL, String longTxnCategory) { 82 this(name, modelEnabled, validationEnabled, longTxnEnabled, 83 longTxnStartURL, longTxnEndURL, longTxnCategory); 84 this.handleRID = handleRID; 85 repository = true; 86 } 87 88 89 92 private void setupMethods() { 93 Class klass = handle.getWebBean().getBeanClass(); 95 Class [] params = handle.getHandleParams(); 96 preHandle = ReflectionTools.findMethod(klass, "preHandle", 97 params, 0); 98 99 Class [] postParams = params; 100 if (params != null && params.length > 0) { 101 postParams = new Class [params.length + 1]; 102 System.arraycopy(params, 0, postParams, 0, params.length); 103 postParams[params.length] = Object .class; 104 } 105 106 postHandle = ReflectionTools.findMethod(klass, "postHandle", 107 postParams, 0); 108 } 109 110 111 116 public String getHandleRID() { 117 return handleRID; 118 } 119 120 125 public boolean isRepository() { 126 return repository; 127 } 128 129 134 public WebBeanHandle getHandle() { 135 return handle; 136 } 137 138 143 void setHandle(WebBeanHandle handle) { 144 assert (handle != null) : "handle == null"; 145 this.handle = handle; 146 setupMethods(); 147 } 148 149 150 156 public boolean isModelEnabled() { 157 return modelEnabled; 158 } 159 160 165 void setModelEnabled(boolean modelEnabled) { 166 this.modelEnabled = modelEnabled; 167 } 168 169 175 public boolean isValidationEnabled() { 176 return validationEnabled; 177 } 178 179 185 void setValidationEnabled(boolean validationEnabled) { 186 this.validationEnabled = validationEnabled; 187 } 188 189 195 public boolean isLongTxnEnabled() { 196 return longTxnEnabled; 197 } 198 199 205 void setLongTxnEnabled(boolean longTxnEnabled) { 206 this.longTxnEnabled = longTxnEnabled; 207 } 208 209 214 public Method getPreHandleMethod() { 215 return preHandle; 216 } 217 218 223 public Method getPostHandleMethod() { 224 return postHandle; 225 } 226 227 232 public String getLongTxnStartURL() { 233 return longTxnStartURL; 234 } 235 236 241 void setLongTxnStartURL(String longTxnStartURL) { 242 this.longTxnStartURL = longTxnStartURL; 243 } 244 245 246 251 public String getLongTxnEndURL() { 252 return longTxnEndURL; 253 } 254 255 260 void setLongTxnEndURL(String longTxnEndURL) { 261 this.longTxnEndURL = longTxnEndURL; 262 } 263 264 270 public String getLongTxnCategory() { 271 return longTxnCategory; 272 } 273 274 280 void setLongTxnCategory(String longTxnCategory) { 281 this.longTxnCategory = longTxnCategory; 282 } 283 } | Popular Tags |