Consistent use of Ordered constants

Prefer Ordered HIGHEST_PRECEDENCE and LOWEST_PRECEDENCE constants to
Integer MAX_VALUE or MIN_VALUE.
pull/313/merge
Phillip Webb 11 years ago
parent 37c2c89bcb
commit f6f8c26f69

@ -26,6 +26,7 @@ import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.config.ConfigFileApplicationListener;
import org.springframework.boot.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.json.JsonParser;
import org.springframework.boot.json.JsonParserFactory;
@ -96,9 +97,8 @@ public class VcapApplicationListener implements
private static final String VCAP_SERVICES = "VCAP_SERVICES";
// Intentionally before ConfigFileApplicationContextInitializer so values there can
// use these ones
private int order = Integer.MIN_VALUE + 9;
// Before ConfigFileApplicationListener so values there can use these ones
private int order = ConfigFileApplicationListener.DEFAULT_CONFIG_LISTENER_ORDER - 1;;
private final JsonParser parser = JsonParserFactory.getJsonParser();

@ -84,12 +84,14 @@ public class ConfigFileApplicationListener implements
private static final String LOCATION_VARIABLE = "${spring.config.location}";
public static final int DEFAULT_CONFIG_LISTENER_ORDER = Ordered.HIGHEST_PRECEDENCE + 10;
private String[] searchLocations = new String[] { "classpath:/", "file:./",
"classpath:/config/", "file:./config/" };
private String names = "${spring.config.name:application}";
private int order = Integer.MIN_VALUE + 10;
private int order = DEFAULT_CONFIG_LISTENER_ORDER;
private final ConversionService conversionService = new DefaultConversionService();

@ -21,6 +21,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.boot.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.core.Ordered;
/**
* An {@link ApplicationListener}that halts application startup if the system file
@ -42,10 +43,15 @@ import org.springframework.context.ApplicationListener;
* @author Dave Syer
*/
public class FileEncodingApplicationListener implements
ApplicationListener<ApplicationEnvironmentPreparedEvent> {
ApplicationListener<ApplicationEnvironmentPreparedEvent>, Ordered {
private static Log logger = LogFactory.getLog(FileEncodingApplicationListener.class);
@Override
public int getOrder() {
return Ordered.LOWEST_PRECEDENCE;
}
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(

@ -25,6 +25,7 @@ import org.springframework.boot.event.ApplicationFailedEvent;
import org.springframework.boot.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.SmartApplicationListener;
import org.springframework.core.Ordered;
/**
* A {@link SmartApplicationListener} that reacts to {@link ApplicationStartedEvent start
@ -37,7 +38,7 @@ import org.springframework.context.event.SmartApplicationListener;
public final class ClasspathLoggingApplicationListener implements
SmartApplicationListener {
private static final int ORDER = Integer.MIN_VALUE + 12;
private static final int ORDER = Ordered.HIGHEST_PRECEDENCE + 12;
private final Log logger = LogFactory.getLog(getClass());

@ -31,6 +31,7 @@ import org.springframework.boot.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.SmartApplicationListener;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.util.ClassUtils;
@ -97,7 +98,7 @@ public class LoggingApplicationListener implements SmartApplicationListener {
private final Log logger = LogFactory.getLog(getClass());
private int order = Integer.MIN_VALUE + 11;
private int order = Ordered.HIGHEST_PRECEDENCE + 11;
private boolean parseArgs = true;

Loading…
Cancel
Save