Save This Page
Home » spring-framework-2.5.6-with-dependencies » org.springframework » web » servlet » mvc » [javadoc | source]
    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;
   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, HttpServletResponse response, Object handler)
   46   			throws Exception {
   47   
   48   		return ((Controller) handler).handleRequest(request, response);
   49   	}
   50   
   51   	public long getLastModified(HttpServletRequest request, Object handler) {
   52   		if (handler instanceof LastModified) {
   53   			return ((LastModified) handler).getLastModified(request);
   54   		}
   55   		return -1L;
   56   	}
   57   
   58   }

Save This Page
Home » spring-framework-2.5.6-with-dependencies » org.springframework » web » servlet » mvc » [javadoc | source]