KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > webflow > execution > support > FlowDefinitionRedirect


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.support;
17
18 import java.util.Collections JavaDoc;
19 import java.util.Map JavaDoc;
20
21 import org.springframework.util.Assert;
22 import org.springframework.webflow.execution.ViewSelection;
23
24 /**
25  * Concrete response type that requests that a <i>new</i> execution of a flow
26  * definition (representing the start of a new conversation) be launched.
27  * <p>
28  * This allows "redirect to new flow" semantics; useful for restarting a flow
29  * after completion, or starting an entirely new flow from within the end state
30  * of another flow definition.
31  *
32  * @author Keith Donald
33  * @author Erwin Vervaet
34  */

35 public final class FlowDefinitionRedirect extends ViewSelection {
36
37     /**
38      * The id of the flow definition to launch.
39      */

40     private final String JavaDoc flowDefinitionId;
41
42     /**
43      * A map of input attributes to pass to the flow.
44      */

45     private final Map JavaDoc executionInput;
46
47     /**
48      * Creates a new flow definition redirect.
49      * @param flowDefinitionId the id of the flow definition to launch
50      * @param executionInput the input data to pass to the new flow execution on launch
51      */

52     public FlowDefinitionRedirect(String JavaDoc flowDefinitionId, Map JavaDoc executionInput) {
53         Assert.hasText(flowDefinitionId, "The flow definition id is required");
54         this.flowDefinitionId = flowDefinitionId;
55         if (executionInput == null) {
56             executionInput = Collections.EMPTY_MAP;
57         }
58         this.executionInput = executionInput;
59     }
60
61     /**
62      * Return the id of the flow definition to launch a new execution of.
63      */

64     public String JavaDoc getFlowDefinitionId() {
65         return flowDefinitionId;
66     }
67
68     /**
69      * Return the flow execution input map as an unmodifiable map. Never returns
70      * null.
71      */

72     public Map JavaDoc getExecutionInput() {
73         return Collections.unmodifiableMap(executionInput);
74     }
75
76     public boolean equals(Object JavaDoc o) {
77         if (!(o instanceof FlowDefinitionRedirect)) {
78             return false;
79         }
80         FlowDefinitionRedirect other = (FlowDefinitionRedirect)o;
81         return flowDefinitionId.equals(other.flowDefinitionId) && executionInput.equals(other.executionInput);
82     }
83
84     public int hashCode() {
85         return flowDefinitionId.hashCode() + executionInput.hashCode();
86     }
87
88     public String JavaDoc toString() {
89         return "flowRedirect:'" + flowDefinitionId + "'";
90     }
91 }
Popular Tags