forked from woowacourse/java-mvc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReflectionsTest.java
27 lines (22 loc) · 1.01 KB
/
ReflectionsTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package reflection;
import org.junit.jupiter.api.Test;
import org.reflections.Reflections;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reflection.annotation.Controller;
import reflection.annotation.Repository;
import reflection.annotation.Service;
class ReflectionsTest {
private static final Logger log = LoggerFactory.getLogger(ReflectionsTest.class);
@Test
void showAnnotationClass() throws Exception {
Reflections reflections = new Reflections("reflection.examples");
reflections.getTypesAnnotatedWith(Controller.class)
.forEach(clazz -> log.info(clazz.getName()));
reflections.getTypesAnnotatedWith(Service.class)
.forEach(clazz -> log.info(clazz.getName()));
reflections.getTypesAnnotatedWith(Repository.class)
.forEach(clazz -> log.info(clazz.getName()));
// TODO 클래스 레벨에 @Controller, @Service, @Repository 애노테이션이 설정되어 모든 클래스 찾아 로그로 출력한다.
}
}