private void initPersistence(
      String configName,
      ConfigurationContext configurationContext,
      ServerContextInformation contextInfo)
      throws RegistryException, AxisFault {
    // Initialize the mediation persistence manager if required
    ServerConfiguration serverConf = ServerConfiguration.getInstance();
    String persistence = serverConf.getFirstProperty(ServiceBusConstants.PERSISTENCE);
    org.wso2.carbon.registry.core.Registry configRegistry =
        (org.wso2.carbon.registry.core.Registry)
            SuperTenantCarbonContext.getCurrentContext(configurationContext)
                .getRegistry(RegistryType.SYSTEM_CONFIGURATION);

    // Check whether persistence is disabled
    if (!ServiceBusConstants.DISABLED.equals(persistence)) {

      // Check registry persistence is disabled or not
      String regPersistence = serverConf.getFirstProperty(ServiceBusConstants.REGISTRY_PERSISTENCE);
      UserRegistry registry =
          ServiceBusConstants.DISABLED.equals(regPersistence)
              ? null
              : (UserRegistry) configRegistry;

      // Check the worker interval is set or not
      String interval = serverConf.getFirstProperty(ServiceBusConstants.WORKER_INTERVAL);
      long intervalInMillis = 5000L;
      if (interval != null && !"".equals(interval)) {
        try {
          intervalInMillis = Long.parseLong(interval);
        } catch (NumberFormatException e) {
          log.error(
              "Invalid value "
                  + interval
                  + " specified for the mediation "
                  + "persistence worker interval, Using defaults",
              e);
        }
      }

      MediationPersistenceManager pm =
          new MediationPersistenceManager(
              registry,
              contextInfo.getServerConfigurationInformation().getSynapseXMLLocation(),
              contextInfo.getSynapseConfiguration(),
              intervalInMillis,
              configName);

      configurationContext
          .getAxisConfiguration()
          .addParameter(new Parameter(ServiceBusConstants.PERSISTENCE_MANAGER, pm));
    } else {
      log.info("Persistence for mediation configuration is disabled");
    }
  }
  public void process(
      HttpRequest request,
      HttpResponse response,
      MessageContext messageContext,
      NHttpServerConnection conn,
      OutputStream outputStream,
      boolean b) {

    boolean isRequestHandled = false;

    String uri = request.getRequestLine().getUri();

    String servicePath = cfgCtx.getServiceContextPath();
    if (!servicePath.startsWith("/")) {
      servicePath = "/" + servicePath;
    }
    String serviceName = getServiceName(request);

    boolean loadBalancer = Boolean.parseBoolean(System.getProperty("wso2.loadbalancer", "false"));
    if (uri.equals("/favicon.ico")) {
      response.setStatusCode(HttpStatus.SC_MOVED_PERMANENTLY);
      response.addHeader("Location", "http://wso2.org/favicon.ico");
      serverHandler.commitResponseHideExceptions(conn, response);
      isRequestHandled = true;
    } else if (uri.startsWith(servicePath) && (serviceName == null || serviceName.length() == 0)) {
      // check if service listing request is blocked
      if (isServiceListBlocked(uri)) {
        response.setStatusCode(HttpStatus.SC_FORBIDDEN);
        serverHandler.commitResponseHideExceptions(conn, response);
      } else {
        generateServicesList(response, conn, outputStream, servicePath);
      }
      try {
        outputStream.flush();
        outputStream.close();
      } catch (IOException ignore) {
      }
      isRequestHandled = true;
    } else {
      int pos = uri.indexOf('?');
      if (pos != -1) {
        String queryString = uri.substring(pos + 1);
        String requestUri = uri.substring(0, pos);
        String requestUrl = uri;
        if (requestUri.indexOf("://") == -1) {
          HttpInetConnection inetConn = (HttpInetConnection) conn;

          String hostName = "localhost";
          ServerConfiguration serverConfig = ServerConfiguration.getInstance();
          if (serverConfig.getFirstProperty("HostName") != null) {
            hostName = serverConfig.getFirstProperty("HostName");
          }

          requestUrl = "http://" + hostName + ":" + inetConn.getLocalPort() + requestUri;
        }

        String contextPath = cfgCtx.getServiceContextPath();
        int beginIndex = -1;
        if (requestUri.indexOf(contextPath) != -1) {
          beginIndex = requestUri.indexOf(contextPath) + contextPath.length() + 1;
        }

        /**
         * This reverseProxyMode was introduce to avoid LB exposing it's own services when invoked
         * through rest call. For a soap call this works well. But for a rest call this does not
         * work as intended. in LB it has to set system property "reverseProxyMode"
         */
        boolean reverseProxyMode = Boolean.parseBoolean(System.getProperty("reverseProxyMode"));
        AxisService axisService = null;
        if (!reverseProxyMode) {
          if (!(beginIndex < 0 || beginIndex > requestUri.length())) {
            serviceName = requestUri.substring(beginIndex);
            axisService = cfgCtx.getAxisConfiguration().getServiceForActivation(serviceName);
          }

          if (axisService == null && !loadBalancer && serviceName != null) {
            // Try to see whether the service is available in a tenant
            try {
              axisService = TenantAxisUtils.getAxisService(serviceName, cfgCtx);
            } catch (AxisFault axisFault) {
              axisFault.printStackTrace();
            }
          }
        }

        if (queryString != null) {
          for (String item : getRequestProcessors.keySet()) {
            if (queryString.indexOf(item) == 0
                && (queryString.equals(item)
                    || queryString.indexOf("&") == item.length()
                    || queryString.indexOf("=") == item.length())) {
              if (axisService == null) {
                continue;
              }

              try {
                processWithGetProcessor(
                    request,
                    response,
                    requestUri,
                    requestUrl,
                    queryString,
                    item,
                    outputStream,
                    conn);
              } catch (Exception e) {
                handleBrowserException(response, conn, outputStream, "Error processing request", e);
              }
              isRequestHandled = true;
              break;
            }
          }
        }
      }
    }

    if (!isRequestHandled) {
      processGetAndDelete(request, response, messageContext, conn, outputStream, "GET", b);
    }
  }