xitiomet / placebohttp (http://openstatic.org/)

Embeded Http server for gcj/java applications. PlaceboHttp uses an automatic session management system, Treating each session as a HttpRequest queue.

Clone this repository (size: 135.1 KB): HTTPS / SSH
$ hg clone http://hg.openstatic.org/placebohttp
commit 21: 3144d982a5c1
parent 20: fc9e1983c2a0
branch: default
Added JSON support. fixed standalone mode
xitiomet
6 months ago

Changed (Δ1.5 KB):

raw changeset »

Makefile (32 lines added, 3 lines removed)

src/PlaceboBase.java (11 lines added, 7 lines removed)

Up to file-list Makefile:

@@ -14,8 +14,10 @@ all: placebohttp
14
14
# Alternate build using the java vm
15
15
jvm:
16
16
	mkdir jvm-build
17
	$(JAVAC) src/*.java src/org/openstatic/http/*.java -d jvm-build
18
	$(JAVAC) src/*.java src/org/openstatic/placebo/*.java -d jvm-build
17
	$(JAVAC) src/*.java
18
	$(JAVAC) src/org/json/*.java -d jvm-build
19
	$(JAVAC) src/org/openstatic/http/*.java -d jvm-build
20
	$(JAVAC) src/org/openstatic/placebo/*.java -d jvm-build
19
21
	$(JAR) -cvmf manifest.mf placebohttp.jar -C jvm-build org -C jvm-build PlaceboBase.class www
20
22
21
23
# Executable Rule for GCJ
@@ -54,10 +56,37 @@ build/org/openstatic/placebo/CoreServer.
54
56
build/org/openstatic/util/JTextAreaOutputStream.class: src/org/openstatic/util/JTextAreaOutputStream.java
55
57
	$(JC) $(JC_FLAGS) --classpath=$(CLASS_PATH) -C $<
56
58
59
build/org/openstatic/util/JSONUtil.class: src/org/openstatic/util/JSONUtil.java
60
	$(JC) $(JC_FLAGS) --classpath=$(CLASS_PATH) -C $<
61
62
# Org.JSON
63
64
build/org/json/JSONArray.class: src/org/json/JSONArray.java build/org/json/JSONObject.class
65
	$(JC) $(JC_FLAGS) -w --classpath=$(CLASS_PATH) -C $<
66
67
build/org/json/JSONException.class: src/org/json/JSONException.java
68
	$(JC) $(JC_FLAGS) -w --classpath=$(CLASS_PATH) -C $<
69
70
build/org/json/JSONObject.class: src/org/json/JSONObject.java build/org/json/JSONException.class build/org/json/JSONTokener.class build/org/json/JSONString.class
71
	$(JC) $(JC_FLAGS) -w --classpath=$(CLASS_PATH) -C $<
72
73
build/org/json/JSONString.class: src/org/json/JSONString.java
74
	$(JC) $(JC_FLAGS) -w --classpath=$(CLASS_PATH) -C $<
75
76
build/org/json/JSONStringer.class: src/org/json/JSONStringer.java
77
	$(JC) $(JC_FLAGS) -w --classpath=$(CLASS_PATH) -C $<
78
79
build/org/json/JSONTokener.class: src/org/json/JSONTokener.java build/org/json/JSONException.class
80
	$(JC) $(JC_FLAGS) -w --classpath=$(CLASS_PATH) -C $<
81
82
build/org/json/JSONWriter.class: src/org/json/JSONWriter.java build/org/json/JSONObject.class
83
	$(JC) $(JC_FLAGS) -w --classpath=$(CLASS_PATH) -C $<
84
85
57
86
# Main Builds
58
87
# -------------------------------------------------------------------------------
59
88
60
placebohttp.jar: build/org/openstatic/http/PlaceboHttpServer.class build/org/openstatic/http/PlaceboSession.class build/org/openstatic/http/HttpRequest.class build/org/openstatic/http/HttpRequestThread.class build/org/openstatic/http/HttpResponse.class build/PlaceboBase.class build/org/openstatic/placebo/ControlPanel.class build/org/openstatic/placebo/CoreServer.class build/org/openstatic/util/JTextAreaOutputStream.class
89
placebohttp.jar: build/org/openstatic/http/PlaceboHttpServer.class build/org/openstatic/http/PlaceboSession.class build/org/openstatic/http/HttpRequest.class build/org/openstatic/http/HttpRequestThread.class build/org/openstatic/http/HttpResponse.class build/PlaceboBase.class build/org/openstatic/placebo/ControlPanel.class build/org/openstatic/placebo/CoreServer.class build/org/openstatic/util/JSONUtil.class build/org/openstatic/util/JTextAreaOutputStream.class build/org/json/JSONArray.class build/org/json/JSONException.class build/org/json/JSONObject.class build/org/json/JSONString.class build/org/json/JSONStringer.class build/org/json/JSONTokener.class build/org/json/JSONWriter.class
61
90
	$(JAR) -cvmf manifest.mf $@ -C build org -C build PlaceboBase.class www
62
91
63
92
clean:

Up to file-list src/PlaceboBase.java:

@@ -11,7 +11,7 @@ public class PlaceboBase
11
11
        System.err.println("  --root [path]                  Set webroot");
12
12
        System.err.println("  --port [port]                  Specify HTTP listening port");
13
13
        System.err.println("  --help                         display this menu");
14
        System.err.println("  --swing                        Start up in swing control panel");
14
        System.err.println("  --headless                     Start up without swing");
15
15
        System.err.println("");
16
16
        System.err.println("");
17
17
    }
@@ -21,7 +21,7 @@ public class PlaceboBase
21
21
        int http_port = 80;
22
22
        boolean debug = false;
23
23
        String web_root = "placebohttp.jar/www";
24
        boolean start_engine = true;
24
        boolean start_engine = false;
25
25
        
26
26
        for (int i = 0; i < args.length; i++)
27
27
        {
@@ -55,15 +55,14 @@ public class PlaceboBase
55
55
                debug = true;
56
56
            }
57
57
            
58
            if (arg.equals("--swing"))
58
            if (arg.equals("--headless"))
59
59
            {
60
                ControlPanel cp = new ControlPanel();
61
                cp.setPort(http_port);
62
                cp.setWebRoot(web_root);
63
                cp.setDebug(debug);
60
                start_engine = true;
64
61
            }
65
62
        }
66
63
        
64
        
65
        
67
66
        if (start_engine)
68
67
        {
69
68
            CoreServer x = new CoreServer();
@@ -71,6 +70,11 @@ public class PlaceboBase
71
70
            x.setWebRoot(web_root);
72
71
            x.setDebug(debug);
73
72
            x.start();
73
        } else {
74
            ControlPanel cp = new ControlPanel();
75
            cp.setPort(http_port);
76
            cp.setWebRoot(web_root);
77
            cp.setDebug(debug);
74
78
        }
75
79
    }
76
80