FileDocCategorySizeDatePackage
DomainReporter.javaAPI DocGlassfish v2 API9181Fri May 04 22:25:10 BST 2007com.sun.enterprise.cli.commands

DomainReporter

public class DomainReporter extends Object
author
kedarm

Fields Summary
private final boolean
detailed
private final com.sun.enterprise.admin.servermgmt.DomainConfig
dc
private static final com.sun.enterprise.cli.framework.CLILogger
logger
private static final com.sun.enterprise.util.i18n.StringManager
lsm
private final List
records
private com.sun.enterprise.config.ConfigContext
cc
private String
sn
Constructors Summary
DomainReporter(com.sun.enterprise.admin.servermgmt.DomainConfig dc, boolean terse, com.sun.enterprise.config.ConfigContext cc)

 // the server name
    /* package private constructor */
          
           
        if (dc == null || cc == null) {
            throw new IllegalArgumentException ("Null Argument");
        }
        this.dc       = dc;
        this.detailed = !terse;
        this.cc       = cc;
    
Methods Summary
private voiddisplay()

        for (final String record : records) {
            logger.printMessage(record);
        }
    
private java.lang.StringgetAdminConsoleMessage()

        final HttpListener admin = ServerHelper.getHttpListener(cc, sn, ServerHelper.ADMIN_HTTP_LISTNER_ID);
        String url = "", port = null;
        if (admin != null) {
            url = ServerHelper.getUrlString(admin);
            port = admin.getPort();
        }
        return ( lsm.getString("admin.console.msg", url, port) );
    
private java.lang.StringgetClusterSupport()

        final boolean sc = ServerHelper.isClusterAdminSupported(cc);
        if (sc)
            return (lsm.getString("clusters.supported.msg"));
        return (lsm.getString("clusters.not.supported.msg"));
    
private java.lang.StringgetDebugMessage()

        String msg = "";
        boolean debugMode = false;
        try{
            debugMode = (Boolean)dc.get(DomainConfig.K_DEBUG);
        } catch(final Exception e) {
            // squelch, it's OK if we couldn't get the debug flag
            e.hashCode();   // silence FindBugs
        }
        if (debugMode) {
            final JavaConfig jc = ServerHelper.getConfigForServer(cc, sn).getJavaConfig();
            final String dopt = jc.getDebugOptions();
            msg = lsm.getString("start.debug.msg", dopt);
        }
        return ( msg );
    
private java.lang.StringgetDomainBanner(java.lang.String dn, java.lang.String version, java.lang.String dr)

        return ( lsm.getString("domain.report.banner", dn, version, dr));
    
private java.lang.StringgetHttpPorts()

        String hp = "";
        final HttpListener[] hss = ServerHelper.getConfigForServer(cc, sn).getHttpService().getHttpListener();
        for (final HttpListener hs : hss) {
            if (hs.isEnabled()) {
                hp += hs.getPort();
                hp += " ";
            }
        }
        return ( hp );
    
private java.lang.StringgetHttpUrlsMessage()

        final HttpListener[] lss = ServerHelper.getHttpListeners(cc, sn);
        String urls = "";
        if (lss != null) {
            for (final HttpListener ls : lss) {
                if (ServerHelper.ADMIN_HTTP_LISTNER_ID.equals(ls.getId()))
                    continue;  //skip the admin listener
                if (ls.isEnabled()) {
                    urls += ServerHelper.getUrlString(ls);
                    urls += " ";
                }
            }
        }
        return ( lsm.getString("http.listeners.msg", urls) );
    
private java.lang.StringgetIiopPorts()

        String ip = "";
        final IiopListener[] ils = ServerHelper.getConfigForServer(cc, sn).getIiopService().getIiopListener();
        for (final IiopListener is : ils) {
            if (is.isEnabled()) {
                ip += is.getPort();
                ip += " ";
            }
        }
        return ( ip );
    
private java.lang.StringgetJmxConnectorPorts()

        String jp = "";
        final JmxConnector[] jcs = ServerHelper.getConfigForServer(cc, sn).getAdminService().getJmxConnector();
        for (final JmxConnector jc : jcs) {
            if (jc.isEnabled()) {
                jp += jc.getPort();
                jp += " ";
            }
        }
        return ( jp );
    
private java.lang.StringgetJmxServiceUrlMessage()

        String url = "";
        final JmxConnector sjc = ServerHelper.getServerSystemConnector(cc, sn);
        if (sjc != null) {
            url += ServerHelper.getJmxServiceUrl(sjc);
        }
        return ( lsm.getString("jmx.connector.msg", url) );
    
private java.lang.StringgetOccupiedPorts()

        String ports = "";
        ports = getHttpPorts() + getIiopPorts() + getJmxConnectorPorts();
        return ( lsm.getString("ports.msg", ports) );
    
private java.lang.StringgetWebContextsMessage()

        final WebModule[] wms = ServerHelper.getAssociatedWebModules(cc, sn);
        String crs = "";
        for (final WebModule wm : wms) {
           crs += wm.getContextRoot();
           crs += " ";
        }
        return ( lsm.getString("web.contexts.msg", crs) );
    
private voidprepare()

        final PEFileLayout layout = new PEFileLayout(dc);
        final String xmlPath      = layout.getDomainConfigFile().getAbsolutePath();
        this.sn                   = SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME;
        
        final String ver = Version.getFullVersion();
        records.add(getDomainBanner(dc.getDomainName(), ver, dc.getDomainRoot()));
        if (detailed) {
            records.add(getAdminConsoleMessage());
            records.add(getHttpUrlsMessage());
            records.add(getWebContextsMessage());
            records.add(getJmxServiceUrlMessage());
            records.add(getOccupiedPorts());
            records.add(getClusterSupport());
            records.add(getDebugMessage());
        }
    
voidreport()

        prepare();
        display();