Skip to content

Commit a0f38fa

Browse files
authored
web.xml and Annotations (GoogleCloudPlatform#672)
* web.xml and Annotations 1. Upgrade all web.xml to 3.1 2. Add annotations 3. Hello World is old, remove this one. * Fix check style * strike unittests 1. things stopped working, so I took them out. I’ll try to put them back later, but they are just a copy from the root.
1 parent 1053054 commit a0f38fa

File tree

66 files changed

+459
-1338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+459
-1338
lines changed

appengine-java8/analytics/src/main/java/com/example/appengine/analytics/AnalyticsServlet.java

+3
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@
2727
import java.net.URL;
2828

2929
import javax.servlet.ServletException;
30+
import javax.servlet.annotation.WebServlet;
3031
import javax.servlet.http.HttpServlet;
3132
import javax.servlet.http.HttpServletRequest;
3233
import javax.servlet.http.HttpServletResponse;
3334

3435
// [START example]
3536
@SuppressWarnings("serial")
37+
@WebServlet(name = "analytics", description = "Analytics: Send Analytics Event to Google Analytics",
38+
urlPatterns = "/analytics")
3639
public class AnalyticsServlet extends HttpServlet {
3740

3841
@Override

appengine-java8/analytics/src/main/webapp/WEB-INF/web.xml

+7-12
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,12 @@
1313
limitations under the License.
1414
-->
1515
<!-- [END_EXCLUDE] -->
16-
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
17-
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
18-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
19-
version="2.5">
20-
<servlet>
21-
<servlet-name>analytics</servlet-name>
22-
<servlet-class>com.example.appengine.analytics.AnalyticsServlet</servlet-class>
23-
</servlet>
24-
<servlet-mapping>
25-
<servlet-name>analytics</servlet-name>
26-
<url-pattern>/</url-pattern>
27-
</servlet-mapping>
16+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
17+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
19+
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
20+
<welcome-file-list>
21+
<welcome-file>analytics</welcome-file>
22+
</welcome-file-list>
2823
</web-app>
2924

appengine-java8/appidentity/src/main/java/com/example/appengine/appidentity/IdentityServlet.java

+3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020

2121
import java.io.IOException;
2222

23+
import javax.servlet.annotation.WebServlet;
2324
import javax.servlet.http.HttpServlet;
2425
import javax.servlet.http.HttpServletRequest;
2526
import javax.servlet.http.HttpServletResponse;
2627

2728
@SuppressWarnings("serial")
29+
@WebServlet(name = "appidentity", description = "AppIdentity: Get the Host Name",
30+
urlPatterns = "/appidentity/identity")
2831
public class IdentityServlet extends HttpServlet {
2932

3033
// [START versioned_hostnames]

appengine-java8/appidentity/src/main/java/com/example/appengine/appidentity/SignForAppServlet.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@
3333
import java.security.cert.CertificateException;
3434
import java.security.cert.CertificateFactory;
3535
import java.util.Arrays;
36+
import java.util.Calendar;
3637
import java.util.Collection;
3738

39+
import javax.servlet.annotation.WebServlet;
3840
import javax.servlet.http.HttpServlet;
3941
import javax.servlet.http.HttpServletRequest;
4042
import javax.servlet.http.HttpServletResponse;
4143

4244
@SuppressWarnings("serial")
45+
@WebServlet(name = "signforapp", description = "AppIdentity: Sign 'abcdefg'",
46+
urlPatterns = "/appidentity/sign")
4347
public class SignForAppServlet extends HttpServlet {
4448
private final AppIdentityService appIdentity;
4549

@@ -79,9 +83,9 @@ private boolean verifySignature(byte[] blob, byte[] blobSignature, PublicKey pk)
7983

8084
private String simulateIdentityAssertion()
8185
throws CertificateException, UnsupportedEncodingException, NoSuchAlgorithmException,
82-
InvalidKeyException, SignatureException {
86+
InvalidKeyException, SignatureException {
8387
// Simulate the sending app.
84-
String message = "abcdefg";
88+
String message = "abcdefg " + Calendar.getInstance().getTime().toString();
8589
byte[] blob = message.getBytes();
8690
byte[] blobSignature = signBlob(blob);
8791
byte[] publicCert = getPublicCertificate();

appengine-java8/appidentity/src/main/java/com/example/appengine/appidentity/UrlShortenerServlet.java

+3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
import java.io.IOException;
2020
import java.io.PrintWriter;
2121

22+
import javax.servlet.annotation.WebServlet;
2223
import javax.servlet.http.HttpServlet;
2324
import javax.servlet.http.HttpServletRequest;
2425
import javax.servlet.http.HttpServletResponse;
2526

2627
@SuppressWarnings("serial")
28+
@WebServlet(name = "UrlShortener", description = "AppIdentity: Url Shortener",
29+
urlPatterns = "/appidentity/shorten")
2730
public class UrlShortenerServlet extends HttpServlet {
2831
private final UrlShortener shortener;
2932

Original file line numberDiff line numberDiff line change
@@ -1,30 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
3-
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
4-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
5-
version="2.5">
6-
<servlet>
7-
<servlet-name>appidentity</servlet-name>
8-
<servlet-class>com.example.appengine.appidentity.IdentityServlet</servlet-class>
9-
</servlet>
10-
<servlet>
11-
<servlet-name>signforapp</servlet-name>
12-
<servlet-class>com.example.appengine.appidentity.SignForAppServlet</servlet-class>
13-
</servlet>
14-
<servlet>
15-
<servlet-name>urlshortener</servlet-name>
16-
<servlet-class>com.example.appengine.appidentity.UrlShortenerServlet</servlet-class>
17-
</servlet>
18-
<servlet-mapping>
19-
<servlet-name>appidentity</servlet-name>
20-
<url-pattern>/</url-pattern>
21-
</servlet-mapping>
22-
<servlet-mapping>
23-
<servlet-name>signforapp</servlet-name>
24-
<url-pattern>/sign</url-pattern>
25-
</servlet-mapping>
26-
<servlet-mapping>
27-
<servlet-name>urlshortener</servlet-name>
28-
<url-pattern>/shorten</url-pattern>
29-
</servlet-mapping>
2+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
5+
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
6+
<welcome-file-list>
7+
<welcome-file>appidentity/identity</welcome-file>
8+
</welcome-file-list>
309
</web-app>

appengine-java8/bigtable/src/main/webapp/WEB-INF/web.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ limitations under the License.
2121
version="3.1">
2222

2323
<welcome-file-list>
24-
<welcome-file>index.jsp</welcome-file>
24+
<welcome-file>bigtable.jsp</welcome-file>
2525
</welcome-file-list>
2626
<context-param>
2727
<param-name>BIGTABLE_PROJECT</param-name>

appengine-java8/cloudsql/src/main/java/com/example/appengine/cloudsql/CloudSqlServlet.java

+3
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@
3030
import java.util.Date;
3131

3232
import javax.servlet.ServletException;
33+
import javax.servlet.annotation.WebServlet;
3334
import javax.servlet.http.HttpServlet;
3435
import javax.servlet.http.HttpServletRequest;
3536
import javax.servlet.http.HttpServletResponse;
3637

3738
// [START example]
3839
@SuppressWarnings("serial")
40+
@WebServlet(name = "CloudSQL", description = "CloudSQL: Write low order IP address to Cloud SQL",
41+
urlPatterns = "/cloudsql")
3942
public class CloudSqlServlet extends HttpServlet {
4043

4144
@Override

appengine-java8/cloudsql/src/main/webapp/WEB-INF/web.xml

+8-12
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,12 @@
1313
limitations under the License.
1414
-->
1515
<!-- [END_EXCLUDE] -->
16-
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
17-
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
18-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
19-
version="2.5">
20-
<servlet>
21-
<servlet-name>cloudsql</servlet-name>
22-
<servlet-class>com.example.appengine.cloudsql.CloudSqlServlet</servlet-class>
23-
</servlet>
24-
<servlet-mapping>
25-
<servlet-name>cloudsql</servlet-name>
26-
<url-pattern>/</url-pattern>
27-
</servlet-mapping>
16+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
17+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
19+
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
20+
version="3.1">
21+
<welcome-file-list>
22+
<welcome-file>cloudsql</welcome-file>
23+
</welcome-file-list>
2824
</web-app>

appengine-java8/datastore/indexes-exploding/src/main/webapp/WEB-INF/web.xml

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
-->
17-
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
18-
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
19-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
20-
version="2.5">
17+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
20+
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
21+
version="3.1">
2122
<servlet>
2223
<servlet-name>indexes-servlet</servlet-name>
2324
<servlet-class>com.example.appengine.IndexesServlet</servlet-class>

appengine-java8/datastore/indexes-perfect/src/main/webapp/WEB-INF/web.xml

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
-->
17-
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
18-
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
19-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
20-
version="2.5">
17+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
20+
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
21+
version="3.1">
2122
<servlet>
2223
<servlet-name>indexes-servlet</servlet-name>
2324
<servlet-class>com.example.appengine.IndexesServlet</servlet-class>

appengine-java8/datastore/indexes/src/main/webapp/WEB-INF/web.xml

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
-->
17-
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
18-
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
19-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
20-
version="2.5">
17+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
20+
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
21+
version="3.1">
2122
<servlet>
2223
<servlet-name>indexes-servlet</servlet-name>
2324
<servlet-class>com.example.appengine.IndexesServlet</servlet-class>

appengine-java8/datastore/src/main/webapp/WEB-INF/web.xml

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
-->
17-
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
18-
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
19-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
20-
version="2.5">
17+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
20+
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
21+
version="3.1">
2122
<servlet>
2223
<servlet-name>guestbook-strong</servlet-name>
2324
<servlet-class>com.example.appengine.GuestbookStrongServlet</servlet-class>

appengine-java8/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
-->
17-
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
17+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
20+
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
21+
version="3.1">
1822
<!-- Wrap the backend with Endpoints Frameworks v2. -->
1923
<servlet>
2024
<servlet-name>EndpointsServlet</servlet-name>

appengine-java8/endpoints-frameworks-v2/migration-example/src/main/webapp/WEB-INF/web.xml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8" standalone="no"?><web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
22
<!--
33
Copyright 2017 Google Inc.
44
@@ -14,6 +14,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
-->
17+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
20+
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
21+
version="3.1">
1722
<!-- Uncomment to use Endpoints Frameworks v1.0 -->
1823
<!--
1924
[START appengine-endpoints]

appengine-java8/firebase-event-proxy/gae-firebase-event-proxy/src/main/webapp/WEB-INF/web.xml

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
See the License for the specific language governing permissions and
1212
limitations under the License.
1313
-->
14-
<web-app version="2.5"
15-
xmlns="http://java.sun.com/xml/ns/javaee"
14+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
1615
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
17-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
16+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
17+
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
18+
version="3.1">
1819

1920
<listener>
2021
<listener-class>com.example.gaefirebaseeventproxy.ServletContextListenerImpl</listener-class>

appengine-java8/firebase-tictactoe/src/main/webapp/WEB-INF/web.xml

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
-->
17-
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18-
xmlns="http://java.sun.com/xml/ns/javaee"
19-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
20-
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
17+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
20+
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
21+
version="3.1">
2122
<welcome-file-list>
2223
<welcome-file>index</welcome-file>
2324
</welcome-file-list>

appengine-java8/guestbook-cloud-datastore/src/main/webapp/WEB-INF/web.xml

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
3-
xmlns="http://java.sun.com/xml/ns/javaee"
4-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
2+
<!--
3+
Copyright 2015 Google Inc.
54
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
20+
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
21+
version="3.1">
622
<!-- [START standard_mappings] -->
723
<servlet>
824
<servlet-name>sign</servlet-name>

appengine-java8/guestbook-objectify/src/main/webapp/WEB-INF/web.xml

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
2+
<!--
3+
Copyright 2015 Google Inc.
54
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
20+
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
21+
version="3.1">
622
<!-- [START standard_mappings] -->
723
<servlet>
824
<servlet-name>sign</servlet-name>

appengine-java8/helloworld/README.md

-18
This file was deleted.

0 commit comments

Comments
 (0)