01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: Site.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package tutorial.numberguess;
09:
10: import com.uwyn.rife.engine.SiteBuilder;
11: import com.uwyn.rife.rep.BlockingParticipant;
12:
13: /*
14: * This is a site definition in Java instead of in XML. It defines exactly the
15: * same structure as the one that you can find in the sites/numberguess.xml
16: * file.
17: * To run the example with the Java site structure, you have to edit the
18: * rep/participants.xml file. Instructions can be found there.
19: */
20: public class Site extends BlockingParticipant {
21: private Object site;
22:
23: protected void initialize() {
24: SiteBuilder builder = new SiteBuilder("numberguess",
25: getResourceFinder());
26: builder.setArrival("Start")
27:
28: .enterElement("Start").setImplementation(Start.class).setUrl(
29: "start")
30:
31: .addInput("gameid")
32:
33: .enterFlowLink("started").destId("Guess").addDataLink("gameid",
34: "gameid").leaveFlowLink().leaveElement()
35:
36: .enterElement("Guess").setImplementation(Guess.class).setUrl(
37: "guess")
38:
39: .addInput("gameid").enterSubmission("performGuess")
40: .addParameter("guess").leaveSubmission()
41:
42: .enterFlowLink("start").destId("Start").addDataLink(
43: "gameid", "gameid").leaveFlowLink()
44:
45: .enterFlowLink("success").destId("Success")
46: .addDataLink("gameid", "gameid").leaveFlowLink()
47: .leaveElement()
48:
49: .enterElement("Success").setImplementation(
50: Success.class)
51:
52: .addInput("gameid")
53:
54: .addFlowLink("start", "Guess").leaveElement();
55:
56: site = builder.getSite();
57: }
58:
59: protected Object _getObject(Object key) {
60: return site;
61: }
62: }
|