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

📄 staxprocessactionfactory.java

📁 Software Testing Automation Framework (STAF)的开发代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
            }        }            }    // STAXJobManagement methods    public void initJob(STAXJob job)    {        boolean result = job.setData("processMap", new HashMap());        if (!result)        {            String msg = "STAXProcessActionFactory.initJob: setData for " +                         "processMap failed.";            job.log(STAXJob.JOB_LOG, "error", msg);        }         result = job.setData("processRequestMap", new TreeMap());         if (!result)        {            String msg = "STAXProcessActionFactory.initJob: setData for " +                         "processRequestMap failed.";            job.log(STAXJob.JOB_LOG, "error", msg);        }         job.registerSTAFQueueListener("STAF/Process/End", this);    }    public void terminateJob(STAXJob job)    { /* Do Nothing */ }    // STAXListRequestHandler method    public STAFResult handleListRequest(String type, STAXJob job,                                        STAXRequestSettings settings)    {        if (type.equalsIgnoreCase("processes"))        {            // LIST JOB <Job ID> PROCESSES            // Create the marshalling context and set its map class definitions            // and create an empty list to contain the block map entries            STAFMarshallingContext mc = new STAFMarshallingContext();            mc.setMapClassDefinition(fProcessInfoMapClass);            List processOutputList = new ArrayList();            // Iterate through the process map, generating the output list            TreeMap processes = (TreeMap)job.getData("processRequestMap");            synchronized (processes)            {                Iterator iter = processes.values().iterator();                while (iter.hasNext())                {                    STAXProcessAction process = (STAXProcessAction)iter.next();                    Map processMap = fProcessInfoMapClass.createInstance();                    processMap.put("processName", process.getName());                    processMap.put("location", process.getLocation());                    processMap.put("handle",                                   "" + process.getProcessHandle());                    processMap.put("command",                                   STAFUtil.maskPrivateData(                                       process.getCommand()));                    processMap.put("parms",                                   STAFUtil.maskPrivateData(                                       process.getParms()));                    processOutputList.add(processMap);                }            }            mc.setRootObject(processOutputList);            return new STAFResult(STAFResult.Ok, mc.marshall());        }        else            return new STAFResult(STAFResult.DoesNotExist, type);    }    // STAXQueryRequestHandler methods    public STAFResult handleQueryRequest(String type, String key, STAXJob job,                                         STAXRequestSettings settings)    {        if (type.equalsIgnoreCase("process"))        {            // QUERY JOB <Job ID> PROCESS <Location:Handle>            // Create the marshalling context and set its map class definition            STAFMarshallingContext mc = new STAFMarshallingContext();            mc.setMapClassDefinition(fQueryProcessMapClass);            TreeMap processes = (TreeMap)job.getData("processRequestMap");            key = key.toLowerCase();            STAXProcessAction process;            synchronized (processes)            {                if (!processes.containsKey(key))                    return new STAFResult(STAFResult.DoesNotExist, key);                else                    process = (STAXProcessAction)processes.get(key);            }            Map processMap = fQueryProcessMapClass.createInstance();            processMap.put("processName", process.getName());            processMap.put("location", process.getLocation());            processMap.put("handle", "" + process.getProcessHandle());            processMap.put("blockName", process.getCurrentBlockName());            processMap.put("threadID",                           "" + process.getThread().getThreadNumber());            processMap.put("startTimestamp", process.getStartTimestamp().                           getTimestampString());            processMap.put("command",                           STAFUtil.maskPrivateData(process.getCommand()));            // The rest of the process elements are optional.            if (!process.getCommandMode().equals(""))                processMap.put("commandMode", process.getCommandMode());            if (!process.getCommandShell().equals(""))                processMap.put("commandShell", process.getCommandShell());                        if (!process.getParms().equals(""))                processMap.put("parms",                               STAFUtil.maskPrivateData(process.getParms()));            if (!process.getTitle().equals(""))                processMap.put("title", process.getTitle());            if (!process.getWorkdir().equals(""))                processMap.put("workdir", process.getWorkdir());            if (!process.getWorkload().equals(""))                processMap.put("workload", process.getWorkload());            List varList = new ArrayList();            Vector vars = process.getVars();            for (int i = 0; i < vars.size(); i++)            {                varList.add((String)vars.elementAt(i));            }            processMap.put("varList", varList);            List envList = new ArrayList();            Vector envs = process.getEnvs();            for (int i = 0; i < envs.size(); i++)            {                envList.add((String)envs.elementAt(i));            }            processMap.put("envList", envList);            if (!process.getUseprocessvars().equals(""))                processMap.put("useProcessVars", "true");            if (!process.getUsername().equals(""))                processMap.put("userName", process.getUsername());                         // Mask the true value for the password             if (!process.getPassword().equals(""))                processMap.put("password", "*******");            if (!process.getDisabledauth().equals(""))                processMap.put("disabledAuth", process.getDisabledauth());            if (!process.getStdin().equals(""))                processMap.put("stdin", process.getStdin());                         if (!process.getStdout().equals(""))            {                processMap.put("stdoutMode", process.getStdoutMode());                processMap.put("stdoutFile", process.getStdout());            }            if (!process.getStderr().equals(""))                processMap.put("stderrFile", process.getStderr());            if (!process.getStderrMode().equals(""))                processMap.put("stderrMode", process.getStderrMode());            if (!process.getReturnStdout().equals(""))                processMap.put("returnStdout", "true");            if (!process.getReturnStderr().equals(""))                processMap.put("returnStderr", "true");            List returnFileList = new ArrayList();            Vector returnfiles = process.getReturnFiles();            for (int i = 0; i < returnfiles.size(); i++)            {                returnFileList.add((String)returnfiles.elementAt(i));            }            processMap.put("returnFileList", returnFileList);            if (!process.getStopusing().equals(""))                processMap.put("stopUsing", process.getStopusing());            if (!process.getConsole().equals(""))                processMap.put("console", process.getConsole());                         if (!process.getFocus().equals(""))                processMap.put("focus", process.getFocus());            if (!process.getStatichandlename().equals(""))                processMap.put("staticHandleName",                               process.getStatichandlename());                        if (!process.getOther().equals(""))                processMap.put("other", process.getOther());                        mc.setRootObject(processMap);            return new STAFResult(STAFResult.Ok, mc.marshall());        }        else            return new STAFResult(STAFResult.DoesNotExist, type);    }        public STAFResult handleQueryJobRequest(STAXJob job,                                            STAXRequestSettings settings)    {        return new STAFResult(STAFResult.Ok, "");    }    private String fName;    private STAFMapClassDefinition fProcessInfoMapClass;    private STAFMapClassDefinition fQueryProcessMapClass;    private static String fDTDInfo ="\n" +"<!--================= The STAF Process Element ===================== -->\n" +"<!--\n" +"     Specifies a STAF process to be started.\n" +"     All of its non-empty element values are evaluated via Python.\n" +"-->\n" +"<!ENTITY % procgroup1 '((parms?, workdir?) | (workdir?, parms?))'>\n" +"<!ENTITY % procgroup2 '((title?, workload?) | (workload?, title?))'>\n" +"<!ENTITY % procgroup1a '((parms?, workload?) | (workload?, parms?))'>\n" +"<!ENTITY % procgroup2a '((title?, workdir?) | (workdir?, title?))'>\n" +"<!ENTITY % procgroup3 '(((vars | var | envs | env)*, useprocessvars?) |\n" +"                        (useprocessvars?, (vars | var | envs | env)*))'>\n" +"<!ENTITY % procgroup4 '(((username, password?)?, disabledauth?) |\n" +"                        ((disabledauth?, (username, password?)?)))'>\n" +"<!ENTITY % procgroup5 '((stdin?, stdout?, stderr?) |\n" + "                        (stdout?, stderr?, stdin?) |\n" +"                        (stderr?, stdin?, stdout?) |\n" +"                        (stdin?, stderr?, stdout?) |\n" +"                        (stdout?, stdin?, stderr?) |\n" +"                        (stderr?, stdout?, stdin?))'>\n" +"<!ENTITY % returnfileinfo '(returnfiles | returnfile)*'>\n" +"<!ENTITY % procgroup5a '((%returnfileinfo;, returnstdout?, returnstderr?) |\n" +"                        (returnstdout?, returnstderr?, %returnfileinfo;) |\n" +"                        (returnstderr?, %returnfileinfo;, returnstdout?) |\n" +"                        (%returnfileinfo;, returnstderr?, returnstdout?) |\n" +"                        (returnstdout?, %returnfileinfo;, returnstderr?) |\n" +"                        (returnstderr?, returnstdout?, %returnfileinfo;))'>\n" +//"<!ENTITY % procgroup6 '((stopusing?, console?, statichandlename?) |\n" +//"                        (stopusing?, statichandlename?, console?) |\n" +//"                        (console?, stopusing?, statichandlename?) |\n" +//"                        (console?, statichandlename?, stopusing?) |\n" +//"                        (statichandlename?, stopusing?, console?) |\n" +//"                        (statichandlename?, console?, stopusing?))'>\n" +"<!ENTITY % procgroup6 '((stopusing?, console?, focus?, statichandlename?) |\n" +"                        (stopusing?, console?, statichandlename?, focus?) |\n" +"                        (stopusing?, focus?, console?, statichandlename?) |\n" +"                        (stopusing?, focus?, statichandlename?, console?) |\n" +"                        (stopusing?, statichandlename?, console?, focus?) |\n" +"                        (stopusing?, statichandlename?, focus?, console?) |\n" +"                        (console?, focus?, stopusing?, statichandlename?) |\n" +"                        (console?, focus?, statichandlename?, stopusing?) |\n" +"                        (console?, stopusing?, focus?, statichandlename?) |\n" +"                        (console?, stopusing?, statichandlename?, focus?) |\n" +"                        (console?, statichandlename?, focus?, stopusing?) |\n" +"                        (console?, statichandlename?, stopusing?, focus?) |\n" +"                        (focus?, console?, stopusing?, statichandlename?) |\n" +"                        (focus?, console?, statichandlename?, stopusing?) |\n" +"                        (focus?, stopusing?, console?, statichandlename?) |\n" +"                        (focus?, stopusing?, statichandlename?, console?) |\n" +"                        (focus?, statichandlename?, console?, stopusing?) |\n" +"                        (focus?, statichandlename?, stopusing?, console?) |\n" +"                        (statichandlename?, stopusing?, console?, focus?) |\n" +"                        (statichandlename?, stopusing?, focus?, console?) |\n" +"                        (statichandlename?, console?, focus?, stopusing?) |\n" +"                        (statichandlename?, console?, stopusing?, focus?) |\n" +"                        (statichandlename?, focus?, console?, stopusing?) |\n" +"                        (statichandlename?, focus?, stopusing?, console?))'>\n" +"<!ELEMENT process    (location, command,\n" +"                      ((%procgroup1;, %procgroup2;) |\n" + "                       (%procgroup2;, %procgroup1;) |\n" +"                       (%procgroup1a;, %procgroup2a;) |\n" +"                       (%procgroup2a;, %procgroup1a;)),\n" +"                      %procgroup3;,\n" + "                      ((%procgroup4;, %procgroup5;, %procgroup5a;, %procgroup6;) |\n" +"                       (%procgroup4;, %procgroup6;, %procgroup5;, %procgroup5a;) |\n" +"                       (%procgroup5;, %procgroup5a;, %procgroup4;, %procgroup6;) |\n" +"                       (%procgroup5;, %procgroup5a;, %procgroup6;, %procgroup4;) |\n" +"                       (%procgroup6;, %procgroup4;, %procgroup5;, %procgroup5a;) |\n" +"                       (%procgroup6;, %procgroup5;, %procgroup5a;, %procgroup4;)),\n" +"                      other?, process-action?)>\n" +"<!ATTLIST process\n" +"          name        CDATA   #IMPLIED\n" +">\n" +"\n" +"<!--\n" +"     The process element must contain a location element and a\n" +"     command element.\n" + "-->\n" +"<!ELEMENT location            (#PCDATA)>\n" +

⌨️ 快捷键说明

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