01: /*
02: * Copyright 2002-2006 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:
17: package org.springframework.web.portlet;
18:
19: import javax.portlet.ActionRequest;
20: import javax.portlet.ActionResponse;
21: import javax.portlet.RenderRequest;
22: import javax.portlet.RenderResponse;
23:
24: /**
25: * Portlet MVC framework SPI interface, allowing parameterization of core MVC workflow.
26: *
27: * <p>Interface that must be implemented for each handler type to handle a request.
28: * This interface is used to allow the DispatcherPortlet to be indefinitely
29: * extensible. The DispatcherPortlet accesses all installed handlers through this
30: * interface, meaning that it does not contain code specific to any handler type.
31: *
32: * <p>Note that a handler can be of type Object. This is to enable handlers from
33: * other frameworks to be integrated with this framework without custom coding.
34: *
35: * <p>This interface is not intended for application developers. It is available
36: * to handlers who want to develop their own web workflow.
37: *
38: * <p>Note: Implementations can implement the Ordered interface to be able to
39: * specify a sorting order and thus a priority for getting applied by
40: * DispatcherPortlet. Non-Ordered instances get treated as lowest priority.
41: *
42: * @author John A. Lewis
43: * @since 2.0
44: * @see org.springframework.web.portlet.mvc.SimpleControllerHandlerAdapter
45: */
46: public interface HandlerAdapter {
47:
48: /**
49: * Given a handler instance, return whether or not this HandlerAdapter can
50: * support it. Typical HandlerAdapters will base the decision on the handler
51: * type. HandlerAdapters will usually only support one handler type each.
52: * <p>A typical implementation:
53: * <p><code>
54: * return (handler instanceof MyHandler);
55: * </code>
56: * @param handler handler object to check
57: * @return whether or not this object can use the given handler
58: */
59: boolean supports(Object handler);
60:
61: /**
62: * Use the given handler to handle this action request.
63: * The workflow that is required may vary widely.
64: * @param request current action request
65: * @param response current action response
66: * @param handler handler to use. This object must have previously been passed
67: * to the <code>supports</code> method of this interface, which must have
68: * returned true.
69: * @throws Exception in case of errors
70: */
71: void handleAction(ActionRequest request, ActionResponse response,
72: Object handler) throws Exception;
73:
74: /**
75: * Use the given handler to handle this render request.
76: * The workflow that is required may vary widely.
77: * @param request current render request
78: * @param response current render response
79: * @param handler handler to use. This object must have previously been passed
80: * to the <code>supports</code> method of this interface, which must have
81: * returned <code>true</code>.
82: * @throws Exception in case of errors
83: * @return ModelAndView object with the name of the view and the required
84: * model data, or <code>null</code> if the request has been handled directly
85: */
86: ModelAndView handleRender(RenderRequest request,
87: RenderResponse response, Object handler) throws Exception;
88:
89: }
|