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 2009/04/24 13:08:20 UTC

svn commit: r768260 - in /tuscany/java/sca: modules/binding-rest-runtime/ modules/binding-rest-runtime/META-INF/ modules/binding-rest-runtime/src/ modules/binding-rest-runtime/src/main/ modules/binding-rest-runtime/src/main/java/ modules/binding-rest-r...

Author: antelder
Date: Fri Apr 24 11:08:18 2009
New Revision: 768260

URL: http://svn.apache.org/viewvc?rev=768260&view=rev
Log:
TUSCANY-2919: Start commiting contribution from Prateek Temkar for JAX-RS Support in Tuscany

Added:
    tuscany/java/sca/modules/binding-rest/   (with props)
    tuscany/java/sca/modules/binding-rest-runtime/   (with props)
    tuscany/java/sca/modules/binding-rest-runtime/META-INF/
    tuscany/java/sca/modules/binding-rest-runtime/META-INF/MANIFEST.MF
    tuscany/java/sca/modules/binding-rest-runtime/pom.xml
    tuscany/java/sca/modules/binding-rest-runtime/src/
    tuscany/java/sca/modules/binding-rest-runtime/src/main/
    tuscany/java/sca/modules/binding-rest-runtime/src/main/java/
    tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/
    tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/
    tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/
    tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/
    tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/
    tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/
    tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingForJersey.java
    tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/
    tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
    tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingProviderFactory.java
    tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java
    tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java
    tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceServlet.java
    tuscany/java/sca/modules/binding-rest-runtime/src/main/resources/
    tuscany/java/sca/modules/binding-rest-runtime/src/main/resources/META-INF/
    tuscany/java/sca/modules/binding-rest-runtime/src/main/resources/META-INF/services/
    tuscany/java/sca/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
    tuscany/java/sca/modules/binding-rest/META-INF/
    tuscany/java/sca/modules/binding-rest/META-INF/MANIFEST.MF
    tuscany/java/sca/modules/binding-rest/pom.xml
    tuscany/java/sca/modules/binding-rest/src/
    tuscany/java/sca/modules/binding-rest/src/main/
    tuscany/java/sca/modules/binding-rest/src/main/java/
    tuscany/java/sca/modules/binding-rest/src/main/java/org/
    tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/
    tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/
    tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/
    tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/
    tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/
    tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java
    tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingFactory.java
    tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/
    tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingFactoryImpl.java
    tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java
    tuscany/java/sca/modules/binding-rest/src/main/resources/
    tuscany/java/sca/modules/binding-rest/src/main/resources/META-INF/
    tuscany/java/sca/modules/binding-rest/src/main/resources/META-INF/services/
    tuscany/java/sca/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.RESTBindingFactory
    tuscany/java/sca/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
    tuscany/java/sca/modules/binding-rest/src/test/
    tuscany/java/sca/modules/binding-rest/src/test/java/
    tuscany/java/sca/modules/binding-rest/src/test/java/org/
    tuscany/java/sca/modules/binding-rest/src/test/java/org/apache/
    tuscany/java/sca/modules/binding-rest/src/test/java/org/apache/tuscany/
    tuscany/java/sca/modules/binding-rest/src/test/java/org/apache/tuscany/sca/
    tuscany/java/sca/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/
    tuscany/java/sca/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/
    tuscany/java/sca/modules/binding-rest/src/test/resources/
    tuscany/java/sca/samples/webapps/helloworld-rest/   (with props)
    tuscany/java/sca/samples/webapps/helloworld-rest/README
    tuscany/java/sca/samples/webapps/helloworld-rest/pom.xml
    tuscany/java/sca/samples/webapps/helloworld-rest/src/
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientJavaTestService.java
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientTestServiceWebapp.java
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldService.java
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldServiceImpl.java
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/resources/
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/resources/rest.composite
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/HelloWorldJSONRPC.html
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/META-INF/
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/META-INF/sca-contribution.xml
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/WEB-INF/
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/WEB-INF/web.xml
    tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/style.css
    tuscany/java/sca/samples/webapps/helloworld-rest/target/
    tuscany/java/sca/samples/webapps/helloworld-rest/target/classes/
    tuscany/java/sca/samples/webapps/helloworld-rest/target/classes/rest.composite

Propchange: tuscany/java/sca/modules/binding-rest/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 24 11:08:18 2009
@@ -0,0 +1,20 @@
+target
+work
+dojo
+*.iws
+*.ipr
+*.iml
+derby.log
+maven.log
+maven-eclipse.xml
+build.xml
+build-dependency.xml
+velocity.log*
+junit*.properties
+surefire*.properties
+.project
+.classpath
+.settings
+.deployables
+.wtpmodules
+.externalToolBuilders

Propchange: tuscany/java/sca/modules/binding-rest-runtime/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 24 11:08:18 2009
@@ -0,0 +1,20 @@
+target
+work
+dojo
+*.iws
+*.ipr
+*.iml
+derby.log
+maven.log
+maven-eclipse.xml
+build.xml
+build-dependency.xml
+velocity.log*
+junit*.properties
+surefire*.properties
+.project
+.classpath
+.settings
+.deployables
+.wtpmodules
+.externalToolBuilders

Added: tuscany/java/sca/modules/binding-rest-runtime/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest-runtime/META-INF/MANIFEST.MF?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest-runtime/META-INF/MANIFEST.MF (added)
+++ tuscany/java/sca/modules/binding-rest-runtime/META-INF/MANIFEST.MF Fri Apr 24 11:08:18 2009
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.rest.runtime;version="2.0.0";uses:="org.apache.tuscany.sca.assembly"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA REST Binding Runtime
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397320062
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA REST Binding Model
+Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.binding.jsonp.runtime;version="2.0.0".
+ org.apache.tuscany.sca.binding.jsonp;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.rest.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6

