Skip to content

Commit f85fc90

Browse files
author
Shun Fan
committed
Update to java8
Update to using app.yaml Update to gcloud-java 0.1.3 Remove websockets for now
1 parent 621a07d commit f85fc90

File tree

56 files changed

+291
-623
lines changed

Some content is hidden

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

56 files changed

+291
-623
lines changed

managed_vms/analytics/pom.xml

+15-10
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
<!-- for hot reload of the web application -->
2525
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
2626
<plugins>
27+
<plugin>
28+
<groupId>com.google.appengine</groupId>
29+
<artifactId>gcloud-maven-plugin</artifactId>
30+
<version>2.0.9.92.v20160118</version>
31+
<configuration>
32+
<promote>true</promote>
33+
</configuration>
34+
</plugin>
2735
<plugin>
2836
<groupId>org.apache.maven.plugins</groupId>
2937
<artifactId>maven-war-plugin</artifactId>
@@ -37,16 +45,8 @@
3745
<version>3.3</version>
3846
<artifactId>maven-compiler-plugin</artifactId>
3947
<configuration>
40-
<source>1.7</source>
41-
<target>1.7</target>
42-
</configuration>
43-
</plugin>
44-
<plugin>
45-
<groupId>com.google.appengine</groupId>
46-
<artifactId>gcloud-maven-plugin</artifactId>
47-
<version>2.0.9.90.v20151210</version>
48-
<configuration>
49-
<promote>true</promote>
48+
<source>1.8</source>
49+
<target>1.8</target>
5050
</configuration>
5151
</plugin>
5252
<plugin>
@@ -63,6 +63,11 @@
6363
<execution><goals><goal>check</goal></goals></execution>
6464
</executions>
6565
</plugin>
66+
<plugin>
67+
<groupId>org.eclipse.jetty</groupId>
68+
<artifactId>jetty-maven-plugin</artifactId>
69+
<version>9.3.7.v20160115</version>
70+
</plugin>
6671
</plugins>
6772
</build>
6873
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
runtime: java
2+
vm: true
3+
runtime_config:
4+
jdk: openjdk8
5+
server: jetty9
6+
7+
# [START env_variables]
8+
env_variables:
9+
GA_TRACKING_ID: YOUR-GA-TRACKING-ID
10+
11+
# [END env_variables]

