Skip to content

Commit 2e4b5f5

Browse files
authored
Update folder structure for flex java 8 (#7741)
1 parent 87cd0e4 commit 2e4b5f5

File tree

132 files changed

+8170
-2
lines changed

Some content is hidden

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

132 files changed

+8170
-2
lines changed

flexible/java-11/springboot-helloworld/src/main/appengine/app.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
14+
# [START gae_flex_java11_yaml]
1515
runtime: java
1616
env: flex
1717
runtime_config:
@@ -23,3 +23,4 @@ handlers:
2323

2424
manual_scaling:
2525
instances: 1
26+
# [END gae_flex_java11_yaml]

flexible/java-17/micronaut-helloworld/src/main/appengine/app.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
14+
# [START gae_flex_java17_yaml]
1515
runtime: java
1616
env: flex
1717
runtime_config:
@@ -23,3 +23,4 @@ handlers:
2323

2424
manual_scaling:
2525
instances: 1
26+
# [END gae_flex_java17_yaml]

flexible/java-8/analytics/pom.xml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<!--
2+
Copyright 2016 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 at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
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 and
14+
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.flexible</groupId>
21+
<artifactId>flexible-analytics</artifactId>
22+
23+
<!--
24+
The parent pom defines common style checks and testing strategies for our samples.
25+
Removing or replacing it should not affect the execution of the samples in anyway.
26+
-->
27+
<parent>
28+
<groupId>com.google.cloud.samples</groupId>
29+
<artifactId>shared-configuration</artifactId>
30+
<version>1.2.0</version>
31+
</parent>
32+
33+
<properties>
34+
<maven.compiler.target>1.8</maven.compiler.target>
35+
<maven.compiler.source>1.8</maven.compiler.source>
36+
37+
<appengine.maven.plugin>2.4.3</appengine.maven.plugin>
38+
<jetty>9.4.44.v20210927</jetty>
39+
<failOnMissingWebXml>false</failOnMissingWebXml> <!-- REQUIRED -->
40+
</properties>
41+
42+
<dependencies>
43+
<dependency>
44+
<groupId>org.apache.httpcomponents</groupId>
45+
<artifactId>httpclient</artifactId>
46+
<version>4.5.13</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>javax.servlet</groupId>
50+
<artifactId>javax.servlet-api</artifactId>
51+
<version>3.1.0</version>
52+
<type>jar</type>
53+
<scope>provided</scope>
54+
</dependency>
55+
</dependencies>
56+
<build>
57+
<!-- for hot reload of the web application -->
58+
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.apache.maven.plugins</groupId>
62+
<artifactId>maven-war-plugin</artifactId>
63+
<version>3.3.2</version>
64+
</plugin>
65+
<plugin>
66+
<groupId>com.google.cloud.tools</groupId>
67+
<artifactId>appengine-maven-plugin</artifactId>
68+
<version>${appengine.maven.plugin}</version>
69+
<configuration>
70+
<projectId>GCLOUD_CONFIG</projectId>
71+
<version>GCLOUD_CONFIG</version>
72+
</configuration>
73+
</plugin>
74+
75+
<plugin>
76+
<groupId>org.eclipse.jetty</groupId>
77+
<artifactId>jetty-maven-plugin</artifactId>
78+
<version>${jetty}</version>
79+
</plugin>
80+
</plugins>
81+
</build>
82+
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2023 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# 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 and
13+
# limitations under the License.
14+
15+
runtime: java
16+
env: flex
17+
18+
handlers:
19+
- url: /.*
20+
script: this field is required, but ignored
21+
22+
# [START gae_flex_analytics_env_variables]
23+
env_variables:
24+
GA_TRACKING_ID: YOUR-GA-TRACKING-ID
25+
# [END gae_flex_analytics_env_variables]
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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 at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* 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 and
14+
* limitations under the License.
15+
*/
16+
17+
package com.example.analytics;
18+
19+
import java.io.IOException;
20+
import java.net.URI;
21+
import java.net.URISyntaxException;
22+
import javax.servlet.ServletException;
23+
import javax.servlet.annotation.WebServlet;
24+
import javax.servlet.http.HttpServlet;
25+
import javax.servlet.http.HttpServletRequest;
26+
import javax.servlet.http.HttpServletResponse;
27+
import org.apache.http.client.HttpClient;
28+
import org.apache.http.client.methods.HttpPost;
29+
import org.apache.http.client.utils.URIBuilder;
30+
import org.apache.http.impl.client.HttpClientBuilder;
31+
32+
// [START gae_flex_analytics_track_event]
33+
@SuppressWarnings("serial")
34+
@WebServlet(name = "analytics", value = "")
35+
public class AnalyticsServlet extends HttpServlet {
36+
37+
@Override
38+
public void doGet(HttpServletRequest req, HttpServletResponse resp)
39+
throws IOException, ServletException {
40+
String trackingId = System.getenv("GA_TRACKING_ID");
41+
HttpClient client = HttpClientBuilder.create().build();
42+
URIBuilder builder = new URIBuilder();
43+
builder
44+
.setScheme("http")
45+
.setHost("www.google-analytics.com")
46+
.setPath("/collect")
47+
.addParameter("v", "1") // API Version.
48+
.addParameter("tid", trackingId) // Tracking ID / Property ID.
49+
// Anonymous Client Identifier. Ideally, this should be a UUID that
50+
// is associated with particular user, device, or browser instance.
51+
.addParameter("cid", "555")
52+
.addParameter("t", "event") // Event hit type.
53+
.addParameter("ec", "example") // Event category.
54+
.addParameter("ea", "test action"); // Event action.
55+
URI uri = null;
56+
try {
57+
uri = builder.build();
58+
} catch (URISyntaxException e) {
59+
throw new ServletException("Problem building URI", e);
60+
}
61+
HttpPost request = new HttpPost(uri);
62+
client.execute(request);
63+
resp.getWriter().println("Event tracked.");
64+
}
65+
}
66+
// [END gae_flex_analytics_track_event]
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
# Example Web App Using Asynchronous Servlets #
3+
4+
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=flexible/async-rest/README.md">
5+
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
6+
7+
8+
This web app demonstrates using asynchronous servlet techniques to reduce server resources.
9+
10+
The code for this tutorial is [here](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/main/flexible/async-rest).
11+
12+
13+
## Initial Setup ##
14+
15+
First, complete the following steps:
16+
17+
- [Create your project](https://developers.google.com/appengine/docs/managed-vms/) and have it enabled for Managed VMs.
18+
- Obtain an app key for the Google Places WebService API.
19+
- Download and install [the Beta build of the Google Cloud SDK](https://developers.google.com/cloud/sdk/#Quick_Start).
20+
- Install the Cloud SDK `app-engine-java` component.
21+
- Authenticate wth the gcloud SDK: gcloud auth application-default login.
22+
- Install [Maven](http://maven.apache.org/download.cgi) if you haven't already.
23+
24+
25+
## Providing your Google Places API key ##
26+
27+
To run locally, you need to edit the pom.xml file and replace YOUR_PLACES_APP_KEY with the value of your key:
28+
29+
<places.appkey>YOUR_PLACES_APP_KEY</places.appkey>
30+
31+
To deploy to gcloud, you need to edit the src/main/appengine/app.yaml file and replace YOUR_PLACES_APP_KEY with the value of your key:
32+
33+
PLACES_APPKEY: 'YOUR_PLACES_APP_KEY'
34+
35+
36+
## Running locally without the AppEngine environment ##
37+
38+
The application does not use any AppEngine specific services, so you can run it simply on your local machine by doing:
39+
40+
mvn jetty:run
41+
42+
Go to http://localhost:8080 to see the webapp.
43+
44+
45+
## Deploying to the cloud as an AppEngine ManagedVM ##
46+
47+
To automatically stage and deploy the webapp to your project in the cloud do:
48+
49+
mvn clean package appengine:deploy
50+
51+
See here for more information on the [GCloud Maven Plugin](https://github.com/GoogleCloudPlatform/gcloud-maven-plugin).
52+

flexible/java-8/async-rest/pom.xml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright 2016 Google Inc.
4+
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+
<project>
18+
<modelVersion>4.0.0</modelVersion>
19+
<groupId>com.google.appengine.demos</groupId>
20+
<artifactId>async-rest</artifactId>
21+
<version>1.0.0-SNAPSHOT</version>
22+
<packaging>war</packaging>
23+
24+
<!--
25+
The parent pom defines common style checks and testing strategies for our samples.
26+
Removing or replacing it should not affect the execution of the samples in anyway.
27+
-->
28+
<parent>
29+
<groupId>com.google.cloud.samples</groupId>
30+
<artifactId>shared-configuration</artifactId>
31+
<version>1.2.0</version>
32+
</parent>
33+
34+
<properties>
35+
<places.appkey>YOUR_PLACES_APP_KEY</places.appkey>
36+
37+
<failOnMissingWebXml>false</failOnMissingWebXml> <!-- REQUIRED -->
38+
39+
<appengine.maven.plugin>2.4.3</appengine.maven.plugin>
40+
<jetty>9.4.44.v20210927</jetty>
41+
42+
<maven.compiler.target>1.8</maven.compiler.target>
43+
<maven.compiler.source>1.8</maven.compiler.source>
44+
</properties>
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-war-plugin</artifactId>
50+
<version>3.3.2</version>
51+
</plugin>
52+
<plugin>
53+
<groupId>org.eclipse.jetty</groupId>
54+
<artifactId>jetty-maven-plugin</artifactId>
55+
<version>${jetty}</version>
56+
<configuration>
57+
<systemProperties>
58+
<systemProperty>
59+
<name>com.google.appengine.demos.asyncrest.appKey</name>
60+
<value>${places.appkey}</value>
61+
</systemProperty>
62+
</systemProperties>
63+
</configuration>
64+
</plugin>
65+
<plugin>
66+
<groupId>com.google.cloud.tools</groupId>
67+
<artifactId>appengine-maven-plugin</artifactId>
68+
<version>${appengine.maven.plugin}</version>
69+
<configuration>
70+
<projectId>GCLOUD_CONFIG</projectId>
71+
<version>GCLOUD_CONFIG</version>
72+
</configuration>
73+
</plugin>
74+
</plugins>
75+
</build>
76+
<dependencies>
77+
<dependency>
78+
<groupId>org.eclipse.jetty</groupId>
79+
<artifactId>jetty-client</artifactId>
80+
<version>${jetty}</version>
81+
</dependency>
82+
<dependency>
83+
<groupId>org.eclipse.jetty</groupId>
84+
<artifactId>jetty-util-ajax</artifactId>
85+
<version>${jetty}</version>
86+
</dependency>
87+
<dependency>
88+
<groupId>org.eclipse.jetty</groupId>
89+
<artifactId>jetty-webapp</artifactId>
90+
<version>${jetty}</version>
91+
<scope>test</scope>
92+
</dependency>
93+
<dependency>
94+
<groupId>javax.servlet</groupId>
95+
<artifactId>javax.servlet-api</artifactId>
96+
<scope>provided</scope>
97+
<version>3.1.0</version>
98+
</dependency>
99+
</dependencies>
100+
</project>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2016 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# 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 and
13+
# limitations under the License.
14+
runtime: custom
15+
env: flex
16+
17+
handlers:
18+
- url: /.*
19+
script: this field is required, but ignored
20+
21+
22+
env_variables:
23+
PLACES_APPKEY: 'YOUR_PLACES_APP_KEY'

0 commit comments

Comments
 (0)