summaryrefslogtreecommitdiffstats
path: root/sandbox/rfeng
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sandbox/rfeng/helloworld-jsp-google-appengine/pom.xml32
-rw-r--r--sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/DatastoreServiceImpl.java130
-rw-r--r--sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/MemcacheServiceImpl.java128
-rw-r--r--sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/URLFetchServiceImpl.java54
-rw-r--r--sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/UserServiceImpl.java71
-rw-r--r--sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java3
-rw-r--r--sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java30
-rw-r--r--sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/appengine-web.xml2
-rw-r--r--sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/web.composite57
9 files changed, 478 insertions, 29 deletions
diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/pom.xml b/sandbox/rfeng/helloworld-jsp-google-appengine/pom.xml
index 3107e3717a..a1124598b1 100644
--- a/sandbox/rfeng/helloworld-jsp-google-appengine/pom.xml
+++ b/sandbox/rfeng/helloworld-jsp-google-appengine/pom.xml
@@ -44,7 +44,37 @@
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
-
+
+ <!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ -->
+
+ <!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webapp</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ -->
</dependencies>
<build>
diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/DatastoreServiceImpl.java b/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/DatastoreServiceImpl.java
new file mode 100644
index 0000000000..5d58358b76
--- /dev/null
+++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/DatastoreServiceImpl.java
@@ -0,0 +1,130 @@
+/*
+ * 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 org.apache.tuscany.sca.gae.services;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+import com.google.appengine.api.datastore.DatastoreService;
+import com.google.appengine.api.datastore.DatastoreServiceFactory;
+import com.google.appengine.api.datastore.Entity;
+import com.google.appengine.api.datastore.EntityNotFoundException;
+import com.google.appengine.api.datastore.Key;
+import com.google.appengine.api.datastore.KeyRange;
+import com.google.appengine.api.datastore.PreparedQuery;
+import com.google.appengine.api.datastore.Query;
+import com.google.appengine.api.datastore.Transaction;
+
+/**
+ *
+ */
+@Service(DatastoreService.class)
+@Scope("COMPOSITE")
+public class DatastoreServiceImpl implements DatastoreService {
+ private DatastoreService delegate;
+
+ public void init() {
+ delegate = DatastoreServiceFactory.getDatastoreService();
+ }
+
+ public KeyRange allocateIds(Key parent, String kind, long num) {
+ return delegate.allocateIds(parent, kind, num);
+ }
+
+ public KeyRange allocateIds(String kind, long num) {
+ return delegate.allocateIds(kind, num);
+ }
+
+ public Transaction beginTransaction() {
+ return delegate.beginTransaction();
+ }
+
+ public void delete(Iterable<Key> keys) {
+ delegate.delete(keys);
+ }
+
+ public void delete(Key... keys) {
+ delegate.delete(keys);
+ }
+
+ public void delete(Transaction txn, Iterable<Key> keys) {
+ delegate.delete(txn, keys);
+ }
+
+ public void delete(Transaction txn, Key... keys) {
+ delegate.delete(txn, keys);
+ }
+
+ public Map<Key, Entity> get(Iterable<Key> keys) {
+ return delegate.get(keys);
+ }
+
+ public Entity get(Key key) throws EntityNotFoundException {
+ return delegate.get(key);
+ }
+
+ public Map<Key, Entity> get(Transaction txn, Iterable<Key> keys) {
+ return delegate.get(txn, keys);
+ }
+
+ public Entity get(Transaction txn, Key key) throws EntityNotFoundException {
+ return delegate.get(txn, key);
+ }
+
+ public Collection<Transaction> getActiveTransactions() {
+ return delegate.getActiveTransactions();
+ }
+
+ public Transaction getCurrentTransaction() {
+ return delegate.getCurrentTransaction();
+ }
+
+ public Transaction getCurrentTransaction(Transaction returnedIfNoTxn) {
+ return delegate.getCurrentTransaction(returnedIfNoTxn);
+ }
+
+ public PreparedQuery prepare(Query query) {
+ return delegate.prepare(query);
+ }
+
+ public PreparedQuery prepare(Transaction txn, Query query) {
+ return delegate.prepare(txn, query);
+ }
+
+ public Key put(Entity entity) {
+ return delegate.put(entity);
+ }
+
+ public List<Key> put(Iterable<Entity> entities) {
+ return delegate.put(entities);
+ }
+
+ public Key put(Transaction txn, Entity entity) {
+ return delegate.put(txn, entity);
+ }
+
+ public List<Key> put(Transaction txn, Iterable<Entity> entities) {
+ return delegate.put(txn, entities);
+ }
+}
diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/MemcacheServiceImpl.java b/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/MemcacheServiceImpl.java
new file mode 100644
index 0000000000..238af4665c
--- /dev/null
+++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/MemcacheServiceImpl.java
@@ -0,0 +1,128 @@
+/*
+ * 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 org.apache.tuscany.sca.gae.services;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+import com.google.appengine.api.memcache.ErrorHandler;
+import com.google.appengine.api.memcache.Expiration;
+import com.google.appengine.api.memcache.MemcacheService;
+import com.google.appengine.api.memcache.MemcacheServiceFactory;
+import com.google.appengine.api.memcache.Stats;
+
+/**
+ *
+ */
+@Service(MemcacheService.class)
+@Scope("COMPOSITE")
+public class MemcacheServiceImpl implements MemcacheService {
+ private MemcacheService delegate;
+
+ @Init
+ public void init() {
+ delegate = MemcacheServiceFactory.getMemcacheService();
+ }
+
+ public void clearAll() {
+ delegate.clearAll();
+ }
+
+ public boolean contains(Object key) {
+ return delegate.contains(key);
+ }
+
+ public boolean delete(Object key, long millisNoReAdd) {
+ return delegate.delete(key, millisNoReAdd);
+ }
+
+ public boolean delete(Object key) {
+ return delegate.delete(key);
+ }
+
+ public Set<Object> deleteAll(Collection<Object> keys, long millisNoReAdd) {
+ return delegate.deleteAll(keys, millisNoReAdd);
+ }
+
+ public Set<Object> deleteAll(Collection<Object> keys) {
+ return delegate.deleteAll(keys);
+ }
+
+ public Object get(Object key) {
+ return delegate.get(key);
+ }
+
+ public Map<Object, Object> getAll(Collection<Object> keys) {
+ return delegate.getAll(keys);
+ }
+
+ public ErrorHandler getErrorHandler() {
+ return delegate.getErrorHandler();
+ }
+
+ public String getNamespace() {
+ return delegate.getNamespace();
+ }
+
+ public Stats getStatistics() {
+ return delegate.getStatistics();
+ }
+
+ public Long increment(Object key, long delta) {
+ return delegate.increment(key, delta);
+ }
+
+ public boolean put(Object key, Object value, Expiration expires, SetPolicy policy) {
+ return delegate.put(key, value, expires, policy);
+ }
+
+ public void put(Object key, Object value, Expiration expires) {
+ delegate.put(key, value, expires);
+ }
+
+ public void put(Object key, Object value) {
+ delegate.put(key, value);
+ }
+
+ public Set<Object> putAll(Map<Object, Object> values, Expiration expires, SetPolicy policy) {
+ return delegate.putAll(values, expires, policy);
+ }
+
+ public void putAll(Map<Object, Object> values, Expiration expires) {
+ delegate.putAll(values, expires);
+ }
+
+ public void putAll(Map<Object, Object> values) {
+ delegate.putAll(values);
+ }
+
+ public void setErrorHandler(ErrorHandler handler) {
+ delegate.setErrorHandler(handler);
+ }
+
+ public void setNamespace(String newNamespace) {
+ delegate.setNamespace(newNamespace);
+ }
+}
diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/URLFetchServiceImpl.java b/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/URLFetchServiceImpl.java
new file mode 100644
index 0000000000..1e3046a32d
--- /dev/null
+++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/URLFetchServiceImpl.java
@@ -0,0 +1,54 @@
+/*
+ * 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 org.apache.tuscany.sca.gae.services;
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+import com.google.appengine.api.urlfetch.HTTPRequest;
+import com.google.appengine.api.urlfetch.HTTPResponse;
+import com.google.appengine.api.urlfetch.URLFetchService;
+import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
+
+/**
+ *
+ */
+@Service(URLFetchService.class)
+@Scope("COMPOSITE")
+public class URLFetchServiceImpl implements URLFetchService {
+ private URLFetchService delegate;
+
+ @Init
+ public void init() {
+ delegate = URLFetchServiceFactory.getURLFetchService();
+ }
+
+ public HTTPResponse fetch(HTTPRequest request) throws IOException {
+ return delegate.fetch(request);
+ }
+
+ public HTTPResponse fetch(URL url) throws IOException {
+ return delegate.fetch(url);
+ }
+}
diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/UserServiceImpl.java b/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/UserServiceImpl.java
new file mode 100644
index 0000000000..dfa491694a
--- /dev/null
+++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/UserServiceImpl.java
@@ -0,0 +1,71 @@
+/*
+ * 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 org.apache.tuscany.sca.gae.services;
+
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+import com.google.appengine.api.users.User;
+import com.google.appengine.api.users.UserService;
+import com.google.appengine.api.users.UserServiceFactory;
+
+/**
+ *
+ */
+@Service(UserService.class)
+@Scope("COMPOSITE")
+public class UserServiceImpl implements UserService {
+ private UserService userService;
+
+ @Init
+ public void init() {
+ userService = UserServiceFactory.getUserService();
+ }
+
+ public String createLoginURL(String destinationURL, String authDomain) {
+ return userService.createLoginURL(destinationURL, authDomain);
+ }
+
+ public String createLoginURL(String destinationURL) {
+ return userService.createLoginURL(destinationURL);
+ }
+
+ public String createLogoutURL(String destinationURL, String authDomain) {
+ return userService.createLogoutURL(destinationURL, authDomain);
+ }
+
+ public String createLogoutURL(String destinationURL) {
+ return userService.createLogoutURL(destinationURL);
+ }
+
+ public User getCurrentUser() {
+ return userService.getCurrentUser();
+ }
+
+ public boolean isUserAdmin() {
+ return userService.isUserAdmin();
+ }
+
+ public boolean isUserLoggedIn() {
+ return userService.isUserLoggedIn();
+ }
+
+}
diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java b/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java
index 53ff7a5ca1..9e19edbf9a 100644
--- a/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java
+++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java
@@ -18,6 +18,9 @@
*/
package sample;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
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
index d69e578698..69227b1750 100644
--- a/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java
+++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java
@@ -18,21 +18,47 @@
*/
package sample;
+import java.io.IOException;
+import java.net.URL;
+
import org.oasisopen.sca.annotation.EagerInit;
import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
import org.oasisopen.sca.annotation.Scope;
+import com.google.appengine.api.urlfetch.HTTPResponse;
+import com.google.appengine.api.urlfetch.URLFetchService;
+import com.google.appengine.api.users.User;
+import com.google.appengine.api.users.UserService;
+
@EagerInit
@Scope("COMPOSITE")
public class HelloworldServiceImpl implements HelloworldService {
+ @Reference
+ protected UserService userService;
+
+ @Reference
+ protected URLFetchService fetchService;
public String sayHello(String name) {
- return "Hello " + name;
+ User user = userService.getCurrentUser();
+ String id = (user == null) ? "" : user.getUserId();
+ String content = "";
+ try {
+ HTTPResponse response = fetchService.fetch(new URL("http://tuscany.apache.org"));
+ content = new String(response.getContent(), 0, 1024);
+ content = content.replace("<", "&lt;");
+ content = content.replace(">", "&gt;");
+ content = content.replace("\"", "&quot;");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return "[" + id + "] Hello " + name + "<hr><h1>Content from Tuscany Web Site</h1><p>" + content;
}
@Init
public void init() {
- System.out.println("Starting..." + sayHello("world"));
+ System.out.println("Starting...");
}
}
diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/appengine-web.xml b/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/appengine-web.xml
index ee5bf38725..6d80666550 100644
--- a/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/appengine-web.xml
+++ b/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/appengine-web.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>scacloud</application>
- <version>2</version>
+ <version>3</version>
<!-- Configure java.util.logging -->
<system-properties>
diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/web.composite b/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/web.composite
index 875d6aae9d..6923254bc2 100644
--- a/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/web.composite
+++ b/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/web.composite
@@ -1,34 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
- xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
- targetNamespace="http://samples"
- name="Helloworld">
+ <!--
+ * 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.
+ -->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://samples" name="Helloworld">
<component name="foo">
- <implementation.web web-uri=""/>
- <reference name="service" target="HelloworldComponent"/>
+ <implementation.web web-uri="" />
+ <reference name="service" target="HelloworldComponent" />
</component>
<component name="HelloworldComponent">
- <implementation.java class="sample.HelloworldServiceImpl"/>
+ <implementation.java class="sample.HelloworldServiceImpl" />
+ <service name="HelloworldService">
+ <binding.sca name="sca" />
+ </service>
+ <reference name="userService" target="UserService"/>
+ <reference name="fetchService" target="URLFetchService"/>
</component>
+ <component name="UserService">
+ <implementation.java class="org.apache.tuscany.sca.gae.services.UserServiceImpl" />
+ </component>
+ <component name="MemcacheService">
+ <implementation.java class="org.apache.tuscany.sca.gae.services.MemcacheServiceImpl" />
+ </component>
+ <component name="URLFetchService">
+ <implementation.java class="org.apache.tuscany.sca.gae.services.URLFetchServiceImpl" />
+ </component>
+ <component name="DatastoreService">
+ <implementation.java class="org.apache.tuscany.sca.gae.services.DatastoreServiceImpl" />
+ </component>
</composite>