📄 staxstafcommandaction.java
字号:
evalElem = "location"; fLocation = thread.pyStringEval(fUnevalLocation); evalElem = "service"; fService = thread.pyStringEval(fUnevalService); evalElem = "request"; fRequest = thread.pyStringEval(fUnevalRequest); if (!fName.equals("")) { evalElem = "stafcmd"; evalAttr = "name"; fName = thread.pyStringEval(fUnevalName); } else { fName = "STAFCommand" + String.valueOf(thread.getJob().getNextCmdNumber()); fUnevalName = fName; } } catch (STAXPythonEvaluationException e) { fState = COMPLETE; fThread.popAction(); StringBuffer msg = new StringBuffer(); if (fUnevalName.equals("")) msg.append("<stafcmd>\n"); else msg.append("<stafcmd name=\"").append(fUnevalName).append( "\">\n"); msg.append(" <location>").append(fUnevalLocation). append("</location>\n"). append(" <service>").append(fUnevalService). append("</service>\n <request>"). append(fUnevalRequest).append("</request>\n"). append("</stafcmd>\n\n"); if (evalAttr == "") { msg.append("Stafcmd sub-element in error: <"). append(evalElem).append(">"); } else { msg.append("Stafcmd 'name' attribute in error: "). append(fUnevalName); } thread.setSignalMsgVar("STAXPythonEvalMsg", msg.toString(), e); fThread.raiseSignal("STAXPythonEvaluationError"); return; } fState = WAIT_REQUEST_COMMAND; // Submit STAF Command STAFResult submitResult = fThread.getJob().submitAsync( fLocation, fService, fRequest, this); if (submitResult.rc == 0) { fRequestNumber = (new Integer(submitResult.result)).intValue(); } if ((submitResult.rc != 0) || (fRequestNumber == 0)) { // Request failed fState = COMPLETE; fThread.popAction(); String msg = getXMLInfo() + "\n" + "\n RC : " + submitResult.rc + "\n Result: " + submitResult.result; thread.setSignalMsgVar("STAXCommandStartErrorMsg", msg); fThread.raiseSignal(new String("STAXCommandStartError")); return; } fThread.addCondition(fHoldCondition); // Set to the current date and time. fStartTimestamp = new STAXTimestamp(); // Add the running STAF command to the stafcmdRequestMap. TreeMap stafcmds = (TreeMap)fThread.getJob(). getData("stafcmdRequestMap"); synchronized (stafcmds) { stafcmds.put(String.valueOf(fRequestNumber), this); } // Set Current Block Name try { fCurrentBlockName = fThread.pyStringEval("STAXCurrentBlock"); } catch (STAXPythonEvaluationException e) { fCurrentBlockName = ""; //Shouldn't happen } HashMap stafCmdMap = new HashMap(); stafCmdMap.put("type", "command"); stafCmdMap.put("block", fCurrentBlockName); stafCmdMap.put("status", "start"); stafCmdMap.put("location", fLocation); stafCmdMap.put("requestNumber", String.valueOf(fRequestNumber)); stafCmdMap.put("service", fService); stafCmdMap.put("request", STAFUtil.maskPrivateData(fRequest)); stafCmdMap.put("name", fName); fThread.getJob().generateEvent( STAXSTAFCommandActionFactory.STAX_STAFCOMMAND_EVENT, stafCmdMap); } else if (fState == COMMAND_COMPLETE) { TreeMap stafcmds = (TreeMap)fThread.getJob(). getData("stafcmdRequestMap"); synchronized (stafcmds) { stafcmds.remove(String.valueOf(fRequestNumber)); } fState = COMPLETE; fThread.popAction(); } } // Note that this entire method is synchronized since the state of the // action can be changed on another thread (via the requestComplete method). public synchronized void handleCondition(STAXThread thread, STAXCondition cond) { // Generates an event to indicate that the STAF command is stopped HashMap stafCmdMap = new HashMap(); stafCmdMap.put("type", "command"); stafCmdMap.put("block", fCurrentBlockName); stafCmdMap.put("status", "stop"); stafCmdMap.put("location", fLocation); stafCmdMap.put("requestNumber", String.valueOf(fRequestNumber)); stafCmdMap.put("service", fService); stafCmdMap.put("request", STAFUtil.maskPrivateData(fRequest)); stafCmdMap.put("name", fName); fThread.getJob().generateEvent( STAXSTAFCommandActionFactory.STAX_STAFCOMMAND_EVENT, stafCmdMap); fState = COMPLETE; thread.removeCondition(fHoldCondition); thread.popAction(); } public STAXAction cloneAction() { STAXSTAFCommandAction clone = new STAXSTAFCommandAction(); clone.fUnevalLocation = fUnevalLocation; clone.fUnevalService = fUnevalService; clone.fUnevalRequest = fUnevalRequest; clone.fUnevalName = fUnevalName; clone.fCurrentBlockName = fCurrentBlockName; clone.fFactory = fFactory; clone.fLocation = fLocation; clone.fService = fService; clone.fRequest = fRequest; clone.fName = fName; return clone; } // requestComplete is a STAXSTAFRequestCompleteListener interface method // // Called when the submitted STAF command request completes so it can set // variables RC and STAFResult with the result from the submitted STAF // command request and remove the hold thread condition and schedule the // thread to run. Generates an event to indicate that the submitted // STAF command request has completed. // // Note that this entire method is synchronized since the state of the // action can be changed on another thread (via the execute and // handleCondition methods). public synchronized void requestComplete(int requestNumber, STAFResult result) { if (fState == COMPLETE) return; HashMap stafCmdMap = new HashMap(); stafCmdMap.put("type", "command"); stafCmdMap.put("block", fCurrentBlockName); stafCmdMap.put("status", "stop"); stafCmdMap.put("location", fLocation); stafCmdMap.put("requestNumber", String.valueOf(fRequestNumber)); stafCmdMap.put("service", fService); stafCmdMap.put("request", STAFUtil.maskPrivateData(fRequest)); stafCmdMap.put("name", fName); fThread.getJob().generateEvent( STAXSTAFCommandActionFactory.STAX_STAFCOMMAND_EVENT, stafCmdMap); fRequestRC = result.rc; fRequestResult = result.result; fThread.pySetVar("RC", new Integer(result.rc)); // Unmarshall the STAFResult try { fThread.pySetVar("STAXSTAFResult", result.result); fThread.pyExec( "STAFResultContext = STAFMarshalling.unmarshall(STAXSTAFResult)\n" + "STAFResult = STAFResultContext.getRootObject()"); } catch (STAXPythonEvaluationException e) { String msg = "Error while unmarshalling result from " + "STAFCommand:\n\n" + getXMLInfo(); fThread.setSignalMsgVar("STAXPythonEvalMsg", msg, e); fThread.raiseSignal("STAXPythonEvaluationError"); } fState = COMMAND_COMPLETE; fThread.removeCondition(fHoldCondition); fThread.schedule(); } STAXThread fThread = null; int fState = INIT; private STAXHoldThreadCondition fHoldCondition = new STAXHoldThreadCondition("STAFCommand"); private String fLocation = new String(); private String fService = new String(); private String fRequest = new String(); private String fName = new String(); private String fUnevalLocation = new String(); private String fUnevalService = new String(); private String fUnevalRequest = new String(); private String fUnevalName = new String(); private int fRequestNumber = 0; private int fRequestRC = 0; private String fRequestResult = new String(); private STAXTimestamp fStartTimestamp; private STAXSTAFCommandActionFactory fFactory; private String fCurrentBlockName = new String();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -