1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20 package org.apache.myfaces.orchestra.viewController;
21
22 /**
23 * Invokes ViewController events using the {@link ViewController} interface.
24 * <p>
25 * This requires that beans implement the ViewController interface in order
26 * to receive view lifecycle events.
27 * <p>
28 * Other implementations are possible that do not require a bean to implement a
29 * specific interface; see ReflectiveViewControllerExecutor for one example.
30 * <p>
31 * Note that each method here returns false if the target bean does not
32 * implement the ViewController interface; this allows this executor to
33 * be "chained" with others.
34 */
35 public class InterfaceViewControllerExecutor extends AbstractViewControllerExecutor
36 {
37 public boolean invokeInitView(String beanName, Object bean)
38 {
39 if (bean instanceof ViewController)
40 {
41 ((ViewController) bean).initView();
42 return true;
43 }
44 return false;
45 }
46
47 public boolean invokePreRenderView(String beanName, Object bean)
48 {
49 if (bean instanceof ViewController)
50 {
51 ((ViewController) bean).preRenderView();
52 return true;
53 }
54 return false;
55 }
56
57 public boolean invokePreProcess(String beanName, Object bean)
58 {
59 if (bean instanceof ViewController)
60 {
61 ((ViewController) bean).preProcess();
62 return true;
63 }
64 return false;
65 }
66 }