You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2010/05/19 02:53:54 UTC

svn commit: r945980 [1/3] - in /tuscany/sca-java-2.x/trunk: distribution/all/ distribution/all/src/main/components/ distribution/all/src/main/release/bin/ features/web20/ itest/callback-basic-ws/src/main/resources/ itest/scdl/src/test/java/org/apache/t...

Author: rfeng
Date: Wed May 19 00:53:52 2010
New Revision: 945980

URL: http://svn.apache.org/viewvc?rev=945980&view=rev
Log:
Merge branch 'jaxrs' into trunk

Added:
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSProvider.java   (with props)
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSReader.java   (with props)
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSWriter.java   (with props)
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java   (with props)
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java   (with props)
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java   (with props)
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/Items.java
      - copied, changed from r945979, tuscany/sca-java-2.x/trunk/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/ResourceWrapper.java
    tuscany/sca-java-2.x/trunk/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/InputStream2JSON.java
      - copied, changed from r945979, tuscany/sca-java-2.x/trunk/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/ResourceWrapper.java
    tuscany/sca-java-2.x/trunk/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JSON2OutputStream.java
      - copied, changed from r945979, tuscany/sca-java-2.x/trunk/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JSON2Object.java
    tuscany/sca-java-2.x/trunk/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer
    tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingContext.java   (with props)
Modified:
    tuscany/sca-java-2.x/trunk/distribution/all/pom.xml
    tuscany/sca-java-2.x/trunk/distribution/all/src/main/components/bin-samples.xml
    tuscany/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE
    tuscany/sca-java-2.x/trunk/features/web20/pom.xml
    tuscany/sca-java-2.x/trunk/itest/callback-basic-ws/src/main/resources/CallBackBasicTest.composite
    tuscany/sca-java-2.x/trunk/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java
    tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml
    tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/META-INF/MANIFEST.MF
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/pom.xml
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorInterceptor.java
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingProviderFactory.java
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatInterceptor.java
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatServiceProvider.java
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatServiceProvider.java
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/binary/BinaryServiceTestCase.java
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/CatalogServiceTestCase.java
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/CustomerServiceTestCase.java
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java
    tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java
    tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
    tuscany/sca-java-2.x/trunk/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONHelper.java
    tuscany/sca-java-2.x/trunk/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JSON2Object.java
    tuscany/sca-java-2.x/trunk/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/jackson/JacksonHelper.java
    tuscany/sca-java-2.x/trunk/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
    tuscany/sca-java-2.x/trunk/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/DataObject2XMLStreamReaderTestCase.java
    tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2Node.java
    tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2Node.java
    tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2OutputStream.java
    tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2String.java
    tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2Writer.java
    tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2Node.java
    tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2ResultTransformer.java
    tuscany/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2StringTransformer.java
    tuscany/sca-java-2.x/trunk/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/MediatorImplTestCase.java
    tuscany/sca-java-2.x/trunk/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DataPipeTestCase.java
    tuscany/sca-java-2.x/trunk/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/Node2StringTestCase.java
    tuscany/sca-java-2.x/trunk/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/PushTransformationTestCase.java
    tuscany/sca-java-2.x/trunk/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/TraxTransformerTestCase.java
    tuscany/sca-java-2.x/trunk/modules/implementation-jaxrs-runtime/META-INF/MANIFEST.MF
    tuscany/sca-java-2.x/trunk/modules/implementation-jaxrs-runtime/pom.xml
    tuscany/sca-java-2.x/trunk/modules/implementation-jaxrs-runtime/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/provider/JAXRSImplementationProvider.java
    tuscany/sca-java-2.x/trunk/modules/implementation-jaxrs-runtime/src/test/java/helloworld/jaxrs/test/HelloWorldTestCase.java
    tuscany/sca-java-2.x/trunk/modules/implementation-jaxrs/META-INF/MANIFEST.MF
    tuscany/sca-java-2.x/trunk/modules/implementation-jaxrs/pom.xml
    tuscany/sca-java-2.x/trunk/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/impl/JAXRSImplementationImpl.java
    tuscany/sca-java-2.x/trunk/modules/implementation-jaxrs/src/main/java/org/apache/tuscany/sca/implementation/jaxrs/xml/JAXRSImplementationProcessor.java
    tuscany/sca-java-2.x/trunk/modules/interface-java-jaxrs/META-INF/MANIFEST.MF
    tuscany/sca-java-2.x/trunk/modules/interface-java-jaxrs/pom.xml
    tuscany/sca-java-2.x/trunk/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/JAXRSJavaInterfaceProcessor.java
    tuscany/sca-java-2.x/trunk/modules/interface-java-jaxrs/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/RootResourceClassGenerator.java
    tuscany/sca-java-2.x/trunk/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/ResourceWrapper.java
    tuscany/sca-java-2.x/trunk/modules/interface-java-jaxrs/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxrs/RootResourceClassGeneratorTestCase.java
    tuscany/sca-java-2.x/trunk/modules/wink/pom.xml

Modified: tuscany/sca-java-2.x/trunk/distribution/all/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/distribution/all/pom.xml?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/distribution/all/pom.xml (original)
+++ tuscany/sca-java-2.x/trunk/distribution/all/pom.xml Wed May 19 00:53:52 2010
@@ -73,6 +73,7 @@
             <version>1.6.8</version>
         </dependency>
 
+        <!--
         <dependency>
             <groupId>org.apache.tuscany.sca.shades</groupId>
             <artifactId>tuscany-base</artifactId>
@@ -83,6 +84,7 @@
             <artifactId>tuscany-spring</artifactId>
             <version>2.0-SNAPSHOT</version>
         </dependency>
+        -->
 
     </dependencies>
 

Modified: tuscany/sca-java-2.x/trunk/distribution/all/src/main/components/bin-samples.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/distribution/all/src/main/components/bin-samples.xml?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/distribution/all/src/main/components/bin-samples.xml (original)
+++ tuscany/sca-java-2.x/trunk/distribution/all/src/main/components/bin-samples.xml Wed May 19 00:53:52 2010
@@ -49,6 +49,9 @@
                 <include>webapps/helloworld-jsp/**/*</include>
                 <include>webapps/helloworld-servlet/**/*</include>
                 <include>webapps/helloworld-stripes/**/*</include>
+                <include>launcher-embedded-jse/**/*</include>
+                <include>launcher-embedded-osgi/**/*</include>
+                <include>launcher-command-line//**/*</include>
             </includes>
             <excludes>
                 <!-- General file/folders to exclude -->

