📄 staxstafcommandaction.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 com.ibm.staf.*;import com.ibm.staf.STAFUtil;import java.util.TreeMap;import java.util.HashMap;import java.util.Map;import java.util.List;/** * The representation of the action to take when a STAF command, * <stafcmd>, element is encountered. * <p> * This is produced by the STAXSTAFCommandActionFactory. The resulting * STAXSTAFCommandAction object describes a <stafcmd> element. It * contains the location, service, and request specified, as well as a name * for the STAF command to be submitted. * * @see STAXSTAFCommandActionFactory */public class STAXSTAFCommandAction implements STAXAction, STAXSTAFRequestCompleteListener { // Initial state of the action static final int INIT = 0; // State where the STAF request command has been submitted, and // now it's waiting for it to complete static final int WAIT_REQUEST_COMMAND = 1; // State where the action has been notified that the STAF command is // complete static final int COMMAND_COMPLETE = 2; // Completion state of the action static final int COMPLETE = 3; static final String INIT_STRING = "INIT"; static final String WAIT_REQUEST_COMMAND_STRING = "WAIT_REQUEST"; static final String COMMAND_COMPLETE_STRING = "COMMAND_COMPLETE"; static final String COMPLETE_STRING = "COMPLETE"; static final String STATE_UNKNOWN_STRING = "UNKNOWN"; /** * Creates a new STAXSTAFCommandAction instance. */ public STAXSTAFCommandAction() { } /** * Gets the factory for the action. * @return an instance of the action's factory */ public STAXSTAFCommandActionFactory getActionFactory() { return fFactory; } /** * Sets the factory for the action. * @param factory an instance of the action's factory */ public void setActionFactory(STAXSTAFCommandActionFactory factory) { fFactory = factory; } /** * Gets the location (destination machine name) to which the request * is submitted. * @return the location (destination machine name) */ public String getLocation() { return fLocation; } /** * Sets the location (destination machine name) to which the request * is submitted. This should be either LOCAL, if you wish to make a * request of the local machine, or the name of the machine to which * you want to make a request. * @param location a string containing the name of the destination * machine for the service request submitted */ public void setLocation(String location) { fLocation = location; fUnevalLocation = location; } /** * Gets the name of the STAF service to which the request is submitted. * @return the name of the STAF service */ public String getService() { return fService; } /** * Sets the name of the STAF service to which the request is submitted. * @param service the name of the STAF service */ public void setService(String service) { fService = service; fUnevalService = service; } /** * Gets the request string to submit to the STAF service. * @return the request string */ public String getRequest() { return fRequest; } /** * Sets the actual request string to submit to the STAF service. * @param request the request string */ public void setRequest(String request) { fRequest = request; fUnevalRequest = request; } /** * Gets the name used to identify the STAF command request. * @return the name identifying the STAF command */ public String getName() { return fName; } /** * Sets a name used by the STAX Monitor to refer to the STAF command * request when monitoring the job. It defaults to STAFCommand<number>, * where <number> is a unique number for each STAF command executed in * a job. * @param name the name used to identify the STAF command request */ public void setName(String name) { fName = name; fUnevalName = name; } /** * Gets the STAX-Thread instance where this action is being executed. * @return the STAX-Thread instance where this action is being executed */ public STAXThread getThread() { return fThread; } /** * Gets the STAX-Thread instance where this action is being executed. * @return the STAX-Thread instance where this action is being executed */ public String getCurrentBlockName() { return fCurrentBlockName; } /** * Gets the timestamp for when this action was started. * @return the timestamp for when this action was started */ public STAXTimestamp getStartTimestamp() { return fStartTimestamp; } /** * Gets the request number for the STAF command request that is submitted. * @return the request number */ public int getRequestNumber() { return fRequestNumber; } /** * Gets a string identifying the state of this action. It could be * "INIT", "WAIT_REQUEST", "COMMAND_COMPLETE", "COMPLETE", or "UNKNOWN". * @return a string identifying the state of this action. */ public String getStateAsString() { switch (fState) { case INIT: return INIT_STRING; case WAIT_REQUEST_COMMAND: return WAIT_REQUEST_COMMAND_STRING; case COMMAND_COMPLETE: return COMMAND_COMPLETE_STRING; case COMPLETE: return COMPLETE_STRING; default: return STATE_UNKNOWN_STRING; } } public String getInfo() { return fName; } public String getDetails() { return "Name:" + fName + ";Location:" + fLocation + ";Service:" + fService + ";Request:" + fRequest + ";State:" + getStateAsString() + ";BlockName:" + fCurrentBlockName + ";StartTimestamp:" + fStartTimestamp + ";RequestNumber:" + fRequestNumber + ";RequestRC:" + fRequestRC + ";RequestResult" + fRequestResult + ";HoldThreadCondition:" + fHoldCondition; } public String getXMLInfo() { StringBuffer xmlInfo = new StringBuffer(); if (fName.startsWith("STAFCommand") || fName.equals("")) xmlInfo.append("<stafcmd>\n"); else xmlInfo.append("<stafcmd name=\"" + fName + "\">\n"); xmlInfo.append(" <location>").append(fLocation).append( "</location>\n").append(" <service>").append(fService).append( "</service>\n").append(" <request>").append(fRequest).append( "</request>\n</stafcmd>"); return xmlInfo.toString(); } // Executes the STAF command request by doing an asynchronous submit of the // service request to the specified machine, adds a hold thread condition, // and waits for the submitted STAF command request to complete. // // If in its INIT state, it does the following: // - Evaluates (using Python) the location, service, and request strings // to resolve variables, etc. If a Python evaluation exception occurs, // it raises a STAXPythonEvaluationError signal and pops itself off the // action stack. // - Submits the STAF Command asyncronously. If an error occurs // submitting the STAF command, it raises a STAXCommandStartError signal // and pops itself off the action stack. // - Adds a hold thread condition while waiting for the submitted STAF // command to complete so that another thread can become active. // - Adds the running STAF command to the stafcmdRequestMap so that it // can be listed or queried. // - Generates an event is generated to indicate that the STAF command // request has been started. // // If in its COMPLETE_REQUEST state, it does the following: // - Removes its entry from the stafcmdRequestMap so that it no longer // will show up in the list of active STAF commands. // - Pops itself off the action stack since it is now complete. // // Note that this entire method is synchronized since its state can be // changed on another thread (e.g. via the requestComplete method). public synchronized void execute(STAXThread thread) { if (fState == INIT) { fThread = thread; String evalElem = ""; String evalAttr = ""; try { // Set RC initially so if an error occurs (that does not // terminate the job) before a STAF request is // submitted, <if expr="RC != 0"> won't fail. fThread.pySetVar("RC", new Integer(-1));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -