-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Update folder structure for flex java 8 #7741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<!-- | ||
Copyright 2016 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. | ||
--> | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<packaging>war</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
<groupId>com.example.flexible</groupId> | ||
<artifactId>flexible-analytics</artifactId> | ||
|
||
<!-- | ||
The parent pom defines common style checks and testing strategies for our samples. | ||
Removing or replacing it should not affect the execution of the samples in anyway. | ||
--> | ||
<parent> | ||
<groupId>com.google.cloud.samples</groupId> | ||
<artifactId>shared-configuration</artifactId> | ||
<version>1.2.0</version> | ||
</parent> | ||
|
||
<properties> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
|
||
<appengine.maven.plugin>2.4.3</appengine.maven.plugin> | ||
<jetty>9.4.44.v20210927</jetty> | ||
<failOnMissingWebXml>false</failOnMissingWebXml> <!-- REQUIRED --> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<version>4.5.13</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<version>3.1.0</version> | ||
<type>jar</type> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<!-- for hot reload of the web application --> | ||
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<version>3.3.2</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.google.cloud.tools</groupId> | ||
<artifactId>appengine-maven-plugin</artifactId> | ||
<version>${appengine.maven.plugin}</version> | ||
<configuration> | ||
<projectId>GCLOUD_CONFIG</projectId> | ||
<version>GCLOUD_CONFIG</version> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-maven-plugin</artifactId> | ||
<version>${jetty}</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2023 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. | ||
|
||
runtime: java | ||
env: flex | ||
|
||
handlers: | ||
- url: /.* | ||
script: this field is required, but ignored | ||
|
||
# [START gae_flex_analytics_env_variables] | ||
env_variables: | ||
GA_TRACKING_ID: YOUR-GA-TRACKING-ID | ||
# [END gae_flex_analytics_env_variables] |
66 changes: 66 additions & 0 deletions
66
flexible/java-8/analytics/src/main/java/com/example/analytics/AnalyticsServlet.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package com.example.analytics; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import org.apache.http.client.HttpClient; | ||
import org.apache.http.client.methods.HttpPost; | ||
import org.apache.http.client.utils.URIBuilder; | ||
import org.apache.http.impl.client.HttpClientBuilder; | ||
|
||
// [START gae_flex_analytics_track_event] | ||
@SuppressWarnings("serial") | ||
@WebServlet(name = "analytics", value = "") | ||
public class AnalyticsServlet extends HttpServlet { | ||
|
||
@Override | ||
public void doGet(HttpServletRequest req, HttpServletResponse resp) | ||
throws IOException, ServletException { | ||
String trackingId = System.getenv("GA_TRACKING_ID"); | ||
HttpClient client = HttpClientBuilder.create().build(); | ||
URIBuilder builder = new URIBuilder(); | ||
builder | ||
.setScheme("http") | ||
.setHost("www.google-analytics.com") | ||
.setPath("/collect") | ||
.addParameter("v", "1") // API Version. | ||
.addParameter("tid", trackingId) // Tracking ID / Property ID. | ||
// Anonymous Client Identifier. Ideally, this should be a UUID that | ||
// is associated with particular user, device, or browser instance. | ||
.addParameter("cid", "555") | ||
.addParameter("t", "event") // Event hit type. | ||
.addParameter("ec", "example") // Event category. | ||
.addParameter("ea", "test action"); // Event action. | ||
URI uri = null; | ||
try { | ||
uri = builder.build(); | ||
} catch (URISyntaxException e) { | ||
throw new ServletException("Problem building URI", e); | ||
} | ||
HttpPost request = new HttpPost(uri); | ||
client.execute(request); | ||
resp.getWriter().println("Event tracked."); | ||
} | ||
} | ||
// [END gae_flex_analytics_track_event] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
# Example Web App Using Asynchronous Servlets # | ||
|
||
<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"> | ||
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a> | ||
|
||
|
||
This web app demonstrates using asynchronous servlet techniques to reduce server resources. | ||
|
||
The code for this tutorial is [here](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/main/flexible/async-rest). | ||
|
||
|
||
## Initial Setup ## | ||
|
||
First, complete the following steps: | ||
|
||
- [Create your project](https://developers.google.com/appengine/docs/managed-vms/) and have it enabled for Managed VMs. | ||
- Obtain an app key for the Google Places WebService API. | ||
- Download and install [the Beta build of the Google Cloud SDK](https://developers.google.com/cloud/sdk/#Quick_Start). | ||
- Install the Cloud SDK `app-engine-java` component. | ||
- Authenticate wth the gcloud SDK: gcloud auth application-default login. | ||
- Install [Maven](http://maven.apache.org/download.cgi) if you haven't already. | ||
|
||
|
||
## Providing your Google Places API key ## | ||
|
||
To run locally, you need to edit the pom.xml file and replace YOUR_PLACES_APP_KEY with the value of your key: | ||
|
||
<places.appkey>YOUR_PLACES_APP_KEY</places.appkey> | ||
|
||
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: | ||
|
||
PLACES_APPKEY: 'YOUR_PLACES_APP_KEY' | ||
|
||
|
||
## Running locally without the AppEngine environment ## | ||
|
||
The application does not use any AppEngine specific services, so you can run it simply on your local machine by doing: | ||
|
||
mvn jetty:run | ||
|
||
Go to http://localhost:8080 to see the webapp. | ||
|
||
|
||
## Deploying to the cloud as an AppEngine ManagedVM ## | ||
|
||
To automatically stage and deploy the webapp to your project in the cloud do: | ||
|
||
mvn clean package appengine:deploy | ||
|
||
See here for more information on the [GCloud Maven Plugin](https://github.com/GoogleCloudPlatform/gcloud-maven-plugin). | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2016 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. | ||
--> | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.google.appengine.demos</groupId> | ||
<artifactId>async-rest</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<packaging>war</packaging> | ||
|
||
<!-- | ||
The parent pom defines common style checks and testing strategies for our samples. | ||
Removing or replacing it should not affect the execution of the samples in anyway. | ||
--> | ||
<parent> | ||
<groupId>com.google.cloud.samples</groupId> | ||
<artifactId>shared-configuration</artifactId> | ||
<version>1.2.0</version> | ||
</parent> | ||
|
||
<properties> | ||
<places.appkey>YOUR_PLACES_APP_KEY</places.appkey> | ||
|
||
<failOnMissingWebXml>false</failOnMissingWebXml> <!-- REQUIRED --> | ||
|
||
<appengine.maven.plugin>2.4.3</appengine.maven.plugin> | ||
<jetty>9.4.44.v20210927</jetty> | ||
|
||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<version>3.3.2</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-maven-plugin</artifactId> | ||
<version>${jetty}</version> | ||
<configuration> | ||
<systemProperties> | ||
<systemProperty> | ||
<name>com.google.appengine.demos.asyncrest.appKey</name> | ||
<value>${places.appkey}</value> | ||
</systemProperty> | ||
</systemProperties> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.google.cloud.tools</groupId> | ||
<artifactId>appengine-maven-plugin</artifactId> | ||
<version>${appengine.maven.plugin}</version> | ||
<configuration> | ||
<projectId>GCLOUD_CONFIG</projectId> | ||
<version>GCLOUD_CONFIG</version> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-client</artifactId> | ||
<version>${jetty}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-util-ajax</artifactId> | ||
<version>${jetty}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-webapp</artifactId> | ||
<version>${jetty}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<scope>provided</scope> | ||
<version>3.1.0</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2016 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. | ||
runtime: custom | ||
env: flex | ||
|
||
handlers: | ||
- url: /.* | ||
script: this field is required, but ignored | ||
|
||
|
||
env_variables: | ||
PLACES_APPKEY: 'YOUR_PLACES_APP_KEY' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.