forked from woowacourse/java-mvc
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(mvc): extract controllerScanner
- Loading branch information
1 parent
b661044
commit 3028bc7
Showing
3 changed files
with
20 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
mvc/src/main/java/com/interface21/webmvc/servlet/mvc/tobe/ControllerScanner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.interface21.webmvc.servlet.mvc.tobe; | ||
|
||
import com.interface21.context.stereotype.Controller; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
import org.reflections.Reflections; | ||
|
||
public class ControllerScanner { | ||
public Set<Class<?>> scan(final Object[] packages) { | ||
return Arrays.stream(packages).map(Reflections::new) | ||
.map(r -> r.getTypesAnnotatedWith(Controller.class)) | ||
.flatMap(Collection::stream) | ||
.collect(Collectors.toSet()); | ||
} | ||
} |