Fixed inconsistency in the dependencies approach

This commit is contained in:
Marcin Grzejszczak
2016-04-18 21:26:30 +02:00
parent 02b800a7a8
commit b588ad7c49
4 changed files with 4 additions and 6 deletions

View File

@@ -96,8 +96,8 @@ You can also benefit from the Zookeeper Dependency Watchers functionality that l
=== How to activate Zookeeper Dependencies
- Including a dependency on `org.springframework.cloud:spring-cloud-starter-zookeeper-discovery` will enable auto-configuration that will setup Spring Cloud Zookeeper Dependencies.
- In addition to that you have to set the property `spring.cloud.zookeeper.dependency.enabled` to true (defaults to `true` if not set explicitly).
- You have to have the `spring.cloud.zookeeper.dependencies` section properly set up - check the subsequent section for more details.
- If you have to have the `spring.cloud.zookeeper.dependencies` section properly set up - check the subsequent section for more details then the feature is active
- You can have the dependencies turned off even if you've provided the dependencies in your properties. Just set the property `spring.cloud.zookeeper.dependency.enabled` to false (defaults to `true`).
=== Setting up Zookeeper Dependencies

View File

@@ -21,7 +21,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Conditional;
/**
@@ -34,6 +33,5 @@ import org.springframework.context.annotation.Conditional;
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Conditional(DependenciesPassedCondition.class)
@ConditionalOnProperty(value = "spring.cloud.zookeeper.dependency.enabled", matchIfMissing = true)
public @interface ConditionalOnDependenciesPassed {
}

View File

@@ -41,7 +41,7 @@ public class DependenciesPassedCondition extends SpringBootCondition {
return ConditionOutcome.match("Dependencies are defined in configuration");
}
Boolean dependenciesEnabled = context.getEnvironment()
.getProperty("spring.cloud.zookeeper.dependency.enabled", Boolean.class, true);
.getProperty("spring.cloud.zookeeper.dependency.enabled", Boolean.class, false);
if (dependenciesEnabled) {
return ConditionOutcome.match("Dependencies are not defined in configuration, but switch is turned on");
}

View File

@@ -62,7 +62,7 @@ public class ZookeeperLifecycleRegistrationDisabledTests {
@Test
public void contextLoads() {
List<ServiceInstance> instances = client.getInstances("myTestNotRegisteredService");
List<ServiceInstance> instances = this.client.getInstances("myTestNotRegisteredService");
assertTrue("service was registered", instances.isEmpty());
}