2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shale.dialog.scxml.action;
19
20 import java.util.Collection;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.commons.scxml.ErrorReporter;
25 import org.apache.commons.scxml.EventDispatcher;
26 import org.apache.commons.scxml.SCInstance;
27 import org.apache.commons.scxml.SCXMLExpressionException;
28 import org.apache.commons.scxml.model.Action;
29 import org.apache.commons.scxml.model.ModelException;
30 import org.apache.shale.dialog.scxml.DialogProperties;
31 import org.apache.shale.dialog.scxml.Globals;
32
33 /***
34 * <p>Custom Commons SCXML action to signal that the next rendered view
35 * in this dialog should use a <i>redirect</i>.</p>
36 *
37 * @since 1.0.4
38 *
39 * $Id: RedirectAction.java 486006 2006-12-12 03:46:29Z rahul $
40 */
41 public class RedirectAction extends Action {
42
43 /***
44 * <p>Set redirection flag in dialog properties so the next rendered
45 * dialog view is issued as a redirect.</p>
46 *
47 * @param evtDispatcher The EventDispatcher for this execution instance
48 * @param errRep The ErrorReporter
49 * @param scInstance The state machine execution instance information
50 * @param appLog The application log
51 * @param derivedEvents The collection of internal events
52 * @throws ModelException If execution causes a non-deterministic state
53 * @throws SCXMLExpressionException Bad expression
54 */
55 public void execute(EventDispatcher evtDispatcher, ErrorReporter errRep,
56 SCInstance scInstance, Log appLog, Collection derivedEvents)
57 throws ModelException, SCXMLExpressionException {
58
59 DialogProperties dp = (DialogProperties) scInstance.getRootContext().
60 get(Globals.DIALOG_PROPERTIES);
61 dp.setNextRedirect(true);
62
63 if (log().isDebugEnabled()) {
64 log().debug("<redirect>: Next view will be issued via a redirect");
65 }
66
67 }
68
69
70
71
72 /***
73 * <p>The <code>Log</code> instance for this class. This value is lazily
74 * instantiated, and is also transient and may need to be regenerated.</p>
75 */
76 private transient Log log = null;
77
78
79 /***
80 * <p>Return the <code>Log</code> instance for this instance.</p>
81 *
82 * @return The {@link Log} instance used by this manager
83 */
84 private Log log() {
85 if (this.log == null) {
86 this.log = LogFactory.getLog(RedirectAction.class);
87 }
88 return this.log;
89 }
90
91 }