Merge remote-tracking branch 'springsource/1.2.x'

pull/4219/head
Phillip Webb 9 years ago
commit 5392c0a52b

@ -87,6 +87,7 @@
<module>spring-boot-sample-undertow</module> <module>spring-boot-sample-undertow</module>
<module>spring-boot-sample-undertow-ssl</module> <module>spring-boot-sample-undertow-ssl</module>
<module>spring-boot-sample-velocity</module> <module>spring-boot-sample-velocity</module>
<module>spring-boot-sample-war</module>
<module>spring-boot-sample-web-freemarker</module> <module>spring-boot-sample-web-freemarker</module>
<module>spring-boot-sample-web-groovy-templates</module> <module>spring-boot-sample-web-groovy-templates</module>
<module>spring-boot-sample-web-method-security</module> <module>spring-boot-sample-web-method-security</module>

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<!-- Your own application should inherit from spring-boot-starter-parent -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-samples</artifactId>
<version>1.2.7.BUILD-SNAPSHOT</version>
</parent>
<artifactId>spring-boot-sample-war</artifactId>
<packaging>war</packaging>
<name>Spring Boot War Sample</name>
<description>Spring Boot War Sample</description>
<url>http://projects.spring.io/spring-boot/</url>
<organization>
<name>Pivotal Software, Inc.</name>
<url>http://www.spring.io</url>
</organization>
<properties>
<main.basedir>${basedir}/../..</main.basedir>
<m2eclipse.wtp.contextRoot>/</m2eclipse.wtp.contextRoot>
</properties>
<dependencies>
<!-- Compile -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>tomcat</id>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>jetty</id>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>undertow</id>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>

@ -0,0 +1,30 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample.war;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class MyController {
@RequestMapping("/")
public String hello() {
return "Hello World!";
}
}

@ -0,0 +1,33 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sample.war;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.web.SpringBootServletInitializer;
/**
* Sample WAR application
*/
@SpringBootApplication
public class SampleWarApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(SampleWarApplication.class, args);
}
}

@ -95,6 +95,10 @@ public abstract class AbstractEmbeddedServletContainerFactory
return null; return null;
} }
private File getWarFileDocumentRoot() {
return getArchiveFileDocumentRoot(".war");
}
private File getArchiveFileDocumentRoot(String extension) { private File getArchiveFileDocumentRoot(String extension) {
File file = getCodeSourceArchive(); File file = getCodeSourceArchive();
if (this.logger.isDebugEnabled()) { if (this.logger.isDebugEnabled()) {
@ -107,10 +111,6 @@ public abstract class AbstractEmbeddedServletContainerFactory
return null; return null;
} }
private File getWarFileDocumentRoot() {
return getArchiveFileDocumentRoot(".war");
}
private File getCommonDocumentRoot() { private File getCommonDocumentRoot() {
for (String commonDocRoot : COMMON_DOC_ROOTS) { for (String commonDocRoot : COMMON_DOC_ROOTS) {
File root = new File(commonDocRoot); File root = new File(commonDocRoot);

@ -64,7 +64,6 @@ import io.undertow.server.HttpHandler;
import io.undertow.server.handlers.accesslog.AccessLogHandler; import io.undertow.server.handlers.accesslog.AccessLogHandler;
import io.undertow.server.handlers.accesslog.AccessLogReceiver; import io.undertow.server.handlers.accesslog.AccessLogReceiver;
import io.undertow.server.handlers.accesslog.DefaultAccessLogReceiver; import io.undertow.server.handlers.accesslog.DefaultAccessLogReceiver;
import io.undertow.server.handlers.resource.ClassPathResourceManager;
import io.undertow.server.handlers.resource.FileResourceManager; import io.undertow.server.handlers.resource.FileResourceManager;
import io.undertow.server.handlers.resource.Resource; import io.undertow.server.handlers.resource.Resource;
import io.undertow.server.handlers.resource.ResourceChangeListener; import io.undertow.server.handlers.resource.ResourceChangeListener;
@ -372,10 +371,12 @@ public class UndertowEmbeddedServletContainerFactory
private void configureAccessLog(DeploymentInfo deploymentInfo) { private void configureAccessLog(DeploymentInfo deploymentInfo) {
deploymentInfo.addInitialHandlerChainWrapper(new HandlerWrapper() { deploymentInfo.addInitialHandlerChainWrapper(new HandlerWrapper() {
@Override @Override
public HttpHandler wrap(HttpHandler handler) { public HttpHandler wrap(HttpHandler handler) {
return createAccessLogHandler(handler); return createAccessLogHandler(handler);
} }
}); });
} }
@ -433,10 +434,7 @@ public class UndertowEmbeddedServletContainerFactory
if (root != null && root.isFile()) { if (root != null && root.isFile()) {
return new JarResourcemanager(root); return new JarResourcemanager(root);
} }
if (this.resourceLoader != null) { return ResourceManager.EMPTY_RESOURCE_MANAGER;
return new ClassPathResourceManager(this.resourceLoader.getClassLoader(), "");
}
return new ClassPathResourceManager(getClass().getClassLoader(), "");
} }
private void configureErrorPages(DeploymentInfo servletBuilder) { private void configureErrorPages(DeploymentInfo servletBuilder) {

@ -513,6 +513,17 @@ public abstract class AbstractEmbeddedServletContainerFactoryTests {
assertThat(getJspServlet(), is(nullValue())); assertThat(getJspServlet(), is(nullValue()));
} }
@Test
public void cannotReadClassPathFiles() throws Exception {
AbstractEmbeddedServletContainerFactory factory = getFactory();
this.container = factory
.getEmbeddedServletContainer(exampleServletRegistration());
this.container.start();
ClientHttpResponse response = getClientResponse(
getLocalUrl("/org/springframework/boot/SpringApplication.class"));
assertThat(response.getStatusCode(), equalTo(HttpStatus.NOT_FOUND));
}
private Ssl getSsl(ClientAuth clientAuth, String keyPassword, String keyStore) { private Ssl getSsl(ClientAuth clientAuth, String keyPassword, String keyStore) {
return getSsl(clientAuth, keyPassword, keyStore, null); return getSsl(clientAuth, keyPassword, keyStore, null);
} }

Loading…
Cancel
Save