File tree
346 files changed
+29175
-68
lines changed- .mvn/wrapper
- appengine-java8
- analytics
- src/main
- java/com/example/appengine/analytics
- webapp/WEB-INF
- appidentity
- src
- main
- java/com/example/appengine/appidentity
- webapp/WEB-INF
- test/java/com/example/appengine/appidentity
- cloudsql
- src/main
- java/com/example/appengine/cloudsql
- webapp/WEB-INF
datastore- indexes-exploding
- src
- main
- java/com/example/appengine
- webapp/WEB-INF
- test/java/com/example/appengine
- indexes-perfect
- src
- main
- java/com/example/appengine
- webapp/WEB-INF
- test/java/com/example/appengine
- indexes
- src
- main
- java/com/example/appengine
- webapp/WEB-INF
- test/java/com/example/appengine
- src
- main
- java/com/example
- appengine
- time
- testing
- webapp
- WEB-INF
- test/java/com/example/appengine
endpoints-frameworks-v2- backend
- src/main
- java/com/example/echo
- webapp/WEB-INF
- migration-example
- gradle/wrapper
- src/main
- java/com/example/helloendpoints
- webapp
- WEB-INF
- bootstrap/css
- css
- js
firebase-event-proxy- gae-firebase-event-proxy
- src/main
- java/com/example/GaeFirebaseEventProxy
- webapp
- WEB-INF
- gae-firebase-listener-python
firebase-tictactoe- src
- main
- java/com/example/appengine/firetactoe
- webapp
- WEB-INF
- view
- static
- test/java/com/example/appengine/firetactoe
guestbook-cloud-datastore- src
- main
- java/com/example/guestbook
- webapp
- WEB-INF
- stylesheets
- test/java/com/example/guestbook
guestbook-objectify- src
- main
- java/com/example/guestbookwebapp
- WEB-INF
- stylesheets
test/java/com/example/guestbookhelloworld- src/main
- java/com/example/appengine/helloworld
- webapp/WEB-INF
images- src/main
- java/com/example/appengine/images
- webapp/WEB-INF
logs- src/main
- java/com/example/appengine/logs
- webapp/WEB-INF
mailgun- src/main
- java/com/example/appengine/mailgun
- webapp
- WEB-INF
mailjet- src/main
- java/com/example/appengine/mailjet
- webapp
- WEB-INF
mail- src/main
- java/com/example/appengine/mail
- webapp/WEB-INF
memcache- src/main
- java/com/example/appengine/memcache
- webapp/WEB-INF
multitenancy- src
- main
- java/com/example/appengine
- webapp
- WEB-INF
- stylesheets
- test/java/com/example/appengine
oauth2- src/main
- java/com/example/appengine
- webapp
- WEB-INF
remote- remote-client
- src/main/java/com/example/appengine/remote
- remote-server
- src/main
- java/com/example/appengine/remote
- webapp/WEB-INF
requests- src
- main
- java/com/example/appengine/requests
- webapp/WEB-INF
- test/java/com/example/appengine/requests
search- src
- main
- java/com/example/appengine/search
- webapp/WEB-INF
- test/java/com/example/appengine/search
sendgrid- src/main
- java/com/example/appengine/sendgrid
- webapp/WEB-INF
static-files- src/main/webapp
- WEB-INF
- stylesheets
taskqueue- deferred
- < B41A /div>src/main
- java/com/google/cloud/taskqueue/samples
- webapp
- WEB-INF
pull- src/main
- java/com/example/taskqueue
- webapp
- WEB-INF
push- src
- main
- java/com/example/appengine/taskqueue/push
- webapp
- WEB-INF
- test/java/com/example/appengine/taskqueue/push
twilio- src/main
- java/com/example/appengine/twilio
- webapp/WEB-INF
unittests- src
- main/webapp/WEB-INF
- test/java/com/google/appengine/samples
urlfetch- src/main
- java/com/example/appengine
- webapp
- WEB-INF
users- src
- main
- java/com/example/appengine/users
- webapp/WEB-INF
- test/java/com/example/appengine/users
appengine- appidentity
- src/main/webapp/WEB-INF
- channel
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.346 files changed
+29175-68lines changedLines changed: 1 addition & 1 deletionOriginal file line number Diff line number Diff line change @@ -1 +1 @@1
-
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip1
+
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zipLines changed: 101 additions & 0 deletionsOriginal file line number Diff line number Diff line change @@ -0,0 +1,101 @@1
+
# Google App Engine Standard Environment Samples for Java 82
+
3
+
This is a repository that contains Java code samples for [Google App Engine4
+
standard environment][ae-docs].5
+
6
+
[ae-docs]: https://cloud.google.com/appengine/docs/java/7
+
8
+
## Prerequisites9
+
10
+
### Download Maven11
+
12
+
These samples use the [Apache Maven][maven] build system. Before getting13
+
started, be sure to [download][maven-download] and [install][maven-install] it.14
+
When you use Maven as described here, it will automatically download the needed15
+
client libraries.16
+
17
+
[maven]: https://maven.apache.org18
+
[maven-download]: https://maven.apache.org/download.cgi19
+
[maven-install]: https://maven.apache.org/install.html20
+
21
+
### Create a Project in the Google Cloud Platform Console22
+
23
+
If you haven't already created a project, create one now. Projects enable you to24
+
manage all Google Cloud Platform resources for your app, including deployment,25
+
access control, billing, and services.26
+
27
+
1. Open the [Cloud Platform Console][cloud-console].28
+
1. In the drop-down menu at the top, select **Create a project**.29
+
1. Give your project a name.30
+
1. Make a note of the project ID, which might be different from the project31
+
name. The project ID is used in commands and in configurations.32
+
33
+
[cloud-console]: https://console.cloud.google.com/34
+
35
+
36
+
## Samples37
+
38
+
### Hello World39
+
40
+
This sample demonstrates how to deploy an application on Google App Engine.41
+
42
+
- [Documentation][ae-docs]43
+
- [Code](helloworld)44
+
45
+
### Sending Email46
+
47
+
#### Sending Email with Mailgun48
+
49
+
This sample demonstrates how to send email using the [Mailgun API][mailgun-api].50
+
51
+
- [Documentation][mailgun-sample-docs]52
+
- [Code](mailgun)53
+
54
+
[mailgun-api]: https://documentation.mailgun.com/55
+
[mailgun-sample-docs]: https://cloud.google.com/appengine/docs/java/mail/mailgun56
+
57
+
#### Sending Email with SendGrid58
+
59
+
This sample demonstrates how to send email using the [SendGrid][sendgrid].60
+
61
+
- [Documentation][sendgrid-sample-docs]62
+
- [Code](sendgrid)63
+
64
+
[sendgrid]: https://sendgrid.com/docs/User_Guide/index.html65
+
[sendgrid-sample-docs]: https://cloud.google.com/appengine/docs/java/mail/sendgrid66
+
67
+
### Sending SMS with Twilio68
+
69
+
This sample demonstrates how to use [Twilio](https://www.twilio.com) on [Google70
+
App Engine standard environment][ae-docs].71
+
72
+
- [Documentation][twilio-sample-docs]73
+
- [Code](twilio)74
+
75
+
[twilio-sample-docs]: https://cloud.google.com/appengine/docs/java/sms/twilio76
+
77
+
### App Identity78
+
79
+
This sample demonstrates how to use the [App Identity API][appid] to discover80
+
the application's ID and assert identity to Google and third-party APIs.81
+
82
+
- [Documentation][appid]83
+
- [Code](appidentity)84
+
85
+
[appid]: https://cloud.google.com/appengine/docs/java/appidentity/86
+
87
+
### Other Samples88
+
89
+
- [Sample Applications][sample-apps]90
+
91
+
[sample-apps]: https://cloud.google.com/appengine/docs/java/samples92
+
93
+
94
+
## Contributing changes95
+
96
+
See [CONTRIBUTING.md](../CONTRIBUTING.md).97
+
98
+
## Licensing99
+
100
+
See [LICENSE](../LICENSE).101
+
Lines changed: 119 additions & 0 deletionsOriginal file line number Diff line number Diff line change @@ -0,0 +1,119 @@1
+
<!--2
+
Copyright 2017 Google Inc.3
+
4
+
Licensed under the Apache License, Version 2.0 (the "License");5
+
you may not use this file except in compliance with the License.6
+
You may obtain a copy of the License at7
+
8
+
http://www.apache.org/licenses/LICENSE-2.09
+
10
+
Unles 10000 s required by applicable law or agreed to in writing, software11
+
distributed under the License is distributed on an "AS IS" BASIS,12
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13
+
See the License for the specific language governing permissions and14
+
limitations under the License.15
+
-->16
+
<project>17
+
<modelVersion>4.0.0</modelVersion>18
+
<packaging>war</packaging>19
+
<version>1.0-SNAPSHOT</version>20
+
<groupId>com.example.appengine</groupId>21
+
<artifactId>appengine-analytics-j8</artifactId>22
+
23
+
<parent>24
+
<artifactId>appengine-java8-samples</artifactId>25
+
<groupId>com.google.cloud</groupId>26
+
<version>1.0.0</version>27
+
<relativePath>..</relativePath>28
+
</parent>29
+
<!-- Parent POM defines ${appengine.sdk.version} (updates frequently). -->30
+
31
+
<properties>32
+
<maven.compiler.target>1.8</maven.compiler.target>33
+
<maven.compiler.source>1.8</maven.compiler.source>34
+
<appengine.sdk.version>1.9.52</appengine.sdk.version>35
+
</properties>36
+
37
+
<dependencies>38
+
<!-- Compile/runtime dependencies -->39
+
<dependency>40
+
<groupId>com.google.appengine</groupId>41
+
<artifactId>appengine-api-1.0-sdk</artifactId>42
+
<version>${appengine.sdk.version}</version>43
+
</dependency>44
+
45
+
<dependency>46
+
<groupId>jstl</groupId>47
+
<artifactId>jstl</artifactId>48
+
<version>1.2</version>49
+
</dependency>50
+
51
+
<dependency>52
+
<groupId>org.apache.httpcomponents</groupId>53
+
<artifactId>httpclient</artifactId>54
+
<version>4.5.3</version>55
+
</dependency>56
+
57
+
<dependency>58
+
<groupId>javax.servlet</groupId>59
+
<artifactId>javax.servlet-api</artifactId>60
+
<version>3.1.0</version>61
+
<type>jar</type>62
+
<scope>provided</scope>63
+
</dependency>64
+
65
+
<!-- Test Dependencies -->66
+
<dependency>67
+
<groupId>com.google.appengine</groupId>68
+
<artifactId>appengine-testing</artifactId>69
+
<version>${appengine.sdk.version}</version>70
+
<scope>test</scope>71
+
</dependency>72
+
<dependency>73
+
<groupId>com.google.appengine</groupId>74
+
<artifactId>appengine-api-stubs</artifactId>75
+
<version>${appengine.sdk.version}</version>76
+
<scope>test</scope>77
+
</dependency>78
+
79
+
<dependency>80
+
<groupId>junit</groupId>81
+
<artifactId>junit</artifactId>82
+
<version>4.12</version>83
+
<scope>test</scope>84
+
</dependency>85
+
<dependency>86
+
<groupId>org.mockito</groupId>87
+
<artifactId>mockito-core</artifactId>88
+
<version>2.7.22</version>89
+
<scope>test</scope>90
+
</dependency>91
+
<dependency>92
+
<groupId>com.jcabi</groupId>93
+
<artifactId>jcabi-matchers</artifactId>94
+
<version>1.4</version>95
+
</dependency>96
+
<dependency>97
+
<groupId>com.google.truth</groupId>98
+
<artifactId>truth</artifactId>99
+
<version>0.32</version>100
+
<scope>test</scope>101
+
</dependency>102
+
</dependencies>103
+
104
+
<build>105
+
<!-- for hot reload of the web application -->106
+
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>107
+
<plugins>108
+
<plugin>109
+
<groupId>com.google.cloud.tools</groupId>110
+
<artifactId>appengine-maven-plugin</artifactId>111
+
<version>1.3.1</version>112
+
<configuration>113
+
<deploy.promote>true</deploy.promote>114
+
<deploy.stopPreviousVersion>true</deploy.stopPreviousVersion>115
+
</configuration>116
+
</plugin>117
+
</plugins>118
+
</build>119
+
</project>Lines changed: 64 additions & 0 deletionsOriginal file line number Diff line number Diff line change @@ -0,0 +1,64 @@1
+
/**2
+
* Copyright 2015 Google Inc.3
+
*4
+
* Licensed under the Apache License, Version 2.0 (the "License");5
+
* you may not use this file except in compliance with the License.6
+
* You may obtain a copy of the License at7
+
*8
+
* http://www.apache.org/licenses/LICENSE-2.09
+
*10
+
* Unless required by applicable law or agreed to in writing, software11
+
* distributed under the License is distributed on an "AS IS" BASIS,12
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13
+
* See the License for the specific language governing permissions and14
+
* limitations under the License.15
+
*/16
+
17
+
package com.example.appengine.analytics;18
+
19
+
import com.google.appengine.api.urlfetch.URLFetchService;20
+
import com.google.appengine.api.urlfetch.URLFetchServiceFactory;21
+
22
+
import org.apache.http.client.utils.URIBuilder;23
+
24
+
import java.io.IOException;25
+
import java.net.URI;26
+
import java.net.URISyntaxException;27
+
import java.net.URL;28
+
29
+
import javax.servlet.ServletException;30
+
import javax.servlet.http.HttpServlet;31
+
import javax.servlet.http.HttpServletRequest;32
+
import javax.servlet.http.HttpServletResponse;33
+
34
+
// [START example]35
+
@SuppressWarnings("serial")36
+
public class AnalyticsServlet extends HttpServlet {37
+
38
+
@Override39
+
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException,40
+
ServletException {41
+
String trackingId = System.getenv("GA_TRACKING_ID");42
+
URIBuilder builder = new URIBuilder();43
+
builder.setScheme("http").setHost("www.google-analytics.com").setPath("/collect")44
+
.addParameter("v", "1") // API Version.45
+
.addParameter("tid", trackingId) // Tracking ID / Property ID.46
+
// Anonymous Client Identifier. Ideally, this should be a UUID that47
+
// is associated with particular user, device, or browser instance.48
+
.addParameter("cid", "555")49
+
.addParameter("t", "event") // Event hit type.50
+
.addParameter("ec", "example") // Event category.51
+
.addParameter("ea", "test action"); // Event action.52
+
URI uri = null;53
+
try {54
+
uri = builder.build();55
+
} catch (URISyntaxException e) {56
+
throw new ServletException("Problem building URI", e);57
+
}58
+
URLFetchService fetcher = URLFetchServiceFactory.getURLFetchService();59
+
URL url = uri.toURL();60
+
fetcher.fetch(url);61
+
resp.getWriter().println("Event tracked.");62
+
}63
+
}64
+
// [END example]Lines changed: 23 additions & 0 deletionsOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@1
+
<?xml version="1.0" encoding="utf-8"?>2
+
<!-- [START_EXCLUDE] -->3
+
<!--4
+
Copyright 2015 Google Inc.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 at8
+
http://www.apache.org/licenses/LICENSE-2.09
+
Unless required by applicable law or agreed to in writing, software10
+
distributed under the License is distributed on an "AS IS" BASIS,11
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12
+
See the License for the specific language governing permissions and13
+
limitations under the License.14
+
-->15
+
<!-- [END_EXCLUDE] -->16
+
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">17
+
<threadsafe>true</threadsafe>18
+
<runtime>java8</runtime>19
+
<env-variables>20
+
<env-var name="GA_TRACKING_ID" value="YOUR-GA-TRACKING-ID" />21
+
</env-variables>22
+
</appengine-web-app>23
+
Lines changed: 29 additions & 0 deletionsOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@1
+
<?xml version="1.0" encoding="utf-8"?>2
+
<!-- [START_EXCLUDE] -->3
+
<!--4
+
Copyright 2015 Google Inc.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 at8
+
http://www.apache.org/licenses/LICENSE-2.09
+
Unless required by applicable law or agreed to in writing, software10
+
distributed under the License is distributed on an "AS IS" BASIS,11
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12
+
See the License for the specific language governing permissions and13
+
limitations under the License.14
+
-->15
+
<!-- [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>28
+
</web-app>29
+
Lines changed: 18 additions & 0 deletionsOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@1
+
# App Identity sample for Google App Engine2
+
3
+
This sample demonstrates how to use the [App Identity API][appid] on [Google App4
+
Engine][ae-docs].5
+
6
+
[appid]: https://cloud.google.com/appengine/docs/java/appidentity/7
+
[ae-docs]: https://cloud.google.com/appengine/docs/java/8
+
9
+
## Running locally10
+
This example uses the11
+
[Maven Cloud SDK based plugin](https://cloud.google.com/appengine/docs/java/tools/using-maven).12
+
To run this sample locally:13
+
14
+
$ mvn appengine:run15
+
16
+
## Deploying17
+
18
+
$ mvn appengine:deploy
0 commit comments