Class AbstractRestMappingScanner

java.lang.Object
cn.herodotus.engine.web.service.initializer.AbstractRestMappingScanner
All Implemented Interfaces:
EventListener, org.springframework.context.ApplicationListener<org.springframework.boot.context.event.ApplicationReadyEvent>

public abstract class AbstractRestMappingScanner extends Object implements org.springframework.context.ApplicationListener<org.springframework.boot.context.event.ApplicationReadyEvent>

Description: RequestMapping 扫描器抽象定义

提取 RequestMapping 扫描共性内容,方便维护

Author:
: gengwei.zheng
Date:
: 2024/1/31 23:38
  • Constructor Details

  • Method Details

    • onApplicationEvent

      public void onApplicationEvent(org.springframework.boot.context.event.ApplicationReadyEvent event)
      Specified by:
      onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.boot.context.event.ApplicationReadyEvent>
    • onApplicationEvent

      protected abstract void onApplicationEvent(org.springframework.context.ApplicationContext applicationContext)
    • isExcludedRequestMapping

      protected boolean isExcludedRequestMapping(org.springframework.web.method.HandlerMethod handlerMethod)
      检测RequestMapping是否需要被排除
      Parameters:
      handlerMethod - HandlerMethod
      Returns:
      boolean
    • isSpringAnnotationMatched

      protected boolean isSpringAnnotationMatched(org.springframework.web.method.HandlerMethod handlerMethod)
      如果开启isJustScanRestController,那么就只扫描RestController
      Parameters:
      handlerMethod - HandlerMethod
      Returns:
      boolean
    • isSwaggerAnnotationMatched

      protected boolean isSwaggerAnnotationMatched(org.springframework.web.method.HandlerMethod handlerMethod)
      有ApiIgnore注解的方法不扫描, 没有ApiOperation注解不扫描
      Parameters:
      handlerMethod - HandlerMethod
      Returns:
      boolean
    • isLegalGroup

      protected boolean isLegalGroup(String className)
      如果当前class的groupId在GroupId列表中,那么就进行扫描,否则就排除
      Parameters:
      className - 当前扫描的controller类名
      Returns:
      Boolean
    • createCode

      protected String createCode(String url, String requestMethods)
      根据 url 和 method 生成与当前 url 对应的 code。

      例如: 1. POST /element 生成为 post:element 2. /open/identity/session 生成为 open:identity:session

      Parameters:
      url - 请求 url
      requestMethods - 请求 method。
      Returns:
      url 对应的 code
    • notExecuteScanning

      protected boolean notExecuteScanning()
      判断当前环境是否符合扫描的条件设定
      Returns:
      是否执行扫描
    • complete

      protected void complete(String serviceId, List<RestMapping> resources)
      扫描完成操作
      Parameters:
      serviceId - 服务ID
      resources - 扫描到的资源
    • getContextPath

      protected String getContextPath(org.springframework.context.ApplicationContext applicationContext)
      ApplicationContext 中读取 Context Path
      Parameters:
      applicationContext - 应用上下文 ApplicationContext
      Returns:
      如果有 Context Path 就返回实际值,如果没有或者为 '/' 则返回空串。
    • toInterface

      protected String toInterface(String contextPath, String url)
      拼接实际的 URL。
      Parameters:
      contextPath - 上下文路径
      url - 实际的 Controller 地址。
      Returns:
      实际的 URL。