Merge remote-tracking branch 'origin/2.1.x'
This commit is contained in:
@@ -30,8 +30,8 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(properties = { "spring.jmx.enabled=true",
|
||||
"endpoints.default.jmx.enabled=true" })
|
||||
@SpringBootTest(
|
||||
properties = { "spring.jmx.enabled=true", "endpoints.default.jmx.enabled=true" })
|
||||
public class BusJmxEndpointTests {
|
||||
|
||||
@Autowired(required = false)
|
||||
|
||||
@@ -50,7 +50,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(properties = "spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS:true", webEnvironment = RANDOM_PORT)
|
||||
@SpringBootTest(
|
||||
properties = "spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS:true",
|
||||
webEnvironment = RANDOM_PORT)
|
||||
public class BusJacksonIntegrationTests {
|
||||
|
||||
@LocalServerPort
|
||||
|
||||
@@ -31,16 +31,12 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.autoconfigure.LifecycleMvcEndpointAutoConfiguration;
|
||||
import org.springframework.cloud.bus.endpoint.EnvironmentBusEndpoint;
|
||||
import org.springframework.cloud.bus.endpoint.RefreshBusEndpoint;
|
||||
import org.springframework.cloud.bus.event.AckRemoteApplicationEvent;
|
||||
import org.springframework.cloud.bus.event.EnvironmentChangeListener;
|
||||
import org.springframework.cloud.bus.event.RefreshListener;
|
||||
import org.springframework.cloud.bus.event.RemoteApplicationEvent;
|
||||
import org.springframework.cloud.bus.event.SentApplicationEvent;
|
||||
import org.springframework.cloud.bus.event.TraceListener;
|
||||
import org.springframework.cloud.context.environment.EnvironmentManager;
|
||||
import org.springframework.cloud.context.refresh.ContextRefresher;
|
||||
import org.springframework.cloud.context.scope.refresh.RefreshScope;
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
import org.springframework.cloud.stream.annotation.Output;
|
||||
import org.springframework.cloud.stream.annotation.StreamListener;
|
||||
@@ -182,13 +178,6 @@ public class BusAutoConfiguration implements ApplicationEventPublisherAware {
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "spring.cloud.bus.refresh.enabled", matchIfMissing = true)
|
||||
@ConditionalOnBean(ContextRefresher.class)
|
||||
public RefreshListener refreshListener(ContextRefresher contextRefresher) {
|
||||
return new RefreshListener(contextRefresher);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
protected static class MatcherConfiguration {
|
||||
|
||||
@@ -212,29 +201,11 @@ public class BusAutoConfiguration implements ApplicationEventPublisherAware {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass({ Endpoint.class, RefreshScope.class })
|
||||
protected static class BusRefreshConfiguration {
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnBean(ContextRefresher.class)
|
||||
protected static class BusRefreshEndpointConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnEnabledEndpoint
|
||||
public RefreshBusEndpoint refreshBusEndpoint(ApplicationContext context,
|
||||
BusProperties bus) {
|
||||
return new RefreshBusEndpoint(context, bus.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass({ Endpoint.class })
|
||||
@ConditionalOnBean(HttpTraceRepository.class)
|
||||
@ConditionalOnProperty(value = "spring.cloud.bus.trace.enabled", matchIfMissing = false)
|
||||
@ConditionalOnProperty(value = "spring.cloud.bus.trace.enabled",
|
||||
matchIfMissing = false)
|
||||
protected static class BusAckTraceConfiguration {
|
||||
|
||||
@Bean
|
||||
@@ -251,7 +222,8 @@ public class BusAutoConfiguration implements ApplicationEventPublisherAware {
|
||||
protected static class BusEnvironmentConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "spring.cloud.bus.env.enabled", matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.cloud.bus.env.enabled",
|
||||
matchIfMissing = true)
|
||||
public EnvironmentChangeListener environmentChangeListener() {
|
||||
return new EnvironmentChangeListener();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2013-2019 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
|
||||
*
|
||||
* https://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.cloud.bus;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.bus.endpoint.RefreshBusEndpoint;
|
||||
import org.springframework.cloud.bus.event.RefreshListener;
|
||||
import org.springframework.cloud.context.refresh.ContextRefresher;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author Ryan Baxter
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnBusEnabled
|
||||
@AutoConfigureAfter(
|
||||
name = { "org.springframework.cloud.autoconfigure.RefreshAutoConfiguration" })
|
||||
public class BusRefreshAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "spring.cloud.bus.refresh.enabled",
|
||||
matchIfMissing = true)
|
||||
@ConditionalOnBean(ContextRefresher.class)
|
||||
public RefreshListener refreshListener(ContextRefresher contextRefresher) {
|
||||
return new RefreshListener(contextRefresher);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnBean(ContextRefresher.class)
|
||||
@ConditionalOnClass(
|
||||
name = { "org.springframework.boot.actuate.endpoint.annotation.Endpoint",
|
||||
"org.springframework.cloud.context.scope.refresh.RefreshScope" })
|
||||
protected static class BusRefreshEndpointConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnEnabledEndpoint
|
||||
public RefreshBusEndpoint refreshBusEndpoint(ApplicationContext context,
|
||||
BusProperties bus) {
|
||||
return new RefreshBusEndpoint(context, bus.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,8 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@ConditionalOnProperty(value = ConditionalOnBusEnabled.SPRING_CLOUD_BUS_ENABLED, matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = ConditionalOnBusEnabled.SPRING_CLOUD_BUS_ENABLED,
|
||||
matchIfMissing = true)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||
public @interface ConditionalOnBusEnabled {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.springframework.cloud.bus.BusPropertiesAutoConfiguration,\
|
||||
org.springframework.cloud.bus.BusAutoConfiguration,\
|
||||
org.springframework.cloud.bus.BusRefreshAutoConfiguration,\
|
||||
org.springframework.cloud.bus.jackson.BusJacksonAutoConfiguration
|
||||
# Environment Post Processor
|
||||
org.springframework.boot.env.EnvironmentPostProcessor=\
|
||||
|
||||
@@ -38,7 +38,7 @@ public class BusAutoConfigurationClassPathTests {
|
||||
public void refreshListenerCreatedWithoutActuator() {
|
||||
new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class,
|
||||
BusAutoConfiguration.class))
|
||||
BusRefreshAutoConfiguration.class))
|
||||
.run(context -> assertThat(context).hasSingleBean(RefreshListener.class)
|
||||
.doesNotHaveBean(RefreshBusEndpoint.class));
|
||||
}
|
||||
|
||||
@@ -149,8 +149,8 @@ public class RemoteApplicationEventScanTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@RemoteApplicationEventScan(basePackages = { "com.acme", "test.foo.bar",
|
||||
"fizz.buzz" })
|
||||
@RemoteApplicationEventScan(
|
||||
basePackages = { "com.acme", "test.foo.bar", "fizz.buzz" })
|
||||
static class BasePackagesConfig {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user