Added: tuscany/java/sca/modules/binding-rest-runtime/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest-runtime/pom.xml?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest-runtime/pom.xml (added)
+++ tuscany/java/sca/modules/binding-rest-runtime/pom.xml Fri Apr 24 11:08:18 2009
@@ -0,0 +1,140 @@
+<?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.    
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-modules</artifactId>
+        <version>2.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>tuscany-binding-rest-runtime</artifactId>
+    <name>Apache Tuscany SCA REST Binding Runtime</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-binding-rest</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>jersey-bundle</groupId>
+            <artifactId>jersey-bundle</artifactId>
+            <version>1.0.1-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-core-spi</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-core</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-databinding</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>        
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-http</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-webapp</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-jetty</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>        
+        
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.5</version> <!-- was originally 2.4 -->  
+            <scope>provided</scope>
+        </dependency>
+        
+        <dependency>
+           <groupId>commons-logging</groupId>
+           <artifactId>commons-logging</artifactId>
+           <version>1.1.1</version>
+           <exclusions>
+               <exclusion>
+                   <groupId>commons-logging</groupId>
+                   <artifactId>commons-logging</artifactId>
+               </exclusion>
+               <exclusion>
+                   <groupId>javax.servlet</groupId>
+                   <artifactId>servlet-api</artifactId>
+               </exclusion>
+           </exclusions>
+        </dependency>          
+
+
+        <!-- Test Dependencies -->
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-embedded</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java-runtime</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>        
+        
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.5</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+	        <groupId>httpunit</groupId>
+	        <artifactId>httpunit</artifactId>
+	        <version>1.6.1</version>
+	        <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+
+    <build>
+    </build>
+
+</project>

Added: tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingForJersey.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingForJersey.java?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingForJersey.java (added)
+++ tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingForJersey.java Fri Apr 24 11:08:18 2009
@@ -0,0 +1,181 @@
+package org.apache.tuscany.sca.binding.rest;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.rest.provider.RESTServiceServlet;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+import com.sun.jersey.tuscany.common.CommonInterface;
+
+public class RESTBindingForJersey implements CommonInterface{
+
+	/**
+	 * This map will save the mappings between the serviceInterface
+	 * and the HttpServlet instance which will be passed by RESTServiceServlet  
+	 *
+	 */
+	private static HashMap<String, RESTServiceServlet> interfacenameServletMap = new HashMap<String, RESTServiceServlet>();
+
+	/**
+	 * This is used to store the contextPath for the web application.
+	 * It will be set in RESTServiceServlet
+	 * It is currently being used by org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker
+	 * 
+	 */
+	private static String contextPath;
+
+	/**
+	 * updateInterfacenameServletMap() is called from RESTServiceServlet.
+	 */
+	public static void updateInterfacenameServletMap(String interfaceName, RESTServiceServlet restServiceServlet){
+
+		//check if the class name already exists. if it does, do not add it.
+		Set set = interfacenameServletMap.entrySet();
+		Iterator hashIt = set.iterator();
+		boolean classFoundFlag = false;
+		while(hashIt.hasNext()){ 
+			Map.Entry me = (Map.Entry)hashIt.next();
+			if(interfaceName.equals( (String)me.getKey() )){
+				classFoundFlag = true;
+			}
+		}
+
+		//if it is not already in map, add it to the map
+		if(classFoundFlag == false){
+			interfacenameServletMap.put(interfaceName, restServiceServlet);
+		}
+
+	}
+
+	/**
+	 * @param clazz The class whose method has been invoked
+	 * @return restServiceServlet
+	 * Find the matching interface for the class in the hashMap and return the corresponding RESTServiceServlet instance
+	 */
+	public static RESTServiceServlet findRESTServiceServletFromClass(Class clazz){
+		RESTServiceServlet restServiceServlet = null;
+		Set set = interfacenameServletMap.entrySet();
+		Iterator hashIt = set.iterator();
+		while(hashIt.hasNext()){ 
+			Map.Entry me = (Map.Entry)hashIt.next();
+			if( (clazz.getSimpleName()).equals( (String)me.getKey() ) )
+			{
+				restServiceServlet = (RESTServiceServlet)me.getValue();
+				break;
+			}
+		}
+		return restServiceServlet;
+	}
+
+	/**
+	 * @param interfaceList This will contain the list of all the interfaces the class (which declares the method) implements
+	 * @return restServiceServlet
+	 * Go through the interfaceList array and find the matching interface in the hashMap and return the corresponding RESTServiceServlet instance
+	 */
+
+	public static RESTServiceServlet findRESTServiceServletFromInterfaceList(Class[] interfaceList){
+		RESTServiceServlet restServiceServlet = null;
+		Set set = interfacenameServletMap.entrySet();
+		Iterator hashIt = set.iterator();
+		//label the outer for loop so that when a match is found, just break out of the whole thing
+		outerForLoop:
+			for(int i=0; i<interfaceList.length; i++){
+				//if the name of the interface matches any key in the map, return the corresponding servlet
+				while(hashIt.hasNext()){ 
+					Map.Entry me = (Map.Entry)hashIt.next();
+					if( (interfaceList[i].getSimpleName()).equals( (String)me.getKey() ) )
+					{
+						restServiceServlet = (RESTServiceServlet)me.getValue();
+						break outerForLoop;
+					}
+				}
+			}
+		return restServiceServlet;
+	}
+
+
+	/**
+	 * Prateek: This class implements CommonInterface. 
+	 * com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider (in Jersey) 
+	 * also implements this CommonInterface.
+	 * EntityParamDispatchProvider invokes returnResult using a handle to the interface.
+	 */
+	public Object returnResult(Method meth, Object[] params) throws InvocationTargetException{
+		
+		//from the meth object, get the name of the class and then the interface
+		// look up interfacenameServletMap to get the HttpServlet instance and use the 
+		//'componentService, binding, serviceContract from there
+		Class clazz = meth.getDeclaringClass();
+
+		Class[] interfaceList = clazz.getInterfaces();
+		RESTServiceServlet restServiceServlet = findRESTServiceServletFromInterfaceList(interfaceList);
+
+		//if the SCA service interface is not a Java Interface but a Java class, then restServiceServlet above will be null
+		//In that case the map will have the mapping of the Java Class and the RESTServiceServlet instance. 
+		if(restServiceServlet == null){
+			restServiceServlet = findRESTServiceServletFromClass(clazz);
+		}
+
+		Binding binding = restServiceServlet.getBinding();
+		RuntimeComponentService componentService = restServiceServlet.getComponentService();
+		InterfaceContract serviceContract = restServiceServlet.getServiceContract();
+
+		String method = "Service." + meth.getName();
+
+		//invoke the request
+		RuntimeWire wire = componentService.getRuntimeWire(binding, serviceContract);
+		Operation restOperation = findOperation(method, serviceContract);
+
+		Object result = null;
+
+		try {
+			result = wire.invoke(restOperation, params);
+			return result;
+		} catch (InvocationTargetException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			throw e;
+		}       
+	}
+
+	private static Operation findOperation(String method,InterfaceContract serviceContract) {
+		if (method.contains(".")) {
+			method = method.substring(method.lastIndexOf(".") + 1);
+		}
+
+		List<Operation> operations = serviceContract.getInterface().getOperations();
+		//componentService.getBindingProvider(binding).getBindingInterfaceContract().getInterface().getOperations();
+
+
+		Operation result = null;
+		for (Operation o : operations) {
+			if (o.getName().equalsIgnoreCase(method)) {
+				result = o;
+				break;
+			}
+		}
+
+		return result;
+	}
+
+	public static String getContextPath() {
+		return contextPath;
+	}
+
+	public static void setContextPath(String contextPath) {
+		RESTBindingForJersey.contextPath = contextPath;
+	}
+
+}
+

