pull/2707/head
Phillip Webb 10 years ago
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");
* 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");
* 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");
* 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");
* 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
`[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
`PropertiesLauncher` looks in `lib/` in your application archive by default, but you can add additional locations by
setting an environment variable `LOADER_PATH` or `loader.path` in `application.properties`
(comma-separated list of directories or archives).
`PropertiesLauncher` looks in `lib/` in your application archive by default, but you can
add additional locations by setting an environment variable `LOADER_PATH` or `loader.path`
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");
* 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());
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");
* 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.
*
* @author Phillip Webb
* @author Dave Syer
*/
public final class EmbeddedJarStarter {
@ -30,4 +30,5 @@ public final class EmbeddedJarStarter {
context.getBean(SpringConfiguration.class).run(args);
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");
* 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.
*
* @author Phillip Webb
* @author Dave Syer
*/
@Configuration
@ComponentScan
@ -48,6 +48,4 @@ public class SpringConfiguration {
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");
* 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);
}
}
catch (Exception e) {
catch (Exception ex) {
// 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");
* 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 boolean errorToSend = false;
private boolean hasErrorToSend = false;
public ErrorWrapperResponse(HttpServletResponse response) {
super(response);
@ -287,25 +287,23 @@ public class ErrorPageFilter extends AbstractConfigurableEmbeddedServletContaine
public void sendError(int status, String message) throws IOException {
this.status = status;
this.message = message;
this.errorToSend = true;
this.hasErrorToSend = true;
// Do not call super because the container may prevent us from handling the
// error ourselves
}
@Override
public int getStatus() {
if (this.errorToSend) {
if (this.hasErrorToSend) {
return this.status;
}
else {
// If there was no error we need to trust the wrapped response
return super.getStatus();
}
}
@Override
public void flushBuffer() throws IOException {
if (this.errorToSend && !isCommitted()) {
if (this.hasErrorToSend && !isCommitted()) {
((HttpServletResponse) getResponse())
.sendError(this.status, this.message);
}

@ -141,7 +141,7 @@ public class LoggingApplicationListener implements SmartApplicationListener {
return isAssignableFrom(sourceType, SOURCE_TYPES);
}
private boolean isAssignableFrom(Class<?> type, Class<?>[] supportedTypes) {
private boolean isAssignableFrom(Class<?> type, Class<?>... supportedTypes) {
for (Class<?> supportedType : supportedTypes) {
if (supportedType.isAssignableFrom(type)) {
return true;
@ -153,23 +153,30 @@ public class LoggingApplicationListener implements SmartApplicationListener {
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ApplicationEnvironmentPreparedEvent) {
ApplicationEnvironmentPreparedEvent available = (ApplicationEnvironmentPreparedEvent) event;
initialize(available.getEnvironment(), available.getSpringApplication()
.getClassLoader());
onApplicationEnvironmentPreparedEvent((ApplicationEnvironmentPreparedEvent) event);
}
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) {
System.setProperty(PID_KEY, new ApplicationPid().toString());
}
LoggingSystem loggingSystem = LoggingSystem.get(ClassUtils
.getDefaultClassLoader());
loggingSystem.beforeInitialize();
}
else {
LoggingSystem loggingSystem = LoggingSystem.get(ClassUtils
.getDefaultClassLoader());
loggingSystem.cleanUp();
LoggingSystem.get(ClassUtils.getDefaultClassLoader()).beforeInitialize();
}
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.
*/
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");
* 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;
/**
* Integration tests for {@link ErrorPageFilter}.
*
* @author Dave Syer
*/
@ -120,6 +121,7 @@ public class ErrorPageFilterIntegrationTests {
public HelloWorldController helloWorldController() {
return new HelloWorldController();
}
}
@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");
* you may not use this file except in compliance with the License.

Loading…
Cancel
Save