类 AbstractSentinelInterceptor

java.lang.Object
com.alibaba.csp.sentinel.adapter.spring.webmvc_v6x.AbstractSentinelInterceptor
所有已实现的接口:
org.springframework.web.servlet.AsyncHandlerInterceptor, org.springframework.web.servlet.HandlerInterceptor
直接已知子类:
SentinelWebInterceptor, SentinelWebTotalInterceptor

public abstract class AbstractSentinelInterceptor extends Object implements org.springframework.web.servlet.AsyncHandlerInterceptor
Since request may be reprocessed in flow if any forwarding or including or other action happened (see ServletRequest.getDispatcherType()) we will only deal with the initial request. So we use reference count to track in dispatching "onion" though which we could figure out whether we are in initial type "REQUEST". That means the sub-requests which we rarely meet in practice will NOT be recorded in Sentinel.

How to implement a forward sub-request in your action:

 initialRequest() {
     ModelAndView mav = new ModelAndView();
     mav.setViewName("another");
     return mav;
 }
 
从以下版本开始:
1.8.8
  • 字段概要

    字段
    修饰符和类型
    字段
    说明
    static final String
     
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    afterCompletion(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object handler, Exception ex)
     
    void
    afterConcurrentHandlingStarted(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object handler)
    When a handler starts an asynchronous request, the DispatcherServlet exits without invoking postHandle and afterCompletion Called instead of postHandle and afterCompletion to exit the context and clean thread-local variables when the handler is being executed concurrently.
    protected String
    getContextName(jakarta.servlet.http.HttpServletRequest request)
    Return the context name of the target web resource.
    protected com.alibaba.csp.sentinel.Entry
    getEntryInRequest(jakarta.servlet.http.HttpServletRequest request, String attrKey)
     
    protected abstract String
    getResourceName(jakarta.servlet.http.HttpServletRequest request)
    Return the resource name of the target web resource.
    protected void
    handleBlockException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String resourceName, com.alibaba.csp.sentinel.slots.block.BlockException e)
     
    protected String
    parseOrigin(jakarta.servlet.http.HttpServletRequest request)
     
    void
    postHandle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object handler, org.springframework.web.servlet.ModelAndView modelAndView)
     
    boolean
    preHandle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object handler)
     
    protected void
    removeEntryInRequest(jakarta.servlet.http.HttpServletRequest request)
     
    protected void
    traceExceptionAndExit(com.alibaba.csp.sentinel.Entry entry, Exception ex)
     

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详细资料

    • SENTINEL_SPRING_WEB_CONTEXT_NAME

      public static final String SENTINEL_SPRING_WEB_CONTEXT_NAME
      另请参阅:
  • 构造器详细资料

    • AbstractSentinelInterceptor

      public AbstractSentinelInterceptor(BaseWebMvcConfig config)
  • 方法详细资料

    • preHandle

      public boolean preHandle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object handler) throws Exception
      指定者:
      preHandle 在接口中 org.springframework.web.servlet.HandlerInterceptor
      抛出:
      Exception
    • getResourceName

      protected abstract String getResourceName(jakarta.servlet.http.HttpServletRequest request)
      Return the resource name of the target web resource.
      参数:
      request - web request
      返回:
      the resource name of the target web resource.
    • getContextName

      protected String getContextName(jakarta.servlet.http.HttpServletRequest request)
      Return the context name of the target web resource.
      参数:
      request - web request
      返回:
      the context name of the target web resource.
    • afterConcurrentHandlingStarted

      public void afterConcurrentHandlingStarted(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object handler) throws Exception
      When a handler starts an asynchronous request, the DispatcherServlet exits without invoking postHandle and afterCompletion Called instead of postHandle and afterCompletion to exit the context and clean thread-local variables when the handler is being executed concurrently.
      指定者:
      afterConcurrentHandlingStarted 在接口中 org.springframework.web.servlet.AsyncHandlerInterceptor
      参数:
      request - the current request
      response - the current response
      handler - the handler (or HandlerMethod) that started async execution, for type and/or instance examination
      抛出:
      Exception
    • afterCompletion

      public void afterCompletion(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object handler, Exception ex) throws Exception
      指定者:
      afterCompletion 在接口中 org.springframework.web.servlet.HandlerInterceptor
      抛出:
      Exception
    • postHandle

      public void postHandle(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, Object handler, org.springframework.web.servlet.ModelAndView modelAndView) throws Exception
      指定者:
      postHandle 在接口中 org.springframework.web.servlet.HandlerInterceptor
      抛出:
      Exception
    • getEntryInRequest

      protected com.alibaba.csp.sentinel.Entry getEntryInRequest(jakarta.servlet.http.HttpServletRequest request, String attrKey)
    • removeEntryInRequest

      protected void removeEntryInRequest(jakarta.servlet.http.HttpServletRequest request)
    • traceExceptionAndExit

      protected void traceExceptionAndExit(com.alibaba.csp.sentinel.Entry entry, Exception ex)
    • handleBlockException

      protected void handleBlockException(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String resourceName, com.alibaba.csp.sentinel.slots.block.BlockException e) throws Exception
      抛出:
      Exception
    • parseOrigin

      protected String parseOrigin(jakarta.servlet.http.HttpServletRequest request)