Added: tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java (added)
+++ tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java Fri Apr 24 11:08:18 2009
@@ -0,0 +1,45 @@
+/*
+ * 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.binding.rest.provider;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * Invoker for the REST Binding
+ * 
+ * @version $Rev: 665897 $ $Date: 2008-06-09 22:31:03 +0100 (Mon, 09 Jun 2008) $
+ */
+public class RESTBindingInvoker implements Invoker {
+    Operation operation;
+    String uri;
+
+    public RESTBindingInvoker(Operation operation, String uri) {
+        this.operation = operation;
+        this.uri = uri;        
+    }
+    
+    public Message invoke(Message msg) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Added: tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingProviderFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingProviderFactory.java?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingProviderFactory.java (added)
+++ tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingProviderFactory.java Fri Apr 24 11:08:18 2009
@@ -0,0 +1,64 @@
+/*
+ * 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.binding.rest.provider;
+
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * REST Provider Factory
+ * 
+ * @version $Rev: 665897 $ $Date: 2008-06-09 22:31:03 +0100 (Mon, 09 Jun 2008) $ 
+ */
+public class RESTBindingProviderFactory implements BindingProviderFactory<RESTBinding> {
+
+    private ServletHost servletHost;
+    
+    public RESTBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+        ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
+        this.servletHost = servletHosts.getServletHosts().get(0);
+    }
+    
+    public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component,
+                                                                   RuntimeComponentReference reference,
+                                                                   RESTBinding binding) {
+        
+        return new RESTReferenceBindingProvider(component, reference, binding);
+    }
+
+    public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component,
+                                                               RuntimeComponentService service,
+                                                               RESTBinding binding) {
+        return new RESTServiceBindingProvider(component, service, binding, servletHost);
+    }
+
+    public Class<RESTBinding> getModelType() {
+        return RESTBinding.class;
+    }
+
+}

Added: tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java (added)
+++ tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java Fri Apr 24 11:08:18 2009
@@ -0,0 +1,70 @@
+/*
+ * 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.binding.rest.provider;
+
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * Implementation of the REST Binding Provider for References
+ * 
+ * @version $Rev: 665897 $ $Date: 2008-06-09 22:31:03 +0100 (Mon, 09 Jun 2008) $
+ */
+public class RESTReferenceBindingProvider implements ReferenceBindingProvider {
+
+    private RuntimeComponentReference reference;
+    private RESTBinding binding;
+    
+    public RESTReferenceBindingProvider(RuntimeComponent component,
+                                           RuntimeComponentReference reference,
+                                           RESTBinding binding) {
+           this.reference = reference;
+           this.binding = binding;
+        
+    }
+
+    public InterfaceContract getBindingInterfaceContract() {
+        return reference.getInterfaceContract();
+    }
+    
+    public Invoker createInvoker(Operation operation) {
+        return new RESTBindingInvoker(operation, binding.getURI());
+    }
+
+    public void start() {
+        // TODO Auto-generated method stub
+
+    }
+
+    public void stop() {
+        // TODO Auto-generated method stub
+
+    }
+
+    public boolean supportsOneWayInvocation() {
+        return false;
+    }
+
+}

