private void addServlet(Map<Integer, ServletContextHandler> handlersMap, Descriptor descriptor) {
    final int port = descriptor.getPort();
    final String path = descriptor.getPath();
    final HttpServlet servlet = descriptor.getServlet();
    // if port is < 0, use one for this servlet only
    int key = port < 0 ? -1 - handlersMap.size() : port;
    ServletContextHandler handler = handlersMap.computeIfAbsent(key, p -> {
      ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
      servletHandler.setContextPath("/");
      servletHandler.setGzipHandler(new GzipHandler());
      return servletHandler;
    });
    ServletHolder servletHolder = new ServletHolder(servlet);
    servletHolder.setInitParameter("javax.ws.rs.Application", "ServiceListPublic");
    handler.addServlet(servletHolder, "/" + path + "/*");
  }
Adds a servlet to its intended servlet context context.

@param handlersMap the map of port to handlers
@param descriptor  the servlet descriptor
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ServletServerBuilder.java