Browse Source

jfinal 3.4

James 7 years ago
parent
commit
23b7e97b4d

+ 9 - 2
src/main/java/com/jfinal/config/Constants.java

@@ -51,9 +51,10 @@ final public class Constants {
 	private int maxPostSize = Const.DEFAULT_MAX_POST_SIZE;
 	private int freeMarkerTemplateUpdateDelay = Const.DEFAULT_FREEMARKER_TEMPLATE_UPDATE_DELAY;	// just for not devMode
 	
+	private ControllerFactory controllerFactory = Const.DEFAULT_CONTROLLER_FACTORY;
+	private int configPluginOrder = Const.DEFAULT_CONFIG_PLUGIN_ORDER;
+	
 	private ITokenCache tokenCache = null;
-	private ControllerFactory controllerFactory = null;
-	private int configPluginOrder = 2;
 	
 	/**
 	 * Set development mode.
@@ -135,6 +136,9 @@ final public class Constants {
 	 * @param encoding the encoding
 	 */
 	public void setEncoding(String encoding) {
+		if (StrKit.isBlank(encoding)) {
+			throw new IllegalArgumentException("encoding can not be blank.");
+		}
 		this.encoding = encoding;
 	}
 	
@@ -143,6 +147,9 @@ final public class Constants {
 	}
 	
 	public void setControllerFactory(ControllerFactory controllerFactory) {
+		if (controllerFactory == null) {
+			throw new IllegalArgumentException("controllerFactory can not be null.");
+		}
 		this.controllerFactory = controllerFactory;
 	}
 	

+ 1 - 6
src/main/java/com/jfinal/core/ActionHandler.java

@@ -40,12 +40,7 @@ public class ActionHandler extends Handler {
 	protected void init(ActionMapping actionMapping, Constants constants) {
 		this.actionMapping = actionMapping;
 		this.devMode = constants.getDevMode();
-		
-		if (constants.getControllerFactory() != null) {
-			controllerFactory = constants.getControllerFactory();
-		} else {
-			controllerFactory = new ControllerFactory();
-		}
+		this.controllerFactory = constants.getControllerFactory();
 	}
 	
 	/**

+ 5 - 1
src/main/java/com/jfinal/core/Const.java

@@ -23,7 +23,7 @@ import com.jfinal.render.ViewType;
  */
 public interface Const {
 	
-	String JFINAL_VERSION = "3.3";
+	String JFINAL_VERSION = "3.4";
 	
 	ViewType DEFAULT_VIEW_TYPE = ViewType.JFINAL_TEMPLATE;
 	
@@ -50,5 +50,9 @@ public interface Const {
 	int DEFAULT_SECONDS_OF_TOKEN_TIME_OUT = 900;			// 900 seconds ---> 15 minutes
 	
 	int MIN_SECONDS_OF_TOKEN_TIME_OUT = 300;				// 300 seconds ---> 5 minutes
+	
+	int DEFAULT_CONFIG_PLUGIN_ORDER = 2;
+	
+	ControllerFactory DEFAULT_CONTROLLER_FACTORY = new ControllerFactory();
 }