Added: tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java (added)
+++ tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java Fri Apr 24 11:08:18 2009
@@ -0,0 +1,148 @@
+/*
+ * 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.binding.rest.provider;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * Implementation of the REST Binding Provider for Services
+ * 
+ * @version $Rev: 683451 $ $Date: 2008-08-07 00:59:24 +0100 (Thu, 07 Aug 2008) $
+ */
+public class RESTServiceBindingProvider implements ServiceBindingProvider {
+    
+    
+        
+    
+    private RuntimeComponent component;
+    private RuntimeComponentService service;
+    private InterfaceContract serviceContract;
+    private RESTBinding binding;
+    private ServletHost servletHost;
+    private List<String> servletMappings = new ArrayList<String>();
+
+    public RESTServiceBindingProvider(RuntimeComponent component,
+                                         RuntimeComponentService service,
+                                         RESTBinding binding,
+                                         ServletHost servletHost) {
+    	this.component = component;
+        this.service = service;
+        this.binding = binding;
+        this.servletHost = servletHost;
+        
+        //clone the service contract to avoid databinding issues
+        try {
+            this.serviceContract = (InterfaceContract)service.getInterfaceContract().clone();
+        } catch(CloneNotSupportedException e) {
+            this.serviceContract = service.getInterfaceContract();
+        }
+
+    }
+
+    public InterfaceContract getBindingInterfaceContract() {
+        return service.getInterfaceContract();
+    }
+
+    public boolean supportsOneWayInvocation() {
+        return false;
+    }
+    
+    public void start() {
+
+        // Determine the service business interface
+        Class<?> serviceInterface = getTargetJavaClass(serviceContract.getInterface());
+
+        // Create a Java proxy to the target service
+        //ProxyFactory proxyFactory = new JDKProxyFactory();
+        Object proxy = component.getComponentContext().createSelfReference(serviceInterface, service).getService();
+        //Object proxy = proxyFactory.createProxy(serviceInterface, service.getRuntimeWire(binding));
+
+        // Create and register a servlet for this service
+        RESTServiceServlet serviceServlet =
+            new RESTServiceServlet(binding, service, serviceContract, serviceInterface, proxy);
+			
+		//Prateek: to add 'rest/' before the name of the service so that it could be added to url-pattern for the filter
+//		String tempURI = binding.getURI();
+//		binding.setURI("rest" + tempURI);
+		
+        String mapping = binding.getURI();
+        if (!mapping.endsWith("/")) {
+            mapping += "/";
+        }
+        if (!mapping.endsWith("*")) {
+        	mapping += "*";
+        }
+
+        servletHost.addServletMapping(mapping, serviceServlet);
+        servletMappings.add(mapping);
+        servletHost.addServletMapping(binding.getURI(), serviceServlet);
+        servletMappings.add(binding.getURI());
+        
+        //Prateek: add /rest for reverse-compatibility
+        servletHost.addServletMapping("/rest" + mapping, serviceServlet);
+        servletMappings.add("/rest" + mapping);
+        servletHost.addServletMapping("/rest" + binding.getURI(), serviceServlet);
+        servletMappings.add("/rest" + binding.getURI());
+        
+        // Save the actual binding URI
+        binding.setURI(servletHost.getURLMapping(binding.getURI()).toString());
+
+        // Register service to scaDomain.js
+        int port;
+        URI uri = URI.create(binding.getURI());
+        port = uri.getPort();
+        if (port == -1) {
+            port = servletHost.getDefaultPort();
+        }
+     }
+
+    public void stop() {
+
+        // Remove the servlet mappings we've added
+        for (String mapping: servletMappings) {
+            servletHost.removeServletMapping(mapping);
+            
+            //Prateek: for /rest
+            servletHost.removeServletMapping("/rest" + mapping);
+        }
+
+    }
+
+    private Class<?> getTargetJavaClass(Interface targetInterface) {
+        // TODO: right now assume that the target is always a Java
+        // Implementation. Need to figure out how to generate Java
+        // Interface in cases where the target is not a Java Implementation
+        return ((JavaInterface)targetInterface).getJavaClass();
+    }
+    
+
+
+}

