src/share/jaxws_classes/com/sun/org/glassfish/external/probe/provider/StatsProviderManager.java

Tue, 06 Mar 2012 16:09:35 -0800

author
ohair
date
Tue, 06 Mar 2012 16:09:35 -0800
changeset 286
f50545b5e2f1
child 368
0989ad8c0860
permissions
-rw-r--r--

7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom

     1 /*
     2  * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.org.glassfish.external.probe.provider;
    28 import java.util.Vector;
    30 /**
    31  *
    32  * @author abbagani
    33  */
    34 public class StatsProviderManager {
    36    private StatsProviderManager(){
    37    }
    40    public static boolean register(String configElement, PluginPoint pp,
    41                                     String subTreeRoot, Object statsProvider) {
    42         return (register(pp, configElement, subTreeRoot, statsProvider, null));
    43    }
    45    public static boolean register(PluginPoint pp, String configElement,
    46                                   String subTreeRoot, Object statsProvider,
    47                                   String invokerId) {
    48         StatsProviderInfo spInfo =
    49             new StatsProviderInfo(configElement, pp, subTreeRoot, statsProvider, invokerId);
    51         return registerStatsProvider(spInfo);
    52    }
    54    public static boolean register(String configElement, PluginPoint pp,
    55                                     String subTreeRoot, Object statsProvider,
    56                                     String configLevelStr) {
    57         return(register(configElement, pp, subTreeRoot, statsProvider, configLevelStr, null));
    58    }
    60    public static boolean register(String configElement, PluginPoint pp,
    61                                     String subTreeRoot, Object statsProvider,
    62                                     String configLevelStr, String invokerId) {
    63         StatsProviderInfo spInfo =
    64             new StatsProviderInfo(configElement, pp, subTreeRoot, statsProvider, invokerId);
    65         spInfo.setConfigLevel(configLevelStr);
    67         return registerStatsProvider(spInfo);
    68    }
    70    private static boolean registerStatsProvider(StatsProviderInfo spInfo) {
    71       //Ideally want to start this in a thread, so we can reduce the startup time
    72       if (spmd == null) {
    73           //Make an entry into the toBeRegistered map
    74           toBeRegistered.add(spInfo);
    75       } else {
    76           spmd.register(spInfo);
    77           return true;
    78       }
    79        return false;
    80    }
    82    public static boolean unregister(Object statsProvider) {
    83       //Unregister the statsProvider if the delegate is not null
    84       if (spmd == null) {
    85           for (StatsProviderInfo spInfo : toBeRegistered) {
    86               if (spInfo.getStatsProvider() == statsProvider) {
    87                   toBeRegistered.remove(spInfo);
    88                   break;
    89               }
    90           }
    92       } else {
    93           spmd.unregister(statsProvider);
    94           return true;
    95       }
    96        return false;
    97    }
   100    public static boolean hasListeners(String probeStr) {
   101       //See if the probe has any listeners registered
   102       if (spmd == null) {
   103           return false;
   104       } else {
   105           return spmd.hasListeners(probeStr);
   106       }
   107    }
   110    public static void setStatsProviderManagerDelegate(
   111                                     StatsProviderManagerDelegate lspmd) {
   112       //System.out.println("in StatsProviderManager.setStatsProviderManagerDelegate ***********");
   113       if (lspmd == null) {
   114           //Should log and throw an exception
   115           return;
   116       }
   118       //Assign the Delegate
   119       spmd = lspmd;
   121       //System.out.println("Running through the toBeRegistered array to call register ***********");
   123       //First register the pending StatsProviderRegistryElements
   124       for (StatsProviderInfo spInfo : toBeRegistered) {
   125           spmd.register(spInfo);
   126       }
   128       //Now that you registered the pending calls, Clear the toBeRegistered store
   129       toBeRegistered.clear();
   130    }
   132    //variables
   133    static StatsProviderManagerDelegate spmd; // populate this during our initilaization process
   134    static Vector<StatsProviderInfo> toBeRegistered = new Vector();
   135 }

mercurial