01: /*
02: * Copyright 2002-2007 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.servlet.mvc;
18:
19: import javax.servlet.http.HttpServletRequest;
20: import javax.servlet.http.HttpServletResponse;
21:
22: import org.springframework.web.servlet.HandlerAdapter;
23: import org.springframework.web.servlet.ModelAndView;
24:
25: /**
26: * Adapter to use the plain {@link Controller} workflow interface with
27: * the generic {@link org.springframework.web.servlet.DispatcherServlet}.
28: * Supports handlers that implement the {@link LastModified} interface.
29: *
30: * <p>This is an SPI class, not used directly by application code.
31: *
32: * @author Rod Johnson
33: * @author Juergen Hoeller
34: * @see org.springframework.web.servlet.DispatcherServlet
35: * @see Controller
36: * @see LastModified
37: * @see HttpRequestHandlerAdapter
38: */
39: public class SimpleControllerHandlerAdapter implements HandlerAdapter {
40:
41: public boolean supports(Object handler) {
42: return (handler instanceof Controller);
43: }
44:
45: public ModelAndView handle(HttpServletRequest request,
46: HttpServletResponse response, Object handler)
47: throws Exception {
48:
49: return ((Controller) handler).handleRequest(request, response);
50: }
51:
52: public long getLastModified(HttpServletRequest request,
53: Object handler) {
54: if (handler instanceof LastModified) {
55: return ((LastModified) handler).getLastModified(request);
56: }
57: return -1L;
58: }
59:
60: }
|