KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > web > servlet > HandlerAdapter


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.servlet;
18
19 import javax.servlet.http.HttpServletRequest JavaDoc;
20 import javax.servlet.http.HttpServletResponse JavaDoc;
21
22 /**
23  * MVC framework SPI interface, allowing parameterization of core MVC workflow.
24  *
25  * <p>Interface that must be implemented for each handler type to handle a request.
26  * This interface is used to allow the DispatcherServlet to be indefinitely
27  * extensible. The DispatcherServlet accesses all installed handlers through this
28  * interface, meaning that it does not contain code specific to any handler type.
29  *
30  * <p>Note that a handler can be of type Object. This is to enable handlers from
31  * other frameworks to be integrated with this framework without custom coding.
32  *
33  * <p>This interface is not intended for application developers. It is available
34  * to handlers who want to develop their own web workflow.
35  *
36  * <p>Note: Implementations can implement the Ordered interface to be able to
37  * specify a sorting order and thus a priority for getting applied by
38  * DispatcherServlet. Non-Ordered instances get treated as lowest priority.
39  *
40  * @author Rod Johnson
41  * @author Juergen Hoeller
42  * @see org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter
43  * @see org.springframework.web.servlet.mvc.throwaway.ThrowawayControllerHandlerAdapter
44  * @see org.springframework.web.servlet.handler.SimpleServletHandlerAdapter
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 JavaDoc handler);
60     
61     /**
62      * Use the given handler to handle this request.
63      * The workflow that is required may vary widely.
64      * @param request current HTTP request
65      * @param response current HTTP 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 <code>true</code>.
69      * @throws Exception in case of errors
70      * @return ModelAndView object with the name of the view and the required
71      * model data, or <code>null</code> if the request has been handled directly
72      */

73     ModelAndView handle(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, Object JavaDoc handler) throws Exception JavaDoc;
74
75     /**
76      * Same contract as for HttpServlet's <code>getLastModified</code> method.
77      * Can simply return -1 if there's no support in the handler class.
78      * @param request current HTTP request
79      * @param handler handler to use
80      * @return the lastModified value for the given handler
81      * @see javax.servlet.http.HttpServlet#getLastModified
82      * @see org.springframework.web.servlet.mvc.LastModified#getLastModified
83      */

84     long getLastModified(HttpServletRequest JavaDoc request, Object JavaDoc handler);
85
86 }
87
Popular Tags