Modified: tuscany/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE (original)
+++ tuscany/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE Wed May 19 00:53:52 2010
@@ -317,8 +317,9 @@ The following components come under Apac
  stripes-1.5.2.jar
  tranql-connector-1.1.jar
  tribes-6.0.26.jar
- wink-common-1.0-incubating.jar
- wink-server-1.0-incubating.jar 
+ wink-common-1.1-incubating.jar
+ wink-client-1.1-incubating.jar
+ wink-server-1.1-incubating.jar 
  woden-api-1.0M8.jar
  woden-impl-dom-1.0M8.jar
  wss4j-1.5.4.jar
@@ -700,7 +701,7 @@ jsr250-api-1.0.jar, 
 jstl-1.1.2.jar,
 mail-1.4.jar, 
 servlet-api-2.5.jar, 
-jsr311-api-1.0.jar
+jsr311-api-1.1.jar
 
 COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
 
@@ -1495,8 +1496,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
 
 ================================================================================
 
-The slf4j-api-1.5.8.jar, slf4j-jdk14-1.5.8.jar, and slf4j-simple-1.5.8.jar
-are distributed under the license:
+The slf4j-api-1.5.11.jar and slf4j-jdk14-1.5.11.jar are distributed under the license:
 
 Copyright (c) 2004-2008 QOS.ch
  All rights reserved.

Modified: tuscany/sca-java-2.x/trunk/features/web20/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/features/web20/pom.xml?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/features/web20/pom.xml (original)
+++ tuscany/sca-java-2.x/trunk/features/web20/pom.xml Wed May 19 00:53:52 2010
@@ -121,6 +121,13 @@
             <version>2.0-SNAPSHOT</version>
         </dependency>                
 
+        <!-- implementations -->
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-widget-runtime-dojo</artifactId>
+            <version>2.0-SNAPSHOT</version>
+        </dependency>                
+
         <!--Databindings -->
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>

Modified: tuscany/sca-java-2.x/trunk/itest/callback-basic-ws/src/main/resources/CallBackBasicTest.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/itest/callback-basic-ws/src/main/resources/CallBackBasicTest.composite?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/itest/callback-basic-ws/src/main/resources/CallBackBasicTest.composite (original)
+++ tuscany/sca-java-2.x/trunk/itest/callback-basic-ws/src/main/resources/CallBackBasicTest.composite Wed May 19 00:53:52 2010
@@ -24,9 +24,9 @@
     <component name="CallBackBasicClient">
 		<implementation.java class="org.apache.tuscany.sca.test.CallBackBasicClientImpl"/>
 		<reference name="aCallBackService" target="CallBackBasicService">
-		  <callback>
-		     <binding.ws uri="http://localhost:8084/aCallBackService"/>
-		  </callback>
+		    <callback>
+		      <binding.ws uri="http://localhost:8084/aCallBackService"/>
+		    </callback>
 		</reference>
     </component> 
     
@@ -34,6 +34,9 @@
       <implementation.java class="org.apache.tuscany.sca.test.CallBackBasicServiceImpl"/>
       <service name="CallBackBasicService">
          <binding.ws uri="http://localhost:8085/CallBackBasicService"/>
+         <callback>
+            <binding.ws uri="http://localhost:8084/aCallBackService"/>
+         </callback>
       </service>
     </component>  
   

