1. /*
  2. * Copyright 2002-2004 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. package org.springframework.web.servlet.mvc;
  17. import javax.servlet.http.HttpServletRequest;
  18. import javax.servlet.http.HttpServletResponse;
  19. import org.springframework.web.servlet.HandlerAdapter;
  20. import org.springframework.web.servlet.ModelAndView;
  21. /**
  22. * Adapter to use the Controller workflow interface with the generic DispatcherServlet.
  23. * Supports controllers that implement the LastModified interface.
  24. *
  25. * <p>This is an SPI class, not used directly by application code.
  26. *
  27. * @author Rod Johnson
  28. * @version $Id: SimpleControllerHandlerAdapter.java,v 1.7 2004/03/18 02:46:08 trisberg Exp $
  29. * @see org.springframework.web.servlet.DispatcherServlet
  30. * @see Controller
  31. * @see LastModified
  32. */
  33. public class SimpleControllerHandlerAdapter implements HandlerAdapter {
  34. public boolean supports(Object handler) {
  35. return (handler instanceof Controller);
  36. }
  37. public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
  38. throws Exception {
  39. return ((Controller) handler).handleRequest(request, response);
  40. }
  41. public long getLastModified(HttpServletRequest request, Object handler) {
  42. if (handler instanceof LastModified) {
  43. return ((LastModified) handler).getLastModified(request);
  44. }
  45. return -1L;
  46. }
  47. }