All Downloads are FREE. Search and download functionalities are using the official Maven repository.

be.bagofwords.application.status.HttpApplicationStatus Maven / Gradle / Ivy

Go to download

Utility classes that are used in the count-db project and other bow-* projects

The newest version!
package be.bagofwords.application.status;

import be.bagofwords.application.ApplicationContext;
import be.bagofwords.web.BaseController;
import spark.Request;
import spark.Response;

import java.io.IOException;
import java.util.List;

public class HttpApplicationStatus extends BaseController {

    private ApplicationContext applicationContext;

    public HttpApplicationStatus() {
        super("/status");
    }

    protected String getOutput() throws IOException {
        StringBuilder sb = new StringBuilder();
        List statusViewables = applicationContext.getBeans(StatusViewable.class);
        for (StatusViewable statusViewable : statusViewables) {
            statusViewable.printHtmlStatus(sb);
        }
        return sb.toString();
    }

    @Override
    public String handleRequest(Request request, Response response) throws IOException {
        StringBuilder sb = new StringBuilder();
        String applicationName = applicationContext.getApplicationName();
        sb.append("" + applicationName + ": application status");
        sb.append(getOutput());
        sb.append("");
        return sb.toString();
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy