From 7b9cd20e98e3bdcfdafb4af08a78b19efe7419d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Fri, 8 Jan 2016 21:01:34 -0500 Subject: [PATCH] Remove deprecated code See gh-4905 --- .../endpoint/jmx/DataEndpointMBean.java | 14 +- .../endpoint/jmx/ShutdownEndpointMBean.java | 14 +- .../writer/DropwizardMetricWriter.java | 139 ------------- .../orm/jpa/EntityManagerFactoryBuilder.java | 182 ------------------ .../jpa/EntityManagerFactoryBuilderTests.java | 70 ------- .../boot/SpringApplication.java | 12 -- .../builder/SpringApplicationBuilder.java | 14 +- .../boot/logging/LoggingSystem.java | 16 +- .../logback/LevelRemappingAppender.java | 4 +- .../LoggingApplicationListenerTests.java | 7 +- 10 files changed, 7 insertions(+), 465 deletions(-) delete mode 100644 spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DropwizardMetricWriter.java delete mode 100644 spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilder.java delete mode 100644 spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilderTests.java diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/DataEndpointMBean.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/DataEndpointMBean.java index 0796c7fc2bb..bdbf774f306 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/DataEndpointMBean.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/DataEndpointMBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2016 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. @@ -32,18 +32,6 @@ import org.springframework.jmx.export.annotation.ManagedResource; @ManagedResource public class DataEndpointMBean extends EndpointMBean { - /** - * Create a new {@link DataEndpointMBean} instance. - * @param beanName the bean name - * @param endpoint the endpoint to wrap - * @deprecated since 1.3 in favor of - * {@link #DataEndpointMBean(String, Endpoint, ObjectMapper)} - */ - @Deprecated - public DataEndpointMBean(String beanName, Endpoint endpoint) { - super(beanName, endpoint); - } - /** * Create a new {@link DataEndpointMBean} instance. * @param beanName the bean name diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/ShutdownEndpointMBean.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/ShutdownEndpointMBean.java index 1f5ffb1f071..11a3cbab9cf 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/ShutdownEndpointMBean.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/ShutdownEndpointMBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2016 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. @@ -32,18 +32,6 @@ import org.springframework.jmx.export.annotation.ManagedResource; @ManagedResource public class ShutdownEndpointMBean extends EndpointMBean { - /** - * Create a new {@link ShutdownEndpointMBean} instance. - * @param beanName the bean name - * @param endpoint the endpoint to wrap - * @deprecated since 1.3 in favor of - * {@link #ShutdownEndpointMBean(String, Endpoint, ObjectMapper)} - */ - @Deprecated - public ShutdownEndpointMBean(String beanName, Endpoint endpoint) { - super(beanName, endpoint); - } - /** * Create a new {@link ShutdownEndpointMBean} instance. * @param beanName the bean name diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DropwizardMetricWriter.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DropwizardMetricWriter.java deleted file mode 100644 index 6e4793b0dfb..00000000000 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DropwizardMetricWriter.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2012-2015 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.actuate.metrics.writer; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.TimeUnit; - -import com.codahale.metrics.Counter; -import com.codahale.metrics.Gauge; -import com.codahale.metrics.Histogram; -import com.codahale.metrics.Meter; -import com.codahale.metrics.MetricRegistry; -import com.codahale.metrics.Timer; - -import org.springframework.boot.actuate.metrics.Metric; -import org.springframework.boot.actuate.metrics.dropwizard.DropwizardMetricServices; - -/** - * A {@link MetricWriter} that send data to a Dropwizard {@link MetricRegistry} based on a - * naming convention. - * - * - * - * @author Dave Syer - * @deprecated Since 1.3 in favor of {@link DropwizardMetricServices} - */ -@Deprecated -public class DropwizardMetricWriter implements MetricWriter { - - private final MetricRegistry registry; - - private final ConcurrentMap gaugeLocks = new ConcurrentHashMap(); - - /** - * Create a new {@link DropwizardMetricWriter} instance. - * @param registry the underlying metric registry - */ - public DropwizardMetricWriter(MetricRegistry registry) { - this.registry = registry; - } - - @Override - public void increment(Delta delta) { - String name = delta.getName(); - long value = delta.getValue().longValue(); - if (name.startsWith("meter")) { - Meter meter = this.registry.meter(name); - meter.mark(value); - } - else { - Counter counter = this.registry.counter(name); - counter.inc(value); - } - } - - @Override - public void set(Metric value) { - String name = value.getName(); - if (name.startsWith("histogram")) { - long longValue = value.getValue().longValue(); - Histogram metric = this.registry.histogram(name); - metric.update(longValue); - } - else if (name.startsWith("timer")) { - long longValue = value.getValue().longValue(); - Timer metric = this.registry.timer(name); - metric.update(longValue, TimeUnit.MILLISECONDS); - } - else { - final double gauge = value.getValue().doubleValue(); - // Ensure we synchronize to avoid another thread pre-empting this thread after - // remove causing an error in Dropwizard Metrics - // NOTE: Dropwizard Metrics provides no way to do this atomically - synchronized (getGaugeLock(name)) { - this.registry.remove(name); - this.registry.register(name, new SimpleGauge(gauge)); - } - } - } - - private Object getGaugeLock(String name) { - Object lock = this.gaugeLocks.get(name); - if (lock == null) { - Object newLock = new Object(); - lock = this.gaugeLocks.putIfAbsent(name, newLock); - lock = (lock == null ? newLock : lock); - } - return lock; - } - - @Override - public void reset(String metricName) { - this.registry.remove(metricName); - } - - /** - * Simple {@link Gauge} implementation to {@literal double} value. - */ - private final static class SimpleGauge implements Gauge { - - private final double value; - - private SimpleGauge(double value) { - this.value = value; - } - - @Override - public Double getValue() { - return this.value; - } - - } - -} diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilder.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilder.java deleted file mode 100644 index e8d04a9ff6d..00000000000 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilder.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2012-2015 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.orm.jpa; - -import java.util.Map; - -import javax.sql.DataSource; - -import org.springframework.orm.jpa.JpaVendorAdapter; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.persistenceunit.PersistenceUnitManager; - -/** - * Convenient builder for JPA EntityManagerFactory instances. Collects common - * configuration when constructed and then allows you to create one or more - * {@link LocalContainerEntityManagerFactoryBean} through a fluent builder pattern. The - * most common options are covered in the builder, but you can always manipulate the - * product of the builder if you need more control, before returning it from a - * {@code @Bean} definition. - * - * @author Dave Syer - * @since 1.1.0 - * @deprecated since 1.3.0 in favor of - * {@link org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder} - */ -@Deprecated -public class EntityManagerFactoryBuilder { - - private final Delegate delegate; - - /** - * Create a new instance passing in the common pieces that will be shared if multiple - * EntityManagerFactory instances are created. - * @param jpaVendorAdapter a vendor adapter - * @param properties common configuration options, including generic map for JPA - * vendor properties - * @param persistenceUnitManager optional source of persistence unit information (can - * be null) - */ - public EntityManagerFactoryBuilder(JpaVendorAdapter jpaVendorAdapter, - JpaProperties properties, PersistenceUnitManager persistenceUnitManager) { - this.delegate = new Delegate(jpaVendorAdapter, properties.getProperties(), - persistenceUnitManager); - } - - public Builder dataSource(DataSource dataSource) { - return new Builder(this.delegate.dataSource(dataSource)); - } - - /** - * An optional callback for new entity manager factory beans. - * @param callback the entity manager factory bean callback - */ - public void setCallback(final EntityManagerFactoryBeanCallback callback) { - this.delegate.setCallback( - new org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder.EntityManagerFactoryBeanCallback() { - - @Override - public void execute(LocalContainerEntityManagerFactoryBean factory) { - callback.execute(factory); - } - - }); - } - - /** - * A fluent builder for a LocalContainerEntityManagerFactoryBean. - * @deprecated since 1.3.0 in favor of - * {@link org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder} - */ - @Deprecated - public final class Builder { - - private final org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder.Builder delegate; - - private Builder( - org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder.Builder delegate) { - this.delegate = delegate; - } - - /** - * The names of packages to scan for {@code @Entity} annotations. - * @param packagesToScan packages to scan - * @return the builder for fluent usage - */ - public Builder packages(String... packagesToScan) { - this.delegate.packages(packagesToScan); - return this; - } - - /** - * The classes whose packages should be scanned for {@code @Entity} annotations. - * @param basePackageClasses the classes to use - * @return the builder for fluent usage - */ - public Builder packages(Class... basePackageClasses) { - this.delegate.packages(basePackageClasses); - return this; - } - - /** - * The name of the persistence unit. If only building one EntityManagerFactory you - * can omit this, but if there are more than one in the same application you - * should give them distinct names. - * @param persistenceUnit the name of the persistence unit - * @return the builder for fluent usage - */ - public Builder persistenceUnit(String persistenceUnit) { - this.delegate.persistenceUnit(persistenceUnit); - return this; - } - - /** - * Generic properties for standard JPA or vendor-specific configuration. These - * properties override any values provided in the {@link JpaProperties} used to - * create the builder. - * @param properties the properties to use - * @return the builder for fluent usage - */ - public Builder properties(Map properties) { - this.delegate.properties(properties); - return this; - } - - /** - * Configure if using a JTA {@link DataSource}, i.e. if - * {@link LocalContainerEntityManagerFactoryBean#setDataSource(DataSource) - * setDataSource} or - * {@link LocalContainerEntityManagerFactoryBean#setJtaDataSource(DataSource) - * setJtaDataSource} should be called on the - * {@link LocalContainerEntityManagerFactoryBean}. - * @param jta if the data source is JTA - * @return the builder for fluent usage - */ - public Builder jta(boolean jta) { - this.delegate.jta(jta); - return this; - } - - public LocalContainerEntityManagerFactoryBean build() { - return this.delegate.build(); - } - - } - - /** - * A callback for new entity manager factory beans created by a Builder. - * @deprecated since 1.3.0 in favor of - * {@link org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder} - */ - @Deprecated - public interface EntityManagerFactoryBeanCallback { - - void execute(LocalContainerEntityManagerFactoryBean factory); - - } - - private static class Delegate - extends org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder { - - Delegate(JpaVendorAdapter jpaVendorAdapter, Map jpaProperties, - PersistenceUnitManager persistenceUnitManager) { - super(jpaVendorAdapter, jpaProperties, persistenceUnitManager); - } - - } - -} diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilderTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilderTests.java deleted file mode 100644 index 6654e5f43a0..00000000000 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/EntityManagerFactoryBuilderTests.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2012-2015 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.orm.jpa; - -import java.util.Collections; - -import javax.sql.DataSource; - -import org.junit.Test; - -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; - -/** - * Tests for {@link EntityManagerFactoryBuilder}. - * - * @author Dave Syer - */ -@Deprecated -public class EntityManagerFactoryBuilderTests { - - private JpaProperties properties = new JpaProperties(); - - private DataSource dataSource1 = mock(DataSource.class); - - private DataSource dataSource2 = mock(DataSource.class); - - @Test - public void entityManagerFactoryPropertiesNotOverwritingDefaults() { - EntityManagerFactoryBuilder factory = new EntityManagerFactoryBuilder( - new HibernateJpaVendorAdapter(), this.properties, null); - LocalContainerEntityManagerFactoryBean result1 = factory - .dataSource(this.dataSource1) - .properties(Collections.singletonMap("foo", "spam")).build(); - assertFalse(result1.getJpaPropertyMap().isEmpty()); - assertTrue(this.properties.getProperties().isEmpty()); - } - - @Test - public void multipleEntityManagerFactoriesDoNotOverwriteEachOther() { - EntityManagerFactoryBuilder factory = new EntityManagerFactoryBuilder( - new HibernateJpaVendorAdapter(), this.properties, null); - LocalContainerEntityManagerFactoryBean result1 = factory - .dataSource(this.dataSource1) - .properties(Collections.singletonMap("foo", "spam")).build(); - assertFalse(result1.getJpaPropertyMap().isEmpty()); - LocalContainerEntityManagerFactoryBean result2 = factory - .dataSource(this.dataSource2).build(); - assertTrue(result2.getJpaPropertyMap().isEmpty()); - } - -} diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index 73a3f68a9ad..6b34ac35a7c 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -773,7 +773,6 @@ public class SpringApplication { */ protected void afterRefresh(ConfigurableApplicationContext context, ApplicationArguments args) { - afterRefresh(context, args.getSourceArgs()); callRunners(context, args); } @@ -810,17 +809,6 @@ public class SpringApplication { } } - /** - * Called after the context has been refreshed. - * @param context the application context - * @param args the application arguments - * @deprecated in 1.3 in favor of - * {@link #afterRefresh(ConfigurableApplicationContext, ApplicationArguments)} - */ - @Deprecated - protected void afterRefresh(ConfigurableApplicationContext context, String[] args) { - } - private void handleRunFailure(ConfigurableApplicationContext context, SpringApplicationRunListeners listeners, Throwable exception) { if (logger.isErrorEnabled()) { diff --git a/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java b/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java index e0e0728e50a..84a57d2c07c 100644 --- a/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java +++ b/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 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. @@ -313,18 +313,6 @@ public class SpringApplicationBuilder { return this; } - /** - * Flag to indicate the startup banner should be printed. - * @param showBanner the flag to set. Default true. - * @return the current builder - * @deprecated Since 1.3.0 in favor of {@link #bannerMode} - */ - @Deprecated - public SpringApplicationBuilder showBanner(boolean showBanner) { - this.application.setShowBanner(showBanner); - return this; - } - public SpringApplicationBuilder bannerMode(Banner.Mode bannerMode) { this.application.setBannerMode(bannerMode); return this; diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java index 1ae19518dd7..8bb92138369 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 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. @@ -69,20 +69,6 @@ public abstract class LoggingSystem { */ public void initialize(LoggingInitializationContext initializationContext, String configLocation, LogFile logFile) { - initialize(configLocation, logFile); - } - - /** - * Fully initialize the logging system. - * @param configLocation a log configuration location or {@code null} if default - * initialization is required - * @param logFile the log output file that should be written or {@code null} for - * console only output - * @deprecated since 1.3 in favor of - * {@link #initialize(LoggingInitializationContext, String, LogFile)} - */ - @Deprecated - public void initialize(String configLocation, LogFile logFile) { } /** diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LevelRemappingAppender.java b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LevelRemappingAppender.java index cb55e59dc6f..97ee14efdf6 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LevelRemappingAppender.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LevelRemappingAppender.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2016 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. @@ -195,7 +195,7 @@ public class LevelRemappingAppender extends AppenderBase { @Override @Deprecated public Map getMdc() { - return this.event.getMdc(); + return this.event.getMDCPropertyMap(); } @Override diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java index eabd5480e90..51ec9ceb85b 100644 --- a/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 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. @@ -499,11 +499,6 @@ public class LoggingApplicationListenerTests { } - @Override - public void initialize(String configLocation, LogFile logFile) { - - } - @Override public void setLogLevel(String loggerName, LogLevel level) {