Polish
This commit is contained in:
parent
d64cc082db
commit
555827cad7
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2013-2014 the original author or authors.
|
* Copyright 2013-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -142,9 +142,9 @@ Their purpose is to load resources (`.class` files etc.) from nested jar files o
|
||||||
files in directories (as opposed to explicitly on the classpath). In the case of the
|
files in directories (as opposed to explicitly on the classpath). In the case of the
|
||||||
`[Jar|War]Launcher` the nested paths are fixed (`+lib/*.jar+` and `+lib-provided/*.jar+` for
|
`[Jar|War]Launcher` the nested paths are fixed (`+lib/*.jar+` and `+lib-provided/*.jar+` for
|
||||||
the war case) so you just add extra jars in those locations if you want more. The
|
the war case) so you just add extra jars in those locations if you want more. The
|
||||||
`PropertiesLauncher` looks in `lib/` in your application archive by default, but you can add additional locations by
|
`PropertiesLauncher` looks in `lib/` in your application archive by default, but you can
|
||||||
setting an environment variable `LOADER_PATH` or `loader.path` in `application.properties`
|
add additional locations by setting an environment variable `LOADER_PATH` or `loader.path`
|
||||||
(comma-separated list of directories or archives).
|
in `application.properties` (comma-separated list of directories or archives).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -76,4 +76,5 @@ public class MultiProjectRepackagingTests {
|
||||||
assertThat(jarFile.getEntry("lib/projectB.jar"), notNullValue());
|
assertThat(jarFile.getEntry("lib/projectB.jar"), notNullValue());
|
||||||
jarFile.close();
|
jarFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -21,7 +21,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
|
||||||
/**
|
/**
|
||||||
* Main class to start the embedded server.
|
* Main class to start the embedded server.
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Dave Syer
|
||||||
*/
|
*/
|
||||||
public final class EmbeddedJarStarter {
|
public final class EmbeddedJarStarter {
|
||||||
|
|
||||||
|
|
@ -30,4 +30,5 @@ public final class EmbeddedJarStarter {
|
||||||
context.getBean(SpringConfiguration.class).run(args);
|
context.getBean(SpringConfiguration.class).run(args);
|
||||||
context.close();
|
context.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -27,7 +27,7 @@ import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||||
/**
|
/**
|
||||||
* Spring configuration.
|
* Spring configuration.
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Dave Syer
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
|
|
@ -48,6 +48,4 @@ public class SpringConfiguration {
|
||||||
System.err.println("Hello Embedded " + this.message + "!");
|
System.err.println("Hello Embedded " + this.message + "!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -553,7 +553,7 @@ public class PropertiesLauncher extends Launcher {
|
||||||
urls.addAll(index + 1, extra);
|
urls.addAll(index + 1, extra);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception ex) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -272,7 +272,7 @@ public class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContaine
|
||||||
|
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
private boolean errorToSend = false;
|
private boolean hasErrorToSend = false;
|
||||||
|
|
||||||
public ErrorWrapperResponse(HttpServletResponse response) {
|
public ErrorWrapperResponse(HttpServletResponse response) {
|
||||||
super(response);
|
super(response);
|
||||||
|
|
@ -287,25 +287,23 @@ public class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContaine
|
||||||
public void sendError(int status, String message) throws IOException {
|
public void sendError(int status, String message) throws IOException {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.errorToSend = true;
|
this.hasErrorToSend = true;
|
||||||
// Do not call super because the container may prevent us from handling the
|
// Do not call super because the container may prevent us from handling the
|
||||||
// error ourselves
|
// error ourselves
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStatus() {
|
public int getStatus() {
|
||||||
if (this.errorToSend) {
|
if (this.hasErrorToSend) {
|
||||||
return this.status;
|
return this.status;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// If there was no error we need to trust the wrapped response
|
// If there was no error we need to trust the wrapped response
|
||||||
return super.getStatus();
|
return super.getStatus();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flushBuffer() throws IOException {
|
public void flushBuffer() throws IOException {
|
||||||
if (this.errorToSend && !isCommitted()) {
|
if (this.hasErrorToSend && !isCommitted()) {
|
||||||
((HttpServletResponse) getResponse())
|
((HttpServletResponse) getResponse())
|
||||||
.sendError(this.status, this.message);
|
.sendError(this.status, this.message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ public class LoggingApplicationListener implements SmartApplicationListener {
|
||||||
return isAssignableFrom(sourceType, SOURCE_TYPES);
|
return isAssignableFrom(sourceType, SOURCE_TYPES);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAssignableFrom(Class<?> type, Class<?>[] supportedTypes) {
|
private boolean isAssignableFrom(Class<?> type, Class<?>... supportedTypes) {
|
||||||
for (Class<?> supportedType : supportedTypes) {
|
for (Class<?> supportedType : supportedTypes) {
|
||||||
if (supportedType.isAssignableFrom(type)) {
|
if (supportedType.isAssignableFrom(type)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -153,23 +153,30 @@ public class LoggingApplicationListener implements SmartApplicationListener {
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(ApplicationEvent event) {
|
public void onApplicationEvent(ApplicationEvent event) {
|
||||||
if (event instanceof ApplicationEnvironmentPreparedEvent) {
|
if (event instanceof ApplicationEnvironmentPreparedEvent) {
|
||||||
ApplicationEnvironmentPreparedEvent available = (ApplicationEnvironmentPreparedEvent) event;
|
onApplicationEnvironmentPreparedEvent((ApplicationEnvironmentPreparedEvent) event);
|
||||||
initialize(available.getEnvironment(), available.getSpringApplication()
|
|
||||||
.getClassLoader());
|
|
||||||
}
|
}
|
||||||
else if (event instanceof ApplicationStartedEvent) {
|
else if (event instanceof ApplicationStartedEvent) {
|
||||||
|
onApplicationStartedEvent((ApplicationStartedEvent) event);
|
||||||
|
}
|
||||||
|
else if (event instanceof ContextClosedEvent) {
|
||||||
|
onContextClosedEvent((ContextClosedEvent) event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onApplicationEnvironmentPreparedEvent(
|
||||||
|
ApplicationEnvironmentPreparedEvent event) {
|
||||||
|
initialize(event.getEnvironment(), event.getSpringApplication().getClassLoader());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onApplicationStartedEvent(ApplicationStartedEvent event) {
|
||||||
if (System.getProperty(PID_KEY) == null) {
|
if (System.getProperty(PID_KEY) == null) {
|
||||||
System.setProperty(PID_KEY, new ApplicationPid().toString());
|
System.setProperty(PID_KEY, new ApplicationPid().toString());
|
||||||
}
|
}
|
||||||
LoggingSystem loggingSystem = LoggingSystem.get(ClassUtils
|
LoggingSystem.get(ClassUtils.getDefaultClassLoader()).beforeInitialize();
|
||||||
.getDefaultClassLoader());
|
|
||||||
loggingSystem.beforeInitialize();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LoggingSystem loggingSystem = LoggingSystem.get(ClassUtils
|
|
||||||
.getDefaultClassLoader());
|
|
||||||
loggingSystem.cleanUp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onContextClosedEvent(ContextClosedEvent event) {
|
||||||
|
LoggingSystem.get(ClassUtils.getDefaultClassLoader()).cleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ public abstract class LoggingSystem {
|
||||||
* should override this method to perform any logging system-specific cleanup.
|
* should override this method to perform any logging system-specific cleanup.
|
||||||
*/
|
*/
|
||||||
public void cleanUp() {
|
public void cleanUp() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -55,6 +55,7 @@ import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Integration tests for {@link ErrorPageFilter}.
|
||||||
*
|
*
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
*/
|
*/
|
||||||
|
|
@ -120,6 +121,7 @@ public class ErrorPageFilterIntegrationTests {
|
||||||
public HelloWorldController helloWorldController() {
|
public HelloWorldController helloWorldController() {
|
||||||
return new HelloWorldController();
|
return new HelloWorldController();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue