summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPDefaultWireFormatProviderFactory.java (renamed from sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPDefaultWireFormatProviderFactory.java)10
-rw-r--r--sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPDefaultWireFormatServiceInterceptor.java71
-rw-r--r--sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPJSONWireFormatProviderFactory.java68
-rw-r--r--sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPJSONWireFormatServiceInterceptor.java (renamed from sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPDefaultWireFormatServiceInterceptor.java)6
-rw-r--r--sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPXMLWireFormatProviderFactory.java (renamed from sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPXMLWireFormatProviderFactory.java)6
-rw-r--r--sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPXMLWireFormatServiceInterceptor.java (renamed from sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPXMLWireFormatServiceInterceptor.java)2
6 files changed, 149 insertions, 14 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPDefaultWireFormatProviderFactory.java b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPDefaultWireFormatProviderFactory.java
index 45e74d8ec8..f3be0c27bf 100644
--- a/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPDefaultWireFormatProviderFactory.java
+++ b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPDefaultWireFormatProviderFactory.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.tuscany.sca.binding.http.format;
+package org.apache.tuscany.sca.binding.http.wireformat.provider;
-import org.apache.tuscany.sca.binding.http.HTTPDefaultWireFormat;
+import org.apache.tuscany.sca.binding.http.wireformat.HTTPDefaultWireFormat;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.invocation.Interceptor;
@@ -36,7 +36,7 @@ public class HTTPDefaultWireFormatProviderFactory implements WireFormatProviderF
@Override
public Class<HTTPDefaultWireFormat> getModelType() {
- return null;
+ return HTTPDefaultWireFormat.class;
}
@Override
@@ -49,10 +49,6 @@ public class HTTPDefaultWireFormatProviderFactory implements WireFormatProviderF
return new WireFormatProvider() {
@Override
public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract) {
- // TODO: Ideally this wants to set the databinding on a per request basis from the
- // http content type and accept headers and so support things like json or xml etc,
- // for now to get started just use json
- interfaceContract.getInterface().resetDataBinding("JSON");
return interfaceContract;
}
@Override
diff --git a/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPDefaultWireFormatServiceInterceptor.java b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPDefaultWireFormatServiceInterceptor.java
new file mode 100644
index 0000000000..d1c2c61242
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPDefaultWireFormatServiceInterceptor.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.http.wireformat.provider;
+
+import org.apache.tuscany.sca.binding.http.HTTPBinding;
+import org.apache.tuscany.sca.common.http.HTTPContext;
+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.RuntimeEndpoint;
+
+/**
+ * Handles the default wire format for the http binding
+ *
+ * 1- determine the request and response format (xml, json, etc) from the
+ * binding config or content type header and accept headers
+ * - TODO: need a way to configure the databinding framework based on that format
+ * 2- get the request contents from the HttpServletRequest
+ * - for a post its just the request body
+ * - for a get need to convert the query string into a body based on the format (xml, json, etc)
+ * 3- send the request on down the wire
+ * 4- set the response contents in the HttpServletResponse
+ * (the databinding should already have put it in the correct format)
+ *
+ */
+public class HTTPDefaultWireFormatServiceInterceptor implements Interceptor {
+
+ private RuntimeEndpoint endpoint;
+ private HTTPBinding binding;
+ private Invoker next;
+
+ public HTTPDefaultWireFormatServiceInterceptor(RuntimeEndpoint endpoint) {
+ this.endpoint = endpoint;
+ this.binding = (HTTPBinding) endpoint.getBinding();
+ }
+
+ @Override
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ @Override
+ public Invoker getNext() {
+ return next;
+ }
+
+ @Override
+ public Message invoke(Message msg) {
+ HTTPContext context = msg.getBindingContext();
+
+ msg.setBody(new Object[] {context.getHttpRequest(), context.getHttpResponse()});
+ return getNext().invoke(msg);
+ }
+}
diff --git a/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPJSONWireFormatProviderFactory.java b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPJSONWireFormatProviderFactory.java
new file mode 100644
index 0000000000..c9ef568402
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPJSONWireFormatProviderFactory.java
@@ -0,0 +1,68 @@
+/*
+ * 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.http.wireformat.provider;
+
+import org.apache.tuscany.sca.binding.http.wireformat.HTTPJSONWireFormat;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.provider.WireFormatProvider;
+import org.apache.tuscany.sca.provider.WireFormatProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+public class HTTPJSONWireFormatProviderFactory implements WireFormatProviderFactory<HTTPJSONWireFormat> {
+
+ public HTTPJSONWireFormatProviderFactory(ExtensionPointRegistry extensionPoints) {
+ }
+
+ @Override
+ public Class<HTTPJSONWireFormat> getModelType() {
+ return HTTPJSONWireFormat.class;
+ }
+
+ @Override
+ public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference) {
+ return null;
+ }
+
+ @Override
+ public WireFormatProvider createServiceWireFormatProvider(final RuntimeEndpoint endpoint) {
+ return new WireFormatProvider() {
+ @Override
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract) {
+ // TODO: Ideally this wants to set the databinding on a per request basis from the
+ // http content type and accept headers and so support things like json or xml etc,
+ // for now to get started just use json
+ interfaceContract.getInterface().resetDataBinding("JSON");
+ return interfaceContract;
+ }
+ @Override
+ public Interceptor createInterceptor() {
+ return new HTTPJSONWireFormatServiceInterceptor(endpoint);
+ }
+ @Override
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_WIREFORMAT;
+ }};
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPDefaultWireFormatServiceInterceptor.java b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPJSONWireFormatServiceInterceptor.java
index e2ac99bfb8..3323fd34fe 100644
--- a/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPDefaultWireFormatServiceInterceptor.java
+++ b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPJSONWireFormatServiceInterceptor.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.tuscany.sca.binding.http.format;
+package org.apache.tuscany.sca.binding.http.wireformat.provider;
import java.io.BufferedReader;
import java.io.IOException;
@@ -58,12 +58,12 @@ import org.oasisopen.sca.ServiceRuntimeException;
* (the databinding should already have put it in the correct format)
*
*/
-public class HTTPDefaultWireFormatServiceInterceptor implements Interceptor {
+public class HTTPJSONWireFormatServiceInterceptor implements Interceptor {
private Invoker next;
private String jsonpCallbackName = "callback";
- public HTTPDefaultWireFormatServiceInterceptor(RuntimeEndpoint endpoint) {
+ public HTTPJSONWireFormatServiceInterceptor(RuntimeEndpoint endpoint) {
}
@Override
diff --git a/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPXMLWireFormatProviderFactory.java b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPXMLWireFormatProviderFactory.java
index cb60101bb7..3a670bd299 100644
--- a/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPXMLWireFormatProviderFactory.java
+++ b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPXMLWireFormatProviderFactory.java
@@ -17,9 +17,9 @@
* under the License.
*/
-package org.apache.tuscany.sca.binding.http.format;
+package org.apache.tuscany.sca.binding.http.wireformat.provider;
-import org.apache.tuscany.sca.binding.http.HTTPXMLWireFormat;
+import org.apache.tuscany.sca.binding.http.wireformat.HTTPXMLWireFormat;
import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
@@ -41,7 +41,7 @@ public class HTTPXMLWireFormatProviderFactory implements WireFormatProviderFacto
@Override
public Class<HTTPXMLWireFormat> getModelType() {
- return null;
+ return HTTPXMLWireFormat.class;
}
@Override
diff --git a/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPXMLWireFormatServiceInterceptor.java b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPXMLWireFormatServiceInterceptor.java
index bfc22ec78f..93935a9f41 100644
--- a/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPXMLWireFormatServiceInterceptor.java
+++ b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/provider/HTTPXMLWireFormatServiceInterceptor.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.tuscany.sca.binding.http.format;
+package org.apache.tuscany.sca.binding.http.wireformat.provider;
import java.io.BufferedReader;
import java.io.IOException;