use of cn.taketoday.framework.web.context.MissingWebServerFactoryBeanException in project today-framework by TAKETODAY.
the class ServletWebServerApplicationContext method getWebServerFactory.
/**
* Returns the {@link ServletWebServerFactory} that should be used to create the
* embedded {@link WebServer}. By default this method searches for a suitable bean in
* the context itself.
*
* @return a {@link ServletWebServerFactory} (never {@code null})
*/
protected ServletWebServerFactory getWebServerFactory() {
// Use bean names so that we don't consider the hierarchy
StandardBeanFactory beanFactory = getBeanFactory();
Set<String> beanNames = beanFactory.getBeanNamesForType(ServletWebServerFactory.class);
if (beanNames.size() == 0) {
throw new MissingWebServerFactoryBeanException(getClass(), ServletWebServerFactory.class, ApplicationType.SERVLET_WEB);
}
if (beanNames.size() > 1) {
throw new ApplicationContextException("Unable to start ServletWebServerApplicationContext due to multiple " + "ServletWebServerFactory beans : " + StringUtils.collectionToCommaDelimitedString(beanNames));
}
return beanFactory.getBean(CollectionUtils.firstElement(beanNames), ServletWebServerFactory.class);
}
use of cn.taketoday.framework.web.context.MissingWebServerFactoryBeanException in project today-infrastructure by TAKETODAY.
the class ServletWebServerApplicationContext method getWebServerFactory.
/**
* Returns the {@link ServletWebServerFactory} that should be used to create the
* embedded {@link WebServer}. By default this method searches for a suitable bean in
* the context itself.
*
* @return a {@link ServletWebServerFactory} (never {@code null})
*/
protected ServletWebServerFactory getWebServerFactory() {
// Use bean names so that we don't consider the hierarchy
StandardBeanFactory beanFactory = getBeanFactory();
Set<String> beanNames = beanFactory.getBeanNamesForType(ServletWebServerFactory.class);
if (beanNames.size() == 0) {
throw new MissingWebServerFactoryBeanException(getClass(), ServletWebServerFactory.class, ApplicationType.SERVLET_WEB);
}
if (beanNames.size() > 1) {
throw new ApplicationContextException("Unable to start ServletWebServerApplicationContext due to multiple " + "ServletWebServerFactory beans : " + StringUtils.collectionToCommaDelimitedString(beanNames));
}
return beanFactory.getBean(CollectionUtils.firstElement(beanNames), ServletWebServerFactory.class);
}
Aggregations