getBean(..) 추가

master
mjkhan21 1 year ago
parent 33f41fda83
commit c9b0a62375

@ -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 <T> Bean
* @param name Bean
* @param klass Bean
* @return Bean
*/
public <T> Optional<T> getBean(String name, Class<T> 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());
}

Loading…
Cancel
Save