diff --git a/src/main/java/cokr/xit/foundation/ApplicationContainer.java b/src/main/java/cokr/xit/foundation/ApplicationContainer.java index 48684f5..ba1beb2 100644 --- a/src/main/java/cokr/xit/foundation/ApplicationContainer.java +++ b/src/main/java/cokr/xit/foundation/ApplicationContainer.java @@ -3,6 +3,7 @@ package cokr.xit.foundation; import java.net.InetAddress; import java.util.Date; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -83,6 +84,21 @@ public class ApplicationContainer implements ApplicationContextAware { return actx; } + /**지정한 이름과 클래스의 Bean을 반환한다. + * @param Bean 유형 + * @param name Bean 이름 + * @param klass Bean 클래스 + * @return 지정한 이름과 클래스의 Bean + */ + public Optional getBean(String name, Class klass) { + if (!actx.containsBean(name)) + return Optional.empty(); + + return klass == null ? + Optional.of((T)actx.getBean(name)) : + Optional.of(actx.getBean(name, klass)); + } + private Log log() { return Log.get(getClass()); }