/**
   * Initialize the backend systems, the log handler and the restrictor. A subclass can tune this
   * step by overriding {@link #createRestrictor(String)} and {@link
   * #createLogHandler(ServletConfig, boolean)}
   *
   * @param pServletConfig servlet configuration
   */
  @Override
  public void init(ServletConfig pServletConfig) throws ServletException {
    super.init(pServletConfig);

    Configuration config = initConfig(pServletConfig);

    // Create a log handler early in the lifecycle, but not too early
    String logHandlerClass = config.get(ConfigKey.LOGHANDLER_CLASS);
    logHandler =
        logHandlerClass != null
            ? (LogHandler) ClassUtil.newInstance(logHandlerClass)
            : createLogHandler(pServletConfig, Boolean.valueOf(config.get(ConfigKey.DEBUG)));

    // Different HTTP request handlers
    httpGetHandler = newGetHttpRequestHandler();
    httpPostHandler = newPostHttpRequestHandler();

    if (restrictor == null) {
      restrictor =
          createRestrictor(NetworkUtil.replaceExpression(config.get(ConfigKey.POLICY_LOCATION)));
    } else {
      logHandler.info("Using custom access restriction provided by " + restrictor);
    }
    configMimeType = config.get(ConfigKey.MIME_TYPE);
    backendManager = new BackendManager(config, logHandler, restrictor);
    requestHandler = new HttpRequestHandler(config, backendManager, logHandler);

    initDiscoveryMulticast(config);
  }
 private void initLimits(Configuration pConfig) {
   // Max traversal depth
   if (pConfig != null) {
     convertOptionsBuilder =
         new JsonConvertOptions.Builder(
             getNullSaveIntLimit(pConfig.get(MAX_DEPTH)),
             getNullSaveIntLimit(pConfig.get(MAX_COLLECTION_SIZE)),
             getNullSaveIntLimit(pConfig.get(MAX_OBJECTS)));
   } else {
     convertOptionsBuilder = new JsonConvertOptions.Builder();
   }
 }
 // Try to find an URL for system props or config
 private String findAgentUrl(Configuration pConfig) {
   // System property has precedence
   String url = System.getProperty("jolokia." + ConfigKey.DISCOVERY_AGENT_URL.getKeyValue());
   if (url == null) {
     url = System.getenv("JOLOKIA_DISCOVERY_AGENT_URL");
     if (url == null) {
       url = pConfig.get(ConfigKey.DISCOVERY_AGENT_URL);
     }
   }
   return NetworkUtil.replaceExpression(url);
 }
 protected JolokiaHandler(Map<String, String> configParameters, Restrictor restrictor) {
   log = new JolokiaLogHandler(LoggerFactory.getLogger(JolokiaHandler.class));
   Configuration config = initConfig(configParameters);
   if (restrictor == null) {
     restrictor =
         createRestrictor(NetworkUtil.replaceExpression(config.get(ConfigKey.POLICY_LOCATION)));
   }
   log.info("Using restrictor " + restrictor);
   BackendManager backendManager = new BackendManager(config, log, restrictor);
   requestHandler = new HttpRequestHandler(config, backendManager, log);
 }
  // Initialize this object;
  private void init(Configuration pConfig) {
    // Central objects
    converters = new Converters();
    initLimits(pConfig);

    // Create and remember request dispatchers
    localDispatcher = new LocalRequestDispatcher(converters, restrictor, pConfig, logHandler);
    ServerHandle serverHandle = localDispatcher.getServerInfo();
    requestDispatchers =
        createRequestDispatchers(
            pConfig.get(DISPATCHER_CLASSES), converters, serverHandle, restrictor);
    requestDispatchers.add(localDispatcher);

    // Backendstore for remembering agent state
    initStores(pConfig);
  }