use of com.kixeye.chassis.transport.websocket.docs.ProtobufEnvelopeDocumentationServlet in project chassis by Kixeye.
the class AdminTransportConfiguration method adminServer.
@Bean(initMethod = "start", destroyMethod = "stop")
@Order(0)
public Server adminServer(@Value("${admin.hostname}") String hostname, @Value("${admin.port}") int port) {
// set up servlets
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS | ServletContextHandler.NO_SECURITY);
context.setErrorHandler(null);
context.setWelcomeFiles(new String[] { "/" });
// enable gzip
context.addFilter(GzipFilter.class, "/*", null);
// add common admin servlets
context.addServlet(new ServletHolder(new HealthServlet(healthCheckRegistry)), "/healthcheck");
context.addServlet(new ServletHolder(new ClasspathResourceServlet("com/kixeye/chassis/transport/admin", "/admin/", "index.html")), "/admin/*");
context.addServlet(new ServletHolder(new PropertiesServlet()), "/admin/properties");
context.addServlet(new ServletHolder(new ClasspathDumpServlet()), "/admin/classpath");
// add websocket servlets if WebSockets have been initialized
if (mappingRegistry != null && messageRegistry != null) {
context.addServlet(new ServletHolder(new ProtobufMessagesDocumentationServlet(appName, mappingRegistry, messageRegistry)), "/schema/messages/protobuf");
context.addServlet(new ServletHolder(new ProtobufEnvelopeDocumentationServlet()), "/schema/envelope/protobuf");
}
// add metric servlets if Metric has been initialized
if (metricRegistry != null && healthCheckRegistry != null) {
context.getServletContext().setAttribute(MetricsServlet.METRICS_REGISTRY, metricRegistry);
context.getServletContext().setAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY, healthCheckRegistry);
ServletHolder holder = new ServletHolder(new AdminServlet());
holder.setInitParameter("service-name", System.getProperty("app.name"));
context.addServlet(holder, "/metrics/*");
}
// create the server
InetSocketAddress address = StringUtils.isBlank(hostname) ? new InetSocketAddress(port) : new InetSocketAddress(hostname, port);
Server server = new Server();
JettyConnectorRegistry.registerHttpConnector(server, address);
server.setHandler(context);
return server;
}
Aggregations