View Javadoc

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  
21  package org.apache.myfaces.orchestra.viewController;
22  
23  import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
24  
25  /***
26   * @see org.apache.myfaces.orchestra.viewController.ViewControllerManager
27   */
28  public abstract class AbstractViewControllerManager implements ViewControllerManager
29  {
30  	protected abstract ViewControllerNameMapper getViewControllerNameMapper();
31  	protected abstract ViewControllerExecutor getViewControllerExecutor();
32  
33  	public String getViewControllerName(String viewId)
34  	{
35  		ViewControllerNameMapper nameMapper = getViewControllerNameMapper();
36  		return nameMapper.mapViewId(viewId);
37  	}
38  
39  	public Object getViewController(String viewId)
40  	{
41  		String beanName = getViewControllerName(viewId);
42  		if (beanName == null)
43  		{
44  			return null;
45  		}
46  
47  		return FrameworkAdapter.getCurrentInstance().getBean(beanName);
48  	}
49  
50  	public void assertConversationState(String viewId)
51  	{
52  	}
53  
54  	public void executeInitView(String viewId)
55  	{
56  		String beanName = getViewControllerNameMapper().mapViewId(viewId);
57  		Object viewController = getViewController(viewId);
58  		if (viewController != null)
59  		{
60  			getViewControllerExecutor().invokeInitView(beanName, viewController);
61  		}
62  	}
63  
64  	public void executePreProcess(String viewId)
65  	{
66  		String beanName = getViewControllerNameMapper().mapViewId(viewId);
67  		Object viewController = getViewController(viewId);
68  		if (viewController != null)
69  		{
70  			getViewControllerExecutor().invokePreProcess(beanName, viewController);
71  		}
72  	}
73  
74  	public void executePreRenderView(String viewId)
75  	{
76  		String beanName = getViewControllerNameMapper().mapViewId(viewId);
77  		Object viewController = getViewController(viewId);
78  		if (viewController != null)
79  		{
80  			getViewControllerExecutor().invokePreRenderView(beanName, viewController);
81  		}
82  	}
83  }