From d07a72f4189286f6c1f34343200062c169e5d820 Mon Sep 17 00:00:00 2001 From: hong-sile Date: Tue, 26 Sep 2023 12:54:25 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20initialize=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EB=B6=84=EB=A6=AC=ED=95=B4=EC=84=9C,=20default=5Fc?= =?UTF-8?q?ontroller=EB=A5=BC=20=EB=8D=AE=EC=96=B4=EC=94=8C=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=84=B0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tobe/handler_mapping/AnnotationHandlerMapping.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mvc/src/main/java/webmvc/org/springframework/web/servlet/mvc/tobe/handler_mapping/AnnotationHandlerMapping.java b/mvc/src/main/java/webmvc/org/springframework/web/servlet/mvc/tobe/handler_mapping/AnnotationHandlerMapping.java index 9c19ef1fe2..c936c50ff5 100644 --- a/mvc/src/main/java/webmvc/org/springframework/web/servlet/mvc/tobe/handler_mapping/AnnotationHandlerMapping.java +++ b/mvc/src/main/java/webmvc/org/springframework/web/servlet/mvc/tobe/handler_mapping/AnnotationHandlerMapping.java @@ -18,8 +18,8 @@ import web.org.springframework.web.bind.annotation.RequestMapping; import web.org.springframework.web.bind.annotation.RequestMethod; import webmvc.org.springframework.web.servlet.exception.RequestMethodNotValidException; -import webmvc.org.springframework.web.servlet.mvc.tobe.handler.Handler; import webmvc.org.springframework.web.servlet.mvc.tobe.default_controller.ForwardController; +import webmvc.org.springframework.web.servlet.mvc.tobe.handler.Handler; public class AnnotationHandlerMapping implements HandlerMapping { @@ -31,14 +31,19 @@ public class AnnotationHandlerMapping implements HandlerMapping { private final Map handlerExecutions; public AnnotationHandlerMapping(final Object... basePackage) { - this.basePackage = Stream.of(basePackage, DEFAULT_CONTROLLER_PACKAGE).toArray(); + this.basePackage = basePackage; this.handlerExecutions = new HashMap<>(); + initializeByPackages(DEFAULT_CONTROLLER_PACKAGE); } @Override public void initialize() { log.info("Initialized AnnotationHandlerMapping!"); + initializeByPackages(basePackage); + } + + private void initializeByPackages(final Object... basePackage) { final Set> controllerClazz = new Reflections(basePackage) .getTypesAnnotatedWith(Controller.class); final Map handlerExecutions = controllerClazz