Use new ContextRefresher rather than RefreshEndpoint.
This commit is contained in:
@@ -20,8 +20,8 @@ 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.endpoint.RefreshEndpoint;
|
||||
import org.springframework.cloud.stream.annotation.EnableBinding;
|
||||
import org.springframework.cloud.stream.annotation.Output;
|
||||
import org.springframework.cloud.stream.config.BindingProperties;
|
||||
@@ -170,13 +170,13 @@ public class BusAutoConfiguration implements ApplicationEventPublisherAware {
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnClass({ Endpoint.class, RefreshScope.class })
|
||||
@ConditionalOnBean(RefreshEndpoint.class)
|
||||
@ConditionalOnBean(ContextRefresher.class)
|
||||
protected static class BusRefreshConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(value = "spring.cloud.bus.refresh.enabled", matchIfMissing = true)
|
||||
public RefreshListener refreshListener(RefreshEndpoint refreshEndpoint) {
|
||||
return new RefreshListener(refreshEndpoint);
|
||||
public RefreshListener refreshListener(ContextRefresher contextRefresher) {
|
||||
return new RefreshListener(contextRefresher);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.springframework.cloud.bus.event;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.cloud.endpoint.RefreshEndpoint;
|
||||
import org.springframework.cloud.context.refresh.ContextRefresher;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
|
||||
/**
|
||||
@@ -15,16 +15,15 @@ public class RefreshListener
|
||||
|
||||
private static Log log = LogFactory.getLog(RefreshListener.class);
|
||||
|
||||
private RefreshEndpoint endpoint;
|
||||
private ContextRefresher contextRefresher;
|
||||
|
||||
public RefreshListener(RefreshEndpoint endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
public RefreshListener(ContextRefresher contextRefresher) {
|
||||
this.contextRefresher = contextRefresher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(RefreshRemoteApplicationEvent event) {
|
||||
String[] keys = endpoint.refresh();
|
||||
log.info(
|
||||
"Received remote refresh request. Keys refreshed " + Arrays.asList(keys));
|
||||
Set<String> keys = contextRefresher.refresh();
|
||||
log.info("Received remote refresh request. Keys refreshed " + keys);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user