diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpoint.java index 53ffa0d826..788da909b5 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpoint.java @@ -17,6 +17,7 @@ package org.springframework.boot.actuate.endpoint; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -286,6 +287,9 @@ public class ConfigurationPropertiesReportEndpoint extends } + /** + * {@link BeanSerializerModifier} to return only relevant configuration properties. + */ protected static class GenericSerializerModifier extends BeanSerializerModifier { @Override @@ -302,7 +306,7 @@ public class ConfigurationPropertiesReportEndpoint extends } private boolean isReadable(BeanDescription beanDesc, BeanPropertyWriter writer) { - String parenType = beanDesc.getType().getRawClass().getName(); + String parentType = beanDesc.getType().getRawClass().getName(); String type = writer.getPropertyType().getName(); AnnotatedMethod setter = beanDesc.findMethod( "set" + StringUtils.capitalize(writer.getName()), @@ -312,10 +316,9 @@ public class ConfigurationPropertiesReportEndpoint extends // that its a nested class used solely for binding to config props, so it // should be kosher. This filter is not used if there is JSON metadata for // the property, so it's mainly for user-defined beans. - boolean readable = setter != null - || ClassUtils.getPackageName(parenType).equals( + return (setter != null) + || ClassUtils.getPackageName(parentType).equals( ClassUtils.getPackageName(type)); - return readable; } } @@ -327,9 +330,11 @@ public class ConfigurationPropertiesReportEndpoint extends */ protected static class ConfigurationPropertiesMetaData { - private Map> matched = new HashMap>(); + private final String metadataLocations; + + private final Map> matched = new HashMap>(); + private Set keys = null; - private String metadataLocations; public ConfigurationPropertiesMetaData(String metadataLocations) { this.metadataLocations = metadataLocations; @@ -349,53 +354,45 @@ public class ConfigurationPropertiesReportEndpoint extends } private boolean matchesInternal(String prefix) { - if (this.matched.get(prefix) != null) { - return true; - } - else { - return false; - } + return this.matched.get(prefix) != null; } private Set findKeys(String prefix) { - - HashSet set = new HashSet(); - - try { - if (this.keys == null) { - - this.keys = new HashSet(); - ObjectMapper mapper = new ObjectMapper(); - Resource[] resources = new PathMatchingResourcePatternResolver() - .getResources(this.metadataLocations); - for (Resource resource : resources) { - addKeys(mapper, resource); - } - - } - } - catch (IOException e) { - logger.warn("Could not deserialize config properties metadata", e); - } - for (String key : this.keys) { + HashSet keys = new HashSet(); + for (String key : getKeys()) { if (key.length() > prefix.length() && key.startsWith(prefix) && ".".equals(key.substring(prefix.length(), prefix.length() + 1))) { - set.add(key.substring(prefix.length() + 1)); + keys.add(key.substring(prefix.length() + 1)); } } - if (set.isEmpty()) { - return null; - } - return set; + return (keys.isEmpty() ? null : keys); } + private Set getKeys() { + if (this.keys != null) { + return this.keys; + } + this.keys = new HashSet(); + try { + ObjectMapper mapper = new ObjectMapper(); + Resource[] resources = new PathMatchingResourcePatternResolver() + .getResources(this.metadataLocations); + for (Resource resource : resources) { + addKeys(mapper, resource); + } + } + catch (IOException ex) { + logger.warn("Could not deserialize config properties metadata", ex); + } + return this.keys; + } + + @SuppressWarnings("unchecked") private void addKeys(ObjectMapper mapper, Resource resource) throws IOException, JsonParseException, JsonMappingException { - @SuppressWarnings("unchecked") - Map map = mapper.readValue(resource.getInputStream(), - Map.class); - @SuppressWarnings("unchecked") + InputStream inputStream = resource.getInputStream(); + Map map = mapper.readValue(inputStream, Map.class); Collection> metadata = (Collection>) map .get("properties"); for (Map value : metadata) { @@ -404,8 +401,8 @@ public class ConfigurationPropertiesReportEndpoint extends this.keys.add((String) value.get("name")); } } - catch (Exception e) { - logger.warn("Could not parse config properties metadata", e); + catch (Exception ex) { + logger.warn("Could not parse config properties metadata", ex); } } } @@ -421,13 +418,13 @@ public class ConfigurationPropertiesReportEndpoint extends return map; } + @SuppressWarnings("unchecked") private void addProperty(Object bean, String key, Map map) { - String prefix = key.contains(".") ? StringUtils.split(key, ".")[0] : key; - String suffix = key.length() > prefix.length() ? key.substring(prefix - .length() + 1) : null; + String prefix = (key.contains(".") ? StringUtils.split(key, ".")[0] : key); + String suffix = (key.length() > prefix.length() ? key.substring(prefix + .length() + 1) : null); String property = prefix; if (bean instanceof Map) { - @SuppressWarnings("unchecked") Map value = (Map) bean; bean = new MapHolder(value); property = "map[" + property + "]"; @@ -446,14 +443,15 @@ public class ConfigurationPropertiesReportEndpoint extends map.put(prefix, value); } } - catch (Exception e) { + catch (Exception ex) { // Probably just lives on a different bean (it happens) logger.debug("Could not parse config properties metadata '" + key + "': " - + e.getMessage()); + + ex.getMessage()); } } protected static class MapHolder { + Map map = new HashMap(); public MapHolder(Map bean) { @@ -467,6 +465,7 @@ public class ConfigurationPropertiesReportEndpoint extends public void setMap(Map map) { this.map = map; } + } } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerMappingCustomizer.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerMappingCustomizer.java index cab05bf5f5..b0877e36dd 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerMappingCustomizer.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerMappingCustomizer.java @@ -20,9 +20,14 @@ package org.springframework.boot.actuate.endpoint.mvc; * Callback for customizing the {@link EndpointHandlerMapping} at configuration time. * * @author Dave Syer + * @since 1.2.0 */ public interface EndpointHandlerMappingCustomizer { + /** + * Customize the specified {@link EndpointHandlerMapping} + * @param mapping the {@link EndpointHandlerMapping} to customize + */ void customize(EndpointHandlerMapping mapping); } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointMvcIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointMvcIntegrationTests.java index 79a6900171..cc3f4a82cb 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointMvcIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointMvcIntegrationTests.java @@ -97,6 +97,7 @@ public class EndpointMvcIntegrationTests { HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class }) protected static @interface MinimalWebConfiguration { + } @Configuration @@ -134,9 +135,11 @@ public class EndpointMvcIntegrationTests { protected TestInterceptor interceptor() { return new TestInterceptor(); } + } protected static class TestInterceptor extends HandlerInterceptorAdapter { + private int count = 0; @Override @@ -148,6 +151,7 @@ public class EndpointMvcIntegrationTests { public int getCount() { return this.count; } + } } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java index 3710cd2476..e0a10efa7f 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java @@ -471,6 +471,7 @@ public class EndpointWebMvcAutoConfigurationTests { public EmbeddedServletContainer getServletContainer() { return this.servletContainer; } + } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java index 04eeb3bef9..6b2d84e1db 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java @@ -36,8 +36,8 @@ import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration; import org.springframework.boot.context.embedded.FilterRegistrationBean; @@ -98,7 +98,7 @@ public class JerseyAutoConfiguration implements WebApplicationInitializer { @Bean @ConditionalOnMissingBean(name = "jerseyFilterRegistration") - @ConditionalOnExpression("'${spring.jersey.type:servlet}' == 'filter'") + @ConditionalOnProperty(prefix = "spring.jersey", name = "type", havingValue = "filter") public FilterRegistrationBean jerseyFilterRegistration() { FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setFilter(new ServletContainer()); @@ -121,7 +121,7 @@ public class JerseyAutoConfiguration implements WebApplicationInitializer { @Bean @ConditionalOnMissingBean(name = "jerseyServletRegistration") - @ConditionalOnExpression("'${spring.jersey.type:servlet}' == 'servlet'") + @ConditionalOnProperty(prefix = "spring.jersey", name = "type", havingValue = "servlet", matchIfMissing = true) public ServletRegistrationBean jerseyServletRegistration() { ServletRegistrationBean registration = new ServletRegistrationBean( new ServletContainer(), this.path); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyProperties.java index c063132973..3b985deb97 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyProperties.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.boot.autoconfigure.jersey; import java.util.HashMap; @@ -21,17 +22,15 @@ import java.util.Map; import org.springframework.boot.context.properties.ConfigurationProperties; /** - * @author Dave Syer + * {@link ConfigurationProperties} for Jersey. * + * @author Dave Syer + * @since 1.2.0 */ @ConfigurationProperties("spring.jersey") public class JerseyProperties { - public enum Type { - servlet, filter; - } - - private Type type = Type.servlet; + private Type type = Type.SERVLET; private Map init = new HashMap(); @@ -61,6 +60,10 @@ public class JerseyProperties { this.init = init; } + public enum Type { + SERVLET, FILTER; + } + public static class Filter { private int order; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index 3f4f3afe12..30c6de116d 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -46,8 +46,8 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.util.StringUtils; /** - * {@link ConfigurationProperties properties} for a web server (e.g. port and path - * settings). Will be used to customize an {@link EmbeddedServletContainerFactory} when an + * {@link ConfigurationProperties} for a web server (e.g. port and path settings). Will be + * used to customize an {@link EmbeddedServletContainerFactory} when an * {@link EmbeddedServletContainerCustomizerBeanPostProcessor} is active. * * @author Dave Syer diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/JettyWebSocketContainerCustomizer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/JettyWebSocketContainerCustomizer.java new file mode 100644 index 0000000000..64c0224115 --- /dev/null +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/JettyWebSocketContainerCustomizer.java @@ -0,0 +1,47 @@ +/* + * Copyright 2012-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.autoconfigure.websocket; + +import org.eclipse.jetty.webapp.AbstractConfiguration; +import org.eclipse.jetty.webapp.WebAppContext; +import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer; +import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; + +/** + * {@link WebSocketContainerCustomizer} for {@link JettyEmbeddedServletContainerFactory}. + * + * @author Dave Syer + * @author Phillip Webb + * @author Andy Wilkinson + * @since 1.2.0 + */ +public class JettyWebSocketContainerCustomizer extends + WebSocketContainerCustomizer { + + @Override + protected void doCustomize(JettyEmbeddedServletContainerFactory container) { + container.addConfigurations(new AbstractConfiguration() { + + @Override + public void configure(WebAppContext context) throws Exception { + WebSocketServerContainerInitializer.configureContext(context); + } + + }); + } + +} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/TomcatWebSocketContainerCustomizer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/TomcatWebSocketContainerCustomizer.java new file mode 100644 index 0000000000..c29762c3f8 --- /dev/null +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/TomcatWebSocketContainerCustomizer.java @@ -0,0 +1,90 @@ +/* + * Copyright 2012-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.autoconfigure.websocket; + +import java.lang.reflect.Constructor; + +import org.apache.catalina.Context; +import org.springframework.beans.BeanUtils; +import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; +import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; +import org.springframework.util.ClassUtils; +import org.springframework.util.ReflectionUtils; + +/** + * {@link WebSocketContainerCustomizer} for {@link TomcatEmbeddedServletContainerFactory}. + * + * @author Dave Syer + * @author Phillip Webb + * @author Andy Wilkinson + * @since 1.2.0 + */ +public class TomcatWebSocketContainerCustomizer extends + WebSocketContainerCustomizer { + + private static final String TOMCAT_7_LISTENER_TYPE = "org.apache.catalina.deploy.ApplicationListener"; + + private static final String TOMCAT_8_LISTENER_TYPE = "org.apache.tomcat.util.descriptor.web.ApplicationListener"; + + private static final String WS_LISTENER = "org.apache.tomcat.websocket.server.WsContextListener"; + + @Override + public void doCustomize(TomcatEmbeddedServletContainerFactory tomcatContainer) { + tomcatContainer.addContextCustomizers(new TomcatContextCustomizer() { + @Override + public void customize(Context context) { + addListener(context, findListenerType()); + } + }); + } + + private Class findListenerType() { + if (ClassUtils.isPresent(TOMCAT_7_LISTENER_TYPE, null)) { + return ClassUtils.resolveClassName(TOMCAT_7_LISTENER_TYPE, null); + } + if (ClassUtils.isPresent(TOMCAT_8_LISTENER_TYPE, null)) { + return ClassUtils.resolveClassName(TOMCAT_8_LISTENER_TYPE, null); + } + // With Tomcat 8.0.8 ApplicationListener is not required + return null; + } + + /** + * Instead of registering the WsSci directly as a ServletContainerInitializer, we use + * the ApplicationListener provided by Tomcat. Unfortunately the ApplicationListener + * class moved packages in Tomcat 8 and been deleted in 8.0.8 so we have to use + * reflection. + * @param context the current context + * @param listenerType the type of listener to add + */ + private void addListener(Context context, Class listenerType) { + Class contextClass = context.getClass(); + if (listenerType == null) { + ReflectionUtils.invokeMethod(ClassUtils.getMethod(contextClass, + "addApplicationListener", String.class), context, WS_LISTENER); + + } + else { + Constructor constructor = ClassUtils.getConstructorIfAvailable( + listenerType, String.class, boolean.class); + Object instance = BeanUtils.instantiateClass(constructor, WS_LISTENER, false); + ReflectionUtils.invokeMethod(ClassUtils.getMethod(contextClass, + "addApplicationListener", listenerType), context, instance); + } + } + +} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfiguration.java index a214b9d534..3225d3a0e7 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/WebSocketAutoConfiguration.java @@ -18,39 +18,26 @@ package org.springframework.boot.autoconfigure.websocket; import javax.servlet.Servlet; -import org.apache.catalina.Context; import org.apache.catalina.startup.Tomcat; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.eclipse.jetty.webapp.AbstractConfiguration; -import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer; -import org.springframework.beans.BeanUtils; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration; -import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; -import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory; -import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer; -import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; -import org.springframework.boot.context.web.NonEmbeddedServletContainerFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.util.ClassUtils; -import org.springframework.util.ReflectionUtils; import org.springframework.web.socket.WebSocketHandler; /** * Auto configuration for websocket server in embedded Tomcat or Jetty. Requires * spring-websocket and either Tomcat or Jetty with their WebSocket modules * to be on the classpath. - *

+ *

* If Tomcat's WebSocket support is detected on the classpath we add a listener that * installs the Tomcat Websocket initializer. In a non-embedded container it should * already be there. - *

+ *

* If Jetty's WebSocket support is detected on the classpath we add a configuration that * configures the context with WebSocket support. In a non-embedded container it should * already be there. @@ -68,65 +55,12 @@ public class WebSocketAutoConfiguration { @ConditionalOnClass(name = "org.apache.tomcat.websocket.server.WsSci", value = Tomcat.class) static class TomcatWebSocketConfiguration { - private static final String TOMCAT_7_LISTENER_TYPE = "org.apache.catalina.deploy.ApplicationListener"; - - private static final String TOMCAT_8_LISTENER_TYPE = "org.apache.tomcat.util.descriptor.web.ApplicationListener"; - - private static final String WS_LISTENER = "org.apache.tomcat.websocket.server.WsContextListener"; - @Bean @ConditionalOnMissingBean(name = "websocketContainerCustomizer") public EmbeddedServletContainerCustomizer websocketContainerCustomizer() { - return new WebSocketContainerCustomizer( - TomcatEmbeddedServletContainerFactory.class) { - - @Override - public void doCustomize( - TomcatEmbeddedServletContainerFactory tomcatContainer) { - tomcatContainer.addContextCustomizers(new TomcatContextCustomizer() { - @Override - public void customize(Context context) { - addListener(context, findListenerType()); - } - }); - } - - }; + return new TomcatWebSocketContainerCustomizer(); } - private static Class findListenerType() { - if (ClassUtils.isPresent(TOMCAT_7_LISTENER_TYPE, null)) { - return ClassUtils.resolveClassName(TOMCAT_7_LISTENER_TYPE, null); - } - if (ClassUtils.isPresent(TOMCAT_8_LISTENER_TYPE, null)) { - return ClassUtils.resolveClassName(TOMCAT_8_LISTENER_TYPE, null); - } - // With Tomcat 8.0.8 ApplicationListener is not required - return null; - } - - /** - * Instead of registering the WsSci directly as a ServletContainerInitializer, we - * use the ApplicationListener provided by Tomcat. Unfortunately the - * ApplicationListener class moved packages in Tomcat 8 and been deleted in 8.0.8 - * so we have to use reflection. - * @param context the current context - * @param listenerType the type of listener to add - */ - private static void addListener(Context context, Class listenerType) { - if (listenerType == null) { - ReflectionUtils.invokeMethod(ClassUtils.getMethod(context.getClass(), - "addApplicationListener", String.class), context, WS_LISTENER); - - } - else { - Object instance = BeanUtils.instantiateClass(ClassUtils - .getConstructorIfAvailable(listenerType, String.class, - boolean.class), WS_LISTENER, false); - ReflectionUtils.invokeMethod(ClassUtils.getMethod(context.getClass(), - "addApplicationListener", listenerType), context, instance); - } - } } @Configuration @@ -136,53 +70,9 @@ public class WebSocketAutoConfiguration { @Bean @ConditionalOnMissingBean(name = "websocketContainerCustomizer") public EmbeddedServletContainerCustomizer websocketContainerCustomizer() { - return new WebSocketContainerCustomizer( - JettyEmbeddedServletContainerFactory.class) { - - @Override - protected void doCustomize(JettyEmbeddedServletContainerFactory container) { - container.addConfigurations(new AbstractConfiguration() { - - @Override - public void configure(WebAppContext context) throws Exception { - WebSocketServerContainerInitializer.configureContext(context); - } - - }); - } - - }; + return new JettyWebSocketContainerCustomizer(); } } - abstract static class WebSocketContainerCustomizer - implements EmbeddedServletContainerCustomizer { - - private Log logger = LogFactory.getLog(getClass()); - - private final Class containerType; - - protected WebSocketContainerCustomizer(Class containerType) { - this.containerType = containerType; - } - - @SuppressWarnings("unchecked") - @Override - public void customize(ConfigurableEmbeddedServletContainer container) { - if (container instanceof NonEmbeddedServletContainerFactory) { - this.logger - .info("NonEmbeddedServletContainerFactory detected. Websockets " - + "support should be native so this normally is not a problem."); - return; - } - if (this.containerType.isAssignableFrom(container.getClass())) { - doCustomize((T) container); - } - } - - protected abstract void doCustomize(T container); - - } - } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/WebSocketContainerCustomizer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/WebSocketContainerCustomizer.java new file mode 100644 index 0000000000..5f0afc3cbf --- /dev/null +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/WebSocketContainerCustomizer.java @@ -0,0 +1,62 @@ +/* + * Copyright 2012-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.autoconfigure.websocket; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer; +import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer; +import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; +import org.springframework.boot.context.web.NonEmbeddedServletContainerFactory; +import org.springframework.core.ResolvableType; + +/** + * {@link EmbeddedServletContainerCustomizer} to configure websockets for a given + * {@link EmbeddedServletContainerFactory}. + * + * @author Dave Syer + * @author Phillip Webb + * @author Andy Wilkinson + * @since 1.2.0 + */ +public abstract class WebSocketContainerCustomizer + implements EmbeddedServletContainerCustomizer { + + private Log logger = LogFactory.getLog(getClass()); + + @SuppressWarnings("unchecked") + @Override + public void customize(ConfigurableEmbeddedServletContainer container) { + if (container instanceof NonEmbeddedServletContainerFactory) { + this.logger.info("NonEmbeddedServletContainerFactory " + + "detected. Websockets support should be native so this " + + "normally is not a problem."); + return; + } + if (getContainerType().isAssignableFrom(container.getClass())) { + doCustomize((T) container); + } + } + + protected Class getContainerType() { + return ResolvableType.forClass(WebSocketContainerCustomizer.class, getClass()) + .resolveGeneric(); + } + + protected abstract void doCustomize(T container); + +} diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrService.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrService.java index 4b22d9e4ee..b89d97aa75 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrService.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrService.java @@ -134,7 +134,8 @@ class InitializrService { */ private CloseableHttpResponse executeInitializrMetadataRetrieval(String url) { HttpGet request = new HttpGet(url); - request.setHeader(new BasicHeader(HttpHeaders.ACCEPT, "application/vnd.initializr.v2+json")); + request.setHeader(new BasicHeader(HttpHeaders.ACCEPT, + "application/vnd.initializr.v2+json")); return execute(request, url, "retrieve metadata"); } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java index 7b72139ac0..631c9083ad 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java @@ -138,7 +138,8 @@ class InitializrServiceMetadata { } JSONObject type = root.getJSONObject(TYPE_EL); JSONArray array = type.getJSONArray(VALUES_EL); - String defaultType = type.has(DEFAULT_ATTRIBUTE) ? type.getString(DEFAULT_ATTRIBUTE) : null; + String defaultType = type.has(DEFAULT_ATTRIBUTE) ? type + .getString(DEFAULT_ATTRIBUTE) : null; for (int i = 0; i < array.length(); i++) { JSONObject typeJson = array.getJSONObject(i); ProjectType projectType = parseType(typeJson, defaultType); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java index 7564f9e2e2..2b0d93e839 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.Map; import org.apache.http.client.utils.URIBuilder; - import org.springframework.util.StringUtils; /** @@ -209,7 +208,8 @@ class ProjectGenerationRequest { } if (!this.dependencies.isEmpty()) { - builder.setParameter("dependencies", StringUtils.collectionToCommaDelimitedString(this.dependencies)); + builder.setParameter("dependencies", + StringUtils.collectionToCommaDelimitedString(this.dependencies)); } if (this.javaVersion != null) { builder.setParameter("javaVersion", this.javaVersion); diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitializrServiceMetadataTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitializrServiceMetadataTests.java index 5ece7c2078..2ca4ac3215 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitializrServiceMetadataTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitializrServiceMetadataTests.java @@ -43,7 +43,8 @@ public class InitializrServiceMetadataTests { assertEquals("1.7", metadata.getDefaults().get("javaVersion")); assertEquals("org.test", metadata.getDefaults().get("groupId")); assertEquals("demo", metadata.getDefaults().get("name")); - assertEquals("Demo project for Spring Boot", metadata.getDefaults().get("description")); + assertEquals("Demo project for Spring Boot", + metadata.getDefaults().get("description")); assertEquals("jar", metadata.getDefaults().get("packaging")); assertEquals("java", metadata.getDefaults().get("language")); assertEquals("demo", metadata.getDefaults().get("artifactId")); diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java index 5347f17868..11057e44fe 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java @@ -108,7 +108,8 @@ public class ProjectGenerationRequestTests { this.request.setType("custom"); this.request.getDependencies().add("data-rest"); assertEquals(new URI(ProjectGenerationRequest.DEFAULT_SERVICE_URL - + "/foo?dependencies=data-rest&type=custom"), this.request.generateUrl(metadata)); + + "/foo?dependencies=data-rest&type=custom"), + this.request.generateUrl(metadata)); } @Test diff --git a/spring-boot-cli/src/test/resources/metadata/service-metadata-2.0.0.json b/spring-boot-cli/src/test/resources/metadata/service-metadata-2.0.0.json index 9cbec6fec7..00d7bed6f3 100644 --- a/spring-boot-cli/src/test/resources/metadata/service-metadata-2.0.0.json +++ b/spring-boot-cli/src/test/resources/metadata/service-metadata-2.0.0.json @@ -1,190 +1,190 @@ { - "_links": { - "maven-build": { - "href": "http://localhost:8080/pom.xml?{dependencies,type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", - "templated": true - }, - "maven-project": { - "href": "http://localhost:8080/starter.zip{?dependencies,type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", - "templated": true - }, - "gradle-build": { - "href": "http://localhost:8080/build.gradle{?dependencies,type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", - "templated": true - }, - "gradle-project": { - "href": "http://localhost:8080/starter.zip{?dependencies,type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", - "templated": true - } - }, - "dependencies": { - "type": "hierarchical-multi-select", - "values": [ - { - "name": "Core", - "values": [ - { - "name": "Security", - "id": "security", - "description": "Security description" - }, - { - "name": "AOP", - "id": "aop" - } - ] - }, - { - "name": "Data", - "values": [ - { - "name": "JDBC", - "id": "jdbc" - }, - { - "name": "JPA", - "id": "data-jpa" - }, - { - "name": "MongoDB", - "id": "data-mongodb" - } - ] - } - ] - }, - "type": { - "type": "action", - "default": "maven-project", - "values": [ - { - "id": "maven-build", - "name": "Maven POM", - "action": "/pom.xml", - "tags": { - "build": "maven", - "format": "build" - } - }, - { - "id": "maven-project", - "name": "Maven Project", - "action": "/starter.zip", - "tags": { - "build": "maven", - "format": "project" - } - }, - { - "id": "gradle-build", - "name": "Gradle Config", - "action": "/build.gradle", - "tags": { - "build": "gradle", - "format": "build" - } - }, - { - "id": "gradle-project", - "name": "Gradle Project", - "action": "/starter.zip", - "tags": { - "build": "gradle", - "format": "project" - } - } - ] - }, - "packaging": { - "type": "single-select", - "default": "jar", - "values": [ - { - "id": "jar", - "name": "Jar" - }, - { - "id": "war", - "name": "War" - } - ] - }, - "javaVersion": { - "type": "single-select", - "default": "1.7", - "values": [ - { - "id": "1.6", - "name": "1.6" - }, - { - "id": "1.7", - "name": "1.7" - }, - { - "id": "1.8", - "name": "1.8" - } - ] - }, - "language": { - "type": "single-select", - "default": "java", - "values": [ - { - "id": "groovy", - "name": "Groovy" - }, - { - "id": "java", - "name": "Java" - } - ] - }, - "bootVersion": { - "type": "single-select", - "default": "1.1.8.RELEASE", - "values": [ - { - "id": "1.2.0.BUILD-SNAPSHOT", - "name": "1.2.0 (SNAPSHOT)" - }, - { - "id": "1.1.8.RELEASE", - "name": "1.1.8" - }, - { - "id": "1.1.8.BUILD-SNAPSHOT", - "name": "1.1.8 (SNAPSHOT)" - }, - { - "id": "1.0.2.RELEASE", - "name": "1.0.2" - } - ] - }, - "groupId": { - "type": "text", - "default": "org.test" - }, - "artifactId": { - "type": "text", - "default": "demo" - }, - "version": { - "type": "text", - "default": "0.0.1-SNAPSHOT" - }, - "name": { - "type": "text", - "default": "demo" - }, - "description": { - "type": "text", - "default": "Demo project for Spring Boot" - }, - "packageName": { - "type": "text", - "default": "demo" - } -} \ No newline at end of file + "_links": { + "maven-build": { + "href": "http://localhost:8080/pom.xml?{dependencies,type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", + "templated": true + }, + "maven-project": { + "href": "http://localhost:8080/starter.zip{?dependencies,type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", + "templated": true + }, + "gradle-build": { + "href": "http://localhost:8080/build.gradle{?dependencies,type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", + "templated": true + }, + "gradle-project": { + "href": "http://localhost:8080/starter.zip{?dependencies,type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", + "templated": true + } + }, + "dependencies": { + "type": "hierarchical-multi-select", + "values": [ + { + "name": "Core", + "values": [ + { + "name": "Security", + "id": "security", + "description": "Security description" + }, + { + "name": "AOP", + "id": "aop" + } + ] + }, + { + "name": "Data", + "values": [ + { + "name": "JDBC", + "id": "jdbc" + }, + { + "name": "JPA", + "id": "data-jpa" + }, + { + "name": "MongoDB", + "id": "data-mongodb" + } + ] + } + ] + }, + "type": { + "type": "action", + "default": "maven-project", + "values": [ + { + "id": "maven-build", + "name": "Maven POM", + "action": "/pom.xml", + "tags": { + "build": "maven", + "format": "build" + } + }, + { + "id": "maven-project", + "name": "Maven Project", + "action": "/starter.zip", + "tags": { + "build": "maven", + "format": "project" + } + }, + { + "id": "gradle-build", + "name": "Gradle Config", + "action": "/build.gradle", + "tags": { + "build": "gradle", + "format": "build" + } + }, + { + "id": "gradle-project", + "name": "Gradle Project", + "action": "/starter.zip", + "tags": { + "build": "gradle", + "format": "project" + } + } + ] + }, + "packaging": { + "type": "single-select", + "default": "jar", + "values": [ + { + "id": "jar", + "name": "Jar" + }, + { + "id": "war", + "name": "War" + } + ] + }, + "javaVersion": { + "type": "single-select", + "default": "1.7", + "values": [ + { + "id": "1.6", + "name": "1.6" + }, + { + "id": "1.7", + "name": "1.7" + }, + { + "id": "1.8", + "name": "1.8" + } + ] + }, + "language": { + "type": "single-select", + "default": "java", + "values": [ + { + "id": "groovy", + "name": "Groovy" + }, + { + "id": "java", + "name": "Java" + } + ] + }, + "bootVersion": { + "type": "single-select", + "default": "1.1.8.RELEASE", + "values": [ + { + "id": "1.2.0.BUILD-SNAPSHOT", + "name": "1.2.0 (SNAPSHOT)" + }, + { + "id": "1.1.8.RELEASE", + "name": "1.1.8" + }, + { + "id": "1.1.8.BUILD-SNAPSHOT", + "name": "1.1.8 (SNAPSHOT)" + }, + { + "id": "1.0.2.RELEASE", + "name": "1.0.2" + } + ] + }, + "groupId": { + "type": "text", + "default": "org.test" + }, + "artifactId": { + "type": "text", + "default": "demo" + }, + "version": { + "type": "text", + "default": "0.0.1-SNAPSHOT" + }, + "name": { + "type": "text", + "default": "demo" + }, + "description": { + "type": "text", + "default": "Demo project for Spring Boot" + }, + "packageName": { + "type": "text", + "default": "demo" + } +} diff --git a/spring-boot-cli/src/test/resources/metadata/service-metadata-types-conflict.json b/spring-boot-cli/src/test/resources/metadata/service-metadata-types-conflict.json index 803450cb30..db9c238322 100644 --- a/spring-boot-cli/src/test/resources/metadata/service-metadata-types-conflict.json +++ b/spring-boot-cli/src/test/resources/metadata/service-metadata-types-conflict.json @@ -1,207 +1,207 @@ { - "_links": { - "maven-build": { - "href": "http://localhost:8080/pom.xml?style={dependencies}{&type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", - "templated": true - }, - "maven-project": { - "href": "http://localhost:8080/starter.zip?style={dependencies}{&type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", - "templated": true - }, - "gradle-build": { - "href": "http://localhost:8080/build.gradle?style={dependencies}{&type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", - "templated": true - }, - "gradle-project": { - "href": "http://localhost:8080/starter.zip?style={dependencies}{&type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", - "templated": true - } - }, - "dependencies": { - "type": "hierarchical-multi-select", - "values": [ - { - "name": "Core", - "values": [ - { - "name": "Security", - "id": "security", - "description": "Security description" - }, - { - "name": "AOP", - "id": "aop" - } - ] - }, - { - "name": "Data", - "values": [ - { - "name": "JDBC", - "id": "jdbc" - }, - { - "name": "JPA", - "id": "data-jpa" - }, - { - "name": "MongoDB", - "id": "data-mongodb" - } - ] - } - ] - }, - "type": { - "type": "action", - "values": [ - { - "id": "maven-build", - "name": "Maven POM", - "action": "/pom.xml", - "tags": { - "build": "maven", - "format": "build" - } - }, - { - "id": "maven-project", - "name": "Maven Project", - "action": "/starter.zip", - "tags": { - "build": "maven", - "format": "project" - } - }, - { - "id": "maven-project-2", - "name": "Another Maven Project", - "action": "/starter.zip", - "tags": { - "build": "maven", - "format": "project" - } - }, - { - "id": "gradle-build", - "name": "Gradle Config", - "action": "/build.gradle", - "tags": { - "build": "gradle", - "format": "build" - } - }, - { - "id": "gradle-project", - "name": "Gradle Project", - "action": "/starter.zip", - "tags": { - "build": "gradle", - "format": "project" - } - }, - { - "id": "gradle-project-2", - "name": "Another Gradle Project", - "action": "/starter.zip", - "tags": { - "build": "gradle", - "format": "project" - } - } - ] - }, - "packaging": { - "type": "single-select", - "default": "jar", - "values": [ - { - "id": "jar", - "name": "Jar" - }, - { - "id": "war", - "name": "War" - } - ] - }, - "javaVersion": { - "type": "single-select", - "default": "1.7", - "values": [ - { - "id": "1.6", - "name": "1.6" - }, - { - "id": "1.7", - "name": "1.7" - }, - { - "id": "1.8", - "name": "1.8" - } - ] - }, - "language": { - "type": "single-select", - "default": "java", - "values": [ - { - "id": "groovy", - "name": "Groovy" - }, - { - "id": "java", - "name": "Java" - } - ] - }, - "bootVersion": { - "type": "single-select", - "default": "1.1.8.RELEASE", - "values": [ - { - "id": "1.2.0.BUILD-SNAPSHOT", - "name": "1.2.0 (SNAPSHOT)" - }, - { - "id": "1.1.8.RELEASE", - "name": "1.1.8" - }, - { - "id": "1.1.8.BUILD-SNAPSHOT", - "name": "1.1.8 (SNAPSHOT)" - }, - { - "id": "1.0.2.RELEASE", - "name": "1.0.2" - } - ] - }, - "groupId": { - "type": "text", - "default": "org.test" - }, - "artifactId": { - "type": "text", - "default": "demo" - }, - "version": { - "type": "text", - "default": "0.0.1-SNAPSHOT" - }, - "name": { - "type": "text", - "default": "demo" - }, - "description": { - "type": "text", - "default": "Demo project for Spring Boot" - }, - "packageName": { - "type": "text", - "default": "demo" - } -} \ No newline at end of file + "_links": { + "maven-build": { + "href": "http://localhost:8080/pom.xml?style={dependencies}{&type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", + "templated": true + }, + "maven-project": { + "href": "http://localhost:8080/starter.zip?style={dependencies}{&type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", + "templated": true + }, + "gradle-build": { + "href": "http://localhost:8080/build.gradle?style={dependencies}{&type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", + "templated": true + }, + "gradle-project": { + "href": "http://localhost:8080/starter.zip?style={dependencies}{&type,packaging,javaVersion,language,bootVersion,groupId,artifactId,version,name,description,packageName}", + "templated": true + } + }, + "dependencies": { + "type": "hierarchical-multi-select", + "values": [ + { + "name": "Core", + "values": [ + { + "name": "Security", + "id": "security", + "description": "Security description" + }, + { + "name": "AOP", + "id": "aop" + } + ] + }, + { + "name": "Data", + "values": [ + { + "name": "JDBC", + "id": "jdbc" + }, + { + "name": "JPA", + "id": "data-jpa" + }, + { + "name": "MongoDB", + "id": "data-mongodb" + } + ] + } + ] + }, + "type": { + "type": "action", + "values": [ + { + "id": "maven-build", + "name": "Maven POM", + "action": "/pom.xml", + "tags": { + "build": "maven", + "format": "build" + } + }, + { + "id": "maven-project", + "name": "Maven Project", + "action": "/starter.zip", + "tags": { + "build": "maven", + "format": "project" + } + }, + { + "id": "maven-project-2", + "name": "Another Maven Project", + "action": "/starter.zip", + "tags": { + "build": "maven", + "format": "project" + } + }, + { + "id": "gradle-build", + "name": "Gradle Config", + "action": "/build.gradle", + "tags": { + "build": "gradle", + "format": "build" + } + }, + { + "id": "gradle-project", + "name": "Gradle Project", + "action": "/starter.zip", + "tags": { + "build": "gradle", + "format": "project" + } + }, + { + "id": "gradle-project-2", + "name": "Another Gradle Project", + "action": "/starter.zip", + "tags": { + "build": "gradle", + "format": "project" + } + } + ] + }, + "packaging": { + "type": "single-select", + "default": "jar", + "values": [ + { + "id": "jar", + "name": "Jar" + }, + { + "id": "war", + "name": "War" + } + ] + }, + "javaVersion": { + "type": "single-select", + "default": "1.7", + "values": [ + { + "id": "1.6", + "name": "1.6" + }, + { + "id": "1.7", + "name": "1.7" + }, + { + "id": "1.8", + "name": "1.8" + } + ] + }, + "language": { + "type": "single-select", + "default": "java", + "values": [ + { + "id": "groovy", + "name": "Groovy" + }, + { + "id": "java", + "name": "Java" + } + ] + }, + "bootVersion": { + "type": "single-select", + "default": "1.1.8.RELEASE", + "values": [ + { + "id": "1.2.0.BUILD-SNAPSHOT", + "name": "1.2.0 (SNAPSHOT)" + }, + { + "id": "1.1.8.RELEASE", + "name": "1.1.8" + }, + { + "id": "1.1.8.BUILD-SNAPSHOT", + "name": "1.1.8 (SNAPSHOT)" + }, + { + "id": "1.0.2.RELEASE", + "name": "1.0.2" + } + ] + }, + "groupId": { + "type": "text", + "default": "org.test" + }, + "artifactId": { + "type": "text", + "default": "demo" + }, + "version": { + "type": "text", + "default": "0.0.1-SNAPSHOT" + }, + "name": { + "type": "text", + "default": "demo" + }, + "description": { + "type": "text", + "default": "Demo project for Spring Boot" + }, + "packageName": { + "type": "text", + "default": "demo" + } +} diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 41eab46a63..2905a46b28 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -157,6 +157,11 @@ content into your application; rather pick only the properties that you need. spring.velocity.suffix=.vm spring.velocity.view-names= # whitelist of view names that can be resolved + # JERSEY ({sc-spring-boot-autoconfigure}}/jersey/JerseyProperties.{sc-ext}[JerseyProperties]) + spring.jersey.type=servlet # servlet or filter + spring.jersey.init= # init params + spring.jersey.filter.order= + # INTERNATIONALIZATION ({sc-spring-boot-autoconfigure}/MessageSourceAutoConfiguration.{sc-ext}[MessageSourceAutoConfiguration]) spring.messages.basename=messages spring.messages.cacheSeconds=-1 diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 5f4fa432cf..34622430f9 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -1084,14 +1084,12 @@ servlet will be registered and mapped to '`+/*+`' by default. You can change the by adding `@ApplicationPath` to your `ResourceConfig`. By default Jersey will be set up as a Servlet in a `@Bean` of type -`ServletRegistrationBean` named "jerseyServletRegistration". You can -disable or override that bean by creating one of your own with the -same name. You can also use a Filter instead of a Servlet by setting -`spring.jersey.type=filter` (in which case the `@Bean` to replace or -override is "jerseyFilterRegistration"). The servlet has an `@Order` -which you can set with `spring.jersey.filter.order`. Both the Servlet -and the Filter registrations can be given init parameters using -`spring.jersey.init.*` to specify a map of properties. +`ServletRegistrationBean` named "jerseyServletRegistration". You can disable or override +that bean by creating one of your own with the same name. You can also use a Filter +instead of a Servlet by setting `spring.jersey.type=filter` (in which case the `@Bean` to +replace or override is "jerseyFilterRegistration"). The servlet has an `@Order`which you +can set with `spring.jersey.filter.order`. Both the Servlet and the Filter registrations +can be given init parameters using `spring.jersey.init.*` to specify a map of properties. There is a {github-code}/spring-boot-samples/spring-boot-sample-jersey[Jersey sample] so you can see how to set things up. There is also a {github-code}/spring-boot-samples/spring-boot-sample-jersey1[Jersey 1.x sample].