KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > web > portlet > mvc > Controller


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
17 package org.springframework.web.portlet.mvc;
18
19 import javax.portlet.ActionRequest;
20 import javax.portlet.ActionResponse;
21 import javax.portlet.RenderRequest;
22 import javax.portlet.RenderResponse;
23
24 import org.springframework.web.portlet.ModelAndView;
25
26 /**
27  * Base portlet Controller interface, representing a component that receives
28  * RenderRequest/RenderResponse and ActionRequest/ActionResponse like a
29  * <code>Portlet</code> but is able to participate in an MVC workflow.
30  *
31  * <p>Any implementation of the portlet Controller interface should be a
32  * <i>reusable, threadsafe</i> class, capable of handling multiple
33  * portlet requests throughout the lifecycle of an application. To be able to
34  * configure Controller(s) in an easy way, Controllers are usually JavaBeans.</p>
35  *
36  * <p><b><a name="workflow">Workflow</a>:</b></p>
37  *
38  * <p>After the DispatcherPortlet has received a request and has done its work
39  * to resolve locales, themes and suchlike, it tries to resolve a
40  * Controller to handle that request, using a
41  * {@link org.springframework.web.portlet.HandlerMapping HandlerMapping}.
42  * When a Controller has been found, the
43  * {@link #handleRenderRequest handleRenderRequest} or {@link #handleActionRequest handleActionRequest}
44  * method will be invoked, which is responsible for handling the actual
45  * request and - if applicable - returning an appropriate ModelAndView.
46  * So actually, these method are the main entrypoint for the
47  * {@link org.springframework.web.portlet.DispatcherPortlet DispatcherPortlet}
48  * which delegates requests to controllers. These method - and also this interface -
49  * should preferrably not be implemented by custom controllers <i>directly</i>, since
50  * abstract controllers also provided by this package already provide a lot of
51  * functionality for typical use cases in portlet applications. A few examples of
52  * those controllers:
53  * {@link AbstractController AbstractController},
54  * {@link AbstractCommandController AbstractCommandController},
55  * {@link AbstractFormController AbstractFormController},
56  * {@link SimpleFormController SimpleFormController}.</p>
57  *
58  * <p>So basically any <i>direct</i> implementation of the Controller interface
59  * just handles RenderRequests/ActionRequests and should return a ModelAndView, to be
60  * further used by the DispatcherPortlet. Any additional functionality such as
61  * optional validation, form handling, etc should be obtained through extending
62  * one of the abstract controller classes mentioned above.</p>
63  *
64  * @author William G. Thompson, Jr.
65  * @author John A. Lewis
66  * @since 2.0
67  * @see SimpleControllerHandlerAdapter
68  * @see AbstractController
69  * @see AbstractCommandController
70  * @see AbstractFormController
71  * @see SimpleFormController
72  * @see org.springframework.context.ApplicationContextAware
73  * @see org.springframework.context.ResourceLoaderAware
74  * @see org.springframework.web.portlet.context.PortletContextAware
75  */

76 public interface Controller {
77
78     /**
79      * Process the action request. There is nothing to return.
80      * @param request current portlet action request
81      * @param response current portlet action response
82      * @throws Exception in case of errors
83      */

84     void handleActionRequest(ActionRequest request, ActionResponse response) throws Exception JavaDoc;
85
86     /**
87      * Process the render request and return a ModelAndView object which the DispatcherPortlet
88      * will render. A <code>null</code> return value is not an error: It indicates that this
89      * object completed request processing itself, thus there is no ModelAndView to render.
90      * @param request current portlet render request
91      * @param response current portlet render response
92      * @return a ModelAndView to render, or null if handled directly
93      * @throws Exception in case of errors
94      */

95     ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response) throws Exception JavaDoc;
96
97 }
98
Popular Tags