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.throwaway;
  17. import javax.servlet.http.HttpServletRequest;
  18. import javax.servlet.http.HttpServletResponse;
  19. import org.springframework.web.bind.ServletRequestDataBinder;
  20. import org.springframework.web.servlet.HandlerAdapter;
  21. import org.springframework.web.servlet.ModelAndView;
  22. /**
  23. * @author Juergen Hoeller
  24. * @since 08.12.2003
  25. */
  26. public class ThrowawayControllerHandlerAdapter implements HandlerAdapter {
  27. public static final String THROWAWAY_CONTROLLER_NAME = "throwawayController";
  28. public boolean supports(Object handler) {
  29. return (handler instanceof ThrowawayController);
  30. }
  31. public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
  32. ThrowawayController throwaway = (ThrowawayController) handler;
  33. ServletRequestDataBinder binder = new ServletRequestDataBinder(throwaway, THROWAWAY_CONTROLLER_NAME);
  34. binder.bind(request);
  35. binder.closeNoCatch();
  36. return throwaway.execute();
  37. }
  38. public long getLastModified(HttpServletRequest request, Object handler) {
  39. return -1;
  40. }
  41. }