Remove classes and methods deprecated since 1.2 and earlier

Closes gh-2697
This commit is contained in:
Andy Wilkinson
2015-05-14 15:23:21 +01:00
parent 9243faa354
commit e3a53cb087
27 changed files with 27 additions and 661 deletions

View File

@@ -37,19 +37,16 @@ import org.springframework.context.annotation.Conditional;
public @interface ConditionalOnMissingClass {
/**
* The classes that must not be present. Since this annotation parsed by loading class
* bytecode it is safe to specify classes here that may ultimately not be on the
* classpath.
* @return the classes that must be present
* @deprecated Since 1.1.0 due to the fact that the reflection errors can occur when
* beans containing the annotation remain in the context. Use {@link #name()} instead.
* The names of the classes that must not be present.
* @return the names of the classes that must not be present
*/
@Deprecated
public Class<?>[] value() default {};
public String[] value() default {};
/**
* The classes names that must not be present.
* @return the class names that must be present.
* An alias for {@link #value} specifying the names of the classes that must not be
* present.
* @return the class names that must not be present.
* @deprecated since 1.3.0 in favor of {@link #value}.
*/
public String[] name() default {};

View File

@@ -1,67 +0,0 @@
/*
* 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.groovy.template;
import groovy.text.markup.MarkupTemplateEngine;
import groovy.text.markup.TemplateConfiguration;
import groovy.text.markup.TemplateResolver;
import java.io.IOException;
import java.net.URL;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.servlet.view.groovy.GroovyMarkupConfigurer;
import org.springframework.web.servlet.view.groovy.GroovyMarkupViewResolver;
/**
* A custom {@link groovy.text.markup.TemplateResolver template resolver} which resolves
* templates using the locale found in the thread locale. This resolver ignores the
* template engine configuration locale.
*
* @author Cédric Champeau
* @since 1.1.0
* @deprecated since 1.2 in favor of Spring 4.1's {@link GroovyMarkupViewResolver} and
* {@link GroovyMarkupConfigurer}.
*/
@Deprecated
public class GroovyTemplateResolver implements TemplateResolver {
private ClassLoader templateClassLoader;
@Override
public void configure(final ClassLoader templateClassLoader,
final TemplateConfiguration configuration) {
this.templateClassLoader = templateClassLoader;
}
@Override
public URL resolveTemplate(final String templatePath) throws IOException {
MarkupTemplateEngine.TemplateResource templateResource = MarkupTemplateEngine.TemplateResource
.parse(templatePath);
URL resource = this.templateClassLoader.getResource(templateResource.withLocale(
LocaleContextHolder.getLocale().toString().replace("-", "_")).toString());
if (resource == null) {
// no resource found with the default locale, try without any locale
resource = this.templateClassLoader.getResource(templateResource.withLocale(
null).toString());
}
if (resource == null) {
throw new IOException("Unable to load template:" + templatePath);
}
return resource;
}
}

View File

@@ -35,7 +35,6 @@ import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.web.HttpMapperProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -50,7 +49,6 @@ import org.springframework.util.ReflectionUtils;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.joda.cfg.JacksonJodaDateFormat;
import com.fasterxml.jackson.datatype.joda.ser.DateTimeSerializer;
@@ -72,7 +70,6 @@ import com.fasterxml.jackson.datatype.joda.ser.DateTimeSerializer;
*/
@Configuration
@ConditionalOnClass(ObjectMapper.class)
@SuppressWarnings("deprecation")
public class JacksonAutoConfiguration {
@Autowired
@@ -151,7 +148,7 @@ public class JacksonAutoConfiguration {
@Configuration
@ConditionalOnClass({ ObjectMapper.class, Jackson2ObjectMapperBuilder.class })
@EnableConfigurationProperties({ HttpMapperProperties.class, JacksonProperties.class })
@EnableConfigurationProperties(JacksonProperties.class)
static class JacksonObjectMapperBuilderConfiguration implements
ApplicationContextAware {
@@ -160,22 +157,11 @@ public class JacksonAutoConfiguration {
@Autowired
private JacksonProperties jacksonProperties;
@Autowired
private HttpMapperProperties httpMapperProperties;
@Bean
@ConditionalOnMissingBean(Jackson2ObjectMapperBuilder.class)
public Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.applicationContext(this.applicationContext);
Boolean isJsonSortKeys = this.httpMapperProperties.isJsonSortKeys();
if (isJsonSortKeys != null && isJsonSortKeys) {
builder.featuresToEnable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);
}
Boolean isJsonPrettyPrint = this.httpMapperProperties.isJsonPrettyPrint();
if (isJsonPrettyPrint != null && isJsonPrettyPrint) {
builder.featuresToEnable(SerializationFeature.INDENT_OUTPUT);
}
if (this.jacksonProperties.getSerializationInclusion() != null) {
builder.serializationInclusion(this.jacksonProperties
.getSerializationInclusion());

View File

@@ -21,8 +21,6 @@ import java.util.Map;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDatabaseConnection;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.orm.jpa.vendor.Database;
@@ -38,8 +36,6 @@ import org.springframework.util.StringUtils;
@ConfigurationProperties(prefix = "spring.jpa")
public class JpaProperties {
private static final Log logger = LogFactory.getLog(JpaProperties.class);
/**
* Additional native properties to set on the JPA provider.
*/
@@ -151,13 +147,6 @@ public class JpaProperties {
this.namingStrategy = namingStrategy;
}
@Deprecated
public void setNamingstrategy(Class<?> namingStrategy) {
logger.warn("The property spring.jpa.namingstrategy has been renamed, "
+ "please update your configuration to use namingStrategy or naming-strategy or naming_strategy");
this.setNamingStrategy(namingStrategy);
}
public String getDdlAuto() {
return this.ddlAuto;
}

View File

@@ -123,7 +123,7 @@ public class RedisAutoConfiguration {
* Redis connection configuration.
*/
@Configuration
@ConditionalOnMissingClass(name = "org.apache.commons.pool2.impl.GenericObjectPool")
@ConditionalOnMissingClass("org.apache.commons.pool2.impl.GenericObjectPool")
protected static class RedisConnectionConfiguration extends
AbstractRedisConfiguration {

View File

@@ -202,7 +202,7 @@ public class SpringBootWebSecurityConfiguration {
// Pull in a plain @EnableWebSecurity if Spring MVC is not available
@ConditionalOnMissingBean(WebMvcSecurityConfigurationConditions.class)
@ConditionalOnMissingClass(name = "org.springframework.web.servlet.support.RequestDataValueProcessor")
@ConditionalOnMissingClass("org.springframework.web.servlet.support.RequestDataValueProcessor")
@Configuration
@EnableWebSecurity
protected static class DefaultWebSecurityConfiguration {

View File

@@ -125,7 +125,7 @@ public class SocialWebAutoConfiguration {
@Configuration
@EnableSocial
@ConditionalOnWebApplication
@ConditionalOnMissingClass(name = "org.springframework.security.core.context.SecurityContextHolder")
@ConditionalOnMissingClass("org.springframework.security.core.context.SecurityContextHolder")
protected static class AnonymousUserIdSourceConfig extends SocialConfigurerAdapter {
@Override

View File

@@ -101,24 +101,6 @@ public abstract class AbstractViewResolverProperties {
this.contentType = contentType;
}
/**
* @deprecated since 1.2.0 in favor of {@link #getCharset()}
* @return the charset
*/
@Deprecated
public String getCharSet() {
return getCharset();
}
/**
* @deprecated since 1.2.0 in favor of {@link #setCharset(String)}
* @param charSet the charset
*/
@Deprecated
public void setCharSet(String charSet) {
setCharset(charSet);
}
public String getCharset() {
return this.charset;
}

View File

@@ -1,78 +0,0 @@
/*
* 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.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.autoconfigure.jackson.JacksonProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.http.converter.HttpMessageConverter;
import com.fasterxml.jackson.databind.SerializationFeature;
/**
* Configuration properties to configure {@link HttpMessageConverter}s.
*
* @author Dave Syer
* @author Piotr Maj
* @author Sebastien Deleuze
* @deprecated in 1.2.0 favor of {@link JacksonProperties}
*/
@ConfigurationProperties(prefix = "http.mappers", ignoreUnknownFields = false)
@Deprecated
public class HttpMapperProperties {
private final Log logger = LogFactory.getLog(HttpMapperProperties.class);
/**
* Enable json pretty print.
*/
private Boolean jsonPrettyPrint;
/**
* Enable key sorting.
*/
private Boolean jsonSortKeys;
public void setJsonPrettyPrint(Boolean jsonPrettyPrint) {
this.logger.warn(getDeprecationMessage("http.mappers.json-pretty-print",
SerializationFeature.INDENT_OUTPUT));
this.jsonPrettyPrint = jsonPrettyPrint;
}
public Boolean isJsonPrettyPrint() {
return this.jsonPrettyPrint;
}
public void setJsonSortKeys(Boolean jsonSortKeys) {
this.logger.warn(getDeprecationMessage("http.mappers.json-sort-keys",
SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS));
this.jsonSortKeys = jsonSortKeys;
}
public Boolean isJsonSortKeys() {
return this.jsonSortKeys;
}
private String getDeprecationMessage(String property,
SerializationFeature alternativeFeature) {
return String.format("%s is deprecated. If you are using Jackson,"
+ " spring.jackson.serialization.%s=true should be used instead.",
property, alternativeFeature.name());
}
}

View File

@@ -16,12 +16,10 @@
package org.springframework.boot.autoconfigure.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
@@ -43,26 +41,14 @@ class JacksonHttpMessageConvertersConfiguration {
@Configuration
@ConditionalOnClass(ObjectMapper.class)
@ConditionalOnBean(ObjectMapper.class)
@EnableConfigurationProperties(HttpMapperProperties.class)
@ConditionalOnProperty(name = HttpMessageConvertersAutoConfiguration.PREFERRED_MAPPER_PROPERTY, havingValue = "jackson", matchIfMissing = true)
@SuppressWarnings("deprecation")
protected static class MappingJackson2HttpMessageConverterConfiguration {
// This can be removed when the deprecated class is removed (the ObjectMapper will
// already have all the correct properties).
@Autowired
private HttpMapperProperties properties = new HttpMapperProperties();
@Bean
@ConditionalOnMissingBean
public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter(
ObjectMapper objectMapper) {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(
objectMapper);
if (this.properties.isJsonPrettyPrint() != null) {
converter.setPrettyPrint(this.properties.isJsonPrettyPrint());
}
return converter;
return new MappingJackson2HttpMessageConverter(objectMapper);
}
}
@@ -70,23 +56,14 @@ class JacksonHttpMessageConvertersConfiguration {
@Configuration
@ConditionalOnClass(XmlMapper.class)
@ConditionalOnBean(Jackson2ObjectMapperBuilder.class)
@EnableConfigurationProperties(HttpMapperProperties.class)
@SuppressWarnings("deprecation")
protected static class MappingJackson2XmlHttpMessageConverterConfiguration {
@Autowired
private HttpMapperProperties properties = new HttpMapperProperties();
@Bean
@ConditionalOnMissingBean
public MappingJackson2XmlHttpMessageConverter mappingJackson2XmlHttpMessageConverter(
Jackson2ObjectMapperBuilder builder) {
MappingJackson2XmlHttpMessageConverter converter = new MappingJackson2XmlHttpMessageConverter();
converter.setObjectMapper(builder.createXmlMapper(true).build());
if (this.properties.isJsonPrettyPrint() != null) {
converter.setPrettyPrint(this.properties.isJsonPrettyPrint());
}
return converter;
return new MappingJackson2XmlHttpMessageConverter(builder.createXmlMapper(
true).build());
}
}

View File

@@ -51,7 +51,7 @@ public class ConditionalOnMissingClassTests {
}
@Configuration
@ConditionalOnMissingClass(ConditionalOnMissingClassTests.class)
@ConditionalOnMissingClass("org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClassTests")
protected static class BasicConfiguration {
@Bean
public String bar() {

View File

@@ -355,28 +355,6 @@ public class JacksonAutoConfigurationTests {
DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
}
@Test
public void httpMappersJsonPrettyPrintIsApplied() {
this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"http.mappers.json-pretty-print:true");
this.context.refresh();
ObjectMapper objectMapper = this.context.getBean(ObjectMapper.class);
assertTrue(objectMapper.getSerializationConfig().isEnabled(
SerializationFeature.INDENT_OUTPUT));
}
@Test
public void httpMappersJsonSortKeysIsApplied() {
this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"http.mappers.json-sort-keys:true");
this.context.refresh();
ObjectMapper objectMapper = this.context.getBean(ObjectMapper.class);
assertTrue(objectMapper.getSerializationConfig().isEnabled(
SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS));
}
@Test
public void moduleBeansAndWellKnownModulesAreRegisteredWithTheObjectMapperBuilder() {
this.context.register(ModuleConfig.class, JacksonAutoConfiguration.class);

View File

@@ -97,21 +97,6 @@ public class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigura
assertThat(actual, equalTo("org.hibernate.cfg.EJB3NamingStrategy"));
}
@Test
public void testNamingStrategyThatWorkedInOneDotOhContinuesToWork() {
EnvironmentTestUtils.addEnvironment(this.context,
"spring.jpa.hibernate.namingstrategy:"
+ "org.hibernate.cfg.EJB3NamingStrategy");
setupTestConfiguration();
this.context.refresh();
LocalContainerEntityManagerFactoryBean bean = this.context
.getBean(LocalContainerEntityManagerFactoryBean.class);
String actual = (String) bean.getJpaPropertyMap().get(
"hibernate.ejb.naming_strategy");
assertThat(actual, equalTo("org.hibernate.cfg.EJB3NamingStrategy"));
}
@Test
public void testCustomNamingStrategyViaJpaProperties() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context,

View File

@@ -21,7 +21,6 @@ import java.util.List;
import org.junit.After;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.test.EnvironmentTestUtils;
@@ -38,7 +37,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/**
@@ -189,29 +187,6 @@ public class HttpMessageConvertersAutoConfigurationTests {
assertConverterBeanRegisteredWithHttpMessageConverters(StringHttpMessageConverter.class);
}
@Test
public void httpMapperPropertiesAreNotAppliedWhenNotConfigured() throws Exception {
this.context.register(JacksonObjectMapperConfig.class,
HttpMessageConvertersAutoConfiguration.class);
this.context.refresh();
MappingJackson2HttpMessageConverter converter = this.context
.getBean(MappingJackson2HttpMessageConverter.class);
assertNull(new DirectFieldAccessor(converter).getPropertyValue("prettyPrint"));
}
@Test
public void httpMapperPropertiesAreAppliedWhenConfigured() throws Exception {
this.context.register(JacksonObjectMapperConfig.class,
HttpMessageConvertersAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"http.mappers.jsonPrettyPrint:true");
this.context.refresh();
MappingJackson2HttpMessageConverter converter = this.context
.getBean(MappingJackson2HttpMessageConverter.class);
assertTrue((Boolean) new DirectFieldAccessor(converter)
.getPropertyValue("prettyPrint"));
}
private void assertConverterBeanExists(Class<?> type, String beanName) {
assertEquals(1, this.context.getBeansOfType(type).size());
List<String> beanNames = Arrays.asList(this.context.getBeanDefinitionNames());