/* throws RuntimeException maybe
   * note the default visibility so that MonitoringBootstrap can call it.
   */
  void tryToRegister(StatsProviderInfo spInfo) {
    final String configElement = spInfo.getConfigElement();
    Object statsProvider = spInfo.getStatsProvider();
    // register the statsProvider
    if (logger.isLoggable(Level.FINE)) logger.fine("registering a statsProvider");
    StatsProviderRegistryElement spre;
    // If configElement is null, create it
    if (monitoringService != null
        && monitoringService.getContainerMonitoring(configElement) == null
        && monitoringService.getMonitoringLevel(configElement) == null) {
      createConfigElement(configElement);
    }

    // First check if the configElement associated for statsProvider is 'ON'
    if (getMonitoringEnabled() && getEnabledValue(configElement)) {
      if (logger.isLoggable(Level.FINE)) logger.fine(" enabled is true ");
      spre = statsProviderRegistry.getStatsProviderRegistryElement(statsProvider);

      if (spre == null) {
        statsProviderRegistry.registerStatsProvider(spInfo);
        spre = statsProviderRegistry.getStatsProviderRegistryElement(statsProvider);
      }
      // Enable the StatsProvider if the enable is allowed
      if (spre.isEnableAllowed(getMonitoringLevel(configElement))) {
        enableStatsProvider(spre);
      }

    } else {
      if (logger.isLoggable(Level.FINE)) logger.fine(" enabled is false ");
      // Register with null values so to know that we need to register them individually and config
      // is on
      statsProviderRegistry.registerStatsProvider(spInfo);
      spre = statsProviderRegistry.getStatsProviderRegistryElement(statsProvider);
    }

    if (logger.isLoggable(Level.FINE)) {
      logger.fine(spre.toString());
      logger.fine("=========================================================");
    }
  }
 private String getMonitoringLevel(String configElement) {
   return monitoringService.getMonitoringLevel(configElement);
 }