Browse Source

Polishing

pull/931/head
Juergen Hoeller 10 years ago
parent
commit
7a7877040f
  1. 32
      spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java

32
spring-beans/src/main/java/org/springframework/beans/factory/config/YamlProcessor.java

@ -150,8 +150,8 @@ public abstract class YamlProcessor {
private boolean process(MatchCallback callback, Yaml yaml, Resource resource) { private boolean process(MatchCallback callback, Yaml yaml, Resource resource) {
int count = 0; int count = 0;
try { try {
if (this.logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
this.logger.debug("Loading from YAML: " + resource); logger.debug("Loading from YAML: " + resource);
} }
Reader reader = new UnicodeReader(resource.getInputStream()); Reader reader = new UnicodeReader(resource.getInputStream());
try { try {
@ -163,8 +163,8 @@ public abstract class YamlProcessor {
} }
} }
} }
if (this.logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
this.logger.debug("Loaded " + count + " document" + (count > 1 ? "s" : "") + logger.debug("Loaded " + count + " document" + (count > 1 ? "s" : "") +
" from YAML resource: " + resource); " from YAML resource: " + resource);
} }
} }
@ -183,8 +183,8 @@ public abstract class YamlProcessor {
this.resolutionMethod != ResolutionMethod.OVERRIDE_AND_IGNORE) { this.resolutionMethod != ResolutionMethod.OVERRIDE_AND_IGNORE) {
throw new IllegalStateException(ex); throw new IllegalStateException(ex);
} }
if (this.logger.isWarnEnabled()) { if (logger.isWarnEnabled()) {
this.logger.warn("Could not load map from " + resource + ": " + ex.getMessage()); logger.warn("Could not load map from " + resource + ": " + ex.getMessage());
} }
} }
@ -221,8 +221,8 @@ public abstract class YamlProcessor {
properties.putAll(getFlattenedMap(map)); properties.putAll(getFlattenedMap(map));
if (this.documentMatchers.isEmpty()) { if (this.documentMatchers.isEmpty()) {
if (this.logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
this.logger.debug("Merging document (no matchers set)" + map); logger.debug("Merging document (no matchers set): " + map);
} }
callback.process(properties, map); callback.process(properties, map);
return true; return true;
@ -233,8 +233,8 @@ public abstract class YamlProcessor {
MatchStatus match = matcher.matches(properties); MatchStatus match = matcher.matches(properties);
result = MatchStatus.getMostSpecific(match, result); result = MatchStatus.getMostSpecific(match, result);
if (match == MatchStatus.FOUND) { if (match == MatchStatus.FOUND) {
if (this.logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
this.logger.debug("Matched document with document matcher: " + properties); logger.debug("Matched document with document matcher: " + properties);
} }
callback.process(properties, map); callback.process(properties, map);
return true; return true;
@ -242,14 +242,16 @@ public abstract class YamlProcessor {
} }
if (result == MatchStatus.ABSTAIN && this.matchDefault) { if (result == MatchStatus.ABSTAIN && this.matchDefault) {
if (this.logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
this.logger.debug("Matched document with default matcher: " + map); logger.debug("Matched document with default matcher: " + map);
} }
callback.process(properties, map); callback.process(properties, map);
return true; return true;
} }
this.logger.debug("Unmatched document"); if (logger.isDebugEnabled()) {
logger.debug("Unmatched document: " + map);
}
return false; return false;
} }
@ -300,7 +302,7 @@ public abstract class YamlProcessor {
} }
} }
else { else {
result.put(key, value == null ? "" : value); result.put(key, value != null ? value : "");
} }
} }
} }
@ -328,7 +330,7 @@ public abstract class YamlProcessor {
/** /**
* Test if the given properties match. * Test if the given properties match.
* @param properties the properties to test * @param properties the properties to test
* @return the status of the match. * @return the status of the match
*/ */
MatchStatus matches(Properties properties); MatchStatus matches(Properties properties);
} }

Loading…
Cancel
Save