Search in sources :

Example 1 with RestServlet

use of org.apache.qpid.server.management.plugin.servlet.rest.RestServlet in project qpid-broker-j by apache.

the class HttpManagement method addRestServlet.

private void addRestServlet(ServletContextHandler root) {
    Set<Class<? extends ConfiguredObject>> categories = new HashSet<>(getModel().getSupportedCategories());
    final RestServlet restServlet = new RestServlet();
    final ApiDocsServlet apiDocsServlet = new ApiDocsServlet();
    for (Class<? extends ConfiguredObject> category : categories) {
        String name = category.getSimpleName().toLowerCase();
        ServletHolder servletHolder = new ServletHolder(name, restServlet);
        servletHolder.getRegistration().setMultipartConfig(new MultipartConfigElement("", getContextValue(Long.class, MAX_HTTP_FILE_UPLOAD_SIZE_CONTEXT_NAME), -1L, getContextValue(Integer.class, MAX_HTTP_FILE_UPLOAD_SIZE_CONTEXT_NAME)));
        List<String> paths = Arrays.asList("/api/latest/" + name, "/api/v" + BrokerModel.MODEL_VERSION + "/" + name);
        for (String path : paths) {
            root.addServlet(servletHolder, path + "/*");
        }
        ServletHolder docServletHolder = new ServletHolder(name + "docs", apiDocsServlet);
        root.addServlet(docServletHolder, "/apidocs/latest/" + name + "/");
        root.addServlet(docServletHolder, "/apidocs/v" + BrokerModel.MODEL_VERSION + "/" + name + "/");
        root.addServlet(docServletHolder, "/apidocs/latest/" + name);
        root.addServlet(docServletHolder, "/apidocs/v" + BrokerModel.MODEL_VERSION + "/" + name);
    }
    final ServletHolder versionsServletHolder = new ServletHolder(new JsonValueServlet(getApiProperties()));
    root.addServlet(versionsServletHolder, "/api");
    root.addServlet(versionsServletHolder, "/api/");
}
Also used : JsonValueServlet(org.apache.qpid.server.management.plugin.servlet.rest.JsonValueServlet) ApiDocsServlet(org.apache.qpid.server.management.plugin.servlet.rest.ApiDocsServlet) MultipartConfigElement(javax.servlet.MultipartConfigElement) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) RestServlet(org.apache.qpid.server.management.plugin.servlet.rest.RestServlet) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 MultipartConfigElement (javax.servlet.MultipartConfigElement)1 ApiDocsServlet (org.apache.qpid.server.management.plugin.servlet.rest.ApiDocsServlet)1 JsonValueServlet (org.apache.qpid.server.management.plugin.servlet.rest.JsonValueServlet)1 RestServlet (org.apache.qpid.server.management.plugin.servlet.rest.RestServlet)1 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)1 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1