📄 simplexmllauncher.java
字号:
getExpressionPool().apply(id, wi); } catch (final Exception e) { log.debug ("Failed to 'launch' RawExpression", e); throw new LaunchException ("Failed to 'launch' RawExpression", e); } log.debug ("launchSub() applied "+id.getWorkflowInstanceId()); return id; } /** * Fetches the attributes from the uninterpreted raw version of a flow * expression. * If rawExpression is an instance of java.util.Map, it will be * returned straight away. */ public java.util.Map fetchAttributes (final Object rawExpression) throws BuildException { if (rawExpression instanceof java.util.Map) return (java.util.Map)rawExpression; final org.jdom.Element e = (org.jdom.Element)rawExpression; final java.util.Map result = XmlUtils.fetchAttributes(e); final String text = e.getTextTrim(); if (text != null && text.length() > 0) // // this will be useful for <set field="nada">truc></set> // result.put(Definitions.A_VALUE, e.getTextTrim()); return result; } /** * This method is used by droflo to load completety a workflowd * definition for display or edition. */ public ProcessDefinition loadProcessDefinition (final String wfdUrl) throws BuildException { //log.debug("loadProcessDefinition(u)"); final String url = Utils.expandUrl(wfdUrl); org.jdom.Element elt = null; try { elt = XmlUtils.extractXml(url, shouldValidate()); } catch (final Exception e) { throw new BuildException("Failed to load "+url, e); } return loadProcessDefinition(url, null, elt); } /** * Loads a sub process definition. */ public ProcessDefinition loadProcessDefinition (final FlowExpressionId parentId, final Object rawExpression) throws BuildException { //log.debug("loadProcessDefinition(p, e)"); return loadProcessDefinition (null, parentId, (org.jdom.Element)rawExpression); } /* * Either wfdUrl is null, either elt is null, not both should be null * at the same time. */ private ProcessDefinition loadProcessDefinition (final String wfdUrl, final FlowExpressionId parentId, final org.jdom.Element elt) throws BuildException { //log.debug("loadProcessDefinition(u, p, e)"); String wfdName = null; String wfdRevision = null; FlowExpressionId pId = parentId; if (pId == null) { pId = new FlowExpressionId(); // // misc data wfdName = elt.getAttributeValue("name"); wfdRevision = elt.getAttributeValue("revision"); // // tweak parent id pId.setWorkflowDefinitionUrl(wfdUrl); pId.setWorkflowDefinitionName(wfdName); pId.setWorkflowDefinitionRevision(wfdRevision); } else { wfdName = pId.getWorkflowDefinitionName(); wfdRevision = pId.getWorkflowDefinitionRevision(); } try { final RawExpression rootExpression = (RawExpression)ReflectionUtils .buildNewInstance (getExpressionMap().getRawExpressionClass().getName()); // // inits the root expression rootExpression.init(getContext(), pId, 0, elt); //log.debug // ("loadProcessDefinition(d, e) root exp is "+ // rootExpression.getId()); final ProcessDefinition result = new ProcessDefinition (getContext(), wfdUrl, wfdName, wfdRevision); final FlowExpression fe = rootExpression.resolveExpression(result); result.setSelf((DefineExpression)fe); //log.debug // ("loadProcessDefinition(d, e) result is \n"+ // result.toString()); return result; } catch (final Exception e) { throw new BuildException("Failed to load "+wfdUrl, e); } } /** * This method is used by droflo to load completety a workflowd * definition for display or edition. */ public ProcessDefinition loadProcessDefinitionFromString (final String xmlDefinition) throws BuildException { try { return loadProcessDefinition (null, // wfdUrl XmlUtils .extractXmlDocument(xmlDefinition, shouldValidate()) .getRootElement()); } catch (final BuildException be) { throw be; } catch (final Exception e) { throw new BuildException ("Failed to extract xml from string xml definition", e); } } // // METHODS protected ExpressionPool getExpressionPool () { return Definitions.getExpressionPool(getContext()); } protected ExpressionMap getExpressionMap () { return Definitions.getExpressionMap(getContext()); } protected ParticipantMap getParticipantMap () { return Definitions.getParticipantMap(getContext()); } /** * This method is called when the process referenced is an * external process (not defined as a subprocess of the current * process definition). */ protected String launchExternalProcess (final InFlowWorkItem wi, final String ref, final FlowExpressionId parentId) //final boolean shouldNotForget) throws LaunchException { final String[] ss = ref.split("::"); final String engineId = ss[0]; final String processUrl = ss[1]; log.debug("launchExternalProcess() engineId >"+engineId+"<"); log.debug("launchExternalProcess() processUrl >"+processUrl+"<"); // // prepare target engine final Participant participant = getParticipantMap().get(engineId); // // prepare launchitem //FlowExpressionId replyTo = null; //if (shouldNotForget) replyTo = wi.getLastExpressionId(); final LaunchItem li = new LaunchItem (processUrl, //replyTo, parentId, wi); // // launch try { final Object o = participant.dispatch(li); return o.toString(); } catch (final DispatchingException de) { throw new LaunchException ("Dispatching (launch) to engine '"+engineId+"' failed", de); } catch (final Exception e) { log.warn("launchExternalProcess() unexpected exception", e); log.warn("launchExternalProcess() returning flowInstanceId = -1L"); } return null; } // // STATIC METHODS /** * Returns true if the VM property 'openwfe.org.launcher.validate' is * set to true. */ public static boolean shouldValidate () { String s = System.getProperty(VALIDATE); if (s == null) return false; s = s.toLowerCase(); return s.equals("true") || s.equals("yes") || s.equals("ok") || s.equals("validate"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -