FileDocCategorySizeDatePackage
ServerXMLVerifier.javaAPI DocGlassfish v2 API10746Fri May 04 22:34:10 BST 2007com.sun.enterprise.admin.verifier

ServerXMLVerifier

public class ServerXMLVerifier extends Object

Fields Summary
static Logger
_logger
public boolean
debug
public String
outputFileStr
public static final int
FAIL
public static final int
WARN
public static final int
ALL
private static int
reportLevel
public String
xmlFileName
public com.sun.enterprise.config.ConfigContext
configContext
public com.sun.enterprise.util.LocalStringManagerImpl
smh
public static ServerMgr
serverMgr
Constructors Summary
public ServerXMLVerifier()

    
      
        try {
            //resultMgr = new ResultMgr();
            //resultReport = new ResultsReport();
            StringManagerHelper.setLocalStringsManager(Class.forName(getClass().getName()));
            smh = StringManagerHelper.getLocalStringsManager();
        }
        catch (ClassNotFoundException e) {
            // Logging
            _logger.log(Level.FINE, "serverxmlverifier.error_getting_localstringsmanager", e);
        }
        init();
    
Methods Summary
public voiddebug(java.lang.String s)

        if(debug)
            // Logging
            _logger.log(Level.INFO, s);
    
public voiddebug(java.lang.Exception e)

        if(debug)
            // Logging
            _logger.log(Level.INFO, "serverxmlverifier.error_check", e);
    
public voidinit()

        File testNames = new File("lib/TestNamesMBean.xml");
        if(testNames.exists())
            // Logging
            _logger.log(Level.INFO, "serverxmlverifier.looking_file", testNames.getAbsolutePath());
    
public static voidmain(java.lang.String[] args)

        ServerXMLVerifier serverVerifier = new ServerXMLVerifier();
        serverVerifier.parseArgs(args);
    
protected voidparseArgs(java.lang.String[] args)

        if (args.length < 1)
            usage();
        else {
            //default report level is set to failures and warnings
            for (int i = 0; i < args.length;  i++) {
                String arg = args[i];
                if (arg.startsWith("-")) {
                    try {
                        switch (arg.charAt(1)) {
                            case 'v":  //verbose
                                debug = true;
                                debug(smh.getLocalString(getClass().getName() + ".verboseFlag",
                                "Setting verbose flag to TRUE."));
                                break;
                            case 'h": // Help Message
                                debug
                                (smh.getLocalString(getClass().getName() + ".helpMessage",
                                "Displaying help message."));
                                usage();
                                break;
                            case 'o": // output file name
                                debug
                                (smh.getLocalString(getClass().getName() + ".outputFileName",
                                "Retrieving results output filename."));
                                char vhstr[] = new char[arg.length()-2];
                                arg.getChars(2, arg.length(), vhstr, 0);
                                outputFileStr = new String(vhstr);
                                debug("Using this output file = " + outputFileStr);
                                ServerMgr.setFile(outputFileStr);
                                //resultReport.setUserSpecifiedOutputFile(true);
                                break;
                            default:
                                usage();
                        }
                    } catch (StringIndexOutOfBoundsException e) {
                        debug(e);
                        usage();
                    }
                }
                else
                {
                    if (xmlFileName == null){
                        xmlFileName = (new File(arg)).getAbsolutePath();
                        debug(smh.getLocalString(getClass().getName() + ".xmlFileName",
                        "XML filename: {0}",
                        new Object[]
                        {xmlFileName}));
                    } else {
                        debug(smh.getLocalString(getClass().getName() + "invalidArg",
                        "invalid argument \"{0}\"",
                        new Object[]
                        {arg}));
                        usage();
                        return;
                    }
                }
            }
            if(xmlFileName == null ){
                usage();
                return;
            }
            //verify();
        }
    
public voidusage()
Display usage message to user upon encountering invalid option

        System.err.println
        ("\n" +
        (smh.getLocalString(getClass().getName() + ".usageLine1",
        "usage: server-verifier [optional_params] <server-xml-filename>"))
        +   "\n\n" +
        (smh.getLocalString(getClass().getName() + ".usageLine2",
        "where :"))
        +   "\n\n" +
        (smh.getLocalString(getClass().getName() + ".usageLine3",
        "  [optional_params]: Must be: "))
        +   "\n\n" +
        (smh.getLocalString(getClass().getName() + ".usageLine4",
        "     -v : verbose debug turned on "))
        +   "\n\n" +
        (smh.getLocalString(getClass().getName() + ".usageLine5",
        "    -o<output file> : test results written to this file (.xml file preferred)"))
        +   "\n" +
        (smh.getLocalString(getClass().getName() + ".usageLine6",
        "                      (Overrides default file - Results.xml)"))
        +   "\n" +
        (smh.getLocalString(getClass().getName() + ".usageLine6a",
        "                      which is created in system defined <tmp> directory"))
        +   "\n" +
        (smh.getLocalString(getClass().getName() + ".usageLine17",
        "<server-xml-filename>: Jar file to perform static verification on "))
        +   "\n\n" );