Skip to content

Commit

Permalink
web.xml and Annotations (#672)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
lesv authored May 22, 2017
1 parent 1053054 commit a0f38fa
Show file tree
Hide file tree
Showing 66 changed files with 459 additions and 1,338 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@
import java.net.URL;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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

@Override
Expand Down
19 changes: 7 additions & 12 deletions appengine-java8/analytics/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@
limitations under the License.
-->
<!-- [END_EXCLUDE] -->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>analytics</servlet-name>
<servlet-class>com.example.appengine.analytics.AnalyticsServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>analytics</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<welcome-file-list>
<welcome-file>analytics</welcome-file>
</welcome-file-list>
</web-app>

Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@

import java.io.IOException;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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

// [START versioned_hostnames]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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

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

private String simulateIdentityAssertion()
throws CertificateException, UnsupportedEncodingException, NoSuchAlgorithmException,
InvalidKeyException, SignatureException {
InvalidKeyException, SignatureException {
// Simulate the sending app.
String message = "abcdefg";
String message = "abcdefg " + Calendar.getInstance().getTime().toString();
byte[] blob = message.getBytes();
byte[] blobSignature = signBlob(blob);
byte[] publicCert = getPublicCertificate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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

Expand Down
35 changes: 7 additions & 28 deletions appengine-java8/appidentity/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>appidentity</servlet-name>
<servlet-class>com.example.appengine.appidentity.IdentityServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>signforapp</servlet-name>
<servlet-class>com.example.appengine.appidentity.SignForAppServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>urlshortener</servlet-name>
<servlet-class>com.example.appengine.appidentity.UrlShortenerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>appidentity</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>signforapp</servlet-name>
<url-pattern>/sign</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>urlshortener</servlet-name>
<url-pattern>/shorten</url-pattern>
</servlet-mapping>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<welcome-file-list>
<welcome-file>appidentity/identity</welcome-file>
</welcome-file-list>
</web-app>
2 changes: 1 addition & 1 deletion appengine-java8/bigtable/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ limitations under the License.
version="3.1">

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>bigtable.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>BIGTABLE_PROJECT</param-name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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

@Override
Expand Down
20 changes: 8 additions & 12 deletions appengine-java8/cloudsql/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@
limitations under the License.
-->
<!-- [END_EXCLUDE] -->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>cloudsql</servlet-name>
<servlet-class>com.example.appengine.cloudsql.CloudSqlServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>cloudsql</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<welcome-file-list>
<welcome-file>cloudsql</welcome-file>
</welcome-file-list>
</web-app>
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<servlet>
<servlet-name>indexes-servlet</servlet-name>
<servlet-class>com.example.appengine.IndexesServlet</servlet-class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<servlet>
<servlet-name>indexes-servlet</servlet-name>
<servlet-class>com.example.appengine.IndexesServlet</servlet-class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<servlet>
<servlet-name>indexes-servlet</servlet-name>
<servlet-class>com.example.appengine.IndexesServlet</servlet-class>
Expand Down
9 changes: 5 additions & 4 deletions appengine-java8/datastore/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<servlet>
<servlet-name>guestbook-strong</servlet-name>
<servlet-class>com.example.appengine.GuestbookStrongServlet</servlet-class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<!-- Wrap the backend with Endpoints Frameworks v2. -->
<servlet>
<servlet-name>EndpointsServlet</servlet-name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?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">
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--
Copyright 2017 Google Inc.
Expand All @@ -14,6 +14,11 @@ 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.
-->
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<!-- Uncomment to use Endpoints Frameworks v1.0 -->
<!--
[START appengine-endpoints]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">

<listener>
<listener-class>com.example.gaefirebaseeventproxy.ServletContextListenerImpl</listener-class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<welcome-file-list>
<welcome-file>index</welcome-file>
</welcome-file-list>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!--
Copyright 2015 Google Inc.
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.
-->
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<!-- [START standard_mappings] -->
<servlet>
<servlet-name>sign</servlet-name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!--
Copyright 2015 Google Inc.
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.
-->
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<!-- [START standard_mappings] -->
<servlet>
<servlet-name>sign</servlet-name>
Expand Down
18 changes: 0 additions & 18 deletions appengine-java8/helloworld/README.md

This file was deleted.

Loading

0 comments on commit a0f38fa

Please sign in to comment.