summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/branches/2.0-Beta1/modules/binding-rest')
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/LICENSE205
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/META-INF/MANIFEST.MF27
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/NOTICE6
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/pom.xml60
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java38
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingFactory.java36
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingFactoryImpl.java36
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java111
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelector.java43
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelectorFactory.java35
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorFactoryImpl.java36
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorImpl.java45
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelector.java43
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelectorFactory.java35
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorFactoryImpl.java36
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorImpl.java45
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormat.java43
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormatFactory.java34
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatFactoryImpl.java36
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatImpl.java44
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormat.java43
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormatFactory.java34
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatFactoryImpl.java37
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatImpl.java44
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java232
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.RESTBindingFactory20
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelectorFactory19
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelectorFactory19
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormatFactory19
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormatFactory19
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor27
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorProcessorTestCase.java107
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatProcessorTestCase.java133
-rw-r--r--sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessorTestCase.java93
34 files changed, 1840 insertions, 0 deletions
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/LICENSE b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/LICENSE
@@ -0,0 +1,205 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
+
+
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/META-INF/MANIFEST.MF b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..767844f4ba
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.rest;version="2.0.0";uses:="org.apache.tuscany.sca.assembly,javax.xml.namespace,javax.servlet.http",
+ org.apache.tuscany.sca.binding.rest.operationselector.jaxrs;version="2.0.0",
+ org.apache.tuscany.sca.binding.rest.operationselector.rpc;version="2.0.0",
+ org.apache.tuscany.sca.binding.rest.wireformat.json;version="2.0.0",
+ org.apache.tuscany.sca.binding.rest.wireformat.xml;version="2.0.0"
+Bundle-Name: Apache Tuscany SCA REST Binding Model
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+SCA-Version: 1.1
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA HTTP Binding Model
+Import-Package: javax.servlet.http,
+ javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.rest;version="2.0.0",
+ org.apache.tuscany.sca.common.http;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.rest
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/NOTICE b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/pom.xml b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/pom.xml
new file mode 100644
index 0000000000..541d1473c3
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-Beta1-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-rest</artifactId>
+ <name>Apache Tuscany SCA REST Binding Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-Beta1-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-http</artifactId>
+ <version>2.0-Beta1-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java
new file mode 100644
index 0000000000..dd01c37537
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBinding.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rest;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.common.http.HTTPHeader;
+
+/**
+ * REST binding model.
+ *
+ * @version $Rev$ $Date$
+*/
+public interface RESTBinding extends Binding {
+ QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.rest");
+
+ public List<HTTPHeader> getHttpHeaders();
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingFactory.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingFactory.java
new file mode 100644
index 0000000000..38d68d532a
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/RESTBindingFactory.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;
+
+
+/**
+ * Factory for the REST binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RESTBindingFactory {
+
+ /**
+ * Creates a new REST binding.
+ * @return a new REST binding
+ */
+ RESTBinding createRESTBinding();
+
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingFactoryImpl.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingFactoryImpl.java
new file mode 100644
index 0000000000..00d5584190
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingFactoryImpl.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.impl;
+
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.binding.rest.RESTBindingFactory;
+
+/**
+ * Factory for the REST binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RESTBindingFactoryImpl implements RESTBindingFactory {
+
+ public RESTBinding createRESTBinding() {
+ return new RESTBindingImpl();
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java
new file mode 100644
index 0000000000..93b59de5a4
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/impl/RESTBindingImpl.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rest.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.common.http.HTTPHeader;
+
+
+/**
+ * Implementation of the HTTP binding model.
+ *
+ * @version $Rev$ $Date$
+ */
+class RESTBindingImpl implements RESTBinding {
+
+ private String name;
+ private String uri;
+
+ private List<HTTPHeader> httpHeaders = new ArrayList<HTTPHeader>();
+
+ private WireFormat requestWireFormat;
+ private WireFormat responseWireFormat;
+ private OperationSelector operationSelector;
+
+ public QName getType() {
+ return TYPE;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public List<HTTPHeader> getHttpHeaders() {
+ return this.httpHeaders;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // The sample binding is always resolved
+ }
+
+ // Wireformat and Operation selection
+
+ public WireFormat getRequestWireFormat() {
+ return requestWireFormat;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ this.requestWireFormat = wireFormat;
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return responseWireFormat;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ this.responseWireFormat = wireFormat;
+ }
+
+ public OperationSelector getOperationSelector() {
+ return operationSelector;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ this.operationSelector = operationSelector;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelector.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelector.java
new file mode 100644
index 0000000000..aea3dce7ae
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelector.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.operationselector.jaxrs;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * JAX_RS Operation Selector model
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JAXRSOperationSelector extends OperationSelector {
+ /**
+ * QName representing the REST JAX_RS Operation Selector extension
+ */
+ public static final QName REST_OPERATION_SELECTOR_JAXRS_QNAME = new QName(Constants.SCA11_TUSCANY_NS, "operationSelector.jaxrs");
+
+ /**
+ * Return the QName identifying the operation selector
+ * @return the QName identifying the operation selector
+ */
+ QName getSchemaName();
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelectorFactory.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelectorFactory.java
new file mode 100644
index 0000000000..bdd3eca740
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/JAXRSOperationSelectorFactory.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rest.operationselector.jaxrs;
+
+
+/**
+ * JAX-RS Operation Selector model factory
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JAXRSOperationSelectorFactory {
+
+ /**
+ * Create a new JAX-RS Operation Selector
+ * @return
+ */
+ JAXRSOperationSelector createJAXRSOperationSelector();
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorFactoryImpl.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorFactoryImpl.java
new file mode 100644
index 0000000000..c47087e660
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorFactoryImpl.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.operationselector.jaxrs.impl;
+
+import org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelector;
+import org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelectorFactory;
+
+/**
+ * JAX-RS Operation Selector model factory implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXRSOperationSelectorFactoryImpl implements JAXRSOperationSelectorFactory {
+
+ public JAXRSOperationSelector createJAXRSOperationSelector() {
+ return new JAXRSOperationSelectorImpl();
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorImpl.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorImpl.java
new file mode 100644
index 0000000000..ef214c3642
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorImpl.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.operationselector.jaxrs.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelector;
+
+
+/**
+ * JAX-RS Operation Selector model implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXRSOperationSelectorImpl implements JAXRSOperationSelector {
+
+ public QName getSchemaName() {
+ return JAXRSOperationSelector.REST_OPERATION_SELECTOR_JAXRS_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+
+ }
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelector.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelector.java
new file mode 100644
index 0000000000..7730a1e75e
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelector.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.operationselector.rpc;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.xml.Constants;
+
+/**
+ * RPC Operation Selector model
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RPCOperationSelector extends OperationSelector {
+ /**
+ * QName representing the RPC Operation Selector extension
+ */
+ public static final QName REST_OPERATION_SELECTOR_RPC_QNAME = new QName(Constants.SCA11_TUSCANY_NS, "operationSelector.rpc");
+
+ /**
+ * Return the QName identifying the operation selector
+ * @return the QName identifying the operation selector
+ */
+ QName getSchemaName();
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelectorFactory.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelectorFactory.java
new file mode 100644
index 0000000000..27a56c374d
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/RPCOperationSelectorFactory.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.binding.rest.operationselector.rpc;
+
+
+/**
+ * RPC Operation Selector model factory
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RPCOperationSelectorFactory {
+
+ /**
+ * Create a new RPC Operation Selector
+ * @return
+ */
+ RPCOperationSelector createRPCOperationSelector();
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorFactoryImpl.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorFactoryImpl.java
new file mode 100644
index 0000000000..9e67f35bc0
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorFactoryImpl.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.operationselector.rpc.impl;
+
+import org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelector;
+import org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelectorFactory;
+
+/**
+ * RPC Operation Selector model factory implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class RPCOperationSelectorFactoryImpl implements RPCOperationSelectorFactory {
+
+ public RPCOperationSelector createRPCOperationSelector() {
+ return new RPCOperationSelectorImpl();
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorImpl.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorImpl.java
new file mode 100644
index 0000000000..bca8218f8d
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/operationselector/rpc/impl/RPCOperationSelectorImpl.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.operationselector.rpc.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelector;
+
+
+/**
+ * RPC Operation Selector model implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class RPCOperationSelectorImpl implements RPCOperationSelector {
+
+ public QName getSchemaName() {
+ return RPCOperationSelector.REST_OPERATION_SELECTOR_RPC_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+
+ }
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormat.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormat.java
new file mode 100644
index 0000000000..d9136da58e
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormat.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 JSONWireFormat extends WireFormat {
+
+ /**
+ * QName representing the JSON Wireformat for REST Binding
+ */
+ public static final QName REST_WIREFORMAT_JSON_QNAME = new QName(SCA11_TUSCANY_NS, "wireFormat.json");
+
+ /**
+ * Return the QName identifying the wire format
+ * @return the QName identifying the wire format
+ */
+ QName getSchemaName();
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormatFactory.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormatFactory.java
new file mode 100644
index 0000000000..f297320b39
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/JSONWireFormatFactory.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 JSONWireFormatFactory {
+
+ /**
+ * Create a new JSON wireformat for REST Binding
+ * @return the new JSON wire format
+ */
+ JSONWireFormat createRESTWireFormatJSON();
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatFactoryImpl.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatFactoryImpl.java
new file mode 100644
index 0000000000..0ddeb8e557
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatFactoryImpl.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.JSONWireFormat;
+import org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormatFactory;
+
+/**
+ * JSON Wireformat factory implementation for REST Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONWireFormatFactoryImpl implements JSONWireFormatFactory {
+
+ public JSONWireFormat createRESTWireFormatJSON() {
+ return new JSONWireFormatImpl();
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatImpl.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatImpl.java
new file mode 100644
index 0000000000..2ce3b95453
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatImpl.java
@@ -0,0 +1,44 @@
+/*
+ * 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.JSONWireFormat;
+
+/**
+ * JSON Wireformat implementation for REST Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONWireFormatImpl implements JSONWireFormat {
+
+ public QName getSchemaName() {
+ return JSONWireFormat.REST_WIREFORMAT_JSON_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // no op
+ }
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormat.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormat.java
new file mode 100644
index 0000000000..7eff067cdc
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormat.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.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.WireFormat;
+
+/**
+ * XML Wireformat model for REST Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface XMLWireFormat extends WireFormat {
+
+ /**
+ * QName representing the XML Wireformat for REST Binding
+ */
+ public static final QName REST_WIREFORMAT_XML_QNAME = new QName(SCA11_TUSCANY_NS, "wireFormat.xml");
+
+ /**
+ * Return the QName identifying the wire format
+ * @return the QName identifying the wire format
+ */
+ QName getSchemaName();
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormatFactory.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormatFactory.java
new file mode 100644
index 0000000000..82d9ad6132
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/XMLWireFormatFactory.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.xml;
+
+/**
+ * XML Wireformat factory for REST Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface XMLWireFormatFactory {
+
+ /**
+ * Create a new XML wireformat for REST Binding
+ * @return the new XML wire format
+ */
+ XMLWireFormat createRESTWireFormatXML();
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatFactoryImpl.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatFactoryImpl.java
new file mode 100644
index 0000000000..b6fd3d6aed
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatFactoryImpl.java
@@ -0,0 +1,37 @@
+/*
+ * 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.xml.impl;
+
+import org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat;
+
+import org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormatFactory;
+
+/**
+ * XML Wireformat factory implementation for REST Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLWireFormatFactoryImpl implements XMLWireFormatFactory {
+
+ public XMLWireFormat createRESTWireFormatXML() {
+ return new XMLWireFormatImpl();
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatImpl.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatImpl.java
new file mode 100644
index 0000000000..3f51fb8832
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/impl/XMLWireFormatImpl.java
@@ -0,0 +1,44 @@
+/*
+ * 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.xml.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat;
+
+/**
+ * XML Wireformat implementation for REST Binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class XMLWireFormatImpl implements XMLWireFormat {
+
+ public QName getSchemaName() {
+ return XMLWireFormat.REST_WIREFORMAT_XML_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ // no op
+ }
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java
new file mode 100644
index 0000000000..81463b2889
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessor.java
@@ -0,0 +1,232 @@
+/*
+ * 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.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.binding.rest.RESTBindingFactory;
+import org.apache.tuscany.sca.common.http.HTTPHeader;
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ * REST Binding Artifact Processor
+ *
+ * @version $Rev$ $Date$
+ */
+public class RESTBindingProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<RESTBinding> {
+ private static final QName HEADERS_QNAME = new QName(Base.SCA11_TUSCANY_NS, "http-headers");
+ private static final QName HEADER_QNAME = new QName(Base.SCA11_TUSCANY_NS, "header");
+ private static final QName RESPONSE_QNAME = new QName(Base.SCA11_TUSCANY_NS, "response");
+
+ private static final String NAME = "name";
+ private static final String VALUE = "value";
+ private static final String URI = "uri";
+
+ private RESTBindingFactory httpBindingFactory;
+ private StAXArtifactProcessor<Object> extensionProcessor;
+
+ public RESTBindingProcessor(ExtensionPointRegistry extensionPoints,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ StAXAttributeProcessor<Object> extensionAttributeProcessor) {
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.httpBindingFactory = modelFactories.getFactory(RESTBindingFactory.class);
+ this.extensionProcessor = (StAXArtifactProcessor<Object>)extensionProcessor;
+ }
+
+ public QName getArtifactType() {
+ return RESTBinding.TYPE;
+ }
+
+ public Class<RESTBinding> getModelType() {
+ return RESTBinding.class;
+ }
+
+ public RESTBinding read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ RESTBinding restBinding = httpBindingFactory.createRESTBinding();
+
+ /**
+ * <tuscany:binding.rest uri="http://localhost:8085/Customer">
+ * <tuscany:wireFormat.xml />
+ * <tuscany:operationSelector.jaxrs />
+ * <tuscany:http-headers>
+ * <tuscany:header name="Cache-Control" value="no-cache"/>
+ * <tuscany:header name="Expires" value="-1"/>
+ * </tuscany:http-headers>
+ * <tuscany:response>
+ * <tuscany:wireFormat.json />
+ * </tuscany:response>
+ * </tuscany:binding.rest>
+ *
+ */
+ while(reader.hasNext()) {
+ QName elementName = null;
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT:
+ elementName = reader.getName();
+
+ if(RESTBinding.TYPE.equals(elementName)) {
+
+ // binding attributes
+ String name = getString(reader, NAME);
+ if(name != null) {
+ restBinding.setName(name);
+ }
+
+ String uri = getURIString(reader, URI);
+ if (uri != null) {
+ restBinding.setURI(uri);
+ }
+ break;
+
+ } else if (HEADERS_QNAME.equals(elementName)) {
+
+ // ignore wrapper element
+ break;
+
+ } else if (HEADER_QNAME.equals(elementName)) {
+
+ // header name/value pair
+ String name = getString(reader, NAME);
+ String value = getURIString(reader, VALUE);
+
+ if(name != null) {
+ restBinding.getHttpHeaders().add(new HTTPHeader(name, value));
+ }
+ break;
+
+ } else if (RESPONSE_QNAME.equals(elementName)) {
+
+ // skip response
+ reader.next();
+ // and position to the next start_element event
+ while (reader.hasNext()) {
+ int sub_event = reader.getEventType();
+ switch (sub_event) {
+ case START_ELEMENT:
+ elementName = reader.getName();
+ break;
+ default: reader.next();
+ }
+ break;
+ }
+
+ // dispatch to read wire format for the response
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null) {
+ if (extension instanceof WireFormat) {
+ restBinding.setResponseWireFormat((WireFormat)extension);
+ }
+ }
+ break;
+ } else {
+ // Read an extension element
+ Object extension = extensionProcessor.read(reader, context);
+ if (extension != null) {
+ if (extension instanceof WireFormat) {
+ restBinding.setRequestWireFormat((WireFormat)extension);
+ restBinding.setResponseWireFormat((WireFormat)extension);
+ } else if(extension instanceof OperationSelector) {
+ restBinding.setOperationSelector((OperationSelector)extension);
+ }
+ }
+ break;
+ }
+
+ case END_ELEMENT:
+ elementName = reader.getName();
+
+ if(RESTBinding.TYPE.equals(elementName)) {
+ return restBinding;
+ }
+ break;
+ }
+
+
+
+ // Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+
+ return restBinding;
+ }
+
+ public void write(RESTBinding restBinding, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+
+ writeStart(writer, RESTBinding.TYPE.getNamespaceURI(), RESTBinding.TYPE.getLocalPart());
+
+ // Write binding name
+ if (restBinding.getName() != null) {
+ writer.writeAttribute(NAME, restBinding.getName());
+ }
+
+ // Write binding URI
+ 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);
+ }
+
+ if ( restBinding.getResponseWireFormat() != null && restBinding.getRequestWireFormat() != restBinding.getResponseWireFormat()) {
+ writeStart(writer, RESPONSE_QNAME.getNamespaceURI(), RESPONSE_QNAME.getLocalPart());
+ extensionProcessor.write(restBinding.getResponseWireFormat(), writer, context);
+ writeEnd(writer);
+ }
+
+
+ writeEnd(writer);
+ }
+
+
+ public void resolve(RESTBinding model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ // Should not need to do anything here for now...
+
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.RESTBindingFactory b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.RESTBindingFactory
new file mode 100644
index 0000000000..e228ebc528
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.RESTBindingFactory
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for model factory
+org.apache.tuscany.sca.binding.rest.impl.RESTBindingFactoryImpl
+
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelectorFactory b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelectorFactory
new file mode 100644
index 0000000000..e108988ecf
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelectorFactory
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for model factory
+org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.impl.JAXRSOperationSelectorFactoryImpl \ No newline at end of file
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelectorFactory b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelectorFactory
new file mode 100644
index 0000000000..7da7b6bf0e
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelectorFactory
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for model factory
+org.apache.tuscany.sca.binding.rest.operationselector.rpc.impl.RPCOperationSelectorFactoryImpl \ No newline at end of file
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormatFactory b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormatFactory
new file mode 100644
index 0000000000..8cc248c7d1
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormatFactory
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for model factory
+org.apache.tuscany.sca.binding.rest.wireformat.json.impl.JSONWireFormatFactoryImpl \ No newline at end of file
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormatFactory b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormatFactory
new file mode 100644
index 0000000000..54d5635e59
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormatFactory
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for model factory
+org.apache.tuscany.sca.binding.rest.wireformat.xml.impl.XMLWireFormatFactoryImpl \ No newline at end of file
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..d88cba48f6
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.binding.rest.xml.RESTBindingProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.rest,model=org.apache.tuscany.sca.binding.rest.RESTBinding,factory=org.apache.tuscany.sca.binding.rest.RESTBindingFactory
+
+# Implementation class for the wireFormat processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#wireFormat.json,model=org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat,factory=org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormatFactory
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#wireFormat.xml,model=org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormat,factory=org.apache.tuscany.sca.binding.rest.wireformat.xml.XMLWireFormatFactory
+
+# Implementation class for operationSelector processor extension
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#operationSelector.jaxrs,model=org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelector,factory=org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelectorFactory
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#operationSelector.rpc,model=org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelector,factory=org.apache.tuscany.sca.binding.rest.operationselector.rpc.RPCOperationSelectorFactory \ No newline at end of file
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorProcessorTestCase.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorProcessorTestCase.java
new file mode 100644
index 0000000000..e808daff6d
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/operationselector/jaxrs/impl/JAXRSOperationSelectorProcessorTestCase.java
@@ -0,0 +1,107 @@
+/*
+ * 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.jaxrs.impl;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.binding.rest.operationselector.jaxrs.JAXRSOperationSelector;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * JSON wire format processor tests to verify properly processing of
+ * wireFormat content in binding configuration in the composite file
+ *
+ * @version $Rev$ $Date$
+ */
+public class JAXRSOperationSelectorProcessorTestCase {
+ public static final String BINDING_WITH_OPERATION_SELECTOR =
+ "<binding.rest xmlns=\"http://tuscany.apache.org/xmlns/sca/1.1\" uri=\"http://localhost:8080/uri\">"
+ + "<operationSelector.jaxrs />"
+ + "</binding.rest>";
+
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static ExtensibleStAXArtifactProcessor staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+
+ context = new ProcessorContext(extensionPoints);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+
+ }
+
+ /**
+ * Tests the APIs:
+ * public OperationSelector getRequstOperationSelector();
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testWireFormat() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(BINDING_WITH_OPERATION_SELECTOR));
+
+ RESTBinding binding = (RESTBinding)staxProcessor.read(reader, context);
+ Assert.assertNotNull(binding);
+
+ OperationSelector operationSelector = binding.getOperationSelector();
+ Assert.assertEquals(JAXRSOperationSelector.class, operationSelector.getClass().getInterfaces()[0]);
+ }
+
+ @Test
+ public void testWriteWireFormat() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(BINDING_WITH_OPERATION_SELECTOR));
+
+ RESTBinding binding = (RESTBinding)staxProcessor.read(reader, context);
+ Assert.assertNotNull(binding);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(binding, bos, context);
+
+ // used for debug comparison
+ // System.out.println(BINDING_WITH_OPERATION_SELECTOR);
+ // System.out.println(bos.toString());
+
+ Assert.assertEquals(BINDING_WITH_OPERATION_SELECTOR, bos.toString());
+
+ }
+
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatProcessorTestCase.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatProcessorTestCase.java
new file mode 100644
index 0000000000..1528bb2f4f
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/wireformat/json/impl/JSONWireFormatProcessorTestCase.java
@@ -0,0 +1,133 @@
+/*
+ * 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 java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.binding.rest.wireformat.json.JSONWireFormat;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * JSON wire format processor tests to verify properly processing of
+ * wireFormat content in binding configuration in the composite file
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONWireFormatProcessorTestCase {
+
+ public static final String BINDING_WITH_WIRE_FORMAT =
+ "<binding.rest xmlns=\"http://tuscany.apache.org/xmlns/sca/1.1\" uri=\"http://localhost:8080/uri\">"
+ + "<wireFormat.json />"
+ + "</binding.rest>";
+
+ public static final String BINDING_WITH_RESPONSE_WIRE_FORMAT =
+ "<binding.rest xmlns=\"http://tuscany.apache.org/xmlns/sca/1.1\" uri=\"http://localhost:8080/uri\">"
+ + "<response>"
+ + "<wireFormat.json />"
+ + "</response>"
+ + "</binding.rest>";
+
+
+ private static XMLInputFactory inputFactory;
+ private static XMLOutputFactory outputFactory;
+ private static ExtensibleStAXArtifactProcessor staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ inputFactory = XMLInputFactory.newInstance();
+ outputFactory = XMLOutputFactory.newInstance();
+
+ context = new ProcessorContext(extensionPoints);
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, outputFactory);
+
+ }
+
+ /**
+ * Tests the APIs:
+ * public WireFormat getRequstWireFormat();
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testWireFormat() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(BINDING_WITH_WIRE_FORMAT));
+
+ RESTBinding binding = (RESTBinding)staxProcessor.read(reader, context);
+ Assert.assertNotNull(binding);
+
+ WireFormat requestWireFormat = binding.getRequestWireFormat();
+ Assert.assertEquals(JSONWireFormat.class, requestWireFormat.getClass().getInterfaces()[0]);
+ }
+
+ /**
+ * Tests the APIs:
+ * public WireFormat getResponseWireFormat();
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testResponseWireFormat() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(BINDING_WITH_RESPONSE_WIRE_FORMAT));
+
+ RESTBinding binding = (RESTBinding)staxProcessor.read(reader, context);
+ Assert.assertNotNull(binding);
+
+ WireFormat responseWireFormat = binding.getResponseWireFormat();
+ Assert.assertEquals(JSONWireFormat.class, responseWireFormat.getClass().getInterfaces()[0]);
+ }
+
+
+ @Test
+ public void testWriteWireFormat() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(BINDING_WITH_WIRE_FORMAT));
+
+ RESTBinding binding = (RESTBinding)staxProcessor.read(reader, context);
+ Assert.assertNotNull(binding);
+ reader.close();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ staxProcessor.write(binding, bos, context);
+
+ // used for debug comparison
+ // System.out.println(BINDING_WITH_WIRE_FORMAT);
+ // System.out.println(bos.toString());
+
+ Assert.assertEquals(BINDING_WITH_WIRE_FORMAT, bos.toString());
+
+ }
+}
diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessorTestCase.java b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessorTestCase.java
new file mode 100644
index 0000000000..55a539044d
--- /dev/null
+++ b/sca-java-2.x/branches/2.0-Beta1/modules/binding-rest/src/test/java/org/apache/tuscany/sca/binding/rest/xml/RESTBindingProcessorTestCase.java
@@ -0,0 +1,93 @@
+/*
+ * 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.xml;
+
+import java.io.StringReader;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.binding.rest.RESTBinding;
+import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RESTBindingProcessorTestCase {
+
+ private static final String COMPOSITE =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\" targetNamespace=\"http://binding-rest\" name=\"binding-rest\">"
+ + " <component name=\"CustomerService\">"
+ + " <implementation.java class=\"services.customer.CustomerServiceImpl\"/>"
+ + " <service name=\"CustomerService\">"
+ + " <tuscany:binding.rest uri=\"http://localhost:8085/Customer\">"
+ + " <tuscany:wireFormat.xml />"
+ + " <tuscany:operationSelector.jaxrs />"
+ + " <tuscany:http-headers>"
+ + " <tuscany:header name=\"Cache-Control\" value=\"no-cache\"/>"
+ + " <tuscany:header name=\"Expires\" value=\"-1\"/>"
+ + " </tuscany:http-headers>"
+ + " </tuscany:binding.rest>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ private static XMLInputFactory inputFactory;
+ private static StAXArtifactProcessor<Object> staxProcessor;
+ private static ProcessorContext context;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ context = new ProcessorContext(extensionPoints);
+ inputFactory = XMLInputFactory.newInstance();
+
+ StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
+ staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+ }
+
+ /**
+ * Test parsing valid composite definition. Valid composite populated with correct values expected.
+ * @throws Exception
+ */
+ @Test
+ public void testLoadValidComposite() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE));
+
+ Composite composite = (Composite)staxProcessor.read(reader, context);
+ RESTBinding binding = (RESTBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ Assert.assertNotNull(binding);
+ Assert.assertEquals(2, binding.getHttpHeaders().size());
+ Assert.assertEquals("Cache-Control", binding.getHttpHeaders().get(0).getName());
+ Assert.assertEquals("no-cache", binding.getHttpHeaders().get(0).getValue());
+ }
+}