managed_vms/analytics/src/main/java/com/example/managedvms/analytics/AnalyticsServlet.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
// [START example]
3535
@SuppressWarnings("serial")
36-
@WebServlet(name = "analytics", value = "/*")
36+
@WebServlet(name = "analytics", value = "")
3737
public class AnalyticsServlet extends HttpServlet {
3838

3939
@Override

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

-12
This file was deleted.

managed_vms/cloudsql/pom.xml

+15-10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
<!-- for hot reload of the web application -->
2727
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
2828
<plugins>
29+
<plugin>
30+
<groupId>com.google.appengine</groupId>
31+
<artifactId>gcloud-maven-plugin</artifactId>
32+
<version>2.0.9.92.v20160118</version>
33+
<configuration>
34+
<promote>true</promote>
35+
</configuration>
36+
</plugin>
2937
<plugin>
3038
<groupId>org.apache.maven.plugins</groupId>
3139
<artifactId>maven-war-plugin</artifactId>
@@ -39,16 +47,8 @@
3947
<artifactId>maven-compiler-plugin</artifactId>
4048
<version>3.3</version>
4149
<configuration>
42-
<source>1.7</source>
43-
<target>1.7</target>
44-
</configuration>
45-
</plugin>
46-
<plugin>
47-
<groupId>com.google.appengine</groupId>
48-
<artifactId>gcloud-maven-plugin</artifactId>
49-
<version>2.0.9.90.v20151210</version>
50-
<configuration>
51-
<promote>true</promote>
50+
<source>1.8</source>
51+
<target>1.8</target>
5252
</configuration>
5353
</plugin>
5454
<plugin>
@@ -65,6 +65,11 @@
6565
<execution><goals><goal>check</goal></goals></execution>
6666
</executions>
6767
</plugin>
68+
<plugin>
69+
<groupId>org.eclipse.jetty</groupId>
70+
<artifactId>jetty-maven-plugin</artifactId>
71+
<version>9.3.7.v20160115</version>
72+
</plugin>
6873
</plugins>
6974
</build>
7075
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
runtime: java
2+
vm: true
3+
runtime_config:
4+
jdk: openjdk8
5+
server: jetty9
6+
7+
# [START env_variables]
8+
env_variables:
9+
SQL_DATABASE_URL: jdbc:mysql://HOST-IP:3306/YOUR-DB-NAME?user=USERNAME&password=PASSWORD
10+
# [END env_variables]

managed_vms/cloudsql/src/main/java/com/example/managedvms/cloudsql/CloudSqlServlet.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
// [START example]
3636
@SuppressWarnings("serial")
37-
@WebServlet(name = "cloudsql", value = "/*")
37+
@WebServlet(name = "cloudsql", value = "")
3838
public class CloudSqlServlet extends HttpServlet {
3939

4040
@Override

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

-12
This file was deleted.

managed_vms/cloudstorage/pom.xml

+16-11
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,21 @@
1717
<dependency>
1818
<groupId>com.google.gcloud</groupId>
1919
<artifactId>gcloud-java-storage</artifactId>
20-
<version>0.1.1</version>
20+
<version>0.1.3</version>
2121
</dependency>
2222
</dependencies>
2323
<build>
2424
<!-- for hot reload of the web application -->
2525
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
2626
<plugins>
27+
<plugin>
28+
<groupId>com.google.appengine</groupId>
29+
<artifactId>gcloud-maven-plugin</artifactId>
30+
<version>2.0.9.92.v20160118</version>
31+
<configuration>
32+
<promote>true</promote>
33+
</configuration>
34+
</plugin>
2735
<plugin>
2836
<groupId>org.apache.maven.plugins</groupId>
2937
<artifactId>maven-war-plugin</artifactId>
@@ -37,16 +45,8 @@
3745
<artifactId>maven-compiler-plugin</artifactId>
3846
<version>3.3</version>
3947
<configuration>
40-
<source>1.7</source>
41-
<target>1.7</target>
42-
</configuration>
43-
</plugin>
44-
<plugin>
45-
<groupId>com.google.appengine</groupId>
46-
<artifactId>gcloud-maven-plugin</artifactId>
47-
<version>2.0.9.90.v20151210</version>
48-
<configuration>
49-
<promote>true</promote>
48+
<source>1.8</source>
49+
<target>1.8</target>
5050
</configuration>
5151
</plugin>
5252
<plugin>
@@ -63,6 +63,11 @@
6363
<execution><goals><goal>check</goal></goals></execution>
6464
</executions>
6565
</plugin>
66+
<plugin>
67+
<groupId>org.eclipse.jetty</groupId>
68+
<artifactId>jetty-maven-plugin</artifactId>
69+
<version>9.3.7.v20160115</version>
70+
</plugin>
6671
</plugins>
6772
</build>
6873
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
runtime: java
2+
vm: true
3+
runtime_config:
4+
jdk: openjdk8
5+
server: jetty9
6+
7+
# [START env_variables]
8+
env_variables:
9+
BUCKET_NAME: YOUR-BUCKET-NAME
10+
# [END env_variables]

managed_vms/cloudstorage/src/main/java/com/example/managedvms/cloudstorage/UploadServlet.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616

1717
package com.example.managedvms.cloudstorage;
1818

19-
import com.google.common.io.ByteStreams;
19+
import com.google.gcloud.storage.Acl;
2020
import com.google.gcloud.storage.BlobInfo;
21-
import com.google.gcloud.storage.BlobWriteChannel;
2221
import com.google.gcloud.storage.Storage;
2322
import com.google.gcloud.storage.StorageOptions;
2423

2524
import java.io.IOException;
26-
import java.io.InputStream;
27-
import java.nio.channels.Channels;
25+
import java.util.ArrayList;
26+
import java.util.List;
2827

2928
import javax.servlet.ServletException;
3029
import javax.servlet.annotation.MultipartConfig;
@@ -53,11 +52,13 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOEx
5352
ServletException {
5453
final Part filePart = req.getPart("file");
5554
final String fileName = filePart.getSubmittedFileName();
56-
BlobInfo blobInfo = BlobInfo.builder(BUCKET_NAME, fileName).build();
57-
InputStream filecontent = filePart.getInputStream();
58-
BlobWriteChannel blobWriter = storage.writer(blobInfo);
59-
ByteStreams.copy(filecontent, Channels.newOutputStream(blobWriter));
60-
blobWriter.close();
55+
List<Acl> acls = new ArrayList<>();
56+
acls.add(Acl.of(Acl.User.ofAllUsers(), Acl.Role.READER));
57+
// the inputstream is closed by default, so we don't need to close it here
58+
BlobInfo blobInfo =
59+
storage.create(
60+
BlobInfo.builder(BUCKET_NAME, fileName).acl(acls).build(),
61+
filePart.getInputStream());
6162
blobInfo = storage.get(BUCKET_NAME, fileName);
6263
resp.getWriter().print(blobInfo.mediaLink());
6364
}

managed_vms/cloudstorage/src/main/webapp/WEB-INF/appengine-web.xml

-12
This file was deleted.

managed_vms/datastore/pom.xml

+16-11
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,21 @@
1717
<dependency>
1818
<groupId>com.google.gcloud</groupId>
1919
<artifactId>gcloud-java-datastore</artifactId>
20-
<version>0.1.1</version>
20+
<version>0.1.3</version>
2121
</dependency>
2222
</dependencies>
2323
<build>
2424
<!-- for hot reload of the web application -->
2525
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
2626
<plugins>
27+
<plugin>
28+
<groupId>com.google.appengine</groupId>
29+
<artifactId>gcloud-maven-plugin</artifactId>
30+
<version>2.0.9.92.v20160118</version>
31+
<configuration>
32+
<promote>true</promote>
33+
</configuration>
34+
</plugin>
2735
<plugin>
2836
<groupId>org.apache.maven.plugins</groupId>
2937
<artifactId>maven-war-plugin</artifactId>
@@ -37,16 +45,8 @@
3745
<artifactId>maven-compiler-plugin</artifactId>
3846
<version>3.3</version>
3947
<configuration>
40-
<source>1.7</source>
41-
<target>1.7</target>
42-
</configuration>
43-
</plugin>
44-
<plugin>
45-
<groupId>com.google.appengine</groupId>
46-
<artifactId>gcloud-maven-plugin</artifactId>
47-
<version>2.0.9.90.v20151210</version>
48-
<configuration>
49-
<promote>true</promote>
48+
<source>1.8</source>
49+
<target>1.8</target>
5050
</configuration>
5151
</plugin>
5252
<plugin>
@@ -63,6 +63,11 @@
6363
<execution><goals><goal>check</goal></goals></execution>
6464
</executions>
6565
</plugin>
66+
<plugin>
67+
<groupId>org.eclipse.jetty</groupId>
68+
<artifactId>jetty-maven-plugin</artifactId>
69+
<version>9.3.7.v20160115</version>
70+
</plugin>
6671
</plugins>
6772
</build>
6873
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
runtime: java
2+
vm: true
3+
runtime_config:
4+
jdk: openjdk8
5+
server: jetty9
6+

managed_vms/datastore/src/main/java/com/example/managedvms/datastore/DatastoreServlet.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,13 @@
3838

3939
// [START example]
4040
@SuppressWarnings("serial")
41-
@WebServlet(name = "datastore", value = "/*")
41+
@WebServlet(name = "datastore", value = "")
4242
public class DatastoreServlet extends HttpServlet {
4343

4444
@Override
4545
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException,
4646
ServletException {
47-
Datastore datastore = DatastoreOptions
48-
.builder()
49-
.projectId(System.getenv("PROJECT_ID"))
50-
.build()
51-
.service();
47+
Datastore datastore = DatastoreOptions.defaultInstance().service();
5248
KeyFactory keyFactory = datastore.newKeyFactory().kind("visit");
5349
IncompleteKey key = keyFactory.kind("visit").newKey();
5450
// Record a visit to the datastore, storing the IP and timestamp.

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

-12
This file was deleted.

0 commit comments

Comments
 (0)