Example #1
0
  /**
   * Initialize this JolokiaServer with the given HttpServer. The calle is responsible for managing
   * (starting/stopping) the HttpServer.
   *
   * @param pServer server to use
   * @param pConfig configuration
   * @param pLazy whether the initialization should be done lazy or not
   */
  protected final void init(HttpServer pServer, JolokiaServerConfig pConfig, boolean pLazy) {
    config = pConfig;
    lazy = pLazy;

    // Create proper context along with handler
    final String contextPath = pConfig.getContextPath();
    jolokiaHttpHandler = new JolokiaHttpHandler(pConfig.getJolokiaConfig());
    HttpContext context = pServer.createContext(contextPath, jolokiaHttpHandler);

    // Add authentication if configured
    final Authenticator authenticator = pConfig.getAuthenticator();
    if (authenticator != null) {
      context.setAuthenticator(authenticator);
    }

    url = detectAgentUrl(pServer, pConfig, contextPath);
  }