KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > web > servlet > mvc > HttpRequestHandlerAdapter


1 /*
2  * Copyright 2002-2007 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.mvc;
18
19 import javax.servlet.http.HttpServletRequest JavaDoc;
20 import javax.servlet.http.HttpServletResponse JavaDoc;
21
22 import org.springframework.web.HttpRequestHandler;
23 import org.springframework.web.servlet.HandlerAdapter;
24 import org.springframework.web.servlet.ModelAndView;
25
26 /**
27  * Adapter to use the plain {@link org.springframework.web.HttpRequestHandler}
28  * interface with the generic {@link org.springframework.web.servlet.DispatcherServlet}.
29  * Supports handlers that implement the {@link LastModified} interface.
30  *
31  * <p>This is an SPI class, not used directly by application code.
32  *
33  * @author Juergen Hoeller
34  * @since 2.0
35  * @see org.springframework.web.servlet.DispatcherServlet
36  * @see org.springframework.web.HttpRequestHandler
37  * @see LastModified
38  * @see SimpleControllerHandlerAdapter
39  */

40 public class HttpRequestHandlerAdapter implements HandlerAdapter {
41
42     public boolean supports(Object JavaDoc handler) {
43         return (handler instanceof HttpRequestHandler);
44     }
45
46     public ModelAndView handle(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, Object JavaDoc handler)
47             throws Exception JavaDoc {
48
49         ((HttpRequestHandler) handler).handleRequest(request, response);
50         return null;
51     }
52
53     public long getLastModified(HttpServletRequest JavaDoc request, Object JavaDoc handler) {
54         if (handler instanceof LastModified) {
55             return ((LastModified) handler).getLastModified(request);
56         }
57         return -1L;
58     }
59
60 }
61
Popular Tags