Android Open Source - inspectable Http Server






From Project

Back to project page inspectable.

License

The source code is released under:

Apache License

If you think the Android project inspectable listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package me.hanqin.apps.inspect.server;
/*from   ww w.j  a  va 2  s  .  com*/
import java.util.Map;

import fi.iki.elonen.NanoHTTPD;

public class HttpServer extends NanoHTTPD {

    private static HttpServer instance;
    private DefaultRequestDispatcher requestDispatcher;

    public HttpServer(int port) {
        super(port);
    }

    public HttpServer(String hostname, int port) {
        super(hostname, port);
    }

    public synchronized static HttpServer instantiate(int testServerPort) {
        if (instance != null) {
            throw new IllegalStateException("Can only instantiate once!");
        }
        instance = new HttpServer(testServerPort);
        return instance;
    }

    public synchronized static HttpServer getInstance() {
        if (instance == null) {
            throw new IllegalStateException("Must be initialized!");
        }
        return instance;
    }

    @Override
    public Response serve(String uri, Method method, Map<String, String> headers, Map<String, String> parms, Map<String, String> files) {
        return requestDispatcher.dispatch(uri, method, headers, parms, files);
    }

    public void setRequestDispatcher(DefaultRequestDispatcher requestDispatcher) {
        this.requestDispatcher = requestDispatcher;
    }
}




Java Source Code List

fi.iki.elonen.NanoHTTPD.java
me.hanqin.apps.inspect.Inspectable.java
me.hanqin.apps.inspect.PreferenceConfigure.java
me.hanqin.apps.inspect.handlers.BaseHandler.java
me.hanqin.apps.inspect.handlers.DatabaseHandler.java
me.hanqin.apps.inspect.server.DefaultRequestDispatcher.java
me.hanqin.apps.inspect.server.HttpServer.java
me.hanqin.apps.inspect.util.JSONUtil.java