XmlSwitch extends AbstractPipe { @IbisDoc({"4", "Name of the key in the <code>PipeLineSession</code> to retrieve the input message from, if a serviceSelectionStylesheetFilename or a xpathExpression is specified. " + "If no serviceSelectionStylesheetFilename or xpathExpression is specified, the value of the session variable is used as the name of the forward. " + "If none of sessionKey, serviceSelectionStylesheetFilename or xpathExpression are specified, the element name of the root node of the input message is taken as the name of forward.", ""}) public void setSessionKey(String sessionKey){ this.sessionKey = sessionKey; }  @Override void configure(); @Override void start(); @Override void stop(); @Override PipeRunResult doPipe(Message message, IPipeLineSession session); @IbisDoc({"1", "stylesheet may return a string representing the forward to look up", "<i>a stylesheet that returns the name of the root-element</i>"}) void setServiceSelectionStylesheetFilename(String newServiceSelectionStylesheetFilename); String getServiceSelectionStylesheetFilename(); @IbisDoc({"2", "xpath-expression that returns a string representing the forward to look up. It's possible to refer to a parameter (which e.g. contains a value from a sessionkey) by using the parameter name prefixed with $", ""}) void setXpathExpression(String xpathExpression); String getXpathExpression(); @IbisDoc({"3", "Namespace defintions for xpathExpression. Must be in the form of a comma or space separated list of <code>prefix=namespaceuri</code>-definitions. For some use other cases (NOT xpathExpression), one entry can be without a prefix, that will define the default namespace.", ""}) void setNamespaceDefs(String namespaceDefs); String getNamespaceDefs(); @IbisDoc({"4", "Name of the key in the <code>PipeLineSession</code> to retrieve the input message from, if a serviceSelectionStylesheetFilename or a xpathExpression is specified. " + "If no serviceSelectionStylesheetFilename or xpathExpression is specified, the value of the session variable is used as the name of the forward. " + "If none of sessionKey, serviceSelectionStylesheetFilename or xpathExpression are specified, the element name of the root node of the input message is taken as the name of forward.", ""}) void setSessionKey(String sessionKey); String getSessionKey(); @IbisDoc({"5", "Forward returned when the pipename derived from the stylesheet could not be found.", ""}) void setNotFoundForwardName(String notFound); String getNotFoundForwardName(); @IbisDoc({"6", "Forward returned when the content, on which the switch is performed, is empty. if <code>emptyforwardname</code> is not specified, <code>notfoundforwardname</code> is used.", ""}) void setEmptyForwardName(String empty); String getEmptyForwardName(); @IbisDoc({"7", "If set to <code>2</code> xslt processor 2.0 (net.sf.saxon) will be used, otherwise xslt processor 1.0 (org.apache.xalan). <code>0</code> will auto detect", "0"}) void setXsltVersion(int xsltVersion); int getXsltVersion(); @IbisDoc({"when set <code>true</code> xslt processor 2.0 (net.sf.saxon) will be used, otherwise xslt processor 1.0 (org.apache.xalan)", "false"}) @Deprecated @ConfigurationWarning("Its value is now auto detected. If necessary, replace with a setting of xsltVersion") void setXslt2(boolean b); static final String XML_SWITCH_FORWARD_FOUND_MONITOR_EVENT; static final String XML_SWITCH_FORWARD_NOT_FOUND_MONITOR_EVENT; }
@Test public void withSessionKey() throws Exception { pipe.registerForward(new PipeForward("Envelope","Envelope-Path")); pipe.registerForward(new PipeForward("selectValue","SelectValue-Path")); pipe.setSessionKey("selectKey"); session=new PipeLineSessionBase(); session.put("selectKey", "selectValue"); String input=TestFileUtils.getTestFile("/XmlSwitch/in.xml"); testSwitch(input,"selectValue"); }