KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > webflow > action > DefaultMultiActionMethodResolver


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.action;
17
18 import org.springframework.webflow.action.MultiAction.MethodResolver;
19 import org.springframework.webflow.execution.RequestContext;
20
21 /**
22  * Default method resolver used by the MultiAction class. It uses the following
23  * algorithm to calculate a method name:
24  * <ol>
25  * <li>If the currently executing action has a "method" property defined, use
26  * the value as method name.</li>
27  * <li>Else use the name of the current state of the flow execution as a method
28  * name.</li>
29  * </ol>
30  *
31  * @see org.springframework.webflow.action.MultiAction
32  *
33  * @author Erwin Vervaet
34  */

35 public class DefaultMultiActionMethodResolver implements MethodResolver {
36
37     public String JavaDoc resolveMethod(RequestContext context) {
38         // implementation note: not using AnnotatedAction.METHOD_ATTRIBUTE since
39
// that resides in the engine subsystem
40
String JavaDoc method = context.getAttributes().getString("method");
41         if (method == null) {
42             if (context.getCurrentState() != null) {
43                 // default to the state id
44
method = context.getCurrentState().getId();
45             }
46             else {
47                 throw new IllegalStateException JavaDoc("Unable to resolve action method; no 'method' context attribute set");
48             }
49         }
50         return method;
51     }
52 }
Popular Tags