パターンNo.4 exclusive choice
で、xmlはこれ↓
#{scenario==1} #{scenario==2}
で、実装はこれ。
public class ExclusiveChoiceTest extends TestCase {
public void testExclusiveChoice() throws Exception {
// Extract a process definition from the processdefinition.xml file.
FileInputStream fis = new FileInputStream("processes/exclusiveChoice.par/processdefinition.xml");
ProcessDefinition processDefinition = ProcessDefinition.parseXmlInputStream(fis);
// Create an instance of the process definition.
ProcessInstance instance = new ProcessInstance(processDefinition);
ContextInstance ci = (ContextInstance) instance.getInstance( ContextInstance.class );
instance.signal();
Token root = instance.getRootToken();
assertSame( processDefinition.getNode("state1"), root.getNode() );
ci.setVariable( "scenario", new Integer(2) );
root.signal();
assertSame( processDefinition.getNode("c"), root.getNode() );
}
}
気になること
- conditionの記述は、jPDL ELというJSP/JSF EL Likeの独自なもの。S2,Tape,WWみたく、OGNLの選択肢は無かったのかなぁ。。
- GPD(ダイアグラム)からcondition記述ができない(XML直接記述)
- DI*AOP適用してActionをフレームワーク依存のないようにもできるけど、やるんだったらGPDも改良しないと.
- XORがわかったほうが絵的にうれしいけどなぁ。