Added: tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceServlet.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceServlet.java?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceServlet.java (added)
+++ tuscany/java/sca/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceServlet.java Fri Apr 24 11:08:18 2009
@@ -0,0 +1,138 @@
+/*
+ * 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.binding.rest.provider;
+
+import java.io.IOException;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServlet;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.rest.RESTBindingForJersey;
+import org.apache.tuscany.sca.host.webapp.WebAppServletHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+
+import com.sun.jersey.impl.container.servlet.ServletAdaptor;
+
+import com.sun.jersey.tuscany.common.CommonDataStructures;
+import com.sun.jersey.tuscany.common.CommonInterface;
+/**
+ * Servlet that handles REST requests invoking SCA services.
+ * 
+ * There is an instance of this Servlet for each <binding.rest>
+ */
+public class RESTServiceServlet extends HttpServlet {
+    private static final long serialVersionUID = 1L;
+
+    transient Binding binding;
+    transient String serviceName;
+    transient Object serviceInstance;
+    transient RuntimeComponentService componentService;
+    transient InterfaceContract serviceContract;
+    transient Class<?> serviceInterface;
+    
+	private ServletConfig servletConfig;
+	private ServletContext servletContext;
+    
+    private static ServletAdaptor jerseyServletContainer;
+
+    public RESTServiceServlet(Binding binding,
+                                 RuntimeComponentService componentService,
+                                 InterfaceContract serviceContract,
+                                 Class<?> serviceInterface,
+                                 Object serviceInstance) {
+        this.binding = binding;
+        this.serviceName = binding.getName();
+        this.componentService = componentService;
+        this.serviceContract = serviceContract;
+        this.serviceInterface = serviceInterface;
+        this.serviceInstance = serviceInstance;
+        
+        //The interface name will be stored in a HashMap in the RESTBindingForJersey class along with a
+		//reference to this servlet
+        RESTBindingForJersey.updateInterfacenameServletMap(serviceInterface.getSimpleName(), this);
+        
+    }
+
+   
+    /* (non-Javadoc)
+     * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig)
+     */
+    @Override
+    public void init(ServletConfig config) {
+    	try{
+			
+			servletConfig = config;	        
+	        servletContext = servletConfig.getServletContext();
+	        String contextPath = servletContext.getContextPath();
+			RESTBindingForJersey.setContextPath(contextPath);
+			
+			//The following code has been moved to the host-webapp modlue. 
+			//(org.apache.tuscany.sca.host.webapp.WebAppServletHost)
+			
+			//jerseyServletContainer.init(config);
+			
+			//Setting the reference below in CommonDataStructures for
+			//com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider
+			//to be able to invoke the method returnResult() method.
+			CommonInterface commonInterface = new RESTBindingForJersey();
+			CommonDataStructures.setCommonInterface(commonInterface);
+			
+		}catch(Exception e){
+			e.printStackTrace(System.out);
+		}
+    }
+
+    @Override
+    public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
+    	try{
+    		jerseyServletContainer = WebAppServletHost.getJerseyServletContainer();
+			jerseyServletContainer.service(request, response);			
+		}catch(ServletException e){
+			e.printStackTrace(System.out);
+		}
+    }
+    
+	public Binding getBinding() {
+		return binding;
+	}
+
+
+	public RuntimeComponentService getComponentService() {
+		return componentService;
+	}
+
+
+	public InterfaceContract getServiceContract() {
+		return serviceContract;
+	}
+
+
+	public static void setJerseyServletContainer(
+			ServletAdaptor jerseyServletContainer) {
+		RESTServiceServlet.jerseyServletContainer = jerseyServletContainer;
+	}
+    
+}

Added: tuscany/java/sca/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory (added)
+++ tuscany/java/sca/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory Fri Apr 24 11:08:18 2009
@@ -0,0 +1,19 @@
+# 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. 
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.rest.provider.RESTBindingProviderFactory;model=org.apache.tuscany.sca.binding.rest.RESTBinding

Added: tuscany/java/sca/modules/binding-rest/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest/META-INF/MANIFEST.MF?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest/META-INF/MANIFEST.MF (added)
+++ tuscany/java/sca/modules/binding-rest/META-INF/MANIFEST.MF Fri Apr 24 11:08:18 2009
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.rest;version="2.0.0";uses:="org.apache.tuscany.sca.assembly"
+Private-Package: org.apache.tuscany.sca.binding.rest.impl;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA REST Binding Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397320062
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA REST Binding Model
+Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.xml;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.binding.jsonp;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.rest
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6

Added: tuscany/java/sca/modules/binding-rest/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest/pom.xml?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest/pom.xml (added)
+++ tuscany/java/sca/modules/binding-rest/pom.xml Fri Apr 24 11:08:18 2009
@@ -0,0 +1,62 @@
+<?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.    
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-modules</artifactId>
+        <version>2.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>tuscany-binding-rest</artifactId>
+    <name>Apache Tuscany SCA REST Binding Model</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-assembly</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-policy</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-interface-java</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.5</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+    </build>
+
+</project>

Added: tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java (added)
+++ tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java Fri Apr 24 11:08:18 2009
@@ -0,0 +1,31 @@
+/*
+ * 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.binding.rest;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+/**
+ * A model for the REST binding.
+ * 
+ * @version $Rev: 705760 $ $Date: 2008-10-17 22:29:28 +0100 (Fri, 17 Oct 2008) $
+ */
+public interface RESTBinding extends Binding {
+
+}

Added: tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingFactory.java?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingFactory.java (added)
+++ tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingFactory.java Fri Apr 24 11:08:18 2009
@@ -0,0 +1,35 @@
+/*
+ * 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.binding.rest;
+
+
+/**
+ * Factory for the REST binding model.
+ * 
+ * @version $Rev: 705760 $ $Date: 2008-10-17 22:29:28 +0100 (Fri, 17 Oct 2008) $
+*/
+public interface RESTBindingFactory {
+
+    /**
+     * Creates a new REST Binding
+     * @return a new REST Binding
+     */
+    RESTBinding createRESTBinding();
+}

Added: tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingFactoryImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingFactoryImpl.java?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingFactoryImpl.java (added)
+++ tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingFactoryImpl.java Fri Apr 24 11:08:18 2009
@@ -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 org.apache.tuscany.sca.binding.rest.impl;
+
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.binding.rest.RESTBindingFactory;
+
+
+/**
+ * Factory for the REST binding model.
+ * 
+ * @version $Rev: 705760 $ $Date: 2008-10-17 22:29:28 +0100 (Fri, 17 Oct 2008) $
+*/
+public class RESTBindingFactoryImpl implements RESTBindingFactory {
+
+    public RESTBinding createRESTBinding() {
+        return new RESTBindingImpl();
+    }
+
+    
+}

