You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2010/01/27 15:40:12 UTC

svn commit: r903659 - in /tuscany/collaboration/wink-helloworld-sca: ./ src/main/java/org/apache/wink/example/helloworld/ src/main/webapp/WEB-INF/

Author: antelder
Date: Wed Jan 27 14:40:10 2010
New Revision: 903659

URL: http://svn.apache.org/viewvc?rev=903659&view=rev
Log:
Copy of the Apache Wink HelloWorld example updated to show an approach to SCA integration

Added:
    tuscany/collaboration/wink-helloworld-sca/
      - copied from r903632, incubator/wink/tags/wink-1.0-incubating/wink-examples/apps/HelloWorld/
    tuscany/collaboration/wink-helloworld-sca/src/main/java/org/apache/wink/example/helloworld/SomeSCAService.java
    tuscany/collaboration/wink-helloworld-sca/src/main/java/org/apache/wink/example/helloworld/SomeSCAServiceImpl.java
    tuscany/collaboration/wink-helloworld-sca/src/main/webapp/WEB-INF/web.composite
Modified:
    tuscany/collaboration/wink-helloworld-sca/pom.xml
    tuscany/collaboration/wink-helloworld-sca/src/main/java/org/apache/wink/example/helloworld/HelloWorld.java
    tuscany/collaboration/wink-helloworld-sca/src/main/webapp/WEB-INF/web.xml

Modified: tuscany/collaboration/wink-helloworld-sca/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/collaboration/wink-helloworld-sca/pom.xml?rev=903659&r1=903632&r2=903659&view=diff
==============================================================================
--- tuscany/collaboration/wink-helloworld-sca/pom.xml (original)
+++ tuscany/collaboration/wink-helloworld-sca/pom.xml Wed Jan 27 14:40:10 2010
@@ -76,5 +76,17 @@
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-sca-api</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tuscany.sca.shades</groupId>
+            <artifactId>tuscany-base</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
     </dependencies>
 </project>

Modified: tuscany/collaboration/wink-helloworld-sca/src/main/java/org/apache/wink/example/helloworld/HelloWorld.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/wink-helloworld-sca/src/main/java/org/apache/wink/example/helloworld/HelloWorld.java?rev=903659&r1=903632&r2=903659&view=diff
==============================================================================
--- tuscany/collaboration/wink-helloworld-sca/src/main/java/org/apache/wink/example/helloworld/HelloWorld.java (original)
+++ tuscany/collaboration/wink-helloworld-sca/src/main/java/org/apache/wink/example/helloworld/HelloWorld.java Wed Jan 27 14:40:10 2010
@@ -30,6 +30,8 @@
 import org.apache.wink.common.model.synd.SyndEntry;
 import org.apache.wink.common.model.synd.SyndText;
 
+import org.oasisopen.sca.annotation.Reference;
+
 /**
  * Simple example - Hello World!
  * <p/>
@@ -49,6 +51,9 @@
 public class HelloWorld {
     public static final String ID = "helloworld:1";
 
+    @Reference
+    protected SomeSCAService service;
+
     /**
      * This method is called by the SDK for HTTP GET method requests where the
      * Accept header allows the Atom media type application/atom+xml. A
@@ -63,7 +68,8 @@
     public SyndEntry getGreeting() {
         // create and return a syndication entry with a "Hello World!" title,
         // some ID and the current time.
-        SyndEntry synd = new SyndEntry(new SyndText("Hello World!"), ID, new Date());
+        String text = service == null ? "SCA reference not injected" : service.getGreeting("World");
+        SyndEntry synd = new SyndEntry(new SyndText(text), ID, new Date());
         return synd;
     }
 

Added: tuscany/collaboration/wink-helloworld-sca/src/main/java/org/apache/wink/example/helloworld/SomeSCAService.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/wink-helloworld-sca/src/main/java/org/apache/wink/example/helloworld/SomeSCAService.java?rev=903659&view=auto
==============================================================================
--- tuscany/collaboration/wink-helloworld-sca/src/main/java/org/apache/wink/example/helloworld/SomeSCAService.java (added)
+++ tuscany/collaboration/wink-helloworld-sca/src/main/java/org/apache/wink/example/helloworld/SomeSCAService.java Wed Jan 27 14:40:10 2010
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.wink.example.helloworld;
+
+public interface SomeSCAService {
+
+    public String getGreeting(String name);
+
+}

Added: tuscany/collaboration/wink-helloworld-sca/src/main/java/org/apache/wink/example/helloworld/SomeSCAServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/wink-helloworld-sca/src/main/java/org/apache/wink/example/helloworld/SomeSCAServiceImpl.java?rev=903659&view=auto
==============================================================================
--- tuscany/collaboration/wink-helloworld-sca/src/main/java/org/apache/wink/example/helloworld/SomeSCAServiceImpl.java (added)
+++ tuscany/collaboration/wink-helloworld-sca/src/main/java/org/apache/wink/example/helloworld/SomeSCAServiceImpl.java Wed Jan 27 14:40:10 2010
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.wink.example.helloworld;
+
+public class SomeSCAServiceImpl implements SomeSCAService {
+
+    public String getGreeting(String name) {
+        return "Hello " + name;
+    }
+
+}

Added: tuscany/collaboration/wink-helloworld-sca/src/main/webapp/WEB-INF/web.composite
URL: http://svn.apache.org/viewvc/tuscany/collaboration/wink-helloworld-sca/src/main/webapp/WEB-INF/web.composite?rev=903659&view=auto
==============================================================================
--- tuscany/collaboration/wink-helloworld-sca/src/main/webapp/WEB-INF/web.composite (added)
+++ tuscany/collaboration/wink-helloworld-sca/src/main/webapp/WEB-INF/web.composite Wed Jan 27 14:40:10 2010
@@ -0,0 +1,34 @@
+<?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/200912"
+           xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+           targetNamespace="http://samples"
+           name="Helloworld">
+
+    <component name="MyWebComponent">
+        <implementation.web web-uri=""/>
+        <reference name="service" target="ServiceComponent"/>
+    </component>
+
+    <component name="ServiceComponent">
+        <implementation.java class="org.apache.wink.example.helloworld.SomeSCAServiceImpl"/>
+    </component>
+
+</composite>

Modified: tuscany/collaboration/wink-helloworld-sca/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/tuscany/collaboration/wink-helloworld-sca/src/main/webapp/WEB-INF/web.xml?rev=903659&r1=903632&r2=903659&view=diff
==============================================================================
--- tuscany/collaboration/wink-helloworld-sca/src/main/webapp/WEB-INF/web.xml (original)
+++ tuscany/collaboration/wink-helloworld-sca/src/main/webapp/WEB-INF/web.xml Wed Jan 27 14:40:10 2010
@@ -25,6 +25,9 @@
 	<display-name>Wink demo</display-name>
 	<description>Demonstration of SDK features</description>
 
+      <!-- Listener to start the Tuscany webapp embedded runtime -->
+	<listener><listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class></listener>
+
 	<!--
 		Wink SDK servlet configuration. This servlet handles HTTP requests
 		of SDK web service on application server.