diff --git a/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ContextRefresher.java b/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ContextRefresher.java index 981493929..cf0c17cbe 100644 --- a/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ContextRefresher.java +++ b/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ContextRefresher.java @@ -90,10 +90,13 @@ protected RefreshScope getScope() { return this.scope; } - public synchronized Set refresh() { - Set keys = refreshEnvironment(); - this.scope.refreshAll(); - return keys; + public Set refresh(Set propertiesToRefresh, RefreshStrategy strategy) { + return strategy.refresh(this, propertiesToRefresh); + } + + public synchronized Set refreshSpecificEnvironment(Set propertiesToRefresh){ + //TODO: Implement this. + return propertiesToRefresh; } public synchronized Set refreshEnvironment() { diff --git a/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/RefreshAllStrategy.java b/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/RefreshAllStrategy.java new file mode 100644 index 000000000..71e520249 --- /dev/null +++ b/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/RefreshAllStrategy.java @@ -0,0 +1,10 @@ +package org.springframework.cloud.context.refresh; + +import java.util.Set; + +public class RefreshAllStrategy implements RefreshStrategy { + @Override + public Set refresh(ContextRefresher contextRefresher, Set propertiesToRefresh) { + return contextRefresher.refreshEnvironment(); + } +} \ No newline at end of file diff --git a/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/RefreshSpecificPropertiesStrategy.java b/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/RefreshSpecificPropertiesStrategy.java new file mode 100644 index 000000000..a9747d70d --- /dev/null +++ b/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/RefreshSpecificPropertiesStrategy.java @@ -0,0 +1,10 @@ +package org.springframework.cloud.context.refresh; + +import java.util.Set; + +public class RefreshSpecificPropertiesStrategy implements RefreshStrategy { + @Override + public Set refresh(ContextRefresher contextRefresher, Set propertiesToRefresh) { + return contextRefresher.refreshSpecificEnvironment(propertiesToRefresh); + } +} \ No newline at end of file diff --git a/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/RefreshStrategy.java b/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/RefreshStrategy.java new file mode 100644 index 000000000..cc833e5bb --- /dev/null +++ b/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/RefreshStrategy.java @@ -0,0 +1,7 @@ +package org.springframework.cloud.context.refresh; + +import java.util.Set; + +public interface RefreshStrategy { + Set refresh(ContextRefresher contextRefresher, Set propertiesToRefresh); +} \ No newline at end of file diff --git a/spring-cloud-context/src/main/java/org/springframework/cloud/endpoint/RefreshEndpoint.java b/spring-cloud-context/src/main/java/org/springframework/cloud/endpoint/RefreshEndpoint.java index 42dcc995e..8f5373b22 100644 --- a/spring-cloud-context/src/main/java/org/springframework/cloud/endpoint/RefreshEndpoint.java +++ b/spring-cloud-context/src/main/java/org/springframework/cloud/endpoint/RefreshEndpoint.java @@ -42,8 +42,11 @@ public RefreshEndpoint(ContextRefresher contextRefresher) { } @WriteOperation - public Collection refresh() { - Set keys = this.contextRefresher.refresh(); + public Collection refresh(Set propertiesToRefresh) { + RefreshStrategy strategy = (propertiesToRefresh != null && !propertiesToRefresh.isEmpty()) + ? new RefreshSpecificPropertiesStrategy() + : new RefreshAllStrategy(); + Set keys = this.contextRefresher.refresh(propertiesToRefresh, strategy); LOG.info("Refreshed keys : " + keys); return keys; }