Added: tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java (added)
+++ tuscany/java/sca/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java Fri Apr 24 11:08:18 2009
@@ -0,0 +1,62 @@
+/*
+ * 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.binding.rest.impl;
+
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+
+/**
+ * A model for the REST binding.
+ *
+ * @version $Rev: 705760 $ $Date: 2008-10-17 22:29:28 +0100 (Fri, 17 Oct 2008) $
+ */
+public class RESTBindingImpl implements RESTBinding {
+    private String name;
+    private String uri;
+
+    public String getName() {
+        return name;
+    }
+
+    public String getURI() {
+        return uri;
+    }
+
+    public void setURI(String uri) {
+        this.uri = uri;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public boolean isUnresolved() {
+        // The binding is always resolved
+        return false;
+    }
+
+    public void setUnresolved(boolean unresolved) {
+        // The binding is always resolved
+    }
+
+    @Override
+    public Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }
+}

Added: tuscany/java/sca/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.RESTBindingFactory
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.RESTBindingFactory?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.RESTBindingFactory (added)
+++ tuscany/java/sca/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.RESTBindingFactory Fri Apr 24 11:08:18 2009
@@ -0,0 +1,19 @@
+# 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. 
+
+# Implementation class for model factory
+org.apache.tuscany.sca.binding.rest.impl.RESTBindingFactoryImpl

Added: tuscany/java/sca/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor (added)
+++ tuscany/java/sca/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor Fri Apr 24 11:08:18 2009
@@ -0,0 +1,19 @@
+# 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. 
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#binding.rest,model=org.apache.tuscany.sca.binding.rest.RESTBinding,factory=org.apache.tuscany.sca.binding.rest.RESTBindingFactory

Propchange: tuscany/java/sca/samples/webapps/helloworld-rest/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 24 11:08:18 2009
@@ -0,0 +1,20 @@
+target
+work
+dojo
+*.iws
+*.ipr
+*.iml
+derby.log
+maven.log
+maven-eclipse.xml
+build.xml
+build-dependency.xml
+velocity.log*
+junit*.properties
+surefire*.properties
+.project
+.classpath
+.settings
+.deployables
+.wtpmodules
+.externalToolBuilders

Added: tuscany/java/sca/samples/webapps/helloworld-rest/README
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/webapps/helloworld-rest/README?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/samples/webapps/helloworld-rest/README (added)
+++ tuscany/java/sca/samples/webapps/helloworld-rest/README Fri Apr 24 11:08:18 2009
@@ -0,0 +1,37 @@
+Hello World REST Sample
+=======================
+
+Sample Overview
+---------------
+The service 'HelloWorldService' is exposed using the REST binding.
+
+helloworld-jsonrpc-webapp/
+  src/
+    main/
+      java/
+        helloworldjsonrpc/
+          HelloWorldService.java      - service interface
+          HelloWorldServiceImpl.java  - service implementation
+          ClientTestServiceWebapp.java - Test class; uses java.net.HttpURLConnection to make 'GET', 'PUT', 'POST requests
+      resources/
+        rest.composite             - the SCA assembly for this sample
+      webapp
+        META-INF/
+          sca-contribution.xml        - specifies the composite to be deployed
+        WEB-INF/
+          web.xml                     - defines the listener that starts up the 
+                                        Tuscany SCA runtime     
+  pom.xml                             - the Maven build file  
+
+Build the sample using Maven.
+A war 'helloworld-rest-webapp.war' will be created in the target directory. Deploy it in your web container.
+You can access the service from the browser by making a simple GET request using the following URL:
+http://<host>:<port>/helloworld-rest-webapp/HelloWorldService/helloworld/getname
+
+Use the test class 'ClientTestServiceWebapp' to test PUT, POST operations.
+
+
+
+
+
+

Added: tuscany/java/sca/samples/webapps/helloworld-rest/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/webapps/helloworld-rest/pom.xml?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/samples/webapps/helloworld-rest/pom.xml (added)
+++ tuscany/java/sca/samples/webapps/helloworld-rest/pom.xml Fri Apr 24 11:08:18 2009
@@ -0,0 +1,80 @@
+<?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.    
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-sca</artifactId>
+        <version>2.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+    <artifactId>helloworld-rest</artifactId>
+    <packaging>war</packaging>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-sca-api</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-web-runtime</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-binding-rest-runtime</artifactId>
+            <version>2.0-SNAPSHOT</version>
+            <scope>runtime</scope>
+        </dependency>
+		
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>jsr311-api</artifactId>
+            <version>1.0</version>
+            <scope>compile</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>jersey-bundle</groupId>
+            <artifactId>jersey-bundle</artifactId>
+            <version>1.0.1-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.5</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+       <finalName>${artifactId}</finalName>
+    </build>
+
+</project>

Added: tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientJavaTestService.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientJavaTestService.java?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientJavaTestService.java (added)
+++ tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientJavaTestService.java Fri Apr 24 11:08:18 2009
@@ -0,0 +1,29 @@
+package helloworldrest;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+import helloworldrest.HelloWorldService;
+
+/*
+ * To test, simply run the program
+ * Access the service by invoking the getName() method of HelloWorldService 
+ */
+
+public class ClientJavaTestService {
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		// TODO Auto-generated method stub
+		SCADomain scaDomain = SCADomain.newInstance("rest.composite");
+        HelloWorldService helloService = 
+            scaDomain.getService(HelloWorldService.class, "HelloWorldRESTServiceComponent");
+        
+		//HelloWorldService helloService = new HelloWorldServiceImpl();
+        System.out.println("### Message from REST service " + helloService.getName());
+        
+        scaDomain.close();
+	}
+
+}