Modified: tuscany/sca-java-2.x/trunk/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java Wed May 19 00:53:52 2010
@@ -47,7 +47,7 @@ public class ContributionTestCase {
     @Test
     public void testRead() throws Exception {
         Deployer deployer = new DefaultDeployer();
-        File file = new File("../../samples/calculator/target/sample-calculator.jar");
+        File file = new File("../../samples/contribution-binding-sca-calculator/target/sample-contribution-binding-sca-calculator.jar");
         URL url = file.toURI().toURL();
         Monitor monitor = deployer.createMonitor();
         Contribution contribution = deployer.loadContribution(url.toURI(), url, monitor);
@@ -56,7 +56,7 @@ public class ContributionTestCase {
         // Ferkle around in the contribution verifying it looks as expected
         Assert.assertNotNull(contribution);
         List<Composite> deployables = contribution.getDeployables();
-        Assert.assertEquals(1, deployables.size());
+        Assert.assertEquals(2, deployables.size());
         Composite calculatorComposte = deployables.get(0);
         Assert.assertEquals("Calculator", calculatorComposte.getName().getLocalPart());
         Assert.assertEquals(5, calculatorComposte.getComponents().size());

Modified: tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/pom.xml Wed May 19 00:53:52 2010
@@ -89,12 +89,12 @@
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
-            <version>1.5.8</version>
+            <version>1.5.11</version>
         </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-jdk14</artifactId>
-            <version>1.5.8</version>
+            <version>1.5.11</version>
         </dependency>
         
         <dependency>

Modified: tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java Wed May 19 00:53:52 2010
@@ -133,7 +133,7 @@ public class JSONRPCDataTypeTestCase {
     @Test
     public void testList() throws Exception {
         JSONObject jsonRequest = new JSONObject(
-        "{ \"method\": \"echoList\", \"params\": [ {\"javaClass\": \"java.util.ArrayList\", \"list\": [0,1,2,3,4]}], \"id\": 8}");
+        "{ \"method\": \"echoList\", \"params\": [[0,1,2,3,4]], \"id\": 8}");
 
         WebConversation wc = new WebConversation();
         WebRequest request = new PostMethodWebRequest(SERVICE_URL,
@@ -144,7 +144,7 @@ public class JSONRPCDataTypeTestCase {
 
         JSONObject jsonResp = new JSONObject(response.getText());
 
-        Assert.assertEquals(0, jsonResp.getJSONObject("result").getJSONArray("list").get(0));
+        Assert.assertEquals(0, jsonResp.getJSONArray("result").get(0));
     }
 
     @Test
@@ -186,7 +186,7 @@ public class JSONRPCDataTypeTestCase {
     @Test
     public void testSet() throws Exception {
         JSONObject jsonRequest = new JSONObject(
-        "{ \"method\": \"echoSet\", \"params\": [ {\"javaClass\": \"java.util.HashSet\", \"set\": {\"1\": \"red\", \"2\": \"blue\"}}],\"id\": 11}");
+        "{ \"method\": \"echoSet\", \"params\": [[\"red\", \"blue\"]],\"id\": 11}");
 
         WebConversation wc = new WebConversation();
         WebRequest request = new PostMethodWebRequest(SERVICE_URL,
@@ -197,6 +197,6 @@ public class JSONRPCDataTypeTestCase {
 
         JSONObject jsonResp = new JSONObject(response.getText());
 
-        Assert.assertEquals("red", jsonResp.getJSONObject("result").getJSONObject("set").getString("red"));
+        Assert.assertEquals("red", jsonResp.getJSONArray("result").get(0));
     }
 }
\ No newline at end of file

Modified: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/META-INF/MANIFEST.MF?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/META-INF/MANIFEST.MF (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/META-INF/MANIFEST.MF Wed May 19 00:53:52 2010
@@ -18,11 +18,17 @@ Import-Package: javax.servlet,
  org.apache.tuscany.sca.binding.rest.wireformat.xml;version="2.0.0",
  org.apache.tuscany.sca.common.http;version="2.0.0",
  org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.databinding;version="2.0.0",
+ org.apache.tuscany.sca.databinding.javabeans;version="2.0.0",
+ org.apache.tuscany.sca.databinding.xml;version="2.0.0",
  org.apache.tuscany.sca.host.http;version="2.0.0",
  org.apache.tuscany.sca.interfacedef;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.impl;version="2.0.0",
+ org.apache.tuscany.sca.interfacedef.util;version="2.0.0",
  org.apache.tuscany.sca.invocation;version="2.0.0",
  org.apache.tuscany.sca.provider;version="2.0.0",
  org.apache.tuscany.sca.runtime;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0",
  org.oasisopen.sca.annotation;version="2.0.0"
 Bundle-SymbolicName: org.apache.tuscany.sca.binding.rest.runtime
 Bundle-DocURL: http://www.apache.org/

Modified: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/pom.xml?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/pom.xml (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/pom.xml Wed May 19 00:53:52 2010
@@ -35,11 +35,12 @@
             <artifactId>tuscany-binding-rest</artifactId>
             <version>2.0-SNAPSHOT</version>
         </dependency>
+                
 
         <dependency>
             <groupId>javax.ws.rs</groupId>
             <artifactId>jsr311-api</artifactId>
-            <version>1.0</version>
+            <version>1.1</version>
         </dependency>
         
         <dependency>
@@ -62,6 +63,12 @@
 
         <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>
@@ -109,7 +116,7 @@
             <groupId>org.apache.tuscany.sca</groupId>
             <artifactId>tuscany-interface-java-jaxrs</artifactId>
             <version>2.0-SNAPSHOT</version>
-            <scope>test</scope>
+            <scope>compile</scope>
         </dependency>
                         
         <dependency>
@@ -120,6 +127,18 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.wink</groupId>
+            <artifactId>wink-server</artifactId>
+            <version>1.1-incubating</version>
+        </dependency>        
+        
+        <dependency>
+            <groupId>org.apache.wink</groupId>
+            <artifactId>wink-client</artifactId>
+            <version>1.1-incubating</version>
+        </dependency>
+                        
+        <dependency>
 	        <groupId>httpunit</groupId>
 	        <artifactId>httpunit</artifactId>
 	        <version>1.6.1</version>

Modified: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorInterceptor.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorInterceptor.java?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorInterceptor.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorInterceptor.java Wed May 19 00:53:52 2010
@@ -83,6 +83,11 @@ public class JAXRSOperationSelectorInter
     public Message invoke(Message msg) {
         try {
             HTTPContext bindingContext = (HTTPContext)msg.getBindingContext();
+            
+            // By-pass the operation selector
+            if (bindingContext == null) {
+                return getNext().invoke(msg);
+            }
 
             String path = URLDecoder.decode(HTTPUtil.getRequestPath(bindingContext.getHttpRequest()), "UTF-8");
 

Added: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSProvider.java?rev=945980&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSProvider.java (added)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSProvider.java Wed May 19 00:53:52 2010
@@ -0,0 +1,201 @@
+/*
+ * 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.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.activation.DataSource;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.ext.Provider;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * A JAX-RS provider that leverages Tuscany's databinding framework to handle read/write
+ * for JAX-RS runtime
+ */
+@Provider
+public abstract class DataBindingJAXRSProvider {
+    protected DataBindingExtensionPoint dataBindingExtensionPoint;
+    protected Mediator mediator;
+
+    public DataBindingJAXRSProvider(ExtensionPointRegistry registry) {
+        this.dataBindingExtensionPoint = registry.getExtensionPoint(DataBindingExtensionPoint.class);
+        UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+        this.mediator = utilities.getUtility(Mediator.class);
+    }
+
+    protected <A extends Annotation> A getAnnotation(Annotation[] annotations, Class<A> type) {
+        for (Annotation a : annotations) {
+            if (a.annotationType() == type) {
+                return type.cast(a);
+            }
+        }
+        return null;
+    }
+
+    protected void introspectAnnotations(Annotation[] annotations, DataType targetDataType) {
+        WebResult result = getAnnotation(annotations, WebResult.class);
+        if (result != null) {
+            QName name = new QName(result.targetNamespace(), result.name());
+            targetDataType.setLogical(new XMLType(name, null));
+        }
+
+        WebParam param = getAnnotation(annotations, WebParam.class);
+        if (param != null) {
+            QName name = new QName(param.targetNamespace(), param.name());
+            targetDataType.setLogical(new XMLType(name, null));
+        }
+    }
+
+    protected DataType createDataType(Class<?> type, Type genericType) {
+        DataType dataType = new DataTypeImpl(null, type, type, genericType);
+        dataBindingExtensionPoint.introspectType(dataType, null);
+        return dataType;
+    }
+
+    protected boolean supports(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+        return MediaType.APPLICATION_JSON_TYPE.equals(mediaType) || MediaType.APPLICATION_XML_TYPE.equals(mediaType)
+        || MediaType.TEXT_XML_TYPE.equals(mediaType);
+    }
+
+    protected Object convert(InputStream content, String contentType, Class<?> type) throws IOException {
+        if (type == DataSource.class) {
+            return type.cast(new InputStreamDataSource(content, contentType));
+        } else if (type == InputStream.class) {
+            return type.cast(content);
+        } else if (type == Reader.class) {
+            return type.cast(new InputStreamReader(content, "UTF-8"));
+        } else if (type == String.class) {
+            try {
+                StringWriter sw = new StringWriter();
+                InputStreamReader reader = new InputStreamReader(content, "UTF-8");
+                char[] buf = new char[8192];
+                while (true) {
+                    int size = reader.read(buf);
+                    if (size < 0) {
+                        break;
+                    }
+                    sw.write(buf, 0, size);
+                }
+                return type.cast(sw.toString());
+            } catch (Exception e) {
+                throw new IllegalArgumentException(e);
+            }
+        } else if (type == byte[].class) {
+            try {
+                ByteArrayOutputStream bos = new ByteArrayOutputStream();
+                byte[] buf = new byte[8192];
+                while (true) {
+                    int size = content.read(buf);
+                    if (size < 0) {
+                        break;
+                    }
+                    bos.write(buf, 0, size);
+                }
+                return type.cast(bos.toByteArray());
+            } catch (Exception e) {
+                throw new IllegalArgumentException(e);
+            }
+        } else {
+            return content;
+        }
+    }
+
+    protected void write(OutputStream out, Object content, Class<?> type) throws IOException {
+        if (content == null) {
+            return;
+        }
+        InputStream in = null;
+        if (DataSource.class.isAssignableFrom(type)) {
+            in = ((DataSource)content).getInputStream();
+        } else if (InputStream.class.isAssignableFrom(type)) {
+            in = (InputStream)content;
+        } else if (type == String.class) {
+            in = new ByteArrayInputStream(((String)content).getBytes("UTF-8"));
+        } else if (type == byte[].class) {
+            in = new ByteArrayInputStream((byte[])content);
+        }
+        if (in == null) {
+            throw new IllegalArgumentException("Type is not supported: " + type);
+        }
+        byte[] buf = new byte[8192];
+        while (true) {
+            int len = in.read(buf);
+            if (len < 0) {
+                in.close();
+                break;
+            }
+            out.write(buf, 0, len);
+        }
+    }
+
+    public static final class InputStreamDataSource implements DataSource {
+
+        public static final String DEFAULT_TYPE = "application/octet-stream";
+
+        private final InputStream in;
+        private final String ctype;
+
+        public InputStreamDataSource(InputStream in) {
+            this(in, null);
+        }
+
+        public InputStreamDataSource(InputStream in, String ctype) {
+            this.in = in;
+            this.ctype = (ctype != null) ? ctype : DEFAULT_TYPE;
+        }
+
+        public String getContentType() {
+            return ctype;
+        }
+
+        public String getName() {
+            return null;
+        }
+
+        public InputStream getInputStream() throws IOException {
+            return in;
+        }
+
+        public OutputStream getOutputStream() throws IOException {
+            return null;
+        }
+
+    }
+}

Propchange: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSReader.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSReader.java?rev=945980&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSReader.java (added)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSReader.java Wed May 19 00:53:52 2010
@@ -0,0 +1,84 @@
+/*
+ * 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 java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+
+/**
+ * The generic JAX-RS message body reader based on Tuscany's databindingframework
+ */
+@Provider
+public class DataBindingJAXRSReader<T> extends DataBindingJAXRSProvider implements MessageBodyReader<T> {
+
+    public DataBindingJAXRSReader(ExtensionPointRegistry registry) {
+        super(registry);
+    }
+
+    public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+//        DataType dataType = createDataType(type, genericType);
+        return supports(type, genericType, annotations, mediaType);
+    }
+
+    public T readFrom(Class<T> type,
+                      Type genericType,
+                      Annotation[] annotations,
+                      MediaType mediaType,
+                      MultivaluedMap<String, String> httpHeaders,
+                      InputStream entityStream) throws IOException, WebApplicationException {
+        
+        Object source = entityStream;
+        DataType targetDataType = createDataType(type, genericType);
+    
+        String dataBinding = null;
+        
+        // FIXME: [rfeng] This is a hack to handle application/json
+        if (MediaType.APPLICATION_JSON_TYPE.equals(mediaType)) {
+            dataBinding = mediaType.toString() + "#" + InputStream.class.getName();
+        } else if (MediaType.APPLICATION_XML_TYPE.equals(mediaType) || MediaType.TEXT_XML_TYPE.equals(mediaType)) {
+            dataBinding = InputStream.class.getName();
+        } else {
+            dataBinding = targetDataType.getDataBinding();
+            source = convert(entityStream, mediaType.toString(), type);
+            return (T) source;
+        }
+        DataType sourceDataType =
+            new DataTypeImpl(dataBinding, InputStream.class, InputStream.class, InputStream.class);
+
+        Object result = mediator.mediate(source, sourceDataType, targetDataType, Collections.<String, Object>emptyMap());
+        return (T)result;
+    }
+    
+
+
+}

Propchange: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSReader.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSWriter.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSWriter.java?rev=945980&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSWriter.java (added)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSWriter.java Wed May 19 00:53:52 2010
@@ -0,0 +1,86 @@
+/*
+ * 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 java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+
+/**
+ * The generic JAX-RS message body writer based on Tuscany's databindingframework
+ */
+@Provider
+public class DataBindingJAXRSWriter<T> extends DataBindingJAXRSProvider implements MessageBodyWriter<T> {
+
+    public DataBindingJAXRSWriter(ExtensionPointRegistry registry) {
+        super(registry);
+    }
+
+    public long getSize(T t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+        return -1;
+    }
+
+    public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+        //        DataType dataType = createDataType(type, genericType);
+        return supports(type, genericType, annotations, mediaType);
+    }
+
+    public void writeTo(T t,
+                        Class<?> type,
+                        Type genericType,
+                        Annotation[] annotations,
+                        MediaType mediaType,
+                        MultivaluedMap<String, Object> httpHeaders,
+                        OutputStream entityStream) throws IOException, WebApplicationException {
+        DataType dataType = createDataType(type, genericType);
+
+        String dataBinding = OutputStream.class.getName();
+        // FIXME: [rfeng] This is a hack to handle application/json
+        if (MediaType.APPLICATION_JSON_TYPE.equals(mediaType)) {
+            dataBinding = mediaType.toString() + "#" + OutputStream.class.getName();
+        } else if (MediaType.APPLICATION_XML_TYPE.equals(mediaType) || MediaType.TEXT_XML_TYPE.equals(mediaType)) {
+            dataBinding = OutputStream.class.getName();
+        } else {
+            dataBinding = dataType.getDataBinding();
+            write(entityStream, t, type);
+            return;
+        }
+        DataType targetDataType =
+            new DataTypeImpl(dataBinding, OutputStream.class, OutputStream.class, OutputStream.class);
+        // dataBindingExtensionPoint.introspectType(targetDataType, null);
+
+        introspectAnnotations(annotations, targetDataType);
+
+        mediator.mediate(t, entityStream, dataType, targetDataType, Collections.<String, Object> emptyMap());
+    }
+
+}

Propchange: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/DataBindingJAXRSWriter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java?rev=945980&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java (added)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java Wed May 19 00:53:52 2010
@@ -0,0 +1,103 @@
+/*
+ * 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.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.HEAD;
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.OPTIONS;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.wink.client.ClientConfig;
+import org.apache.wink.client.EntityType;
+import org.apache.wink.client.Resource;
+import org.apache.wink.client.RestClient;
+
+/**
+ * 
+ */
+public class RESTBindingInvoker implements Invoker {
+    private RESTBinding binding;
+    private Operation operation;
+
+    public RESTBindingInvoker(RESTBinding binding, Operation operation) {
+        super();
+        this.binding = binding;
+        this.operation = operation;
+    }
+
+    private static Map<Class<?>, String> mapping = new HashMap<Class<?>, String>();
+    static {
+        mapping.put(GET.class, HttpMethod.GET);
+        mapping.put(POST.class, HttpMethod.POST);
+        mapping.put(PUT.class, HttpMethod.PUT);
+        mapping.put(DELETE.class, HttpMethod.DELETE);
+        mapping.put(HEAD.class, HttpMethod.HEAD);
+        mapping.put(OPTIONS.class, HttpMethod.OPTIONS);
+    }
+
+    public Message invoke(Message msg) {
+        ClientConfig config = new ClientConfig();
+        RestClient client = new RestClient();
+        Resource resource = client.resource(binding.getURI());
+        String method = null;
+        for (Map.Entry<Class<?>, String> e : mapping.entrySet()) {
+            if (operation.getAttributes().get(e.getKey()) != null) {
+                method = e.getValue();
+                break;
+            }
+        }
+        EntityType<?> entityType = new EntityType() {
+
+            @Override
+            public Class getRawClass() {
+                if (operation.getOutputType() != null) {
+                    return operation.getOutputType().getPhysical();
+                } else {
+                    return null;
+                }
+            }
+
+            @Override
+            public Type getType() {
+                if (operation.getOutputType() != null) {
+                    return operation.getOutputType().getGenericType();
+                } else {
+                    return null;
+                }
+            }
+
+        };
+        Object result = resource.invoke(method, entityType, msg.getBody());
+        msg.setBody(result);
+        return msg;
+    }
+
+}

Propchange: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingProviderFactory.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingProviderFactory.java?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingProviderFactory.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingProviderFactory.java Wed May 19 00:53:52 2010
@@ -50,8 +50,9 @@ public class RESTBindingProviderFactory 
     }
 
     public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+        return new RESTReferenceBindingProvider(extensionPoints, endpointReference);
     	// Binding REST is currently NOT supporting References
-        return null;
+        // throw new UnsupportedOperationException("binding.rest for SCA references is not implemented yet.");
     }
 
     public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {

Added: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java?rev=945980&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java (added)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java Wed May 19 00:53:52 2010
@@ -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.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.EndpointReferenceProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * 
+ */
+public class RESTReferenceBindingProvider implements EndpointReferenceProvider {
+    private ExtensionPointRegistry registry;
+    private RuntimeEndpointReference endpointReference;
+
+    public RESTReferenceBindingProvider(ExtensionPointRegistry registry, RuntimeEndpointReference endpointReference) {
+        super();
+        this.registry = registry;
+        this.endpointReference = endpointReference;
+    }
+
+    public void configure() {
+    }
+
+    public Invoker createInvoker(Operation operation) {
+        return new RESTBindingInvoker((RESTBinding)endpointReference.getBinding(), operation);
+    }
+
+    public InterfaceContract getBindingInterfaceContract() {
+        return endpointReference.getComponentReferenceInterfaceContract();
+    }
+
+    public boolean supportsOneWayInvocation() {
+        return false;
+    }
+
+    public void start() {
+    }
+
+    public void stop() {
+    }
+
+}

Propchange: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTReferenceBindingProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java Wed May 19 00:53:52 2010
@@ -19,13 +19,31 @@
 
 package org.apache.tuscany.sca.binding.rest.provider;
 
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
 import javax.servlet.Servlet;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+import javax.xml.namespace.QName;
 
 import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat;
+import org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
 import org.apache.tuscany.sca.host.http.ServletHost;
 import org.apache.tuscany.sca.interfacedef.InterfaceContract;
 import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.jaxrs.RootResourceClassGenerator;
+import org.apache.tuscany.sca.invocation.Interceptor;
 import org.apache.tuscany.sca.invocation.InvocationChain;
 import org.apache.tuscany.sca.invocation.Invoker;
 import org.apache.tuscany.sca.invocation.MessageFactory;
@@ -39,6 +57,8 @@ import org.apache.tuscany.sca.provider.W
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.runtime.RuntimeComponentService;
 import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.wink.server.utils.RegistrationUtils;
+import org.oasisopen.sca.ServiceRuntimeException;
 
 /**
  * Implementation of an HTTP binding provider.
@@ -47,86 +67,98 @@ import org.apache.tuscany.sca.runtime.Ru
  */
 public class RESTServiceBindingProvider implements EndpointProvider {
     private ExtensionPointRegistry extensionPoints;
-    
+
     private RuntimeEndpoint endpoint;
     private RuntimeComponent component;
-    private RuntimeComponentService service;  
+    private RuntimeComponentService service;
     private InterfaceContract serviceContract;
     private RESTBinding binding;
     private MessageFactory messageFactory;
-    
+
     private OperationSelectorProvider osProvider;
     private WireFormatProvider wfProvider;
-    
+
     private ServletHost servletHost;
     private String servletMapping;
     private RESTBindingListenerServlet bindingListenerServlet;
-   
+
+    private SimpleApplication application;
+
     public RESTServiceBindingProvider(RuntimeEndpoint endpoint,
                                       ExtensionPointRegistry extensionPoints,
                                       MessageFactory messageFactory,
                                       ServletHost servletHost) {
-    	
-    	this.endpoint = endpoint;
+
+        this.endpoint = endpoint;
         this.component = (RuntimeComponent)endpoint.getComponent();
         this.service = (RuntimeComponentService)endpoint.getService();
         this.binding = (RESTBinding)endpoint.getBinding();
-        
+
         this.extensionPoints = extensionPoints;
         this.messageFactory = messageFactory;
         this.servletHost = servletHost;
-        
+
         // retrieve operation selector and wire format service providers
-        
-        ProviderFactoryExtensionPoint  providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
 
-        
+        ProviderFactoryExtensionPoint providerFactories =
+            extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+
         if (binding.getOperationSelector() != null) {
             // Configure the interceptors for operation selection
-            OperationSelectorProviderFactory osProviderFactory = (OperationSelectorProviderFactory) providerFactories.getProviderFactory(binding.getOperationSelector().getClass());
+            OperationSelectorProviderFactory osProviderFactory =
+                (OperationSelectorProviderFactory)providerFactories.getProviderFactory(binding.getOperationSelector()
+                    .getClass());
             if (osProviderFactory != null) {
                 this.osProvider = osProviderFactory.createServiceOperationSelectorProvider(endpoint);
-            }            
+            }
         }
-        
+
         if (binding.getRequestWireFormat() != null && binding.getResponseWireFormat() != null) {
             // Configure the interceptors for wire format
-            WireFormatProviderFactory wfProviderFactory = (WireFormatProviderFactory) providerFactories.getProviderFactory(binding.getRequestWireFormat().getClass());
+            WireFormatProviderFactory wfProviderFactory =
+                (WireFormatProviderFactory)providerFactories.getProviderFactory(binding.getRequestWireFormat()
+                    .getClass());
             if (wfProviderFactory != null) {
                 this.wfProvider = wfProviderFactory.createServiceWireFormatProvider(endpoint);
-            }            
+            }
         }
 
-        
         //clone the service contract to avoid databinding issues
         try {
-            this.serviceContract = (InterfaceContract) service.getInterfaceContract().clone();
-            
+            this.serviceContract = (InterfaceContract)service.getInterfaceContract().clone();
+
             // configure data binding
             if (this.wfProvider != null) {
                 wfProvider.configureWireFormatInterfaceContract(serviceContract);
             }
-        } catch(CloneNotSupportedException e) {
+        } catch (CloneNotSupportedException e) {
             this.serviceContract = service.getInterfaceContract();
         }
-        
+
     }
 
     public void start() {
+        InvocationChain bindingChain = endpoint.getBindingInvocationChain();
+
+        application = registerWithJAXRS();
+        if (application != null) {
+            return;
+        }
+
         // Get the invokers for the supported operations
         Servlet servlet = null;
-        Invoker bindingInvoker = endpoint.getBindingInvocationChain().getHeadInvoker();
-        bindingListenerServlet = new RESTBindingListenerServlet(binding, bindingInvoker, messageFactory );
+        Invoker bindingInvoker = bindingChain.getHeadInvoker();
+        bindingListenerServlet = new RESTBindingListenerServlet(binding, bindingInvoker, messageFactory);
         for (InvocationChain invocationChain : endpoint.getInvocationChains()) {
-            
+
             Operation operation = invocationChain.getTargetOperation();
             Invoker serviceInvoker = invocationChain.getHeadInvoker();
             String operationName = operation.getName();
-            
+
             if (binding.getOperationSelector() != null || binding.getRequestWireFormat() != null) {
                 bindingListenerServlet.setInvoker(serviceInvoker);
                 servlet = bindingListenerServlet;
-            } else if (operationName.equals("get")) { 
+            } else if (operationName.equals("get")) {
                 bindingListenerServlet.setGetInvoker(serviceInvoker);
                 servlet = bindingListenerServlet;
             } else if (operationName.equals("conditionalGet")) {
@@ -153,12 +185,12 @@ public class RESTServiceBindingProvider 
             } else if (operationName.equals("service")) {
                 servlet = new RESTServiceListenerServlet(binding, serviceInvoker, messageFactory);
                 break;
-            }             
+            }
         }
         if (servlet == null) {
             throw new IllegalStateException("No get or service method found on the service");
         }
-                
+
         // Create our HTTP service listener Servlet and register it with the
         // Servlet host
         servletMapping = binding.getURI();
@@ -168,11 +200,139 @@ public class RESTServiceBindingProvider 
         if (!servletMapping.endsWith("*")) {
             servletMapping += "*";
         }
-        
+
         servletHost.addServletMapping(servletMapping, servlet);
     }
 
-    public void stop() {        
+    private static Map<QName, String> wireFormatToMediaTypeMapping = new HashMap<QName, String>();
+    static {
+        wireFormatToMediaTypeMapping.put(JSONWireFormat.REST_WIREFORMAT_JSON_QNAME, MediaType.APPLICATION_JSON);
+        wireFormatToMediaTypeMapping.put(XMLWireFormat.REST_WIREFORMAT_XML_QNAME, MediaType.APPLICATION_XML);
+    }
+
+    private SimpleApplication registerWithJAXRS() {
+        try {
+            SimpleApplication application = null;
+
+            JavaInterface javaInterface = (JavaInterface)endpoint.getComponentServiceInterfaceContract().getInterface();
+            Class<?> interfaze = javaInterface.getJavaClass();
+
+            boolean isJAXRS = isJAXRSResource(interfaze);
+            if (isJAXRS) {
+                application = new SimpleApplication(interfaze);
+
+                TuscanyRESTServlet restServlet = new TuscanyRESTServlet(extensionPoints);
+
+                // Create our HTTP service listener Servlet and register it with the
+                // Servlet host
+                servletMapping = binding.getURI();
+                if (!servletMapping.endsWith("/")) {
+                    servletMapping += "/";
+                }
+                if (!servletMapping.endsWith("*")) {
+                    servletMapping += "*";
+                }
+
+                servletHost.addServletMapping(servletMapping, restServlet);
+                RegistrationUtils.registerApplication(application, restServlet.getServletContext());
+                return application;
+            } else {
+                return null;
+            }
+        } catch (Exception e) {
+            throw new ServiceRuntimeException(e);
+        }
+    }
+
+    private class SimpleApplication extends Application {
+        private Class<?> resourceClass;
+
+        public SimpleApplication(Class<?> resourceClass) {
+            super();
+            // boolean isJAXRS = isJAXRSResource(resourceClass);
+            // if (isJAXRS) {
+            if (resourceClass.isInterface()) {
+                this.resourceClass = generateResourceClass(resourceClass);
+            } else {
+                this.resourceClass = resourceClass;
+            }
+            // } else {
+            //    throw new ServiceRuntimeException(resourceClass+" is not a JAX-RS resource class.");
+            // }
+        }
+
+        @Override
+        public Set<Class<?>> getClasses() {
+            Set<Class<?>> classes = new HashSet<Class<?>>();
+            classes.add(resourceClass);
+            return classes;
+        }
+
+        private Class<?> generateResourceClass(Class<?> interfaze) {
+            try {
+                QName requestWireFormat = null;
+                if (binding.getRequestWireFormat() != null) {
+                    requestWireFormat = binding.getRequestWireFormat().getSchemaName();
+                }
+                QName responeWireFormat = null;
+                if (binding.getResponseWireFormat() != null) {
+                    responeWireFormat = binding.getRequestWireFormat().getSchemaName();
+                }
+                String requestMediaType = wireFormatToMediaTypeMapping.get(requestWireFormat);
+                String responseMediaType = wireFormatToMediaTypeMapping.get(responeWireFormat);
+
+                String uri = endpoint.getBinding().getURI();
+                String path = URI.create(uri).getPath();
+                Class<?> cls =
+                    RootResourceClassGenerator.generateRootResourceClass(interfaze,
+                                                                         path,
+                                                                         requestMediaType,
+                                                                         responseMediaType);
+                ProxyFactory proxyFactory = ExtensibleProxyFactory.getInstance(extensionPoints);
+                Object proxy = proxyFactory.createProxy(interfaze, endpoint);
+                RootResourceClassGenerator.injectProxy(cls, proxy);
+                return cls;
+            } catch (Exception e) {
+                throw new ServiceRuntimeException(e);
+            }
+        }
+
+        public void destroy() {
+            resourceClass = null;
+        }
+    }
+
+    public static boolean isJAXRSResource(Class<?> cls) {
+        for (Annotation a : cls.getAnnotations()) {
+            if (a.annotationType().getName().startsWith("javax.ws.rs.")) {
+                return true;
+            }
+        }
+        for (Method method : cls.getMethods()) {
+            for (Annotation a : method.getAnnotations()) {
+                if (a.annotationType().getName().startsWith("javax.ws.rs.")) {
+                    return true;
+                }
+            }
+            
+            /*
+            for (Annotation[] annotations : method.getParameterAnnotations()) {
+                for (Annotation a : annotations) {
+                    if (a.annotationType().getName().startsWith("javax.ws.rs.")) {
+                        return true;
+                    }
+                }
+
+            }
+            */
+        }
+        return false;
+    }
+
+    public void stop() {
+        if (application != null) {
+            application.destroy();
+        }
         // Unregister the Servlet from the Servlet host
         servletHost.removeServletMapping(servletMapping);
     }
@@ -180,11 +340,11 @@ public class RESTServiceBindingProvider 
     public InterfaceContract getBindingInterfaceContract() {
         return serviceContract;
     }
-    
+
     public boolean supportsOneWayInvocation() {
         return false;
     }
-    
+
     /**
      * Add specific rest interceptor to invocation chain
      */
@@ -193,12 +353,18 @@ public class RESTServiceBindingProvider 
         InvocationChain bindingChain = endpoint.getBindingInvocationChain();
 
         if (wfProvider != null) {
-            bindingChain.addInterceptor(Phase.SERVICE_BINDING_WIREFORMAT, wfProvider.createInterceptor());
+            Interceptor interceptor = wfProvider.createInterceptor();
+            if (interceptor != null) {
+                bindingChain.addInterceptor(Phase.SERVICE_BINDING_WIREFORMAT, interceptor);
+            }
+        }
+
+        if (osProvider != null) {
+            Interceptor interceptor = osProvider.createInterceptor();
+            if (interceptor != null) {
+                bindingChain.addInterceptor(Phase.SERVICE_BINDING_OPERATION_SELECTOR, interceptor);
+            }
         }
-        
-        if(osProvider != null) {
-            bindingChain.addInterceptor(Phase.SERVICE_BINDING_OPERATION_SELECTOR, osProvider.createInterceptor());    
-        }        
 
     }
 

Added: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java?rev=945980&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java (added)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java Wed May 19 00:53:52 2010
@@ -0,0 +1,94 @@
+/*
+ * 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 java.util.Enumeration;
+
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.wink.common.internal.registry.ProvidersRegistry;
+import org.apache.wink.server.internal.DeploymentConfiguration;
+import org.apache.wink.server.internal.RequestProcessor;
+import org.apache.wink.server.internal.handlers.ServerMessageContext;
+import org.apache.wink.server.internal.servlet.RestServlet;
+
+/**
+ * 
+ */
+public class TuscanyRESTServlet extends RestServlet {
+    private static final long serialVersionUID = 89997233133964915L;
+    private ExtensionPointRegistry registry;
+
+    public TuscanyRESTServlet(ExtensionPointRegistry registry) {
+        super();
+        this.registry = registry;
+    }
+
+    @Override
+    public DeploymentConfiguration getDeploymentConfiguration() throws ClassNotFoundException, InstantiationException,
+        IllegalAccessException, IOException {
+        DeploymentConfiguration config = super.getDeploymentConfiguration();
+        // [rfeng] FIXME: This is a hack to fool Apache wink to not remove the servlet path
+        config.setFilterConfig(new FilterConfig() {
+            
+            public ServletContext getServletContext() {
+                return getServletContext();
+            }
+            
+            public Enumeration getInitParameterNames() {
+                return getInitParameterNames();
+            }
+            
+            public String getInitParameter(String arg0) {
+                return getInitParameter(arg0);
+            }
+            
+            public String getFilterName() {
+                return getServletName();
+            }
+        });
+        ProvidersRegistry providers = config.getProvidersRegistry();
+        providers.addProvider(new DataBindingJAXRSReader(registry), 0.001, true);
+        providers.addProvider(new DataBindingJAXRSWriter(registry), 0.001, true);
+        return config;
+    }
+
+    @Override
+    public RequestProcessor getRequestProcessor() {
+        return super.getRequestProcessor();
+    }
+
+    public ServerMessageContext createMessageContext(HttpServletRequest request, HttpServletResponse response) {
+        ServerMessageContext messageContext;
+        try {
+            messageContext = new ServerMessageContext(request, response, getDeploymentConfiguration());
+        } catch (Exception e) {
+            throw new IllegalArgumentException(e);
+        }
+        return messageContext;
+    }
+    
+
+}

Propchange: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatInterceptor.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatInterceptor.java?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatInterceptor.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatInterceptor.java Wed May 19 00:53:52 2010
@@ -54,7 +54,9 @@ public class JSONWireFormatInterceptor i
     
     public Message invoke(Message msg) {
         HTTPContext bindingContext = (HTTPContext) msg.getBindingContext();
-        
+        if (bindingContext == null) {
+            return getNext().invoke(msg);
+        }
         // Decode using the charset in the request if it exists otherwise
         // use UTF-8 as this is what all browser implementations use.
         String charset = bindingContext.getHttpRequest().getCharacterEncoding();

Modified: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatServiceProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatServiceProvider.java?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatServiceProvider.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatServiceProvider.java Wed May 19 00:53:52 2010
@@ -22,6 +22,7 @@ package org.apache.tuscany.sca.binding.r
 import java.util.List;
 
 import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.rest.provider.RESTServiceBindingProvider;
 import org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.javabeans.SimpleJavaDataBinding;
@@ -30,6 +31,7 @@ import org.apache.tuscany.sca.interfaced
 import org.apache.tuscany.sca.interfacedef.Interface;
 import org.apache.tuscany.sca.interfacedef.InterfaceContract;
 import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
 import org.apache.tuscany.sca.invocation.Interceptor;
 import org.apache.tuscany.sca.invocation.Phase;
 import org.apache.tuscany.sca.provider.WireFormatProvider;
@@ -46,27 +48,44 @@ public class JSONWireFormatServiceProvid
     
     private InterfaceContract serviceContract;
     private Binding binding;
+    private boolean jaxrs;
     
     public JSONWireFormatServiceProvider(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint) {
         this.extensionPoints = extensionPoints;
         this.endpoint = endpoint;
         this.binding = endpoint.getBinding();
+        this.jaxrs = isJAXRSResource();
+    }
+    
+    private boolean isJAXRSResource() {
+        Interface interfaze = endpoint.getComponentServiceInterfaceContract().getInterface();
+        if (interfaze instanceof JavaInterface) {
+            if (RESTServiceBindingProvider.isJAXRSResource(((JavaInterface)interfaze).getJavaClass())) {
+                return true;
+            }
+        } 
+        return false;
     }
     
     public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract) {
         serviceContract = interfaceContract;
         
-        //set JSON databinding
-        setDataBinding(serviceContract.getInterface());
-        
-        //make JSON databinding default
-        serviceContract.getInterface().resetDataBinding(JSONDataBinding.NAME);
+        if (!jaxrs) {
+            //set JSON databinding
+            setDataBinding(serviceContract.getInterface());
+
+            //make JSON databinding default
+            serviceContract.getInterface().resetDataBinding(JSONDataBinding.NAME);
+        }
         
         return serviceContract;
     }
 
     public Interceptor createInterceptor() {
-        if(binding.getRequestWireFormat() != null && binding.getRequestWireFormat() instanceof JSONWireFormat) {
+        if (jaxrs) {
+            return null;
+        }
+        if (binding.getRequestWireFormat() != null && binding.getRequestWireFormat() instanceof JSONWireFormat) {
             return new JSONWireFormatInterceptor(extensionPoints, endpoint);
         }
         return null;

Modified: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatServiceProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatServiceProvider.java?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatServiceProvider.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatServiceProvider.java Wed May 19 00:53:52 2010
@@ -24,6 +24,7 @@ import java.util.List;
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.rest.provider.RESTServiceBindingProvider;
 import org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.javabeans.SimpleJavaDataBinding;
@@ -32,6 +33,7 @@ import org.apache.tuscany.sca.interfaced
 import org.apache.tuscany.sca.interfacedef.Interface;
 import org.apache.tuscany.sca.interfacedef.InterfaceContract;
 import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
 import org.apache.tuscany.sca.invocation.Interceptor;
 import org.apache.tuscany.sca.invocation.Phase;
 import org.apache.tuscany.sca.provider.WireFormatProvider;
@@ -51,26 +53,44 @@ public class XMLWireFormatServiceProvide
     private InterfaceContract serviceContract;
     private Binding binding;
     
+    private boolean jaxrs;
+    
     public XMLWireFormatServiceProvider(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint) {
         this.extensionPoints = extensionPoints;
         this.endpoint = endpoint;
         this.binding = endpoint.getBinding();
+        this.jaxrs = isJAXRSResource();
+    }
+    
+    private boolean isJAXRSResource() {
+        Interface interfaze = endpoint.getComponentServiceInterfaceContract().getInterface();
+        if (interfaze instanceof JavaInterface) {
+            if (RESTServiceBindingProvider.isJAXRSResource(((JavaInterface)interfaze).getJavaClass())) {
+                return true;
+            }
+        } 
+        return false;
     }
     
     public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract) {
         serviceContract = interfaceContract;
-        
-        //make XML databinding default
-        serviceContract.getInterface().resetDataBinding(DATABABINDING);
-        
-        //set XML databinding
-        setDataBinding(serviceContract.getInterface());
+        if (!jaxrs) {
+
+            //make XML databinding default
+            serviceContract.getInterface().resetDataBinding(DATABABINDING);
+
+            //set XML databinding
+            setDataBinding(serviceContract.getInterface());
+        }
 
         return serviceContract;
     }
 
     public Interceptor createInterceptor() {
-        if(binding.getRequestWireFormat() != null && binding.getRequestWireFormat() instanceof XMLWireFormat) {
+        if (jaxrs) {
+            return null;
+        }
+        if (binding.getRequestWireFormat() != null && binding.getRequestWireFormat() instanceof XMLWireFormat) {
             return new XMLWireFormatInterceptor(extensionPoints, endpoint);
         }
         return null;

Modified: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java Wed May 19 00:53:52 2010
@@ -28,6 +28,7 @@ import org.apache.tuscany.sca.node.NodeF
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
 
 import com.meterware.httpunit.GetMethodWebRequest;
@@ -35,6 +36,7 @@ import com.meterware.httpunit.WebConvers
 import com.meterware.httpunit.WebRequest;
 import com.meterware.httpunit.WebResponse;
 
+@Ignore
 public class EchoServiceTestCase {
     private static final String SERVICE_URL = "http://localhost:8085/EchoService";
 
@@ -76,6 +78,7 @@ public class EchoServiceTestCase {
 
         WebConversation wc = new WebConversation();
         WebRequest request = new GetMethodWebRequest(SERVICE_URL + queryString);
+        request.setHeaderField("Content-Type", "application/json");
         WebResponse response = wc.getResource(request);
 
         Assert.assertEquals(200, response.getResponseCode());
@@ -88,6 +91,7 @@ public class EchoServiceTestCase {
 
         WebConversation wc = new WebConversation();
         WebRequest request = new GetMethodWebRequest(SERVICE_URL + queryString);
+        request.setHeaderField("Content-Type", "application/json");
         WebResponse response = wc.getResource(request);
 
         Assert.assertEquals(200, response.getResponseCode());

Modified: tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/binary/BinaryServiceTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/binary/BinaryServiceTestCase.java?rev=945980&r1=945979&r2=945980&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/binary/BinaryServiceTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/binary/BinaryServiceTestCase.java Wed May 19 00:53:52 2010
@@ -80,7 +80,7 @@ public class BinaryServiceTestCase {
                                      "application/octet-stream");
         WebResponse response = wc.getResource(request);
 
-        Assert.assertEquals(200, response.getResponseCode());
+        Assert.assertEquals(204, response.getResponseCode());
         
         // Read the content
         request = new GetMethodWebRequest(SERVICE_URL);
@@ -94,7 +94,7 @@ public class BinaryServiceTestCase {
                                      "application/octet-stream");
         response = wc.getResource(request);
 
-        Assert.assertEquals(200, response.getResponseCode());
+        Assert.assertEquals(204, response.getResponseCode());
 
         //read new results and expect to get new item back in the response
         request = new GetMethodWebRequest(SERVICE_URL);