⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 staxmonitor.java

📁 Software Testing Automation Framework (STAF)的开发代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        new String("staf/staxmonitor/extension/");    static final String STAX_EXTENSION_INFO =        new String("staf/staxinfo/extension");    static final String NOT_APPLICABLE = new String("<N/A>");    static final String sNONE = new String("<None>");    static final int STAX_SERVICE_EXTENSION = 1;    static final int LOCAL_EXTENSION = 2;    private STAFVersion fMonitorVersion = null;    STAFVersion fSTAXServiceVersion;    public STAXMonitor(String argv[])    {        String jobIDToMonitor = "";        try        {            fHandle =                STAXMonitorUtil.getNewSTAFHandle("STAX/JobMonitor/Controller");        }        catch(STAFException ex)        {            if (ex.rc == STAFResult.HandleAlreadyExists)            {                System.out.println("Ensure that SET ALLOWMULTIREG is " +                                   "specified in the STAF.cfg file");            }            else            {                System.out.println("STAX Job Monitor V" + fVersion +                                   " requires STAF V" + fSTAFRequiredVersion +                                   " or later to be running");            }            System.exit(0);        }        STAFResult result = new STAFResult();        // Resolve the line separator variable for the local machine        result = fHandle.submit2(            "local", "VAR", "RESOLVE STRING {STAF/Config/Sep/Line}");        if (result.rc != STAFResult.Ok)        {            System.out.println("rc=" + result.rc);            JOptionPane.showMessageDialog(                this, "Error resolving {STAF/Config/Sep/Line} " +                "variable\nRC=" + result.rc + ", STAFResult=" + result.result,                "Error resolving variable", JOptionPane.ERROR_MESSAGE);           }        String lineSep = result.result;        // Verify the required version of STAF is running on the STAX Monitor        // Note:  Method compareSTAFVersion was added in STAF V3.1.0        try        {            result = STAFUtil.compareSTAFVersion(                "local", fHandle, fSTAFRequiredVersion);            if (result.rc != STAFResult.Ok)            {                if (result.rc == STAFResult.InvalidSTAFVersion)                {                    JOptionPane.showMessageDialog(                        this, "ERROR: Minimum required STAF version for " +                        "the STAX Monitor is not running." + lineSep +                        result.result, "Required STAF Version Not Running",                        JOptionPane.ERROR_MESSAGE);                }                else                {                    JOptionPane.showMessageDialog(                        this, "Error verifying STAF version. RC: " +                        result.rc + ", Additional info: " + result.result,                        "Error verifying STAF version",                        JOptionPane.ERROR_MESSAGE);                }            }        }        catch (Error err)        {            JOptionPane.showMessageDialog(                this, "ERROR: The STAX Monitor requires STAF Version " +                fSTAFRequiredVersion + " or later.",                "Required STAF Version Not Running",                JOptionPane.ERROR_MESSAGE);        }        // Verify that the version specified for the STAX Monitor is valid        try        {            fMonitorVersion = new STAFVersion(fVersion);        }        catch (NumberFormatException e)        {            System.out.println("ERROR: " + fVersion +                               " is an invalid STAX monitor version.\n" +                               e.toString());            System.exit(0);        }                // Resolve the {STAF/Config/Machine} variable        result = fHandle.submit2(            "local", "VAR", "RESOLVE STRING {STAF/Config/Machine}");                if (result.rc != 0)        {            System.out.println("rc=" + result.rc);            JOptionPane.showMessageDialog(                this, "Error resolving {STAF/Config/Machine} " +                "variable\nRC=" + result.rc + ", STAFResult=" + result.result,                "Error resolving variable", JOptionPane.ERROR_MESSAGE);           }        else        {            fLocalMachineName = result.result;        }                fFileSep = File.separator;        String userHome = System.getProperty("user.home");        if (!(userHome.endsWith(fFileSep)))        {            userHome += fFileSep;        }        fMonitorFileDirectory = userHome + "staxmonitordata3";        File dir = new File(fMonitorFileDirectory);        if (!dir.exists())        {            if (!(dir.mkdirs()))            {                JOptionPane.showMessageDialog(this,                                      "Error creating directory: " +                                      fMonitorFileDirectory,                                      "Error creating directory",                                      JOptionPane.ERROR_MESSAGE);            }        }        fLastJobParmsFileName = fMonitorFileDirectory +                                fFileSep + kMonitorLastJobDataFileName;        fPropertiesFileName = fMonitorFileDirectory +                              fFileSep + kMonitorPropertiesFileName;        fRecentFilesName =  fMonitorFileDirectory + fFileSep +                            kRecentFilesFileName;        fCurrentJobParmsFile = fLastJobParmsFileName;        // Check if any arguments were specified        if (argv.length > 0)        {            if (argv[0].equalsIgnoreCase("-HELP"))            {                System.out.println(helpText);                System.exit(0);            }            else if (argv[0].equalsIgnoreCase("-VERSION"))            {                System.out.println(kSplashText);                System.exit(0);            }            else if (argv[0].equalsIgnoreCase("-JOB"))            {                jobIDToMonitor = resolveVar(argv[1], fHandle.getHandle());                if (jobIDToMonitor == null)                {                    System.out.println("Invalid parameters");                    System.out.println(helpText);                    System.exit(0);                }                if (argv.length > 2)                {                    if (argv[2].equalsIgnoreCase("-CLOSEONEND"))                    {                        fCloseOnEndJobID = jobIDToMonitor;                    }                    else                    {                        System.out.println("Invalid parameters");                        System.out.println(helpText);                        System.exit(0);                    }                }            }            else if (argv[0].equalsIgnoreCase("-JOBPARMS"))            {                fStartNewJobParmFileName = resolveVar(                    argv[1], fHandle.getHandle());                if (argv.length > 2)                {                    if (argv[2].equalsIgnoreCase("-CLOSEONEND"))                    {                        fStartNewJobCloseOnEnd = true;                    }                    else                    {                        System.out.println("Invalid parameters");                        System.out.println(helpText);                        System.exit(0);                    }                }            }            else if (argv[0].equalsIgnoreCase("-EXTENSIONS"))            {                // Handle later in the constructor            }            else if (argv[0].equalsIgnoreCase("-PROPERTIES"))            {                boolean noStart = false;                int numPropsSet = 0;                String newStaxMachineName = "";                String newStaxServiceName = "";                String newEventMachineName = "";                String newEventServiceName = "";                String newJobParmsDirectory = "";                for (int i = 1; i < argv.length; i++)                {                    if (argv[i].equalsIgnoreCase("-STAXMACHINE"))                    {                        if (!newStaxMachineName.equals(""))                        {                            System.out.println(                                "Invalid parameters - " +                                 "Can specify -staxMachine property only once");                            System.out.println(helpText);                            System.exit(0);                        }                        i++;                        if (i < argv.length)                        {                            newStaxMachineName = resolveVar(                                argv[i], fHandle.getHandle());                            numPropsSet++;                        }                        else                        {                            System.out.println(                                "Invalid parameters - " +                                "Must specify a value for -staxMachine");                            System.out.println(helpText);                            System.exit(0);                        }                    }                    else if (argv[i].equalsIgnoreCase("-STAXSERVICENAME"))                    {                        if (!newStaxServiceName.equals(""))                        {                            System.out.println(                                "Invalid parameters - " +                                 "Can specify -staxServiceName property only once");                            System.out.println(helpText);                            System.exit(0);                        }                        i++;                        if (i < argv.length)                        {                            newStaxServiceName = resolveVar(                                argv[i], fHandle.getHandle());                            numPropsSet++;                        }                        else                        {                            System.out.println(                                "Invalid parameters - " +                                "Must specify a value for -staxServiceName");                            System.out.println(helpText);                            System.exit(0);                        }                    }                    /*                    else if (argv[i].equalsIgnoreCase("-JOBPARMSDIRECTORY"))                    {                        if (!newJobParmsDirectory.equals(""))                        {                            System.out.println(                                "Invalid parameters - " +                                 "Can specify -jobParmsDirectory property " +                                "only once");                            System.out.println(helpText);                            System.exit(0);                        }                        i++;                        if (i < argv.length)                        {                            newJobParmsDirectory = resolveVar(                                argv[i], fHandle.getHandle());                            numPropsSet++;                        }                        else                        {                            System.out.println(                                "Invalid parameters - " +                                "Must specify a value for -jobParmsDirectory");                            System.out.println(helpText);                            System.exit(0);                        }                    }                    */                    else if (argv[i].equalsIgnoreCase("-NOSTART"))                    {                        noStart = true;                    }                    else                    {                        System.out.println("Invalid parameters");                        System.out.println(helpText);                        System.exit(0);                    }                }                if (numPropsSet > 0)                {                    updateProperties(newStaxMachineName, newStaxServiceName,                                     newEventMachineName, newEventServiceName,                                     newJobParmsDirectory, !noStart);                }                else                {                    System.out.println(

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -