Class MethodHandlerInterceptor

  • All Implemented Interfaces:
    org.springframework.web.servlet.HandlerInterceptor
    Direct Known Subclasses:
    AnnotatedMethodHandlerInterceptor

    public abstract class MethodHandlerInterceptor
    extends java.lang.Object
    implements org.springframework.web.servlet.HandlerInterceptor
    HandlerMethod HandlerInterceptor abstract implementation
    Since:
    1.0.0
    Author:
    Mercy
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void afterCompletion​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler, java.lang.Exception ex)  
      protected abstract void afterCompletion​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.web.method.HandlerMethod handlerMethod, java.lang.Exception ex)  
      protected java.lang.Object[] getHandlerMethodArguments​(javax.servlet.ServletRequest request, org.springframework.web.method.HandlerMethod handlerMethod)
      Gets the HandlerMethod method parameter
      protected <T> T getHandlerMethodRequestBodyArgument​(javax.servlet.ServletRequest request, org.springframework.web.method.HandlerMethod handlerMethod)
      Gets the @RequestBody method parameter from the ServletRequest context
      protected <T> T getHandlerMethodReturnValue​(javax.servlet.ServletRequest request, org.springframework.web.method.HandlerMethod handlerMethod)
      Gets the value returned by the HandlerMethod method
      void postHandle​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler, org.springframework.web.servlet.ModelAndView modelAndView)  
      protected abstract void postHandle​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.web.method.HandlerMethod handlerMethod, org.springframework.web.servlet.ModelAndView modelAndView)  
      boolean preHandle​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Object handler)  
      protected abstract boolean preHandle​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.web.method.HandlerMethod handlerMethod)  
      protected boolean supports​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.web.method.HandlerMethod handlerMethod)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MethodHandlerInterceptor

        public MethodHandlerInterceptor()
    • Method Detail

      • preHandle

        public final boolean preHandle​(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response,
                                       java.lang.Object handler)
                                throws java.lang.Exception
        Specified by:
        preHandle in interface org.springframework.web.servlet.HandlerInterceptor
        Throws:
        java.lang.Exception
      • preHandle

        protected abstract boolean preHandle​(javax.servlet.http.HttpServletRequest request,
                                             javax.servlet.http.HttpServletResponse response,
                                             org.springframework.web.method.HandlerMethod handlerMethod)
                                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • postHandle

        public final void postHandle​(javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response,
                                     java.lang.Object handler,
                                     @Nullable
                                     org.springframework.web.servlet.ModelAndView modelAndView)
                              throws java.lang.Exception
        Specified by:
        postHandle in interface org.springframework.web.servlet.HandlerInterceptor
        Throws:
        java.lang.Exception
      • postHandle

        protected abstract void postHandle​(javax.servlet.http.HttpServletRequest request,
                                           javax.servlet.http.HttpServletResponse response,
                                           org.springframework.web.method.HandlerMethod handlerMethod,
                                           org.springframework.web.servlet.ModelAndView modelAndView)
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • afterCompletion

        public final void afterCompletion​(javax.servlet.http.HttpServletRequest request,
                                          javax.servlet.http.HttpServletResponse response,
                                          java.lang.Object handler,
                                          @Nullable
                                          java.lang.Exception ex)
                                   throws java.lang.Exception
        Specified by:
        afterCompletion in interface org.springframework.web.servlet.HandlerInterceptor
        Throws:
        java.lang.Exception
      • afterCompletion

        protected abstract void afterCompletion​(javax.servlet.http.HttpServletRequest request,
                                                javax.servlet.http.HttpServletResponse response,
                                                org.springframework.web.method.HandlerMethod handlerMethod,
                                                java.lang.Exception ex)
                                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • supports

        protected boolean supports​(javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.http.HttpServletResponse response,
                                   org.springframework.web.method.HandlerMethod handlerMethod)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getHandlerMethodArguments

        protected java.lang.Object[] getHandlerMethodArguments​(javax.servlet.ServletRequest request,
                                                               org.springframework.web.method.HandlerMethod handlerMethod)
        Gets the HandlerMethod method parameter
        Parameters:
        request - ServletRequest
        handlerMethod - HandlerMethod
        Returns:
        non-null
      • getHandlerMethodReturnValue

        protected <T> T getHandlerMethodReturnValue​(javax.servlet.ServletRequest request,
                                                    org.springframework.web.method.HandlerMethod handlerMethod)
        Gets the value returned by the HandlerMethod method
        Type Parameters:
        T - Method return value type
        Parameters:
        request - ServletRequest
        handlerMethod - HandlerMethod
        Returns:
        HandlerMethod Method return value
      • getHandlerMethodRequestBodyArgument

        protected <T> T getHandlerMethodRequestBodyArgument​(javax.servlet.ServletRequest request,
                                                            org.springframework.web.method.HandlerMethod handlerMethod)
        Gets the @RequestBody method parameter from the ServletRequest context
        Type Parameters:
        T - @RequestBody Method parameter Types
        Parameters:
        request - ServletRequest
        handlerMethod - HandlerMethod
        Returns:
        @RequestBody Method argument if present, otherwise null