KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > data > xpath > JoinCondition


1 package org.jbpm.bpel.data.xpath;
2
3 import java.util.Iterator JavaDoc;
4
5 import org.jaxen.*;
6
7 import org.jbpm.graph.exe.Token;
8
9 import org.jbpm.bpel.def.Activity;
10 import org.jbpm.bpel.def.Link;
11 import org.jbpm.bpel.exe.LinkInstance;
12 import org.jbpm.bpel.xml.BpelConstants;
13
14 /**
15  * A join condition coded in XPath 1.0. Only link-status can be used within
16  * join-conditions and only join-conditions can make use of link-status.
17  * @see "WS-BPEL 2.0 §12.5.1"
18  * @author Juan Cantú
19  * @version $Revision: 1.4 $ $Date: 2005/05/31 00:49:53 $
20  */

21 class JoinCondition extends XPathScript {
22   
23   private static final long serialVersionUID = 1L;
24   public static final FunctionContext FUNCTION_LIBRARY;
25   
26   JoinCondition(String JavaDoc snippet) throws JaxenException {
27     super(snippet);
28   }
29   
30   protected FunctionContext createFunctionContext() {
31     return FUNCTION_LIBRARY;
32   }
33   
34   /**
35    * Gets a context for expression evaluation. The context for a join
36    * condition is:<ul>
37    * <li>the variable bindings are the links targeting the current node of the given token</li>
38    * <li>the function context is {@link #FUNCTION_LIBRARY}</li>
39    * <li>the namespace declarations are taken from the snippet</li></ul>
40    * @param node an instance of {@link Token}
41    */

42   protected Context getContext(Object JavaDoc node) {
43     SimpleVariableContext variableContext = new SimpleVariableContext();
44     Token token = (Token) node;
45     Iterator JavaDoc it = ((Activity) token.getNode()).getTargets().iterator();
46     while (it.hasNext()) {
47       String JavaDoc linkName = ((Link)it.next()).getName();
48       variableContext.setVariableValue(linkName, LinkInstance.get(token, linkName).getReached());
49     }
50     
51     ContextSupport support = new ContextSupport(getNamespaceContext(),
52         getFunctionContext(), variableContext, getNavigator());
53     return new Context(support);
54   }
55   
56   static {
57     XPathFunctionContext functionContext = new XPathFunctionContext();
58     FUNCTION_LIBRARY = functionContext;
59     // WS-BPEL 2.0 library
60
functionContext.registerFunction(BpelConstants.NS_BPWS_1_1, "getLinkStatus", new GetLinkStatusFunction());
61   }
62 }
63
Popular Tags