KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > webflow > execution > FlowExecutionListener


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.springframework.webflow.execution;
17
18 import org.springframework.webflow.core.collection.AttributeMap;
19 import org.springframework.webflow.core.collection.MutableAttributeMap;
20 import org.springframework.webflow.definition.FlowDefinition;
21 import org.springframework.webflow.definition.StateDefinition;
22 import org.springframework.webflow.engine.FlowExecutionExceptionHandler;
23
24 /**
25  * Interface to be implemented by objects that wish to listen and respond to the
26  * lifecycle of {@link FlowExecution flow executions}.
27  * <p>
28  * An 'observer' that is very aspect like, allowing you to insert 'cross
29  * cutting' behavior at well-defined points within one or more well-defined flow
30  * execution lifecycles.
31  * <p>
32  * For example, one custom listener may apply security checks at the flow
33  * execution level, preventing a flow from starting or a state from entering if
34  * the curent user does not have the necessary permissions. Another listener may
35  * track flow execution navigation history to support bread crumbs. Another may
36  * perform auditing, or setup and tear down connections to a transactional
37  * resource.
38  * <p>
39  * Note that flow execution listeners are registered with a flow execution when
40  * that execution is created by a {@link FlowExecutionFactory factory} or
41  * restored by a {@link org.springframework.webflow.execution.repository.FlowExecutionRepository}.
42  * Typically a listener will not be registered with a flow execution <i>at
43  * runtime</i>, when the flow execution is already active.
44  *
45  * @see FlowDefinition
46  * @see StateDefinition
47  * @see FlowExecution
48  * @see RequestContext
49  * @see Event
50  * @see ViewSelection
51  *
52  * @author Keith Donald
53  * @author Erwin Vervaet
54  */

55 public interface FlowExecutionListener {
56
57     /**
58      * Called when any client request is submitted to manipulate this flow
59      * execution. This call happens before request processing.
60      * @param context the source of the event
61      */

62     public void requestSubmitted(RequestContext context);
63
64     /**
65      * Called when a client request has completed processing.
66      * @param context the source of the event
67      */

68     public void requestProcessed(RequestContext context);
69
70     /**
71      * Called immediately after a start event is signaled, indicating a new
72      * session of the flow is starting but has not yet entered its start state.
73      * An exception may be thrown from this method to veto the start operation.
74      * Any type of runtime exception can be used for this purpose.
75      * @param context the source of the event
76      * @param definition the flow for which a new session is starting
77      * @param input a mutable input map to the starting flow session
78      */

79     public void sessionStarting(RequestContext context, FlowDefinition definition, MutableAttributeMap input);
80
81     /**
82      * Called when a new flow session has started. At this point the start state
83      * has been entered.
84      * @param context the source of the event
85      */

86     public void sessionStarted(RequestContext context, FlowSession session);
87
88     /**
89      * Called when an event is signaled in the current state, but prior to any
90      * state transition.
91      * @param context the source of the event
92      * @param event the event that occured
93      */

94     public void eventSignaled(RequestContext context, Event event);
95
96     /**
97      * Called when a state transitions, after the transition is matched but
98      * before the transition occurs.
99      * @param context the source of the event
100      * @param state the proposed state to transition to
101      * @throws EnterStateVetoException when entering the state is not allowed
102      */

103     public void stateEntering(RequestContext context, StateDefinition state) throws EnterStateVetoException;
104
105     /**
106      * Called when a state transitions, after the transition occured.
107      * @param context the source of the event
108      * @param previousState <i>from</i> state of the transition
109      * @param state <i>to</i> state of the transition
110      */

111     public void stateEntered(RequestContext context, StateDefinition previousState, StateDefinition state);
112     
113     /**
114      * Called when a flow execution is paused, for instance when it is waiting
115      * for user input (after event processing).
116      * @param context the source of the event
117      * @param selectedView the view that will display
118      */

119     public void paused(RequestContext context, ViewSelection selectedView);
120
121     /**
122      * Called after a flow execution is successfully reactivated after pause
123      * (but before event processing).
124      * @param context the source of the event
125      */

126     public void resumed(RequestContext context);
127
128     /**
129      * Called when the active flow execution session has been asked to end but
130      * before it has ended.
131      * @param context the source of the event
132      * @param session the current active session that is ending
133      * @param output the flow output produced by the ending session, this map may
134      * be modified by this listener to affect the output returned
135      */

136     public void sessionEnding(RequestContext context, FlowSession session, MutableAttributeMap output);
137
138     /**
139      * Called when a flow execution session ends. If the ended session was the
140      * root session of the flow execution, the entire flow execution also ends.
141      * @param context the source of the event
142      * @param session ending flow session
143      * @param output final, unmodifiable output returned by the ended session
144      */

145     public void sessionEnded(RequestContext context, FlowSession session, AttributeMap output);
146     
147     /**
148      * Called when an exception is thrown during a flow execution, before the
149      * exception is handled by any registered {@link FlowExecutionExceptionHandler handler}.
150      * @param context the source of the exception
151      * @param exception the exception that occurred
152      */

153     public void exceptionThrown(RequestContext context, FlowExecutionException exception);
154 }
Popular Tags