FileDocCategorySizeDatePackage
MonitorUtil.javaAPI DocGlassfish v2 API4654Fri May 04 22:36:02 BST 2007com.sun.enterprise.web

MonitorUtil

public final class MonitorUtil extends Object
author
lwhite

Fields Summary
private static final Logger
_logger
Constructors Summary
Methods Summary
public static voidresetMonitorStats(EmbeddedWebContainer embedded, com.sun.enterprise.server.ServerContext serverContext)
Resets the stats of all web modules.

        _logger = LogDomains.getLogger(LogDomains.WEB_LOGGER);
    

        MonitoringRegistry monitoringRegistry =
            serverContext.getMonitoringRegistry();

        Engine[] engines = embedded.getEngines();            
        for(int h=0; h<engines.length; h++) {
            Container engine = (Container) engines[h];            
            Container[] hosts = engine.findChildren();
            for(int i=0; i<hosts.length; i++) {
                Container nextHost = hosts[i];
                Container [] webModules = nextHost.findChildren();
                for (int j=0; j<webModules.length; j++) {
                    WebModule webModule = (WebModule) webModules[j];
                    if (!webModule.hasWebXml()) {
                        // Ad-hoc module
                        continue;
                    }
                    /*
                     * Standalone webmodules are loaded with the application
                     * name set to the string "null"
                     */
                    String j2eeApp = webModule.getJ2EEApplication();
                    if ("null".equalsIgnoreCase(j2eeApp)) {
                        j2eeApp = null;
                    }
                    WebModuleStats stats =
                        monitoringRegistry.getWebModuleStats(
                            j2eeApp,
                            webModule.getModuleName(),
                            webModule.getPath(),
                            nextHost.getName());
                    if (stats != null) {
                        try {
                            stats.reset();
                        } catch (Throwable th) {
                            _logger.log(Level.SEVERE,
                                        "Error resetting WebModuleStats", th);
                        }                
                    }
                }
            }
        }