Added: tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientTestServiceWebapp.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientTestServiceWebapp.java?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientTestServiceWebapp.java (added)
+++ tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientTestServiceWebapp.java Fri Apr 24 11:08:18 2009
@@ -0,0 +1,105 @@
+package helloworldrest;
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Formatter;
+import java.io.InputStreamReader;
+import java.io.BufferedReader;
+
+/**
+ *
+ * To test, deploy the application as a webapp.
+ * Then, run this file to access the REST web service by making HTTP GET/POST requests 
+ * 
+ */
+public class ClientTestServiceWebapp {
+      
+	final static String UrlBase = "http://localhost:8080/helloworld-rest-webapp/HelloWorldService";
+	
+    final static class HttpResponse {
+        Object content;
+        int code;
+        String message;
+    }
+    
+    static HttpResponse makeHttpGetRequest(String method, String url, String contentType) throws Exception {
+        HttpResponse response = new HttpResponse();
+        URL urlAddress = new URL(url);
+        HttpURLConnection huc = (HttpURLConnection) urlAddress.openConnection();
+        huc.setRequestMethod(method);
+        huc.setRequestProperty("Content-type", contentType);
+        huc.connect();
+        InputStreamReader isr = new InputStreamReader(huc.getInputStream());
+        
+        BufferedReader in = new BufferedReader(isr);
+        String uline = in.readLine();
+        response.content = uline;        
+        
+//        huc.disconnect();
+//        System.out.println("####  huc disconnected ###");
+        
+        return response;
+    }
+
+    static HttpResponse makeHttpRequest(String method, String url, String contentType, InputStream is) throws Exception {
+        HttpResponse response = new HttpResponse();
+        URL urlAddress = new URL(url);
+        HttpURLConnection huc = (HttpURLConnection) urlAddress.openConnection();
+        huc.setRequestMethod(method);
+        if (null != is) {
+            huc.setDoOutput(true);
+            huc.setRequestProperty("Content-Type", contentType);
+            OutputStream os = huc.getOutputStream();
+            byte[] buf = new byte[1024];
+            int read;
+            while ((read = is.read(buf)) != -1) {
+                os.write(buf, 0, read);
+            }            
+        }
+        InputStreamReader isr = new InputStreamReader(huc.getInputStream());
+        BufferedReader in = new BufferedReader(isr);
+        String uline = in.readLine();
+        response.content = uline;        
+        return response;
+    }
+
+    static HttpResponse makeHttpGetRequest(String method, String url, String contentType, String content) throws Exception {
+        return makeHttpRequest(method, url, contentType, new ByteArrayInputStream(content.getBytes("UTF-8")));
+    }
+    
+    static HttpResponse makeHttpRequest(String method, String url) throws Exception {
+        return makeHttpRequest(method, url, null, (InputStream)null);
+    }
+    
+    public static void main(String[] args) {
+        try {        	        
+
+            HttpResponse response;
+            
+            System.out.println("Getting the name *BEFORE* setting it:");
+            response = makeHttpGetRequest("GET", UrlBase + "/helloworld/getname", "text/plain");
+            System.out.println(new Formatter().format("---- Received String:\n%s", response.content.toString()));
+            
+            System.out.println("Setting the name:");
+            String newText = "Morpheus";
+            InputStream inputStream = new ByteArrayInputStream(newText.getBytes());
+            response = makeHttpRequest("PUT", UrlBase + "/helloworld/setname", "text/plain", inputStream);
+            
+            System.out.println("Getting the name *AFTER* setting it:");
+            response = makeHttpGetRequest("GET", UrlBase + "/helloworld/getname", "text/plain");
+            System.out.println(new Formatter().format("---- Received String:\n%s", response.content.toString()));
+            
+            System.out.println("POST Operation:");
+            response = makeHttpGetRequest("POST", UrlBase + "/helloworld/postoperation/prateek", "text/plain");
+            //System.out.println(new Formatter().format("---- Received String:\n%s", response.content.toString()));
+            
+            System.out.println("Getting the name *AFTER* the POST operation:");
+            response = makeHttpGetRequest("GET", UrlBase + "/helloworld/getname", "text/plain");
+            System.out.println(new Formatter().format("---- Received String:\n%s", response.content.toString()));
+        } catch (Exception e){
+            System.out.println("TEST FAILED! :-(");
+            e.printStackTrace(System.out);
+        }
+    }
+}

Added: tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldService.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldService.java?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldService.java (added)
+++ tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldService.java Fri Apr 24 11:08:18 2009
@@ -0,0 +1,11 @@
+package helloworldrest;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface HelloWorldService {
+
+    public void setName(String name);
+    public String getName();
+    public void postOperationTest(String name);
+}

Added: tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldServiceImpl.java?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldServiceImpl.java (added)
+++ tuscany/java/sca/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldServiceImpl.java Fri Apr 24 11:08:18 2009
@@ -0,0 +1,47 @@
+package helloworldrest;
+
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.Path;
+
+
+@Service(HelloWorldService.class)
+@Scope("Composite")
+@Path("/helloworld")
+
+public class HelloWorldServiceImpl implements HelloWorldService {
+	   
+	private String name = new String("original!");
+		
+	@Path("/setname")		
+	@PUT 
+	@Consumes("text/plain") 
+	
+	public void setName(String name){
+		this.name = name;
+
+	}
+
+	//http://<host>:<port>/helloworld-rest-webapp/HelloWorldService/helloworld/getname
+	@Path("/getname")		
+	@GET 
+	@Produces("text/plain") 
+	public String getName(){
+		return this.name;
+	}
+	
+	@POST
+	@Path("/postoperation/{name}/")
+	@Consumes("text/plain")
+	public void postOperationTest(@PathParam("name")String name){
+		this.name = name;
+	}
+
+}

