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 Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractRestMappingScanner(ServiceProperties.Scan scan, RestMappingScanEventManager restMappingScanEventManager) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcomplete(String serviceId, List<RestMapping> resources) 扫描完成操作protected StringcreateCode(String url, String requestMethods) 根据 url 和 method 生成与当前 url 对应的 code。protected StringgetContextPath(org.springframework.context.ApplicationContext applicationContext) 从ApplicationContext中读取 Context Pathprotected booleanisExcludedRequestMapping(org.springframework.web.method.HandlerMethod handlerMethod) 检测RequestMapping是否需要被排除protected booleanisLegalGroup(String className) 如果当前class的groupId在GroupId列表中,那么就进行扫描,否则就排除protected booleanisSpringAnnotationMatched(org.springframework.web.method.HandlerMethod handlerMethod) 如果开启isJustScanRestController,那么就只扫描RestControllerprotected booleanisSwaggerAnnotationMatched(org.springframework.web.method.HandlerMethod handlerMethod) 有ApiIgnore注解的方法不扫描, 没有ApiOperation注解不扫描protected boolean判断当前环境是否符合扫描的条件设定voidonApplicationEvent(org.springframework.boot.context.event.ApplicationReadyEvent event) protected abstract voidonApplicationEvent(org.springframework.context.ApplicationContext applicationContext) protected StringtoInterface(String contextPath, String url) 拼接实际的 URL。Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
Constructor Details
-
AbstractRestMappingScanner
protected AbstractRestMappingScanner(ServiceProperties.Scan scan, RestMappingScanEventManager restMappingScanEventManager)
-
-
Method Details
-
onApplicationEvent
public void onApplicationEvent(org.springframework.boot.context.event.ApplicationReadyEvent event) - Specified by:
onApplicationEventin interfaceorg.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
如果当前class的groupId在GroupId列表中,那么就进行扫描,否则就排除- Parameters:
className- 当前扫描的controller类名- Returns:
- Boolean
-
createCode
根据 url 和 method 生成与当前 url 对应的 code。例如: 1. POST /element 生成为 post:element 2. /open/identity/session 生成为 open:identity:session
- Parameters:
url- 请求 urlrequestMethods- 请求 method。- Returns:
- url 对应的 code
-
notExecuteScanning
protected boolean notExecuteScanning()判断当前环境是否符合扫描的条件设定- Returns:
- 是否执行扫描
-
complete
扫描完成操作- Parameters:
serviceId- 服务IDresources- 扫描到的资源
-
getContextPath
从ApplicationContext中读取 Context Path- Parameters:
applicationContext- 应用上下文ApplicationContext- Returns:
- 如果有 Context Path 就返回实际值,如果没有或者为 '/' 则返回空串。
-
toInterface
拼接实际的 URL。- Parameters:
contextPath- 上下文路径url- 实际的 Controller 地址。- Returns:
- 实际的 URL。
-