diff options
Diffstat (limited to 'sandbox/rfeng/helloworld-jsp-google-appengine/src')
5 files changed, 153 insertions, 0 deletions
diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/src/META-INF/jdoconfig.xml b/sandbox/rfeng/helloworld-jsp-google-appengine/src/META-INF/jdoconfig.xml new file mode 100644 index 0000000000..5f56aa196e --- /dev/null +++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/META-INF/jdoconfig.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig"> + + <persistence-manager-factory name="transactions-optional"> + <property name="javax.jdo.PersistenceManagerFactoryClass" + value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/> + <property name="javax.jdo.option.ConnectionURL" value="appengine"/> + <property name="javax.jdo.option.NontransactionalRead" value="true"/> + <property name="javax.jdo.option.NontransactionalWrite" value="true"/> + <property name="javax.jdo.option.RetainValues" value="true"/> + <property name="datanucleus.appengine.autoCreateDatastoreTxns" value="true"/> + </persistence-manager-factory> +</jdoconfig> diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/src/log4j.properties b/sandbox/rfeng/helloworld-jsp-google-appengine/src/log4j.properties new file mode 100644 index 0000000000..d9c3edc9fe --- /dev/null +++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/log4j.properties @@ -0,0 +1,24 @@ +# A default log4j configuration for log4j users. +# +# To use this configuration, deploy it into your application's WEB-INF/classes +# directory. You are also encouraged to edit it as you like. + +# Configure the console as our one appender +log4j.appender.A1=org.apache.log4j.ConsoleAppender +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%c] - %m%n + +# tighten logging on the DataNucleus Categories +log4j.category.DataNucleus.JDO=WARN, A1 +log4j.category.DataNucleus.Persistence=WARN, A1 +log4j.category.DataNucleus.Cache=WARN, A1 +log4j.category.DataNucleus.MetaData=WARN, A1 +log4j.category.DataNucleus.General=WARN, A1 +log4j.category.DataNucleus.Utility=WARN, A1 +log4j.category.DataNucleus.Transaction=WARN, A1 +log4j.category.DataNucleus.Datastore=WARN, A1 +log4j.category.DataNucleus.ClassLoading=WARN, A1 +log4j.category.DataNucleus.Plugin=WARN, A1 +log4j.category.DataNucleus.ValueGeneration=WARN, A1 +log4j.category.DataNucleus.Enhancer=WARN, A1 +log4j.category.DataNucleus.SchemaTool=WARN, A1 diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java b/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java new file mode 100644 index 0000000000..53ff7a5ca1 --- /dev/null +++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 sample; + +public interface HelloworldService { + + String sayHello(String name); + +} diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java b/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java new file mode 100644 index 0000000000..d69e578698 --- /dev/null +++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 sample; + +import org.oasisopen.sca.annotation.EagerInit; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Scope; + +@EagerInit +@Scope("COMPOSITE") +public class HelloworldServiceImpl implements HelloworldService { + + public String sayHello(String name) { + return "Hello " + name; + } + + @Init + public void init() { + System.out.println("Starting..." + sayHello("world")); + } + +} diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/appengine/HelloWorldServlet.java b/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/appengine/HelloWorldServlet.java new file mode 100644 index 0000000000..2750c04c9d --- /dev/null +++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/appengine/HelloWorldServlet.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 sample.appengine; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.google.appengine.api.users.User; +import com.google.appengine.api.users.UserService; +import com.google.appengine.api.users.UserServiceFactory; + +@SuppressWarnings("serial") +public class HelloWorldServlet extends HttpServlet { + public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { + resp.setContentType("text/html"); + UserService userService = UserServiceFactory.getUserService(); + User user = userService.getCurrentUser(); + if (user == null) { + resp.sendRedirect(userService.createLoginURL(req.getRequestURI())); + } else { + PrintWriter pw = resp.getWriter(); + pw.println("<html><head><title>Test</title></head><body>"); + pw.println("<h1>"); + pw.println("Welcome to the SCA Cloud hosted by Google App Engine: " + user); + if (user != null) { + pw.println("User ID: " + user.getUserId() + " E-mail: " + user.getEmail()); + } + pw.println("</h1></body></html>"); + } + } +} |