Skip to content

Commit

Permalink
Update to java8
Browse files Browse the repository at this point in the history
Update to using app.yaml
Update to gcloud-java 0.1.3
Remove websockets for now
  • Loading branch information
Shun Fan committed Jan 28, 2016
1 parent 621a07d commit f85fc90
Show file tree
Hide file tree
Showing 56 changed files with 291 additions and 623 deletions.
25 changes: 15 additions & 10 deletions managed_vms/analytics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
<!-- for hot reload of the web application -->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>gcloud-maven-plugin</artifactId>
<version>2.0.9.92.v20160118</version>
<configuration>
<promote>true</promote>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
Expand All @@ -37,16 +45,8 @@
<version>3.3</version>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>gcloud-maven-plugin</artifactId>
<version>2.0.9.90.v20151210</version>
<configuration>
<promote>true</promote>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand All @@ -63,6 +63,11 @@
<execution><goals><goal>check</goal></goals></execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.7.v20160115</version>
</plugin>
</plugins>
</build>
</project>
11 changes: 11 additions & 0 deletions managed_vms/analytics/src/main/appengine/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
runtime: java
vm: true
runtime_config:
jdk: openjdk8
server: jetty9

# [START env_variables]
env_variables:
GA_TRACKING_ID: YOUR-GA-TRACKING-ID

# [END env_variables]
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

