📄 staxprocessactionfactory.java
字号:
/*****************************************************************************//* Software Testing Automation Framework (STAF) *//* (C) Copyright IBM Corp. 2002, 2004 *//* *//* This software is licensed under the Common Public License (CPL) V1.0. *//*****************************************************************************/package com.ibm.staf.service.stax;import org.w3c.dom.Node;import org.w3c.dom.NamedNodeMap;import org.w3c.dom.NodeList;import com.ibm.staf.*;import java.util.Map;import java.util.TreeMap;import java.util.HashMap;import java.util.List;import java.util.ArrayList;import java.util.Iterator;import java.util.Vector;public class STAXProcessActionFactory implements STAXActionFactory, STAXSTAFQueueListener, STAXListRequestHandler, STAXQueryRequestHandler, STAXJobManagementHandler{ static boolean debug = false; static final String STAX_PROCESS_EVENT = new String("Process"); static final String sProcessInfoMapClassName = new String( "STAF/Service/STAX/ProcessInfo"); static final String sQueryProcessMapClassName = new String( "STAF/Service/STAX/QueryProcess"); // Constructor public STAXProcessActionFactory(STAX staxService) { staxService.registerListHandler("PROCESSES", this); staxService.registerQueryHandler("PROCESS", "Location:Handle", this); staxService.registerJobManagementHandler(this); // Construct map-class for list process information fProcessInfoMapClass = new STAFMapClassDefinition( sProcessInfoMapClassName); fProcessInfoMapClass.addKey("processName", "Process Name"); fProcessInfoMapClass.addKey("location", "Location"); fProcessInfoMapClass.addKey("handle", "Handle"); fProcessInfoMapClass.addKey("command", "Command"); fProcessInfoMapClass.addKey("parms", "Parms"); // Construct map-class for query process information fQueryProcessMapClass = new STAFMapClassDefinition( sQueryProcessMapClassName); fQueryProcessMapClass.addKey("processName", "Process Name"); fQueryProcessMapClass.addKey("location", "Location"); fQueryProcessMapClass.addKey("handle", "Handle"); fQueryProcessMapClass.addKey("blockName", "Block Name"); fQueryProcessMapClass.addKey("threadID", "Thread ID"); fQueryProcessMapClass.addKey("startTimestamp", "Start Date-Time"); fQueryProcessMapClass.addKey("command", "Command"); fQueryProcessMapClass.addKey("commandMode", "Command Mode"); fQueryProcessMapClass.addKey("commandShell", "Command Shell"); fQueryProcessMapClass.addKey("parms", "Parms"); fQueryProcessMapClass.addKey("title", "Title"); fQueryProcessMapClass.addKey("workdir", "Workdir"); fQueryProcessMapClass.addKey("workload", "Workload"); fQueryProcessMapClass.addKey("varList", "Vars"); fQueryProcessMapClass.addKey("envList", "Envs"); fQueryProcessMapClass.addKey("useProcessVars", "Use Process Vars"); fQueryProcessMapClass.addKey("userName", "User Name"); fQueryProcessMapClass.addKey("password", "Password"); fQueryProcessMapClass.addKey("disabledAuth", "Disabled Auth"); fQueryProcessMapClass.addKey("stdin", "Stdin"); fQueryProcessMapClass.addKey("stdoutMode", "Stdout Mode"); fQueryProcessMapClass.addKey("stdoutFile", "Stdout File"); fQueryProcessMapClass.addKey("stderrMode", "Stderr Mode"); fQueryProcessMapClass.addKey("stderrFile", "Stderr File"); fQueryProcessMapClass.addKey("returnStdout", "Return Stdout"); fQueryProcessMapClass.addKey("returnStderr", "Return Stderr"); fQueryProcessMapClass.addKey("returnFileList", "Returned Files"); fQueryProcessMapClass.addKey("stopUsing", "Stop Using"); fQueryProcessMapClass.addKey("console", "Console"); fQueryProcessMapClass.addKey("focus", "Focus"); fQueryProcessMapClass.addKey("staticHandleName", "Static Handle Name"); fQueryProcessMapClass.addKey("other", "Other"); } public String getName() { return fName; } // STAXActionFactory methods public String getDTDInfo() { return fDTDInfo; } public String getDTDTaskName() { return "process"; } public STAXAction parseAction(STAX staxService, STAXJob job, org.w3c.dom.Node root) throws STAXException { STAXProcessAction process = new STAXProcessAction(); process.setActionFactory(this); NamedNodeMap rootAttrs = root.getAttributes(); for (int i = 0; i < rootAttrs.getLength(); ++i) { Node thisAttr = rootAttrs.item(i); String errorInfo = "\n Element: " + root.getNodeName() + " Attribute: " + thisAttr.getNodeName(); if (thisAttr.getNodeName().equals("name")) { process.setName( STAXUtil.parseAndCompileForPython( thisAttr.getNodeValue(), errorInfo)); } else { throw new STAXInvalidXMLAttributeException( root.getNodeName() + ": " + thisAttr.getNodeName()); } } NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); ++i) { Node thisChild = children.item(i); if (thisChild.getNodeType() == Node.COMMENT_NODE) { /* Do nothing */ } else if (thisChild.getNodeType() == Node.ELEMENT_NODE) { if (thisChild.getNodeName().equals("location")) { NamedNodeMap attrs = thisChild.getAttributes(); for (int j = 0; j < attrs.getLength(); ++j) { Node thisAttr = attrs.item(j); throw new STAXInvalidXMLAttributeException( thisChild.getNodeName() + ": " + thisAttr.getNodeName()); } process.setLocation(handleChild(thisChild)); } else if (thisChild.getNodeName().equals("command")) { NamedNodeMap attrs = thisChild.getAttributes(); for (int j = 0; j < attrs.getLength(); ++j) { Node thisAttr = attrs.item(j); String errorInfo = "\n Element: " + thisChild.getNodeName() + " Attribute: " + thisAttr.getNodeName(); if (thisAttr.getNodeName().equals("mode")) { String mode = STAXUtil.parseAndCompileForPython( thisAttr.getNodeValue(), errorInfo); process.setCommandMode(mode); } else if (thisAttr.getNodeName().equals("shell")) { String shell = STAXUtil.parseAndCompileForPython( thisAttr.getNodeValue(), errorInfo); process.setCommandShell(shell); } else { throw new STAXInvalidXMLAttributeException( thisChild.getNodeName() + ": " + thisAttr.getNodeName()); } } process.setCommand(handleChild(thisChild)); } else if (thisChild.getNodeName().equals("workload")) { process.setWorkload(handleChild(thisChild), handleIfAttribute(thisChild)); } else if (thisChild.getNodeName().equals("title")) { process.setTitle(handleChild(thisChild), handleIfAttribute(thisChild)); } else if (thisChild.getNodeName().equals("parms")) { process.setParms(handleChild(thisChild), handleIfAttribute(thisChild)); } else if (thisChild.getNodeName().equals("workdir")) { process.setWorkdir(handleChild(thisChild), handleIfAttribute(thisChild)); } else if (thisChild.getNodeName().equals("vars")) { process.setVars(handleChild(thisChild), handleIfAttribute(thisChild)); } else if (thisChild.getNodeName().equals("var")) { process.setVars(handleChild(thisChild), handleIfAttribute(thisChild)); } else if (thisChild.getNodeName().equals("envs")) { process.setEnvs(handleChild(thisChild), handleIfAttribute(thisChild)); } else if (thisChild.getNodeName().equals("env")) { process.setEnvs(handleChild(thisChild), handleIfAttribute(thisChild)); } else if (thisChild.getNodeName().equals("useprocessvars")) { process.setUseprocessvars("useprocessvars", handleIfAttribute(thisChild)); } else if (thisChild.getNodeName().equals("stopusing")) { process.setStopusing(handleChild(thisChild), handleIfAttribute(thisChild)); } else if (thisChild.getNodeName().equals("console")) { String ifValue = new String(); String useValue = new String(); NamedNodeMap attrs = thisChild.getAttributes(); for (int j = 0; j < attrs.getLength(); ++j) { Node thisAttr = attrs.item(j); String errorInfo = "\n Element: " + thisChild.getNodeName() + " Attribute: " + thisAttr.getNodeName(); if (thisAttr.getNodeName().equals("if")) ifValue = STAXUtil.parseAndCompileForPython( thisAttr.getNodeValue(), errorInfo); else if (thisAttr.getNodeName().equals("use")) useValue = STAXUtil.parseAndCompileForPython( thisAttr.getNodeValue(), errorInfo); else throw new STAXInvalidXMLAttributeException( thisChild.getNodeName() + ": " + thisAttr.getNodeName()); } process.setConsole(useValue, ifValue); } else if (thisChild.getNodeName().equals("focus")) { String ifValue = new String(); String modeValue = new String(); NamedNodeMap attrs = thisChild.getAttributes(); for (int j = 0; j < attrs.getLength(); ++j) { Node thisAttr = attrs.item(j); String errorInfo = "\n Element: " + thisChild.getNodeName() + " Attribute: " + thisAttr.getNodeName(); if (thisAttr.getNodeName().equals("if")) ifValue = STAXUtil.parseAndCompileForPython( thisAttr.getNodeValue(), errorInfo); else if (thisAttr.getNodeName().equals("mode")) modeValue = STAXUtil.parseAndCompileForPython( thisAttr.getNodeValue(), errorInfo); else throw new STAXInvalidXMLAttributeException( thisChild.getNodeName() + ": " + thisAttr.getNodeName()); } process.setFocus(modeValue, ifValue); } else if (thisChild.getNodeName().equals("username")) { process.setUsername(handleChild(thisChild), handleIfAttribute(thisChild)); } else if (thisChild.getNodeName().equals("password")) { process.setPassword(handleChild(thisChild), handleIfAttribute(thisChild)); } else if (thisChild.getNodeName().equals("disabledauth")) { String ifValue = new String(); String actionValue = new String(); NamedNodeMap attrs = thisChild.getAttributes(); for (int j = 0; j < attrs.getLength(); ++j) { Node thisAttr = attrs.item(j);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -