Polish
This commit is contained in:
parent
d87f2713af
commit
49039c33ea
|
@ -28,20 +28,19 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
|
|||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Phillip Webb
|
||||
* @since 1.3.0
|
||||
*/
|
||||
abstract class CacheConfigFileCondition extends SpringBootCondition {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final String configPrefix;
|
||||
private final String prefix;
|
||||
|
||||
private final String[] resourceLocations;
|
||||
|
||||
public CacheConfigFileCondition(String name, String configPrefix,
|
||||
public CacheConfigFileCondition(String name, String prefix,
|
||||
String... resourceLocations) {
|
||||
this.name = name;
|
||||
this.configPrefix = (configPrefix.endsWith(".") ? configPrefix : configPrefix + ".");
|
||||
this.prefix = (prefix.endsWith(".") ? prefix : prefix + ".");
|
||||
this.resourceLocations = resourceLocations;
|
||||
}
|
||||
|
||||
|
@ -49,9 +48,9 @@ abstract class CacheConfigFileCondition extends SpringBootCondition {
|
|||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(
|
||||
context.getEnvironment(), this.configPrefix);
|
||||
context.getEnvironment(), this.prefix);
|
||||
if (resolver.containsProperty("config")) {
|
||||
return ConditionOutcome.match("A '" + this.configPrefix + ".config' "
|
||||
return ConditionOutcome.match("A '" + this.prefix + ".config' "
|
||||
+ "property is specified");
|
||||
}
|
||||
return getResourceOutcome(context, metadata);
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.cache;
|
|||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.test.EnvironmentTestUtils;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
@ -63,8 +62,7 @@ public class CacheConfigFileConditionTests {
|
|||
assertTrue(this.context.containsBean("foo"));
|
||||
}
|
||||
|
||||
private void load(Class<?> config,
|
||||
String... environment) {
|
||||
private void load(Class<?> config, String... environment) {
|
||||
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
|
||||
EnvironmentTestUtils.addEnvironment(applicationContext, environment);
|
||||
applicationContext.register(config);
|
||||
|
@ -72,7 +70,6 @@ public class CacheConfigFileConditionTests {
|
|||
this.context = applicationContext;
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@Conditional(CacheConfigFileDefaultFileCondition.class)
|
||||
static class DefaultFileConfiguration {
|
||||
|
@ -93,16 +90,19 @@ public class CacheConfigFileConditionTests {
|
|||
}
|
||||
}
|
||||
|
||||
private static class CacheConfigFileDefaultFileCondition extends CacheConfigFileCondition {
|
||||
private static class CacheConfigFileDefaultFileCondition extends
|
||||
CacheConfigFileCondition {
|
||||
|
||||
public CacheConfigFileDefaultFileCondition() {
|
||||
super("test", "spring.cache.test.", "classpath:/ehcache.xml");
|
||||
}
|
||||
}
|
||||
|
||||
private static class CacheConfigFileNoDefaultFileCondition extends CacheConfigFileCondition {
|
||||
private static class CacheConfigFileNoDefaultFileCondition extends
|
||||
CacheConfigFileCondition {
|
||||
public CacheConfigFileNoDefaultFileCondition() {
|
||||
super("test", "spring.cache.test", "classpath:/this-cache-file-does-not-exist.xml");
|
||||
super("test", "spring.cache.test",
|
||||
"classpath:/this-cache-file-does-not-exist.xml");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,14 +8,14 @@ class Example implements CommandLineRunner {
|
|||
private MyService myService
|
||||
|
||||
void run(String... args) {
|
||||
println "Hello ${this.myService.sayWorld()} From ${getClass().getClassLoader().getResource('samples/retry.groovy')}"
|
||||
println "Hello ${this.myService.sayWorld()} From ${getClass().getClassLoader().getResource('samples/retry.groovy')}"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Service
|
||||
class MyService {
|
||||
|
||||
|
||||
static int count = 0
|
||||
|
||||
@Retryable
|
||||
|
@ -26,5 +26,3 @@ class MyService {
|
|||
return "World!"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
* 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.
|
||||
|
@ -26,6 +26,7 @@ import org.springframework.boot.cli.compiler.DependencyCustomizer;
|
|||
* {@link CompilerAutoConfiguration} for Spring Retry.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public class SpringRetryCompilerAutoConfiguration extends CompilerAutoConfiguration {
|
||||
|
||||
|
|
Loading…
Reference in New Issue