Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
XuxuGood committed Mar 22, 2024
1 parent 5518c5c commit b72de0d
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static void reset(DefaultListableBeanFactory beanFactory,
ResetRequestMappingCaches.newBeanNames = newBeanNames;
ResetRequestMappingCaches.beanFactory = beanFactory;

// 判断是否是 SpringMVC Controller bean 变更
// Determine whether it is a spring mvc controller bean change
if (!needReloadSpringMVC()) {
LOGGER.trace("Spring: spring mvc no changes");
return;
Expand All @@ -78,9 +78,9 @@ public static void reset(DefaultListableBeanFactory beanFactory,
}

try {
// 处理 Servlet 的映射
// Handle Servlet mapping
processServletMappings(abstractHandlerMethodMapping);
// 处理 Spring 的映射
// Handle Spring mapping
processSpringMappings(abstractHandlerMethodMapping, beanFactory);
} catch (Exception e) {
LOGGER.error("Failed to clear HandlerMappings", e);
Expand Down Expand Up @@ -160,11 +160,11 @@ private static void processMappings(Class<?> abstractHandlerMethodMapping, Objec
HandlerMethod handlerMethod = (HandlerMethod) unmodifiableHandlerMethods.get(key);
if (ResetRequestMappingCaches.beansToProcess.contains(handlerMethod.getBean().toString())) {
LOGGER.trace("Unregistering handler method {}", key);
// 卸载mapping
// Uninstall mapping
u.invoke(handlerMapping, key);
}
}
// 手动注册mapping
// Register mapping manually
registerHandlerBeans(ResetRequestMappingCaches.beansToProcess, abstractHandlerMethodMapping, handlerMapping);
registerHandlerBeans(ResetRequestMappingCaches.newBeanNames, abstractHandlerMethodMapping, handlerMapping);
}
Expand All @@ -189,17 +189,17 @@ private static void registerHandlerBeans(Set<String> beanNames,
}

private static boolean isMvcHandler(Class<?> beanClass) {
// 判断类上是否有@Controller注解或其衍生注解
// Determine whether there is @Controller annotation or its derived annotation on the class
if (beanClass.isAnnotationPresent(Controller.class) || beanClass.isAnnotationPresent(RestController.class)) {
return true;
}

// 判断类是否实现了Spring MVC中的控制器接口
// Determine whether the class implements the controller interface in Spring MVC
if (Controller.class.isAssignableFrom(beanClass)) {
return true;
}

// 判断方法是否使用了Spring MVC中的相关注解
// Determine whether the method uses relevant annotations in Spring MVC
for (Method method : beanClass.getDeclaredMethods()) {
if (method.isAnnotationPresent(RequestMapping.class) ||
method.isAnnotationPresent(GetMapping.class) ||
Expand All @@ -215,7 +215,7 @@ private static boolean isMvcHandler(Class<?> beanClass) {
}

/**
* DispatcherServlet实例化注册HandlerMapping
* DispatcherServlet instantiation registration HandlerMapping
*
* @param handlerMappings
*/
Expand Down

0 comments on commit b72de0d

Please sign in to comment.