/** checks whether GlobalStatsProvider is registered */
 public synchronized void register() {
   if (!registered) {
     StatsProviderManager.register(ContainerMonitoring.JERSEY, PluginPoint.SERVER, "", this);
     Logger.getLogger(GlassfishMonitoringServiceProvider.LOGGER_JERSEY_MONITORING)
         .log(Level.INFO, "GlobalStatsProvider registered");
     registered = true;
   }
 }
 /** Unregister the AppStatsProviders registered for this connection pool. */
 @Override
 public void unRegisterConnectionPool() {
   Iterator jdbcProviders = jdbcPoolAppStatsProviders.iterator();
   while (jdbcProviders.hasNext()) {
     JdbcConnPoolAppStatsProvider jdbcPoolAppStatsProvider =
         (JdbcConnPoolAppStatsProvider) jdbcProviders.next();
     StatsProviderManager.unregister(jdbcPoolAppStatsProvider);
   }
   jdbcPoolAppStatsProviders.clear();
 }
  /**
   * Unregister Jdbc Connection pool from the StatsProviderManager. Remove the pool lifecycle
   * listeners associated with this pool.
   *
   * @param poolInfo
   */
  @Override
  public void unregisterPool(PoolInfo poolInfo) {
    if (jdbcStatsProviders != null) {
      Iterator i = jdbcStatsProviders.iterator();
      while (i.hasNext()) {
        JdbcConnPoolStatsProvider jdbcPoolStatsProvider = (JdbcConnPoolStatsProvider) i.next();
        if (poolInfo.equals(jdbcPoolStatsProvider.getPoolInfo())) {
          // Get registry and unregister this pool from the registry
          PoolLifeCycleListenerRegistry poolRegistry = jdbcPoolStatsProvider.getPoolRegistry();
          poolRegistry.unRegisterPoolLifeCycleListener(poolInfo);
          StatsProviderManager.unregister(jdbcPoolStatsProvider);

          i.remove();
        }
      }
    }
    connectionPoolStatsProviderBootstrapProvider.get().postUnregisterPool(poolInfo);
  }
 /**
  * Register the jdbc connection pool Stats Provider object to the monitoring framework under the
  * specific application name monitoring sub tree.
  *
  * @param appName
  * @return
  */
 @Override
 public ConnectionPoolAppProbeProvider registerConnectionPool(PoolInfo poolInfo, String appName) {
   ConnectionPoolAppProbeProvider probeAppProvider = null;
   ResourcePool pool = runtime.getConnectionPoolConfig(poolInfo);
   if (pool instanceof JdbcConnectionPool) {
     probeAppProvider = new JdbcConnPoolAppProbeProvider();
     JdbcConnPoolAppStatsProvider jdbcPoolAppStatsProvider =
         new JdbcConnPoolAppStatsProvider(poolInfo, appName);
     StatsProviderManager.register(
         "jdbc-connection-pool",
         PluginPoint.SERVER,
         "resources/"
             + ConnectorsUtil.escapeResourceNameForMonitoring(poolInfo.getName())
             + "/"
             + appName,
         jdbcPoolAppStatsProvider);
     jdbcPoolAppStatsProviders.add(jdbcPoolAppStatsProvider);
   }
   return probeAppProvider;
 }
 /**
  * Register jdbc connection pool to the StatsProviderManager. Add the pool lifecycle listeners for
  * the pool to receive events on change of any of the monitoring attribute values. Finally, add
  * this provider to the list of jdbc providers maintained.
  *
  * @param poolInfo
  */
 @Override
 public void registerPool(PoolInfo poolInfo) {
   if (poolManager.getPool(poolInfo) != null) {
     getProbeProviderUtil().createJdbcProbeProvider();
     // Found in the pool table (pool has been initialized/created)
     JdbcConnPoolStatsProvider jdbcPoolStatsProvider =
         new JdbcConnPoolStatsProvider(poolInfo, logger);
     StatsProviderManager.register(
         "jdbc-connection-pool",
         PluginPoint.SERVER,
         ConnectorsUtil.getPoolMonitoringSubTreeRoot(poolInfo, true),
         jdbcPoolStatsProvider);
     // String jdbcPoolName = jdbcPoolStatsProvider.getJdbcPoolName();
     PoolLifeCycleListenerRegistry registry =
         connectionPoolStatsProviderBootstrapProvider
             .get()
             .registerPool(poolInfo, getProbeProviderUtil().getJdbcProbeProvider());
     jdbcPoolStatsProvider.setPoolRegistry(registry);
     jdbcStatsProviders.add(jdbcPoolStatsProvider);
   }
 }
  @ProbeListener("glassfish:jersey:server-hidden:requestStart")
  public void requestStart(@ProbeParam("requestUri") java.net.URI requestUri) {
    UriRuleProbeProvider.requestStart(requestUri.toString());

    // add application to applications (global "statistics")
    String applicationName = getApplicationName(requestUri.getPath());

    ApplicationStatsProvider applicationStatsProvider;

    if (!applicationStatsProviders.containsKey(applicationName)) {
      // register new ApplicationStatsProvider
      applicationStatsProvider = new ApplicationStatsProvider(applicationName);
      applicationStatsProviders.put(applicationName, applicationStatsProvider);

      // strange functionality of PluginPoint.APPLICATIONS; it causes to
      // managed object be registered as "server.server.applications.jersey..."
      // and we ant to have it as "server.applications
      // StatsProviderManager.register("glassfish", PluginPoint.APPLICATIONS,
      //        appName + "/jersey/resources", applicationStatsProvider);

      // workaround for ^^^
      StatsProviderManager.register(
          ContainerMonitoring.JERSEY,
          PluginPoint.SERVER,
          "applications/" + applicationName + "/jersey/resources",
          applicationStatsProvider);

      Logger.getLogger(GlassfishMonitoringServiceProvider.LOGGER_JERSEY_MONITORING)
          .log(
              Level.INFO,
              "ApplicationStatsProvider for application \"" + applicationName + "\" registered");

    } else {
      applicationStatsProvider = applicationStatsProviders.get(applicationName);
    }

    currentApplicationStatProvider.set(applicationStatsProvider);
  }