From 0807c27c26e852d4ef4f9cb0106f96dc5ee9e0d1 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 24 Jan 2017 17:25:28 +0000 Subject: [PATCH] Complete removing support for Tomcat 7 Closes gh-6416 --- .../src/main/asciidoc/getting-started.adoc | 6 +- spring-boot-docs/src/main/asciidoc/howto.adoc | 51 ------- spring-boot-samples/README.adoc | 6 - spring-boot-samples/pom.xml | 2 - .../spring-boot-sample-tomcat7-jsp/pom.xml | 73 ---------- .../jsp/SampleTomcat7JspApplication.java | 36 ----- .../sample/tomcat7/jsp/WelcomeController.java | 39 ----- .../src/main/resources/application.properties | 3 - .../src/main/webapp/WEB-INF/jsp/welcome.jsp | 18 --- .../jsp/SampleWebJspApplicationTests.java | 53 ------- .../spring-boot-sample-tomcat7-ssl/pom.xml | 60 -------- .../ssl/SampleTomcatSslApplication.java | 29 ---- .../tomcat/ssl/web/SampleController.java | 32 ----- .../src/main/resources/application.properties | 4 - .../src/main/resources/sample.jks | Bin 2264 -> 0 bytes .../ssl/SampleTomcatSslApplicationTests.java | 48 ------- .../tomcat/SkipPatternJarScanner.java | 35 +---- .../TomcatEmbeddedServletContainer.java | 15 +- .../embedded/tomcat/TomcatResources.java | 135 ------------------ 19 files changed, 6 insertions(+), 639 deletions(-) delete mode 100644 spring-boot-samples/spring-boot-sample-tomcat7-jsp/pom.xml delete mode 100644 spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/java/sample/tomcat7/jsp/SampleTomcat7JspApplication.java delete mode 100644 spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/java/sample/tomcat7/jsp/WelcomeController.java delete mode 100644 spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/resources/application.properties delete mode 100644 spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/webapp/WEB-INF/jsp/welcome.jsp delete mode 100644 spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/test/java/sample/tomcat7/jsp/SampleWebJspApplicationTests.java delete mode 100644 spring-boot-samples/spring-boot-sample-tomcat7-ssl/pom.xml delete mode 100644 spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/main/java/sample/tomcat/ssl/SampleTomcatSslApplication.java delete mode 100644 spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/main/java/sample/tomcat/ssl/web/SampleController.java delete mode 100644 spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/main/resources/application.properties delete mode 100644 spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/main/resources/sample.jks delete mode 100644 spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/test/java/sample/tomcat/ssl/SampleTomcatSslApplicationTests.java delete mode 100644 spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatResources.java diff --git a/spring-boot-docs/src/main/asciidoc/getting-started.adoc b/spring-boot-docs/src/main/asciidoc/getting-started.adoc index fb7b3822f6..43874e6045 100644 --- a/spring-boot-docs/src/main/asciidoc/getting-started.adoc +++ b/spring-boot-docs/src/main/asciidoc/getting-started.adoc @@ -50,14 +50,10 @@ The following embedded servlet containers are supported out of the box: |=== |Name |Servlet Version |Java Version -|Tomcat 8 +|Tomcat 8.5 |3.1 |Java 7+ -|Tomcat 7 -|3.0 -|Java 6+ - |Jetty 9.3 |3.1 |Java 8+ diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index 59f9e56bc7..5c52110a02 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -930,57 +930,6 @@ add a listener to the `Builder`: -[[howto-use-tomcat-7]] -=== Use Tomcat 7.x or 8.0 -Tomcat 7 & 8.0 work with Spring Boot, but the default is to use Tomcat 8.5. If you cannot -use Tomcat 8.5 (for example, because you are using Java 1.6) you will need to change your -classpath to reference a different version. - - - -[[howto-use-tomcat-7-maven]] -==== Use Tomcat 7.x or 8.0 with Maven -If you are using the starters and parent you can change the Tomcat version property -and additionally import `tomcat-juli`. E.g. for a simple webapp or service: - -[source,xml,indent=0,subs="verbatim,quotes,attributes"] ----- - - 7.0.59 - - - ... - - org.springframework.boot - spring-boot-starter-web - - - org.apache.tomcat - tomcat-juli - ${tomcat.version} - - ... - ----- - - - -==== Use Tomcat 7.x or 8.0 with Gradle -[[howto-use-tomcat-7-gradle]] -With Gradle, you can change the Tomcat version by setting the `tomcat.version` property -and then additionally include `tomcat-juli`: - -[source,groovy,indent=0,subs="verbatim,quotes,attributes"] ----- - ext['tomcat.version'] = '7.0.59' - dependencies { - compile 'org.springframework.boot:spring-boot-starter-web' - compile group:'org.apache.tomcat', name:'tomcat-juli', version:property('tomcat.version') - } ----- - - - [[howto-use-jetty-9.2]] === Use Jetty 9.2 Jetty 9.2 works with Spring Boot, but the default is to use Jetty 9.3. If you cannot use diff --git a/spring-boot-samples/README.adoc b/spring-boot-samples/README.adoc index a441fd8b8d..fbc9704a6b 100644 --- a/spring-boot-samples/README.adoc +++ b/spring-boot-samples/README.adoc @@ -207,12 +207,6 @@ The following sample applications are provided: | link:spring-boot-sample-tomcat-ssl[spring-boot-sample-tomcat-ssl] | Web application that uses Tomcat configured with SSL -| link:spring-boot-sample-tomcat7-jsp[spring-boot-sample-tomcat7-jsp] -| Web application that uses JSP templates with Tomcat 7 - -| link:spring-boot-sample-tomcat7-ssl[spring-boot-sample-tomcat7-ssl] -| Web application that uses Tomcat 7 configured with SSL - | link:spring-boot-sample-tomcat80-ssl[spring-boot-sample-tomcat80-ssl] | Web application that uses Tomcat 8.0 configured with SSL diff --git a/spring-boot-samples/pom.xml b/spring-boot-samples/pom.xml index e7104b3362..478991b99f 100644 --- a/spring-boot-samples/pom.xml +++ b/spring-boot-samples/pom.xml @@ -89,8 +89,6 @@ spring-boot-sample-tomcat-jsp spring-boot-sample-tomcat-ssl spring-boot-sample-tomcat-multi-connectors - spring-boot-sample-tomcat7-jsp - spring-boot-sample-tomcat7-ssl spring-boot-sample-tomcat80-ssl spring-boot-sample-traditional spring-boot-sample-undertow diff --git a/spring-boot-samples/spring-boot-sample-tomcat7-jsp/pom.xml b/spring-boot-samples/spring-boot-sample-tomcat7-jsp/pom.xml deleted file mode 100644 index 706f544eb2..0000000000 --- a/spring-boot-samples/spring-boot-sample-tomcat7-jsp/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - 4.0.0 - - - org.springframework.boot - spring-boot-samples - 2.0.0.BUILD-SNAPSHOT - - spring-boot-sample-tomcat7-jsp - war - Spring Boot Tomcat 7 JSP Sample - Spring Boot Tomcat 7 JSP Sample - http://projects.spring.io/spring-boot/ - - Pivotal Software, Inc. - http://www.spring.io - - - ${basedir}/../.. - / - 7.0.59 - - - - - org.springframework.boot - spring-boot-starter-web - - - javax.servlet - jstl - - - - org.springframework.boot - spring-boot-starter-tomcat - provided - - - org.apache.tomcat - tomcat-juli - ${tomcat.version} - provided - - - org.apache.tomcat.embed - tomcat-embed-jasper - provided - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - false - - - - - diff --git a/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/java/sample/tomcat7/jsp/SampleTomcat7JspApplication.java b/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/java/sample/tomcat7/jsp/SampleTomcat7JspApplication.java deleted file mode 100644 index bb13733f99..0000000000 --- a/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/java/sample/tomcat7/jsp/SampleTomcat7JspApplication.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2012-2016 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.tomcat7.jsp; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.support.SpringBootServletInitializer; - -@SpringBootApplication -public class SampleTomcat7JspApplication extends SpringBootServletInitializer { - - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(SampleTomcat7JspApplication.class); - } - - public static void main(String[] args) throws Exception { - SpringApplication.run(SampleTomcat7JspApplication.class, args); - } - -} diff --git a/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/java/sample/tomcat7/jsp/WelcomeController.java b/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/java/sample/tomcat7/jsp/WelcomeController.java deleted file mode 100644 index 7f32d43556..0000000000 --- a/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/java/sample/tomcat7/jsp/WelcomeController.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2012-2016 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.tomcat7.jsp; - -import java.util.Date; -import java.util.Map; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; - -@Controller -public class WelcomeController { - - @Value("${application.message:Hello World}") - private String message = "Hello World"; - - @GetMapping("/") - public String welcome(Map model) { - model.put("time", new Date()); - model.put("message", this.message); - return "welcome"; - } - -} diff --git a/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/resources/application.properties deleted file mode 100644 index 2af7f6e200..0000000000 --- a/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/resources/application.properties +++ /dev/null @@ -1,3 +0,0 @@ -spring.mvc.view.prefix: /WEB-INF/jsp/ -spring.mvc.view.suffix: .jsp -application.message: Hello Phil \ No newline at end of file diff --git a/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/webapp/WEB-INF/jsp/welcome.jsp b/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/webapp/WEB-INF/jsp/welcome.jsp deleted file mode 100644 index 3196dac625..0000000000 --- a/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/webapp/WEB-INF/jsp/welcome.jsp +++ /dev/null @@ -1,18 +0,0 @@ - - -<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> - - - - - - - Spring URL: ${springUrl} at ${time} -
- JSTL URL: ${url} -
- Message: ${message} - - - diff --git a/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/test/java/sample/tomcat7/jsp/SampleWebJspApplicationTests.java b/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/test/java/sample/tomcat7/jsp/SampleWebJspApplicationTests.java deleted file mode 100644 index a112afcde7..0000000000 --- a/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/test/java/sample/tomcat7/jsp/SampleWebJspApplicationTests.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2012-2016 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.tomcat7.jsp; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Basic integration tests for JSP application. - * - * @author Phillip Webb - */ -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DirtiesContext -public class SampleWebJspApplicationTests { - - @Autowired - private TestRestTemplate restTemplate; - - @Test - public void testJspWithEl() throws Exception { - ResponseEntity entity = this.restTemplate.getForEntity("/", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(entity.getBody()).contains("/resources/text.txt"); - } - -} diff --git a/spring-boot-samples/spring-boot-sample-tomcat7-ssl/pom.xml b/spring-boot-samples/spring-boot-sample-tomcat7-ssl/pom.xml deleted file mode 100644 index ae2d300fe7..0000000000 --- a/spring-boot-samples/spring-boot-sample-tomcat7-ssl/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - 4.0.0 - - - org.springframework.boot - spring-boot-samples - 2.0.0.BUILD-SNAPSHOT - - spring-boot-sample-tomcat7-ssl - Spring Boot Tomcat 7 SSL Sample - Spring Boot Tomcat 7 SSL Sample - http://projects.spring.io/spring-boot/ - - Pivotal Software, Inc. - http://www.spring.io - - - ${basedir}/../.. - 7.0.69 - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-tomcat - - - org.springframework - spring-webmvc - - - org.apache.httpcomponents - httpclient - - - org.apache.tomcat - tomcat-juli - ${tomcat.version} - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/main/java/sample/tomcat/ssl/SampleTomcatSslApplication.java b/spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/main/java/sample/tomcat/ssl/SampleTomcatSslApplication.java deleted file mode 100644 index c801ea33d0..0000000000 --- a/spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/main/java/sample/tomcat/ssl/SampleTomcatSslApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2012-2016 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.tomcat.ssl; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class SampleTomcatSslApplication { - - public static void main(String[] args) throws Exception { - SpringApplication.run(SampleTomcatSslApplication.class, args); - } - -} diff --git a/spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/main/java/sample/tomcat/ssl/web/SampleController.java b/spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/main/java/sample/tomcat/ssl/web/SampleController.java deleted file mode 100644 index 7ca0d5ed01..0000000000 --- a/spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/main/java/sample/tomcat/ssl/web/SampleController.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2012-2016 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.tomcat.ssl.web; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class SampleController { - - @GetMapping("/") - @ResponseBody - public String helloWorld() { - return "Hello, world"; - } - -} diff --git a/spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/main/resources/application.properties deleted file mode 100644 index 37199bfd25..0000000000 --- a/spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/main/resources/application.properties +++ /dev/null @@ -1,4 +0,0 @@ -server.port = 8443 -server.ssl.key-store = classpath:sample.jks -server.ssl.key-store-password = secret -server.ssl.key-password = password diff --git a/spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/main/resources/sample.jks b/spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/main/resources/sample.jks deleted file mode 100644 index 6aa9a28053a591e41453e665e5024e8a8cb78b3d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2264 zcmchYX*3iJ7sqE|hQS!q5Mv)4GM2$i#uAFqC`%7x7baWA*i&dRX>3`uq(XS?3XSYp z%38`&ib7E$8j~$cF^}gt?|I+noW8#w?uYxk=iGD8|K9Vzd#pVc0002(2k@T|2@MMI zqxqr2AhQO*TVi`j@((S;e;g;l$#dAA{>vf0kX$R(Qn4oKgGEYjZ5zti2dw?Z6A zh%LuFCNI?9o+Z1duJL-++e#cjO`zlK?u9s030=k_*wD1#-$FbIDRDnA^vo@fm( zzjt(3VJrGOr0iHXSTM|rYN#>RZ@Dp`PwB2zrDQffLvuoR2~V3ReYa0&vU^dXd8isV zsAf*@!8s%xBvHLseXn6f?1kefe(8uAmAbaF$x{Ykzb6c6jdUwY1$y4tFzsj7 zIghr!T#ODfu@Po!a29@kXQ8kY#(LE<0o7?7PQ|eMeY@Equ?R-6*f@Na3o&stDQ=6( zQzDSQhCnS(9Bu9W_~giknP0vECqUsr4_9y_}nEU`cy z4}dApnAip92wMwgzciAFpc3i}+-#Zlq+iF7d1y}d4Qsp8=%l1N8NIs161I`HmkcpQ zY4*CUCFJJf(2!M{`&qQ}3($KeTQ=)mMrBs`DOb;%Of0tC)9he_p~w&CO#DfCgx(%s z{@|D(brX_Gb}ZDLmGej*JgEl0Et>q~kgTXuJg-PwvRjNx8sBbIShxD=xOySzw{;^X zAvrh5HTg>Xq@<{#^!Kg}B?qz@b<{ebD)yaSf&RChBIJQo-?Ahzw@qopSe^e&>^IuU zydM4Y1_C&>k7u|}=; z63R7$H6zat=hNExxEwXu1fQ*ytuEkP!{w{|#6TIEq1#*ck=6_NM*ILF65tmD-O5&R zMI!-MT<3U~t@}(CN4@RlZ~1I>C=!ywF)dNI{VvH;5Y3(Z4jY^%_c&fsm4Q`<1g|qX z&!h29jXjVE3nJnet*L)XL?-8<>qDbVGP%i^NwOZfwWO7?Mr!X7 zl}sG@9S_5}}td}$xrWIYY=e(VVBiv%A+M-{M z!3_^Tc=pV?niT!{D`!{e@W;MvrZ(OER{x7itVAtwE~spPtPtma|J=5dv&_oE!5H#` zdgXJ;+gJ4hI}*9QX9jpL`Gb)yCe%1}t!&O-^sihyZys%%5uF~WhsR_w(q7;vV5d4P zr%ZUA2}kO+L^2ePTgGT9Ua71w<+)poSyjTdLq&xbUn`<6&SpwFp(HRHUyU6J3WZ_! zfztko79+94Tq%mTYj53(RYcL&1~5`I#+w3`(Q|r+P(aT z%?r(^?IWw~19CB&uvXf(f7&BnEE{zwK4piVU`I4j1j?v5d4N<7VUJ8nM`$7S*mfKR z#9-JzPRZ?{M!@L+0N^V)IyeeP2T|^UK|m0QD+Ibs!wEoml^N!YO#vW~j~jraX(0A3 z6Kux?IRLez`O^X;{!4g%BhcRn>^H*qKZ3*|{_YGuz)KCJcu;)DSES5D2tDE`C02YR0R%Vy1T7k|RQ;3g<0icA$AuP0pOvc~jGl zz+NeKv_FT_;GWK&8XlDUv&hv9kxg?@c!bu?83i=YQ$S!K09Y)Glg3Hz?@|)ZCBlVz zP8i}#XZkMoje3I=h&I!!s_m?Qi@1MR`yv7X*yEs47qOs^t^?&=;*IQ!q&)gq_Sx5* z?fhU8Q*PSe*w7y)FH#P!9R^Xw!lTT+zI39L<&8cViaj$A(Z2Cg7!{V?uuyi#vlNCg z40i}2ivw&y&1-&Nh&WMG`&aIt>)(#tKTJ}^@696Kw1-{IzSOTnFF+0@k$o3%ZHS;Q#;t diff --git a/spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/test/java/sample/tomcat/ssl/SampleTomcatSslApplicationTests.java b/spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/test/java/sample/tomcat/ssl/SampleTomcatSslApplicationTests.java deleted file mode 100644 index 81856affbb..0000000000 --- a/spring-boot-samples/spring-boot-sample-tomcat7-ssl/src/test/java/sample/tomcat/ssl/SampleTomcatSslApplicationTests.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012-2016 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.tomcat.ssl; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@DirtiesContext -public class SampleTomcatSslApplicationTests { - - @Autowired - private TestRestTemplate restTemplate; - - @Test - public void testHome() throws Exception { - ResponseEntity entity = this.restTemplate.getForEntity("/", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(entity.getBody()).isEqualTo("Hello, world"); - } - -} diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/SkipPatternJarScanner.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/SkipPatternJarScanner.java index 6e3343e508..6b555df41d 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/SkipPatternJarScanner.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/SkipPatternJarScanner.java @@ -23,7 +23,6 @@ import org.apache.tomcat.util.scan.StandardJarScanFilter; import org.apache.tomcat.util.scan.StandardJarScanner; import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; /** @@ -37,24 +36,15 @@ import org.springframework.util.StringUtils; */ class SkipPatternJarScanner extends StandardJarScanner { - private static final String JAR_SCAN_FILTER_CLASS = "org.apache.tomcat.JarScanFilter"; - private final JarScanner jarScanner; - private final Set patterns; - SkipPatternJarScanner(JarScanner jarScanner, Set patterns) { Assert.notNull(jarScanner, "JarScanner must not be null"); Assert.notNull(jarScanner, "Patterns must not be null"); this.jarScanner = jarScanner; - this.patterns = patterns; - setPatternToTomcat8SkipFilter(); - } - - private void setPatternToTomcat8SkipFilter() { - if (ClassUtils.isPresent(JAR_SCAN_FILTER_CLASS, null)) { - new Tomcat8TldSkipSetter(this).setSkipPattern(this.patterns); - } + StandardJarScanFilter filter = new StandardJarScanFilter(); + filter.setTldSkip(StringUtils.collectionToCommaDelimitedString(patterns)); + this.jarScanner.setJarScanFilter(filter); } /** @@ -68,23 +58,4 @@ class SkipPatternJarScanner extends StandardJarScanner { context.setJarScanner(scanner); } - /** - * Tomcat 8 specific logic to setup the scanner. - */ - private static class Tomcat8TldSkipSetter { - - private final StandardJarScanner jarScanner; - - Tomcat8TldSkipSetter(StandardJarScanner jarScanner) { - this.jarScanner = jarScanner; - } - - public void setSkipPattern(Set patterns) { - StandardJarScanFilter filter = new StandardJarScanFilter(); - filter.setTldSkip(StringUtils.collectionToCommaDelimitedString(patterns)); - this.jarScanner.setJarScanFilter(filter); - } - - } - } diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainer.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainer.java index ac82e37b27..93fe10e467 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainer.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainer.java @@ -100,7 +100,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer Context context = findContext(); try { - ContextBindings.bindClassLoader(context, getNamingToken(context), + ContextBindings.bindClassLoader(context, context.getNamingToken(), getClass().getClassLoader()); } catch (NamingException ex) { @@ -194,7 +194,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer } finally { Context context = findContext(); - ContextBindings.unbindClassLoader(context, getNamingToken(context), + ContextBindings.unbindClassLoader(context, context.getNamingToken(), getClass().getClassLoader()); } } @@ -317,15 +317,4 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer return this.tomcat; } - private Object getNamingToken(Context context) { - try { - return context.getNamingToken(); - } - catch (NoSuchMethodError ex) { - // Use the context itself on Tomcat 7 - return context; - } - - } - } diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatResources.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatResources.java deleted file mode 100644 index 57372769db..0000000000 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatResources.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2012-2016 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 org.springframework.boot.context.embedded.tomcat; - -import java.io.File; -import java.net.URL; -import java.net.URLClassLoader; - -import org.apache.catalina.Context; -import org.apache.catalina.WebResourceRoot.ResourceSetType; - -/** - * Abstraction to add resources that works with Tomcat 8. - * - * @author Dave Syer - * @author Phillip Webb - */ -abstract class TomcatResources { - - private final Context context; - - TomcatResources(Context context) { - this.context = context; - } - - /** - * Add resources from the classpath. - */ - public void addClasspathResources() { - ClassLoader loader = getClass().getClassLoader(); - if (loader instanceof URLClassLoader) { - for (URL url : ((URLClassLoader) loader).getURLs()) { - String file = url.getFile(); - if (file.endsWith(".jar") || file.endsWith(".jar!/")) { - String jar = url.toString(); - if (!jar.startsWith("jar:")) { - // A jar file in the file system. Convert to Jar URL. - jar = "jar:" + jar + "!/"; - } - addJar(jar); - } - else if (url.toString().startsWith("file:")) { - String dir = url.toString().substring("file:".length()); - if (new File(dir).isDirectory()) { - addDir(dir, url); - } - } - } - } - } - - protected final Context getContext() { - return this.context; - } - - /** - * Called to add a JAR to the resources. - * @param jar the URL spec for the jar - */ - protected abstract void addJar(String jar); - - /** - * Called to add a dir to the resource. - * @param dir the dir - * @param url the URL - */ - protected abstract void addDir(String dir, URL url); - - /** - * Return a {@link TomcatResources} instance for the currently running Tomcat version. - * @param context the tomcat context - * @return a {@link TomcatResources} instance. - */ - public static TomcatResources get(Context context) { - return new Tomcat8Resources(context); - } - - /** - * {@link TomcatResources} for Tomcat 8. - */ - static class Tomcat8Resources extends TomcatResources { - - Tomcat8Resources(Context context) { - super(context); - } - - @Override - protected void addJar(String jar) { - addResourceSet(jar); - } - - @Override - protected void addDir(String dir, URL url) { - addResourceSet(url.toString()); - } - - private void addResourceSet(String resource) { - try { - if (isInsideNestedJar(resource)) { - // It's a nested jar but we now don't want the suffix because Tomcat - // is going to try and locate it as a root URL (not the resource - // inside it) - resource = resource.substring(0, resource.length() - 2); - } - URL url = new URL(resource); - String path = "/META-INF/resources"; - getContext().getResources().createWebResourceSet( - ResourceSetType.RESOURCE_JAR, "/", url, path); - } - catch (Exception ex) { - // Ignore (probably not a directory) - } - } - - private boolean isInsideNestedJar(String dir) { - return dir.indexOf("!/") < dir.lastIndexOf("!/"); - } - - } - -}