01: /*
02: * Copyright 2004-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 java.io.Serializable;
19:
20: import org.springframework.binding.method.MethodSignature;
21: import org.springframework.util.Assert;
22: import org.springframework.webflow.execution.RequestContext;
23:
24: /**
25: * Thin action proxy that delegates to a method on an arbitrary bean. The bean
26: * instance is managed locally by this Action in an instance variable.
27: *
28: * @author Keith Donald
29: */
30: class LocalBeanInvokingAction extends AbstractBeanInvokingAction
31: implements Serializable {
32:
33: /**
34: * The target bean (any POJO) to invoke.
35: */
36: private Object bean;
37:
38: /**
39: * Creates a bean invoking action that invokes a method on the specified bean.
40: * The bean may be a proxy providing a layer of indirection if necessary.
41: * @param bean the bean to invoke
42: */
43: public LocalBeanInvokingAction(MethodSignature methodSignature,
44: Object bean) {
45: super (methodSignature);
46: Assert.notNull(bean,
47: "The bean to invoke by this action cannot be null");
48: this .bean = bean;
49: }
50:
51: /**
52: * Returns the target bean to invoke methods on.
53: */
54: public Object getBean() {
55: return bean;
56: }
57:
58: protected Object getBean(RequestContext context) throws Exception {
59: return getBean();
60: }
61: }
|