Added: tuscany/java/sca/samples/webapps/helloworld-rest/src/main/resources/rest.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/webapps/helloworld-rest/src/main/resources/rest.composite?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/samples/webapps/helloworld-rest/src/main/resources/rest.composite (added)
+++ tuscany/java/sca/samples/webapps/helloworld-rest/src/main/resources/rest.composite Fri Apr 24 11:08:18 2009
@@ -0,0 +1,37 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+	       xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"   
+	       targetNamespace="http://sample"        
+           xmlns:sample="http://sample"
+           name="helloworldrest">
+           
+	<service name="HelloWorldService" promote="HelloWorldRESTServiceComponent/HelloWorldService">
+         <interface.java interface="helloworldrest.HelloWorldService"/>
+         <tuscany:binding.rest />
+     </service>           
+
+    <component name="HelloWorldRESTServiceComponent">
+        <implementation.java class="helloworldrest.HelloWorldServiceImpl"/>
+    </component>
+
+</composite>
+

Added: tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/HelloWorldJSONRPC.html
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/HelloWorldJSONRPC.html?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/HelloWorldJSONRPC.html (added)
+++ tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/HelloWorldJSONRPC.html Fri Apr 24 11:08:18 2009
@@ -0,0 +1,75 @@
+<html>
+<!--
+ * 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.    
+ -->
+  <head>
+    <title>Tuscany JSON-RPC HelloWorld Example</TITLE>
+    
+    <script type="text/javascript" src="SCADomain/scaDomain.js"></script>
+
+    <script language="JavaScript">
+
+       function getGreeting() {
+          var name = document.getElementById("name").value;
+          HelloWorldService.getGreetings(name, handleResponse);
+       }
+       
+       function handleResponse(result) {
+          document.getElementById('greeting').innerHTML=result;
+       }
+
+    </script>
+    
+    <link rel="stylesheet" type="text/css" href="style.css" />
+  </head>
+
+  <body>
+
+    <h2>Tuscany JSON-RPC HelloWorld Sample</h2>
+     
+    <table>
+      <tr>
+        <th colspan="2">Non-Dojo Example</th>
+      </tr>
+      <tr>
+        <td colspan="2">
+           This example uses the JavaScript served from 
+           <a href="SCADomain/scaDomain.js">SCADomain/scaDomain.js</a> 
+           to make JSON-RPC requests to the SCA service 'HelloWorldService'
+      </tr>
+      <tr>
+        <td>Request</td>
+        <td>Response</td>
+      </tr>
+      <tr>
+        <td>
+            <p>
+              Name please: &nbsp;&nbsp;&nbsp;
+              <input type="text" id="name" size="30" value="World" />               
+              <input type="button" value="Submit" onclick="getGreeting()" />
+            </p>
+            
+        </td>
+        <td>           
+            <div id='greeting'>None Yet.</div>
+        </td>
+      </tr>
+    </table>
+           
+  </body>
+</html>

Added: tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/META-INF/sca-contribution.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/META-INF/sca-contribution.xml?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/META-INF/sca-contribution.xml (added)
+++ tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/META-INF/sca-contribution.xml Fri Apr 24 11:08:18 2009
@@ -0,0 +1,26 @@
+<?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.    
+-->
+
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+              targetNamespace="http://sample"
+              xmlns:sample="http://sample">
+   <deployable composite="sample:helloworldrest"/>
+</contribution>
+

Added: tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/WEB-INF/web.xml?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/WEB-INF/web.xml (added)
+++ tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/WEB-INF/web.xml Fri Apr 24 11:08:18 2009
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ * 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.    
+-->
+
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
+Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+    
+	<filter>
+        <filter-name>tuscany</filter-name>
+        <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+    </filter>
+ 
+    <filter-mapping>
+        <filter-name>tuscany</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+
+</web-app>

Added: tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/style.css
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/style.css?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/style.css (added)
+++ tuscany/java/sca/samples/webapps/helloworld-rest/src/main/webapp/style.css Fri Apr 24 11:08:18 2009
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+* { font-family: arial; }
+
+table, th, td { border: 2px solid blue; border-collapse: collapse; }
+th { color: white; background-color: blue; }

Added: tuscany/java/sca/samples/webapps/helloworld-rest/target/classes/rest.composite
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/webapps/helloworld-rest/target/classes/rest.composite?rev=768260&view=auto
==============================================================================
--- tuscany/java/sca/samples/webapps/helloworld-rest/target/classes/rest.composite (added)
+++ tuscany/java/sca/samples/webapps/helloworld-rest/target/classes/rest.composite Fri Apr 24 11:08:18 2009
@@ -0,0 +1,37 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+	       xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"   
+	       targetNamespace="http://sample"        
+           xmlns:sample="http://sample"
+           name="helloworldrest">
+           
+	<service name="HelloWorldService" promote="HelloWorldRESTServiceComponent/HelloWorldService">
+         <interface.java interface="helloworldrest.HelloWorldService"/>
+         <tuscany:binding.rest />
+     </service>           
+
+    <component name="HelloWorldRESTServiceComponent">
+        <implementation.java class="helloworldrest.HelloWorldServiceImpl"/>
+    </component>
+
+</composite>
+