This commit is contained in:
Johnny Lim
2017-09-30 02:47:40 +09:00
committed by Andy Wilkinson
parent bcbf7b5511
commit bfa291f671
16 changed files with 99 additions and 98 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -49,28 +49,28 @@ import org.springframework.boot.ansi.AnsiStyle;
@ConverterKeys({ "clr", "color" })
public final class ColorConverter extends LogEventPatternConverter {
private static final Map<String, AnsiElement> ELEMENTS;
private static final Map<String, AnsiElement> elements;
static {
Map<String, AnsiElement> elements = new HashMap<String, AnsiElement>();
elements.put("faint", AnsiStyle.FAINT);
elements.put("red", AnsiColor.RED);
elements.put("green", AnsiColor.GREEN);
elements.put("yellow", AnsiColor.YELLOW);
elements.put("blue", AnsiColor.BLUE);
elements.put("magenta", AnsiColor.MAGENTA);
elements.put("cyan", AnsiColor.CYAN);
ELEMENTS = Collections.unmodifiableMap(elements);
Map<String, AnsiElement> ansiElements = new HashMap<String, AnsiElement>();
ansiElements.put("faint", AnsiStyle.FAINT);
ansiElements.put("red", AnsiColor.RED);
ansiElements.put("green", AnsiColor.GREEN);
ansiElements.put("yellow", AnsiColor.YELLOW);
ansiElements.put("blue", AnsiColor.BLUE);
ansiElements.put("magenta", AnsiColor.MAGENTA);
ansiElements.put("cyan", AnsiColor.CYAN);
elements = Collections.unmodifiableMap(ansiElements);
}
private static final Map<Integer, AnsiElement> LEVELS;
private static final Map<Integer, AnsiElement> levels;
static {
Map<Integer, AnsiElement> levels = new HashMap<Integer, AnsiElement>();
levels.put(Level.FATAL.intLevel(), AnsiColor.RED);
levels.put(Level.ERROR.intLevel(), AnsiColor.RED);
levels.put(Level.WARN.intLevel(), AnsiColor.YELLOW);
LEVELS = Collections.unmodifiableMap(levels);
Map<Integer, AnsiElement> ansiLevels = new HashMap<Integer, AnsiElement>();
ansiLevels.put(Level.FATAL.intLevel(), AnsiColor.RED);
ansiLevels.put(Level.ERROR.intLevel(), AnsiColor.RED);
ansiLevels.put(Level.WARN.intLevel(), AnsiColor.YELLOW);
levels = Collections.unmodifiableMap(ansiLevels);
}
private final List<PatternFormatter> formatters;
@@ -101,7 +101,7 @@ public final class ColorConverter extends LogEventPatternConverter {
}
PatternParser parser = PatternLayout.createPatternParser(config);
List<PatternFormatter> formatters = parser.parse(options[0]);
AnsiElement element = (options.length == 1 ? null : ELEMENTS.get(options[1]));
AnsiElement element = (options.length == 1 ? null : elements.get(options[1]));
return new ColorConverter(formatters, element);
}
@@ -125,7 +125,7 @@ public final class ColorConverter extends LogEventPatternConverter {
AnsiElement element = this.styling;
if (element == null) {
// Assume highlighting
element = LEVELS.get(event.getLevel().intLevel());
element = levels.get(event.getLevel().intLevel());
element = (element == null ? AnsiColor.GREEN : element);
}
appendAnsiString(toAppendTo, buf.toString(), element);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2013 the original author or authors.
* Copyright 2012-2017 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.
@@ -38,35 +38,35 @@ import org.springframework.boot.ansi.AnsiStyle;
*/
public class ColorConverter extends CompositeConverter<ILoggingEvent> {
private static final Map<String, AnsiElement> ELEMENTS;
private static final Map<String, AnsiElement> elements;
static {
Map<String, AnsiElement> elements = new HashMap<String, AnsiElement>();
elements.put("faint", AnsiStyle.FAINT);
elements.put("red", AnsiColor.RED);
elements.put("green", AnsiColor.GREEN);
elements.put("yellow", AnsiColor.YELLOW);
elements.put("blue", AnsiColor.BLUE);
elements.put("magenta", AnsiColor.MAGENTA);
elements.put("cyan", AnsiColor.CYAN);
ELEMENTS = Collections.unmodifiableMap(elements);
Map<String, AnsiElement> ansiElements = new HashMap<String, AnsiElement>();
ansiElements.put("faint", AnsiStyle.FAINT);
ansiElements.put("red", AnsiColor.RED);
ansiElements.put("green", AnsiColor.GREEN);
ansiElements.put("yellow", AnsiColor.YELLOW);
ansiElements.put("blue", AnsiColor.BLUE);
ansiElements.put("magenta", AnsiColor.MAGENTA);
ansiElements.put("cyan", AnsiColor.CYAN);
elements = Collections.unmodifiableMap(ansiElements);
}
private static final Map<Integer, AnsiElement> LEVELS;
private static final Map<Integer, AnsiElement> levels;
static {
Map<Integer, AnsiElement> levels = new HashMap<Integer, AnsiElement>();
levels.put(Level.ERROR_INTEGER, AnsiColor.RED);
levels.put(Level.WARN_INTEGER, AnsiColor.YELLOW);
LEVELS = Collections.unmodifiableMap(levels);
Map<Integer, AnsiElement> ansiLevels = new HashMap<Integer, AnsiElement>();
ansiLevels.put(Level.ERROR_INTEGER, AnsiColor.RED);
ansiLevels.put(Level.WARN_INTEGER, AnsiColor.YELLOW);
levels = Collections.unmodifiableMap(ansiLevels);
}
@Override
protected String transform(ILoggingEvent event, String in) {
AnsiElement element = ELEMENTS.get(getFirstOption());
AnsiElement element = elements.get(getFirstOption());
if (element == null) {
// Assume highlighting
element = LEVELS.get(event.getLevel().toInteger());
element = levels.get(event.getLevel().toInteger());
element = (element == null ? AnsiColor.GREEN : element);
}
return toAnsiString(in, element);

View File

@@ -66,23 +66,23 @@ public class ApplicationPidFileWriter
private static final String DEFAULT_FILE_NAME = "application.pid";
private static final List<Property> FILE_PROPERTIES;
private static final List<Property> fileProperties;
static {
List<Property> properties = new ArrayList<Property>();
properties.add(new SpringProperty("spring.pid.", "file"));
properties.add(new SpringProperty("spring.", "pidfile"));
properties.add(new SystemProperty("PIDFILE"));
FILE_PROPERTIES = Collections.unmodifiableList(properties);
fileProperties = Collections.unmodifiableList(properties);
}
private static final List<Property> FAIL_ON_WRITE_ERROR_PROPERTIES;
private static final List<Property> failOnWriteErrorProperties;
static {
List<Property> properties = new ArrayList<Property>();
properties.add(new SpringProperty("spring.pid.", "fail-on-write-error"));
properties.add(new SystemProperty("PID_FAIL_ON_WRITE_ERROR"));
FAIL_ON_WRITE_ERROR_PROPERTIES = Collections.unmodifiableList(properties);
failOnWriteErrorProperties = Collections.unmodifiableList(properties);
}
private static final AtomicBoolean created = new AtomicBoolean(false);
@@ -153,7 +153,7 @@ public class ApplicationPidFileWriter
private void writePidFile(SpringApplicationEvent event) throws IOException {
File pidFile = this.file;
String override = getProperty(event, FILE_PROPERTIES);
String override = getProperty(event, fileProperties);
if (override != null) {
pidFile = new File(override);
}
@@ -162,7 +162,7 @@ public class ApplicationPidFileWriter
}
private boolean failOnWriteError(SpringApplicationEvent event) {
String value = getProperty(event, FAIL_ON_WRITE_ERROR_PROPERTIES);
String value = getProperty(event, failOnWriteErrorProperties);
return (value == null ? false : Boolean.parseBoolean(value));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -43,14 +43,14 @@ import org.springframework.web.context.WebApplicationContext;
class ServletComponentRegisteringPostProcessor
implements BeanFactoryPostProcessor, ApplicationContextAware {
private static final List<ServletComponentHandler> HANDLERS;
private static final List<ServletComponentHandler> handlers;
static {
List<ServletComponentHandler> handlers = new ArrayList<ServletComponentHandler>();
handlers.add(new WebServletHandler());
handlers.add(new WebFilterHandler());
handlers.add(new WebListenerHandler());
HANDLERS = Collections.unmodifiableList(handlers);
List<ServletComponentHandler> servletComponentHandlers = new ArrayList<ServletComponentHandler>();
servletComponentHandlers.add(new WebServletHandler());
servletComponentHandlers.add(new WebFilterHandler());
servletComponentHandlers.add(new WebListenerHandler());
handlers = Collections.unmodifiableList(servletComponentHandlers);
}
private final Set<String> packagesToScan;
@@ -78,7 +78,7 @@ class ServletComponentRegisteringPostProcessor
for (BeanDefinition candidate : componentProvider
.findCandidateComponents(packageToScan)) {
if (candidate instanceof ScannedGenericBeanDefinition) {
for (ServletComponentHandler handler : HANDLERS) {
for (ServletComponentHandler handler : handlers) {
handler.handle(((ScannedGenericBeanDefinition) candidate),
(BeanDefinitionRegistry) this.applicationContext);
}
@@ -97,7 +97,7 @@ class ServletComponentRegisteringPostProcessor
false);
componentProvider.setEnvironment(this.applicationContext.getEnvironment());
componentProvider.setResourceLoader(this.applicationContext);
for (ServletComponentHandler handler : HANDLERS) {
for (ServletComponentHandler handler : handlers) {
componentProvider.addIncludeFilter(handler.getTypeFilter());
}
return componentProvider;