summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-rest-runtime/src
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-rest-runtime/src')
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorProviderFactory.java (renamed from sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorProviderFctory.java)4
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorInterceptor.java156
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorProviderFactory.java52
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorReferenceProvider.java50
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorServiceProvider.java57
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingListenerServlet.java25
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatProviderFactory.java (renamed from sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatProviderFctory.java)4
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatProviderFactory.java (renamed from sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatProviderFctory.java)4
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory3
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory4
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java98
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/echo/Echo.java43
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/echo/EchoImpl.java50
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/resources/echo.composite36
14 files changed, 552 insertions, 34 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorProviderFctory.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorProviderFactory.java
index 12a90d8fbb..d057f1a852 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorProviderFctory.java
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/provider/JAXRSOperationSelectorProviderFactory.java
@@ -31,10 +31,10 @@ import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
*
* @version $Rev$ $Date$
*/
-public class JAXRSOperationSelectorProviderFctory implements OperationSelectorProviderFactory<JAXRSOperationSelector>{
+public class JAXRSOperationSelectorProviderFactory implements OperationSelectorProviderFactory<JAXRSOperationSelector>{
private ExtensionPointRegistry extensionPoints;
- public JAXRSOperationSelectorProviderFctory(ExtensionPointRegistry extensionPoints) {
+ public JAXRSOperationSelectorProviderFactory(ExtensionPointRegistry extensionPoints) {
this.extensionPoints = extensionPoints;
}
public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeEndpointReference endpointReference) {
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorInterceptor.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorInterceptor.java
new file mode 100644
index 0000000000..9d9edaaf6f
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorInterceptor.java
@@ -0,0 +1,156 @@
+/*
+ * 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.operationselector.rpc.provider;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.QueryParam;
+
+import org.apache.tuscany.sca.common.http.HTTPContext;
+import org.apache.tuscany.sca.common.http.HTTPUtil;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * RPC operation selector Interceptor.
+ *
+ * @version $Rev$ $Date$
+*/
+public class RPCOperationSelectorInterceptor implements Interceptor {
+ private ExtensionPointRegistry extensionPoints;
+ private RuntimeEndpoint endpoint;
+
+ private RuntimeComponentService service;
+ private InterfaceContract interfaceContract;
+ private List<Operation> serviceOperations;
+
+ private Invoker next;
+
+ public RPCOperationSelectorInterceptor(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint) {
+ this.extensionPoints = extensionPoints;
+ this.endpoint = endpoint;
+
+ this.service = (RuntimeComponentService)endpoint.getService();
+ this.interfaceContract = service.getInterfaceContract();
+ this.serviceOperations = service.getInterfaceContract().getInterface().getOperations();
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ HTTPContext bindingContext = (HTTPContext)msg.getBindingContext();
+
+ String path = URLDecoder.decode(HTTPUtil.getRequestPath(bindingContext.getHttpRequest()), "UTF-8");
+
+ if (path.startsWith("/")) {
+ path = path.substring(1);
+ }
+
+ String operationName = bindingContext.getHttpRequest().getParameter("method");
+ Operation operation = findOperation( operationName );
+
+ if (operation == null) {
+ throw new RuntimeException("Invalid Operation '" + operationName + "'" );
+ }
+
+ final JavaOperation javaOperation = (JavaOperation)operation;
+ final Method method = javaOperation.getJavaMethod();
+
+ List<DataType> operationInputType = operation.getInputType().getLogical();
+ int size = operationInputType.size();
+ for (int i = 0; i < size; i++) {
+ System.out.println(operationInputType.get(i));
+ }
+
+ List<Object> messageParameters = new ArrayList<Object>();
+ for(int i=0; i<method.getParameterTypes().length; i++) {
+ for(Annotation annotation : method.getParameterAnnotations()[i]) {
+ if (annotation instanceof QueryParam) {
+ QueryParam queryParam = (QueryParam) annotation;
+ String name = queryParam.value();
+ String[] values = bindingContext.getHttpRequest().getParameterValues(name);
+ if(values.length == 1) {
+ messageParameters.add(values[0]);
+ } else {
+ messageParameters.add(values);
+ }
+
+ }
+ }
+ }
+
+
+ System.out.println(messageParameters);
+
+ Object[] body = new Object[messageParameters.size()];
+ messageParameters.toArray(body);
+
+ msg.setBody(body);
+ msg.setOperation(operation);
+
+ return getNext().invoke(msg);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Find the operation from the component service contract
+ * @param componentService
+ * @param method
+ * @return
+ */
+ private Operation findOperation(String method) {
+ if (method.contains(".")) {
+ method = method.substring(method.lastIndexOf(".") + 1);
+ }
+
+ List<Operation> operations = endpoint.getComponentServiceInterfaceContract().getInterface().getOperations();
+
+ Operation result = null;
+ for (Operation o : operations) {
+ if (o.getName().equalsIgnoreCase(method)) {
+ result = o;
+ break;
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorProviderFactory.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorProviderFactory.java
new file mode 100644
index 0000000000..011e89e7cc
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorProviderFactory.java
@@ -0,0 +1,52 @@
+/*
+ * 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.operationselector.rpc.provider;
+
+import org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelector;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * RPC operation selector Provider Factory.
+ *
+ * @version $Rev$ $Date$
+*/
+public class RPCOperationSelectorProviderFactory implements OperationSelectorProviderFactory<RPCOperationSelector>{
+ private ExtensionPointRegistry extensionPoints;
+
+ public RPCOperationSelectorProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ }
+ public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeEndpointReference endpointReference) {
+ return new RPCOperationSelectorReferenceProvider(extensionPoints, endpointReference);
+ }
+
+ public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeEndpoint endpoint) {
+ return new RPCOperationSelectorServiceProvider(extensionPoints, endpoint);
+ }
+
+ public Class<RPCOperationSelector> getModelType() {
+ return RPCOperationSelector.class;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorReferenceProvider.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorReferenceProvider.java
new file mode 100644
index 0000000000..c87b2fc21d
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorReferenceProvider.java
@@ -0,0 +1,50 @@
+/*
+ * 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.operationselector.rpc.provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * RPC operation selector Reference Provider.
+ *
+ * @version $Rev$ $Date$
+*/
+public class RPCOperationSelectorReferenceProvider implements OperationSelectorProvider {
+ private ExtensionPointRegistry extensionPoints;
+ private RuntimeEndpointReference endpointReference;
+
+ public RPCOperationSelectorReferenceProvider(ExtensionPointRegistry extensionPoints, RuntimeEndpointReference endpointReference ) {
+ this.extensionPoints = extensionPoints;
+ this.endpointReference = endpointReference;
+ }
+
+ public Interceptor createInterceptor() {
+ return null;
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_OPERATION_SELECTOR;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorServiceProvider.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorServiceProvider.java
new file mode 100644
index 0000000000..e4a003d4b5
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/provider/RPCOperationSelectorServiceProvider.java
@@ -0,0 +1,57 @@
+/*
+ * 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.operationselector.rpc.provider;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelector;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.OperationSelectorProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * RPC operation selector Service Provider.
+ *
+ * @version $Rev$ $Date$
+*/
+public class RPCOperationSelectorServiceProvider implements OperationSelectorProvider {
+ private ExtensionPointRegistry extensionPoints;
+ private RuntimeEndpoint endpoint;
+
+ private Binding binding;
+
+ public RPCOperationSelectorServiceProvider(ExtensionPointRegistry extensionPoints, RuntimeEndpoint endpoint) {
+ this.extensionPoints = extensionPoints;
+ this.endpoint = endpoint;
+ this.binding = endpoint.getBinding();
+ }
+
+ public Interceptor createInterceptor() {
+ if(binding.getOperationSelector() != null && binding.getOperationSelector() instanceof RPCOperationSelector) {
+ return new RPCOperationSelectorInterceptor(extensionPoints, endpoint);
+ }
+ return null;
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_OPERATION_SELECTOR;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingListenerServlet.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingListenerServlet.java
index d09e197388..5eba58dd9e 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingListenerServlet.java
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingListenerServlet.java
@@ -102,25 +102,6 @@ public class RESTBindingListenerServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if( binding.getOperationSelector() != null || binding.getRequestWireFormat() != null) {
- // Decode using the charset in the request if it exists otherwise
- // use UTF-8 as this is what all browser implementations use.
- String charset = request.getCharacterEncoding();
- if (charset == null) {
- charset = "UTF-8";
- }
-
- /*
- BufferedReader in = new BufferedReader(new InputStreamReader(request.getInputStream(), charset));
-
- // Read the request
- CharArrayWriter data = new CharArrayWriter();
- char[] buf = new char[4096];
- int ret;
- while ((ret = in.read(buf, 0, 4096)) != -1) {
- data.write(buf, 0, ret);
- }
- */
-
HTTPContext bindingContext = new HTTPContext();
bindingContext.setHttpRequest(request);
bindingContext.setHttpResponse(response);
@@ -131,12 +112,6 @@ public class RESTBindingListenerServlet extends HttpServlet {
requestMessage.setBody(new Object[] {request.getInputStream()});
- /*
- if(data.size() > 0) {
- requestMessage.setBody(new Object[]{data});
- }
- */
-
Message responseMessage = bindingInvoker.invoke(requestMessage);
// return response to client
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatProviderFctory.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatProviderFactory.java
index 0c417c0d94..6b1bb6cca7 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatProviderFctory.java
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatProviderFactory.java
@@ -31,10 +31,10 @@ import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
*
* @version $Rev$ $Date$
*/
-public class JSONWireFormatProviderFctory implements WireFormatProviderFactory<JSONWireFormat>{
+public class JSONWireFormatProviderFactory implements WireFormatProviderFactory<JSONWireFormat>{
private ExtensionPointRegistry extensionPoints;
- public JSONWireFormatProviderFctory(ExtensionPointRegistry extensionPoints) {
+ public JSONWireFormatProviderFactory(ExtensionPointRegistry extensionPoints) {
this.extensionPoints = extensionPoints;
}
public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) {
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatProviderFctory.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatProviderFactory.java
index 6e15897b39..33900b3de9 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatProviderFctory.java
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatProviderFactory.java
@@ -31,10 +31,10 @@ import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
*
* @version $Rev$ $Date$
*/
-public class XMLWireFormatProviderFctory implements WireFormatProviderFactory<XMLWireFormat>{
+public class XMLWireFormatProviderFactory implements WireFormatProviderFactory<XMLWireFormat>{
private ExtensionPointRegistry extensionPoints;
- public XMLWireFormatProviderFctory(ExtensionPointRegistry extensionPoints) {
+ public XMLWireFormatProviderFactory(ExtensionPointRegistry extensionPoints) {
this.extensionPoints = extensionPoints;
}
public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) {
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory
index de0944c6ed..be5e3ab636 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory
@@ -16,4 +16,5 @@
# under the License.
# Implementation class for the wire format provider factory
-org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.provider.JAXRSOperationSelectorProviderFctory;model=org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelector \ No newline at end of file
+org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.provider.JAXRSOperationSelectorProviderFactory;model=org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelector
+org.apache.tuscany.sca.binding.rest.operationselector.rpc.provider.RPCOperationSelectorProviderFactory;model=org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelector \ No newline at end of file
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory
index 05a99af29b..80062349ff 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory
@@ -16,5 +16,5 @@
# under the License.
# Implementation class for the wire format provider factory
-org.apache.tuscany.sca.binding.rest.wireformat.json.provider.JSONWireFormatProviderFctory;model=org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat
-org.apache.tuscany.sca.binding.rest.wireformat.xml.provider.XMLWireFormatProviderFctory;model=org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat \ No newline at end of file
+org.apache.tuscany.sca.binding.rest.wireformat.json.provider.JSONWireFormatProviderFactory;model=org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat
+org.apache.tuscany.sca.binding.rest.wireformat.xml.provider.XMLWireFormatProviderFactory;model=org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat \ No newline at end of file
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java
new file mode 100644
index 0000000000..4fa6fdf0a4
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/org/apache/tuscany/sca/binding/rest/rpc/EchoServiceTestCase.java
@@ -0,0 +1,98 @@
+/*
+ * 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.rpc;
+
+import java.net.Socket;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.WebConversation;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
+public class EchoServiceTestCase {
+ private static final String SERVICE_URL = "http://localhost:8085/EchoService";
+
+ private static final String GET_RESPONSE = "[{\"price\":\"$1.55\",\"name\":\"Pear\",\"javaClass\":\"services.store.Item\"},{\"price\":\"$2.99\",\"name\":\"Apple\",\"javaClass\":\"services.store.Item\"},{\"price\":\"$3.55\",\"name\":\"Orange\",\"javaClass\":\"services.store.Item\"}]";
+ private static final String NEW_ITEM = "{\"price\":\"$4.35\",\"name\":\"Grape\"}\"";
+ private static final String GET_NEW_RESPONSE = "[{\"price\":\"$1.55\",\"name\":\"Pear\",\"javaClass\":\"services.store.Item\"},{\"price\":\"$2.99\",\"name\":\"Apple\",\"javaClass\":\"services.store.Item\"},{\"price\":\"$3.55\",\"name\":\"Orange\",\"javaClass\":\"services.store.Item\"},{\"price\":\"$4.35\",\"name\":\"Grape\",\"javaClass\":\"services.store.Item\"}]";
+ private static final String UPDATED_ITEM = "{\"price\":\"$1.35\",\"name\":\"Grape\"}\"";
+ private static final String GET_UPDATED_RESPONSE = "[{\"price\":\"$1.55\",\"name\":\"Pear\",\"javaClass\":\"services.store.Item\"},{\"price\":\"$2.99\",\"name\":\"Apple\",\"javaClass\":\"services.store.Item\"},{\"price\":\"$3.55\",\"name\":\"Orange\",\"javaClass\":\"services.store.Item\"},{\"price\":\"$1.35\",\"name\":\"Grape\",\"javaClass\":\"services.store.Item\"}]";
+
+ private static Node node;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ String contribution = ContributionLocationHelper.getContributionLocation(EchoServiceTestCase.class);
+ node = NodeFactory.newInstance().createNode("echo.composite", new Contribution("echo", contribution));
+ node.start();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void destroy() throws Exception {
+ if(node != null) {
+ node.stop();
+ }
+ }
+
+ @Test
+ public void testPing() throws Exception {
+ new Socket("127.0.0.1", 8085);
+ //System.in.read();
+ }
+
+ @Test
+ public void testRPCGetOperation() throws Exception {
+ String queryString = "?method=echo&msg=Hello RPC";
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest(SERVICE_URL + queryString);
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertEquals("Hello RPC", response.getText());
+ }
+
+ @Test
+ public void testRPCGetArrayOperation() throws Exception {
+ String queryString = "?method=echoArrayString&msgArray=Hello RPC1&msgArray=Hello RPC2";
+
+ WebConversation wc = new WebConversation();
+ WebRequest request = new GetMethodWebRequest(SERVICE_URL + queryString);
+ WebResponse response = wc.getResource(request);
+
+ Assert.assertEquals(200, response.getResponseCode());
+ Assert.assertEquals("[\"Hello RPC1\",\"Hello RPC2\"]", response.getText());
+ }
+
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/echo/Echo.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/echo/Echo.java
new file mode 100644
index 0000000000..ca5d73246a
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/echo/Echo.java
@@ -0,0 +1,43 @@
+/*
+ * 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 services.echo;
+
+import javax.ws.rs.QueryParam;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Interface of our sample JSONRPC service.
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface Echo {
+
+ String echo(@QueryParam("msg") String msg);
+
+ int echoInt(int param);
+
+ boolean echoBoolean(boolean param);
+
+ String [] echoArrayString(@QueryParam("msgArray") String[] stringArray);
+
+ int [] echoArrayInt(int[] intArray);
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/echo/EchoImpl.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/echo/EchoImpl.java
new file mode 100644
index 0000000000..2596637ce8
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/echo/EchoImpl.java
@@ -0,0 +1,50 @@
+/*
+ * 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 services.echo;
+
+
+/**
+ * A simple client component that uses a reference with an JSONRPC binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoImpl implements Echo {
+
+ public String echo(String msg) {
+ return msg;
+ }
+
+ public int echoInt(int param) {
+ int value = param;
+ return value;
+ }
+
+ public boolean echoBoolean(boolean param) {
+ boolean value = param;
+ return value;
+ }
+
+ public String[] echoArrayString(String[] stringArray) {
+ return stringArray;
+ }
+
+ public int[] echoArrayInt(int[] intArray) {
+ return intArray;
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/resources/echo.composite b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/resources/echo.composite
new file mode 100644
index 0000000000..b69107834a
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/resources/echo.composite
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://echo"
+ xmlns:echo="http://echo"
+ name="Echo">
+
+ <component name="EchoComponent">
+ <implementation.java class="services.echo.EchoImpl"/>
+ <service name="Echo">
+ <tuscany:binding.rest uri="http://localhost:8085/EchoService">
+ <tuscany:wireFormat.json />
+ <tuscany:operationSelector.rpc />
+ </tuscany:binding.rest>
+ </service>
+ </component>
+
+</composite>