Skip to content

Commit

Permalink
feat: initialize 메서드 분리해서, default_controller를 덮어씌을 수 있도록 리팩터링
Browse files Browse the repository at this point in the history
  • Loading branch information
hong-sile committed Sep 26, 2023
1 parent ec903f8 commit d07a72f
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -31,14 +31,19 @@ public class AnnotationHandlerMapping implements HandlerMapping {
private final Map<HandlerKey, HandlerExecution> 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<Class<?>> controllerClazz = new Reflections(basePackage)
.getTypesAnnotatedWith(Controller.class);
final Map<HandlerKey, HandlerExecution> handlerExecutions = controllerClazz
Expand Down

0 comments on commit d07a72f

Please sign in to comment.