浏览代码

jfinal 2.3 ^_^

James 9 年之前
父节点
当前提交
8593182d2f
共有 1 个文件被更改,包括 17 次插入7 次删除
  1. 17 7
      src/com/jfinal/server/JettyServer.java

+ 17 - 7
src/com/jfinal/server/JettyServer.java

@@ -47,12 +47,15 @@ class JettyServer implements IServer {
 	private WebAppContext webApp;
 	private WebAppContext webApp;
 	
 	
 	JettyServer(String webAppDir, int port, String context, int scanIntervalSeconds) {
 	JettyServer(String webAppDir, int port, String context, int scanIntervalSeconds) {
-		if (webAppDir == null)
+		if (webAppDir == null) {
 			throw new IllegalStateException("Invalid webAppDir of web server: " + webAppDir);
 			throw new IllegalStateException("Invalid webAppDir of web server: " + webAppDir);
-		if (port < 0 || port > 65536)
+		}
+		if (port < 0 || port > 65535) {
 			throw new IllegalArgumentException("Invalid port of web server: " + port);
 			throw new IllegalArgumentException("Invalid port of web server: " + port);
-		if (StrKit.isBlank(context))
+		}
+		if (StrKit.isBlank(context)) {
 			throw new IllegalStateException("Invalid context of web server: " + context);
 			throw new IllegalStateException("Invalid context of web server: " + context);
+		}
 		
 		
 		this.webAppDir = webAppDir;
 		this.webAppDir = webAppDir;
 		this.port = port;
 		this.port = port;
@@ -62,8 +65,13 @@ class JettyServer implements IServer {
 	
 	
 	public void start() {
 	public void start() {
 		if (!running) {
 		if (!running) {
-			try {doStart();} catch (Exception e) {LogKit.error(e.getMessage(), e);}
-			running = true;
+			try {
+				running = true;
+				doStart();
+			} catch (Exception e) {
+				System.err.println(e.getMessage());
+				LogKit.error(e.getMessage(), e);
+			}
 		}
 		}
 	}
 	}
 	
 	
@@ -75,8 +83,9 @@ class JettyServer implements IServer {
 	}
 	}
 	
 	
 	private void doStart() {
 	private void doStart() {
-		if (!available(port))
+		if (!available(port)) {
 			throw new IllegalStateException("port: " + port + " already in use!");
 			throw new IllegalStateException("port: " + port + " already in use!");
+		}
 		
 		
 		deleteSessionData();
 		deleteSessionData();
 		
 		
@@ -155,8 +164,9 @@ class JettyServer implements IServer {
 	
 	
 	private String getStoreDir() {
 	private String getStoreDir() {
 		String storeDir = PathKit.getWebRootPath() + "/../../session_data" + context;
 		String storeDir = PathKit.getWebRootPath() + "/../../session_data" + context;
-		if ("\\".equals(File.separator))
+		if ("\\".equals(File.separator)) {
 			storeDir = storeDir.replaceAll("/", "\\\\");
 			storeDir = storeDir.replaceAll("/", "\\\\");
+		}
 		return storeDir;
 		return storeDir;
 	}
 	}