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/");
}
Aggregations