// [START example]
@SuppressWarnings("serial")
@WebServlet(name = "analytics", value = "/*")
@WebServlet(name = "analytics", value = "")
public class AnalyticsServlet extends HttpServlet {

@Override
Expand Down
12 changes: 0 additions & 12 deletions managed_vms/analytics/src/main/webapp/WEB-INF/appengine-web.xml

This file was deleted.

25 changes: 15 additions & 10 deletions managed_vms/cloudsql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
<!-- for hot reload of the web application -->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>gcloud-maven-plugin</artifactId>
<version>2.0.9.92.v20160118</version>
<configuration>
<promote>true</promote>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
Expand All @@ -39,16 +47,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>gcloud-maven-plugin</artifactId>
<version>2.0.9.90.v20151210</version>
<configuration>
<promote>true</promote>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand All @@ -65,6 +65,11 @@
<execution><goals><goal>check</goal></goals></execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.7.v20160115</version>
</plugin>
</plugins>
</build>
</project>
10 changes: 10 additions & 0 deletions managed_vms/cloudsql/src/main/appengine/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
runtime: java
vm: true
runtime_config:
jdk: openjdk8
server: jetty9

# [START env_variables]
env_variables:
SQL_DATABASE_URL: jdbc:mysql://HOST-IP:3306/YOUR-DB-NAME?user=USERNAME&password=PASSWORD
# [END env_variables]
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

// [START example]
@SuppressWarnings("serial")
@WebServlet(name = "cloudsql", value = "/*")
@WebServlet(name = "cloudsql", value = "")
public class CloudSqlServlet extends HttpServlet {

@Override
Expand Down
12 changes: 0 additions & 12 deletions managed_vms/cloudsql/src/main/webapp/WEB-INF/appengine-web.xml

This file was deleted.

27 changes: 16 additions & 11 deletions managed_vms/cloudstorage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@
<dependency>
<groupId>com.google.gcloud</groupId>
<artifactId>gcloud-java-storage</artifactId>
<version>0.1.1</version>
<version>0.1.3</version>
</dependency>
</dependencies>
<build>
<!-- for hot reload of the web application -->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>gcloud-maven-plugin</artifactId>
<version>2.0.9.92.v20160118</version>
<configuration>
<promote>true</promote>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
Expand All @@ -37,16 +45,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>gcloud-maven-plugin</artifactId>
<version>2.0.9.90.v20151210</version>
<configuration>
<promote>true</promote>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand All @@ -63,6 +63,11 @@
<execution><goals><goal>check</goal></goals></execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.7.v20160115</version>
</plugin>
</plugins>
</build>
</project>
10 changes: 10 additions & 0 deletions managed_vms/cloudstorage/src/main/appengine/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
runtime: java
vm: true
runtime_config:
jdk: openjdk8
server: jetty9

# [START env_variables]
env_variables:
BUCKET_NAME: YOUR-BUCKET-NAME
# [END env_variables]
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@

package com.example.managedvms.cloudstorage;

import com.google.common.io.ByteStreams;
import com.google.gcloud.storage.Acl;
import com.google.gcloud.storage.BlobInfo;
import com.google.gcloud.storage.BlobWriteChannel;
import com.google.gcloud.storage.Storage;
import com.google.gcloud.storage.StorageOptions;

import java.io.IOException;
import java.io.InputStream;
import java.nio.channels.Channels;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
Expand Down Expand Up @@ -53,11 +52,13 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOEx
ServletException {
final Part filePart = req.getPart("file");
final String fileName = filePart.getSubmittedFileName();
BlobInfo blobInfo = BlobInfo.builder(BUCKET_NAME, fileName).build();
InputStream filecontent = filePart.getInputStream();
BlobWriteChannel blobWriter = storage.writer(blobInfo);
ByteStreams.copy(filecontent, Channels.newOutputStream(blobWriter));
blobWriter.close();
List<Acl> acls = new ArrayList<>();
acls.add(Acl.of(Acl.User.ofAllUsers(), Acl.Role.READER));
// the inputstream is closed by default, so we don't need to close it here
BlobInfo blobInfo =
storage.create(
BlobInfo.builder(BUCKET_NAME, fileName).acl(acls).build(),
filePart.getInputStream());
blobInfo = storage.get(BUCKET_NAME, fileName);
resp.getWriter().print(blobInfo.mediaLink());
}
Expand Down
12 changes: 0 additions & 12 deletions managed_vms/cloudstorage/src/main/webapp/WEB-INF/appengine-web.xml

This file was deleted.

27 changes: 16 additions & 11 deletions managed_vms/datastore/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@
<dependency>
<groupId>com.google.gcloud</groupId>
<artifactId>gcloud-java-datastore</artifactId>
<version>0.1.1</version>
<version>0.1.3</version>
</dependency>
</dependencies>
<build>
<!-- for hot reload of the web application -->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>gcloud-maven-plugin</artifactId>
<version>2.0.9.92.v20160118</version>
<configuration>
<promote>true</promote>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
Expand All @@ -37,16 +45,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>gcloud-maven-plugin</artifactId>
<version>2.0.9.90.v20151210</version>
<configuration>
<promote>true</promote>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand All @@ -63,6 +63,11 @@
<execution><goals><goal>check</goal></goals></execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.7.v20160115</version>
</plugin>
</plugins>
</build>
</project>
6 changes: 6 additions & 0 deletions managed_vms/datastore/src/main/appengine/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
runtime: java
vm: true
runtime_config:
jdk: openjdk8
server: jetty9

Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,13 @@

// [START example]
@SuppressWarnings("serial")
@WebServlet(name = "datastore", value = "/*")
@WebServlet(name = "datastore", value = "")
public class DatastoreServlet extends HttpServlet {

@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException,
ServletException {
Datastore datastore = DatastoreOptions
.builder()
.projectId(System.getenv("PROJECT_ID"))
.build()
.service();
Datastore datastore = DatastoreOptions.defaultInstance().service();
KeyFactory keyFactory = datastore.newKeyFactory().kind("visit");
IncompleteKey key = keyFactory.kind("visit").newKey();
// Record a visit to the datastore, storing the IP and timestamp.
Expand Down
12 changes: 0 additions & 12 deletions managed_vms/datastore/src/main/webapp/WEB-INF/appengine-web.xml

This file was deleted.

Loading

0 comments on commit f85fc90

Please sign in to comment.