Commit e5827f48 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '1.3.x'

parents 867f86a4 6c8f8c9d
...@@ -16,12 +16,15 @@ ...@@ -16,12 +16,15 @@
package org.springframework.boot.actuate.autoconfigure; package org.springframework.boot.actuate.autoconfigure;
import java.lang.reflect.Modifier;
import javax.servlet.Servlet; import javax.servlet.Servlet;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.FatalBeanException;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;
...@@ -183,13 +186,12 @@ public class EndpointWebMvcAutoConfiguration ...@@ -183,13 +186,12 @@ public class EndpointWebMvcAutoConfiguration
private void registerEmbeddedServletContainerFactory( private void registerEmbeddedServletContainerFactory(
AnnotationConfigEmbeddedWebApplicationContext childContext) { AnnotationConfigEmbeddedWebApplicationContext childContext) {
try { try {
EmbeddedServletContainerFactory servletContainerFactory = this.applicationContext
.getBean(EmbeddedServletContainerFactory.class);
ConfigurableListableBeanFactory beanFactory = childContext.getBeanFactory(); ConfigurableListableBeanFactory beanFactory = childContext.getBeanFactory();
if (beanFactory instanceof BeanDefinitionRegistry) { if (beanFactory instanceof BeanDefinitionRegistry) {
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory; BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
registry.registerBeanDefinition("embeddedServletContainerFactory", registry.registerBeanDefinition("embeddedServletContainerFactory",
new RootBeanDefinition(servletContainerFactory.getClass())); new RootBeanDefinition(
determineEmbeddedServletContainerFactoryClass()));
} }
} }
catch (NoSuchBeanDefinitionException ex) { catch (NoSuchBeanDefinitionException ex) {
...@@ -197,6 +199,25 @@ public class EndpointWebMvcAutoConfiguration ...@@ -197,6 +199,25 @@ public class EndpointWebMvcAutoConfiguration
} }
} }
private Class<?> determineEmbeddedServletContainerFactoryClass()
throws NoSuchBeanDefinitionException {
Class<?> servletContainerFactoryClass = this.applicationContext
.getBean(EmbeddedServletContainerFactory.class).getClass();
if (cannotBeInstantiated(servletContainerFactoryClass)) {
throw new FatalBeanException("EmbeddedServletContainerFactory implementation "
+ servletContainerFactoryClass.getName() + " cannot be instantiated. "
+ "To allow a separate management port to be used, a top-level class "
+ "or static inner class should be used instead");
}
return servletContainerFactoryClass;
}
private boolean cannotBeInstantiated(Class<?> clazz) {
return clazz.isLocalClass()
|| (clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers()))
|| clazz.isAnonymousClass();
}
/** /**
* Add an alias for 'local.management.port' that actually resolves using * Add an alias for 'local.management.port' that actually resolves using
* 'local.server.port'. * 'local.server.port'.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment