diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2010-04-25 17:51:44 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2010-04-25 17:51:44 +0000 |
commit | 2dc8a46b4910235c1d4aa808e889e037f6dae687 (patch) | |
tree | a16d5c17bf8c8b7d392753773793ee127d746526 /sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache | |
parent | beb8930cd57cbb9ff4c2fc95a04978af344fdba3 (diff) |
Initial support for json wire format model
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@937845 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache')
5 files changed, 173 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/RESTWireFormatJSON.java b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/RESTWireFormatJSON.java new file mode 100644 index 0000000000..3181bdba58 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/RESTWireFormatJSON.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 org.apache.tuscany.sca.binding.rest.wireformat.json; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.WireFormat; + +/** + * JSON Wireformat model for REST Binding + * + * @version $Rev$ $Date$ + */ +public interface RESTWireFormatJSON extends WireFormat { + + /** + * QName representing the JSON Wireformat for REST Binding + */ + public static final QName REST_WIREFORMAT_JSON_QNAME = new QName(SCA11_TUSCANY_NS, "wireFormat.jsonrpc"); + + /** + * Return the QName identifying the wire format + * @return the QName identifying the wire format + */ + QName getSchemaName(); +} diff --git a/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/RESTWireFormatJSONFactory.java b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/RESTWireFormatJSONFactory.java new file mode 100644 index 0000000000..e030207755 --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/RESTWireFormatJSONFactory.java @@ -0,0 +1,34 @@ +/* + * 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.wireformat.json; + +/** + * JSON Wireformat factory for REST Binding + * + * @version $Rev$ $Date$ + */ +public interface RESTWireFormatJSONFactory { + + /** + * Create a new JSON wireformat for REST Binding + * @return the new JSON wire format + */ + RESTWireFormatJSON createRESTWireFormatJSON(); +} diff --git a/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/RESTWireFormatJSONFactoryImpl.java b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/RESTWireFormatJSONFactoryImpl.java new file mode 100644 index 0000000000..bd10980daf --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/RESTWireFormatJSONFactoryImpl.java @@ -0,0 +1,36 @@ +/* + * 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.wireformat.json.impl; + +import org.apache.tuscany.sca.binding.rest.wireformat.json.RESTWireFormatJSON; +import org.apache.tuscany.sca.binding.rest.wireformat.json.RESTWireFormatJSONFactory; + +/** + * JSON Wireformat factory implementation for REST Binding + * + * @version $Rev$ $Date$ + */ +public class RESTWireFormatJSONFactoryImpl implements RESTWireFormatJSONFactory { + + public RESTWireFormatJSON createRESTWireFormatJSON() { + return new RESTWireFormatJSONImpl(); + } + +} diff --git a/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/RESTWireFormatJSONImpl.java b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/RESTWireFormatJSONImpl.java new file mode 100644 index 0000000000..3819ac856d --- /dev/null +++ b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/RESTWireFormatJSONImpl.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.rest.wireformat.json.impl; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.binding.rest.wireformat.json.RESTWireFormatJSON; + + +/** + * JSON Wireformat implementation for REST Binding + * + * @version $Rev$ $Date$ + */ +public class RESTWireFormatJSONImpl implements RESTWireFormatJSON { + + public QName getSchemaName() { + return RESTWireFormatJSON.REST_WIREFORMAT_JSON_QNAME; + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + // no op + } +} diff --git a/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java index 304e778bce..acb2e13213 100644 --- a/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java +++ b/sca-java-2.x/trunk/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java @@ -114,19 +114,29 @@ public class RESTBindingProcessor extends BaseStAXArtifactProcessor implements S return httpBinding; } - public void write(RESTBinding httpBinding, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException { + public void write(RESTBinding restBinding, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException { //writer.writeStartElement(Constants.SCA10_NS, BINDING_HTTP); writeStart(writer, RESTBinding.TYPE.getNamespaceURI(), RESTBinding.TYPE.getLocalPart()); // Write binding name - if (httpBinding.getName() != null) { - writer.writeAttribute(NAME, httpBinding.getName()); + if (restBinding.getName() != null) { + writer.writeAttribute(NAME, restBinding.getName()); } // Write binding URI - if (httpBinding.getURI() != null) { - writer.writeAttribute(URI, httpBinding.getURI()); + if (restBinding.getURI() != null) { + writer.writeAttribute(URI, restBinding.getURI()); + } + + // Write operation selectors + if ( restBinding.getOperationSelector() != null ) { + extensionProcessor.write(restBinding.getOperationSelector(), writer, context); + } + + // Write wire formats + if ( restBinding.getRequestWireFormat() != null ) { + extensionProcessor.write(restBinding.getRequestWireFormat(), writer, context); } writeEnd(writer); |