Browse Source

[ci fw-only Java/act]

Gelin Luo 8 years ago
parent
commit
6b44e3d6c7

+ 28 - 0
frameworks/Java/act/src/main/java/com/techempower/act/AppEntry.java

@@ -1,11 +1,39 @@
 package com.techempower.act;
 
 
+import act.Act;
 import act.Version;
 import act.boot.app.RunApp;
+import act.job.OnAppStart;
+import com.alibaba.fastjson.JSON;
+import org.osgl.http.H;
 
 public class AppEntry {
 
+	private static final String HELLO_WORLD = "Hello, World!";
+
+	public static final class Message {
+
+		private final String message;
+
+		private Message(String message) {
+			this.message = message;
+		}
+
+		public String getMessage() {
+			return message;
+		}
+
+	}
+
+
+	@OnAppStart
+	public void routing() {
+		Act.get("/json", context -> context.resp()
+				.contentType(H.Format.JSON.contentType())
+				.writeContent(JSON.toJSONString(new Message(HELLO_WORLD))));
+	}
+
 	public static void main(String[] args) throws Exception {
 		RunApp.start("Act Test", Version.appVersion(), AppEntry.class);
 	}

+ 0 - 36
frameworks/Java/act/src/main/java/com/techempower/act/controller/HelloController.java

@@ -1,36 +0,0 @@
-package com.techempower.act.controller;
-
-import act.controller.Controller;
-import act.handler.NonBlock;
-import org.osgl.mvc.annotation.GetAction;
-import org.osgl.mvc.annotation.SessionFree;
-
-import javax.inject.Singleton;
-
-@Singleton
-final class HelloController extends Controller.Util {
-
-    private static final String HELLO_WORLD = "Hello, World!";
-
-    @GetAction("/json")
-    @SessionFree
-    @NonBlock
-    public void json() throws Exception {
-        json(new Message(HELLO_WORLD));
-    }
-
-    public static final class Message {
-
-        private final String message;
-
-        private Message(String message) {
-            this.message = message;
-        }
-
-        public String getMessage() {
-            return message;
-        }
-
-    }
-
-}

+ 4 - 0
frameworks/Java/act/src/main/resources/conf/common/app.properties

@@ -1,5 +1,9 @@
+# follow Java world convention
+http.port=8080
+
 # disable CLI service
 cli=false
+
 # disable internal metric service
 metric=false
 

+ 0 - 2
frameworks/Java/act/src/main/resources/conf/prod/app.properties

@@ -1,2 +0,0 @@
-http.port=8080
-cli.port=8081