You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2010/08/05 17:16:45 UTC

svn commit: r982657 [1/2] - in /tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/tuscany/ src/main/java/org/apache/tuscany/sca/ src/main/java...

Author: slaws
Date: Thu Aug  5 15:16:43 2010
New Revision: 982657

URL: http://svn.apache.org/viewvc?rev=982657&view=rev
Log:
Add a port of the 2.x version of the JSON databinding. This works with the JSONP binding. If I apply the 2.x changes to the existing JSON databinding the I can get the JSONP binding to work but it messes up other bindings, e.g. JSONRPC, which rely on it. These other bindings have been changed for 2.x also. Not in build yet. 

Added:
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/LICENSE
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/NOTICE
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/pom.xml
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSON2JavaBean.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSON2String.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSON2XMLStreamReader.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSONDataBinding.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSONHelper.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JavaBean2JSON.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JavaBean2JSONObject.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/String2JSON.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/XMLStreamReader2JSON.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/JSON2OMElement.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/JSONBadgerfishDataSource.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/JSONDataSource.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/jackson/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/jackson/InputStream2JSON.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/jackson/JSON2Object.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/jackson/JSON2OutputStream.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/jackson/JacksonHelper.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/jackson/Object2JSON.java
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/resources/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/resources/META-INF/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/resources/META-INF/services/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/META-INF/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/META-INF/LICENSE
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/META-INF/MANIFEST.MF
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/META-INF/NOTICE
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/META-INF/services/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/JSON2JavaBean.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/JSON2String.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/JSON2XMLStreamReader.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/JSONDataBinding.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/JSONHelper.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/JavaBean2JSON.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/JavaBean2JSONObject$1.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/JavaBean2JSONObject.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/String2JSON.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/XMLStreamReader2JSON.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/axiom/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/axiom/JSON2OMElement.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/axiom/JSONBadgerfishDataSource.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/axiom/JSONDataSource.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/jackson/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/jackson/InputStream2JSON.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/jackson/JSON2Object.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/jackson/JSON2OutputStream.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/jackson/JacksonHelper.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/classes/org/apache/tuscany/sca/databinding/json2x/jackson/Object2JSON.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/surefire-reports/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/surefire-reports/TEST-org.apache.tuscany.sca.databinding.json.JSONTransformerTestCase.xml
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/surefire-reports/TEST-org.apache.tuscany.sca.databinding.json.JavaBean2JSONTestCase.xml
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/surefire-reports/TEST-org.apache.tuscany.sca.databinding.json.POJOTestCase.xml
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/ipo.xsd
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/org/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/org/apache/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/org/apache/tuscany/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/org/apache/tuscany/sca/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/org/apache/tuscany/sca/databinding/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/org/apache/tuscany/sca/databinding/json/
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/org/apache/tuscany/sca/databinding/json/JSONTransformerTestCase.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/org/apache/tuscany/sca/databinding/json/JavaBean2JSONTestCase$MyBean.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/org/apache/tuscany/sca/databinding/json/JavaBean2JSONTestCase$YourBean.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/org/apache/tuscany/sca/databinding/json/JavaBean2JSONTestCase.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/org/apache/tuscany/sca/databinding/json/MyBean.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/org/apache/tuscany/sca/databinding/json/MyInterface.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/org/apache/tuscany/sca/databinding/json/MyInterfaceImpl.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/test-classes/org/apache/tuscany/sca/databinding/json/POJOTestCase.class   (with props)
    tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/target/tuscany-databinding-json-2-x-1.7-SNAPSHOT.jar   (with props)

Propchange: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Aug  5 15:16:43 2010
@@ -0,0 +1,3 @@
+.classpath
+.project
+.settings

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/LICENSE
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/LICENSE?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/LICENSE (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/LICENSE Thu Aug  5 15:16:43 2010
@@ -0,0 +1,202 @@
+
+                                 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.

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/NOTICE
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/NOTICE?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/NOTICE (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/NOTICE Thu Aug  5 15:16:43 2010
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2009 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/pom.xml?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/pom.xml (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/pom.xml Thu Aug  5 15:16:43 2010
@@ -0,0 +1,155 @@
+<?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>1.7-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>tuscany-databinding-json-2-x</artifactId>
+    <name>Apache Tuscany SCA Data Binding for JSON from 2.x codebase</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-core-spi</artifactId>
+            <version>1.7-SNAPSHOT</version>
+        </dependency>        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-databinding</artifactId>
+            <version>1.7-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.codehaus.jackson</groupId>
+            <artifactId>jackson-core-asl</artifactId>
+            <version>1.5.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.codehaus.jackson</groupId>
+            <artifactId>jackson-mapper-asl</artifactId>
+            <version>1.5.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.codehaus.jackson</groupId>
+            <artifactId>jackson-xc</artifactId>
+            <version>1.5.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.jabsorb</groupId>
+            <artifactId>jabsorb</artifactId>
+            <version>1.3.1</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.codehaus.jettison</groupId>
+            <artifactId>jettison</artifactId>
+            <version>1.0.1</version>
+            <scope>compile</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>stax</groupId>
+                    <artifactId>stax-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-api</artifactId>
+            <version>1.2.7</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>xerces</groupId>
+                    <artifactId>xercesImpl</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>javax.mail</groupId>
+                    <artifactId>mail</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>commons-logging</groupId>
+                    <artifactId>commons-logging</artifactId>
+                </exclusion>                 
+                <exclusion>
+                    <groupId>stax</groupId>
+                    <artifactId>stax-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-impl</artifactId>
+            <version>1.2.7</version>
+            <scope>runtime</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.5</version>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
+           <groupId>commons-logging</groupId>
+           <artifactId>commons-logging</artifactId>
+           <version>1.1.1</version>
+           <exclusions>
+               <exclusion>
+                   <groupId>commons-logging</groupId>
+                   <artifactId>commons-logging</artifactId>
+               </exclusion>
+               <exclusion>
+                   <groupId>javax.servlet</groupId>
+                   <artifactId>servlet-api</artifactId>
+               </exclusion>
+           </exclusions>
+           <scope>test</scope>
+        </dependency>          
+    </dependencies>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+
+                <configuration>
+                    <instructions>
+                        <Bundle-Version>${tuscany.version}</Bundle-Version>
+                        <Bundle-SymbolicName>org.apache.tuscany.sca.databinding.json</Bundle-SymbolicName>
+                        <Bundle-Description>${pom.name}</Bundle-Description>
+                        <Export-Package>org.apache.tuscany.sca.databinding.json*</Export-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Propchange: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Aug  5 15:16:43 2010
@@ -0,0 +1 @@
+test

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSON2JavaBean.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSON2JavaBean.java?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSON2JavaBean.java (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSON2JavaBean.java Thu Aug  5 15:16:43 2010
@@ -0,0 +1,72 @@
+/*
+ * 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.databinding.json2x;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.javabeans.JavaBeansDataBinding;
+import org.jabsorb.JSONSerializer;
+import org.jabsorb.serializer.SerializerState;
+
+/**
+ * @version $Rev: 822905 $ $Date: 2009-10-07 21:52:32 +0100 (Wed, 07 Oct 2009) $
+ */
+public class JSON2JavaBean implements PullTransformer<Object, Object> {
+    private JSONSerializer serializer;
+
+    public JSON2JavaBean() {
+        super();
+        serializer = new JSONSerializer();
+        try {
+            serializer.registerDefaultSerializers();
+        } catch (Exception e) {
+            throw new TransformationException(e);
+        }
+        serializer.setMarshallClassHints(true);
+        serializer.setMarshallNullAttributes(true);
+    }
+
+    public Object transform(Object source, TransformationContext context) {
+        if (source == null) {
+            return null;
+        }
+
+        try {
+            SerializerState state = new SerializerState();
+            return serializer.unmarshall(state, context.getTargetDataType().getPhysical(), source);
+        } catch (Exception e) {
+            throw new TransformationException(e);
+        }
+
+    }
+
+    public String getSourceDataBinding() {
+        return JSONDataBinding.NAME;
+    }
+
+    public String getTargetDataBinding() {
+        return JavaBeansDataBinding.NAME;
+    }
+
+    public int getWeight() {
+        return 5000;
+    }
+}

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSON2String.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSON2String.java?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSON2String.java (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSON2String.java Thu Aug  5 15:16:43 2010
@@ -0,0 +1,61 @@
+/*
+ * 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.databinding.json2x;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+
+/**
+ * @version $Rev: 916888 $ $Date: 2010-02-27 00:44:05 +0000 (Sat, 27 Feb 2010) $
+ */
+public class JSON2String extends BaseTransformer<Object, String> implements
+    PullTransformer<Object, String> {
+    
+    @Override
+    protected Class<Object> getSourceType() {
+        return Object.class;
+    }
+
+    @Override
+    protected Class<String> getTargetType() {
+        return String.class;
+    }
+
+    public String transform(Object source, TransformationContext context) {
+        try {
+            return source.toString();
+        } catch (Exception e) {
+            throw new TransformationException(e);
+        } 
+    }
+
+    @Override
+    public int getWeight() {
+        return 500;
+    }
+    
+    @Override
+    public String getSourceDataBinding() {
+        return JSONDataBinding.NAME;
+    }
+
+}

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSON2XMLStreamReader.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSON2XMLStreamReader.java?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSON2XMLStreamReader.java (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSON2XMLStreamReader.java Thu Aug  5 15:16:43 2010
@@ -0,0 +1,65 @@
+/*
+ * 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.databinding.json2x;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+import org.codehaus.jettison.badgerfish.BadgerFishXMLStreamReader;
+import org.codehaus.jettison.json.JSONObject;
+
+/**
+ * @version $Rev: 916888 $ $Date: 2010-02-27 00:44:05 +0000 (Sat, 27 Feb 2010) $
+ */
+public class JSON2XMLStreamReader extends BaseTransformer<Object, XMLStreamReader> implements
+    PullTransformer<Object, XMLStreamReader> {
+    
+    @Override
+    protected Class<Object> getSourceType() {
+        return Object.class;
+    }
+
+    @Override
+    protected Class<XMLStreamReader> getTargetType() {
+        return XMLStreamReader.class;
+    }
+
+    public XMLStreamReader transform(Object source, TransformationContext context) {
+        try {
+            JSONObject json = JSONHelper.toJettison(source);
+            return new BadgerFishXMLStreamReader(json);
+        } catch (Exception e) {
+            throw new TransformationException(e);
+        } 
+    }
+
+    @Override
+    public int getWeight() {
+        return 500;
+    }
+    @Override
+    public String getSourceDataBinding() {
+        return JSONDataBinding.NAME;
+    }
+
+}

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSONDataBinding.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSONDataBinding.java?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSONDataBinding.java (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSONDataBinding.java Thu Aug  5 15:16:43 2010
@@ -0,0 +1,76 @@
+/*
+ * 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.databinding.json2x;
+
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.databinding.impl.BaseDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.codehaus.jettison.json.JSONObject;
+
+/**
+ * JAXB DataBinding
+ *
+ * @version $Rev: 916888 $ $Date: 2010-02-27 00:44:05 +0000 (Sat, 27 Feb 2010) $
+ */
+public class JSONDataBinding extends BaseDataBinding {
+    public static final String NAME = "JSON2x";
+
+    public static final String ROOT_NAMESPACE = "http://tuscany.apache.org/xmlns/sca/databinding/json/1.0";
+    public static final QName ROOT_ELEMENT = new QName(ROOT_NAMESPACE, "root");
+
+    public JSONDataBinding() {
+        super(NAME, org.json.JSONObject.class);
+    }
+
+    @Override
+    public boolean introspect(DataType type, Operation operation) {
+        assert type != null;
+        Class cls = type.getPhysical();
+        if (JSONObject.class.isAssignableFrom(cls) || org.json.JSONObject.class.isAssignableFrom(cls)) {
+            type.setDataBinding(getName());
+            if (type.getLogical() == null) {
+                type.setLogical(XMLType.UNKNOWN);
+            }
+            return true;
+        }
+        return false;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Object copy(Object arg,
+                       DataType dataType,
+                       Operation operation) {
+        if (arg == null) {
+            return null;
+        }
+        try {
+            Class type = arg != null ? arg.getClass() : null;
+            return JSONHelper.toJSON(arg.toString(), type);
+        } catch (Exception e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+
+}

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSONHelper.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSONHelper.java?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSONHelper.java (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JSONHelper.java Thu Aug  5 15:16:43 2010
@@ -0,0 +1,106 @@
+/*
+ * 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.databinding.json2x;
+
+import java.util.Collection;
+
+import org.apache.tuscany.sca.databinding.json2x.jackson.JacksonHelper;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.json.JSONArray;
+
+/**
+ * @version $Rev: 945980 $ $Date: 2010-05-19 01:53:52 +0100 (Wed, 19 May 2010) $
+ */
+public class JSONHelper {
+    private JSONHelper() {
+
+    }
+
+    /**
+     * Convert to Jettison JSONObject
+     * @param source
+     * @return
+     */
+    public static JSONObject toJettison(Object source) {
+        JSONObject json = null;
+        if (source instanceof JSONObject) {
+            json = (JSONObject)source;
+        } else if (source instanceof org.json.JSONObject || source instanceof String) {
+            json = stringToJettision(source.toString());
+        } else if (source instanceof JsonNode) {
+            json = stringToJettision(JacksonHelper.toString((JsonNode)source));
+        } else if (source instanceof JsonParser) {
+            json = stringToJettision(JacksonHelper.toString((JsonParser)source));
+        }
+        return json;
+    }
+
+    private static JSONObject stringToJettision(String content) {
+        try {
+            return new JSONObject(content);
+        } catch (JSONException e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+
+    /**
+     * Convert to org.json.JSONObject
+     * @param source
+     * @return
+     */
+    public static org.json.JSONObject toJSONOrg(Object source) {
+        org.json.JSONObject json = null;
+        if (source instanceof JSONObject) {
+            try {
+                json = new org.json.JSONObject(((JSONObject)source).toString());
+            } catch (org.json.JSONException e) {
+                throw new IllegalArgumentException(e);
+            }
+        } else if (source instanceof org.json.JSONObject) {
+            json = (org.json.JSONObject)source;
+        }
+        return json;
+    }
+
+    public static Object toJSON(String json, Class<?> type) {
+        if (type == JSONObject.class) {
+            try {
+                return new JSONObject(json);
+            } catch (JSONException e) {
+                throw new IllegalArgumentException(e);
+            }
+        } else {
+            if (type == null) {
+                type = org.json.JSONObject.class;
+            }
+            try {
+                if (type == JSONArray.class || type.isArray() || Collection.class.isAssignableFrom(type)) {
+                    return new JSONArray(json);
+                }
+                return new org.json.JSONObject(json);
+            } catch (org.json.JSONException e) {
+                throw new IllegalArgumentException(e);
+            }
+        }
+    }
+}

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JavaBean2JSON.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JavaBean2JSON.java?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JavaBean2JSON.java (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JavaBean2JSON.java Thu Aug  5 15:16:43 2010
@@ -0,0 +1,81 @@
+/*
+ * 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.databinding.json2x;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+import org.apache.tuscany.sca.databinding.javabeans.JavaBeansDataBinding;
+import org.jabsorb.JSONSerializer;
+import org.jabsorb.serializer.SerializerState;
+
+public class JavaBean2JSON extends BaseTransformer<Object, Object> implements PullTransformer<Object, Object> {
+    private JSONSerializer serializer;
+    
+    public JavaBean2JSON() {
+        serializer = new JSONSerializer();
+        try {
+            serializer.registerDefaultSerializers();
+        } catch (Exception e) {
+            throw new TransformationException(e);
+        }
+        serializer.setMarshallClassHints(true);
+        serializer.setMarshallNullAttributes(true);
+    }
+
+    @Override
+    public String getSourceDataBinding() {
+        return JavaBeansDataBinding.NAME;
+    }
+
+    @Override
+    protected Class<Object> getSourceType() {
+        return Object.class;
+    }
+
+    @Override
+    public String getTargetDataBinding() {
+        return JSONDataBinding.NAME;
+    }
+
+    @Override
+    protected Class<Object> getTargetType() {
+        return Object.class;
+    }
+
+    public Object toJSON(Object source) throws Exception {
+        if (source == null) {
+            return org.json.JSONObject.NULL;
+        }
+
+        SerializerState state = new SerializerState();
+        return serializer.marshall(state, null, source, new Integer(0));
+    }
+
+    public Object transform(Object source, TransformationContext context) {
+        try {
+            return toJSON(source);
+        } catch (Exception e) {
+            throw new TransformationException(e);
+        }
+    }
+
+}

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JavaBean2JSONObject.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JavaBean2JSONObject.java?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JavaBean2JSONObject.java (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/JavaBean2JSONObject.java Thu Aug  5 15:16:43 2010
@@ -0,0 +1,142 @@
+/*
+ * 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.databinding.json2x;
+
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Array;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.databinding.javabeans.JavaBeansDataBinding;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONObject;
+
+public class JavaBean2JSONObject extends BaseTransformer<Object, Object> implements PullTransformer<Object, Object> {
+	private static final SimpleTypeMapper SIMPLE_TYPE_MAPPER = new SimpleTypeMapperImpl();
+	
+    private static final Comparator<PropertyDescriptor> COMPARATOR = new Comparator<PropertyDescriptor>() {
+        public int compare(PropertyDescriptor o1, PropertyDescriptor o2) {
+            return o1.getName().compareTo(o2.getName());
+        }
+    };
+
+    private static final SimpleTypeMapperImpl MAPPER = new SimpleTypeMapperImpl();
+    private static final Object[] NULL = null;
+
+    private static String getStringValue(Object o) {
+        if (o == null) {
+            return null;
+        }
+        TypeInfo info = SimpleTypeMapperImpl.getXMLType(o.getClass());
+        if (info != null) {
+            return MAPPER.toXMLLiteral(info.getQName(), o, null);
+        } else {
+            return String.valueOf(o);
+        }
+    }
+
+    private static boolean isSimpleType(Class<?> javaType) {
+        return SimpleTypeMapperImpl.getXMLType(javaType) != null;
+    }
+
+    public JavaBean2JSONObject() {
+    }
+
+    @Override
+    public String getSourceDataBinding() {
+        return JavaBeansDataBinding.NAME;
+    }
+
+    @Override
+    protected Class<Object> getSourceType() {
+        return Object.class;
+    }
+
+    @Override
+    public String getTargetDataBinding() {
+        return JSONDataBinding.NAME;
+    }
+
+    @Override
+    protected Class<Object> getTargetType() {
+        return Object.class;
+    }
+
+    public Object toJSON(Object source) throws Exception {
+        if (source == null) {
+            return JSONObject.NULL;
+        }
+        Class<?> type = source.getClass();
+        if (isSimpleType(type)) {
+            return source;
+        } else if (type.isArray()) {
+            JSONArray array = new JSONArray();
+            int i1 = Array.getLength(source);
+            for (int j = 0; j < i1; j++) {
+                Object o = Array.get(source, j);
+                array.put(toJSON(o));
+            }
+            return array;
+        } else if (Collection.class.isAssignableFrom(type)) {
+            Collection c = (Collection)source;
+            JSONArray array = new JSONArray();
+            for (Object element : c) {
+                array.put(toJSON(element));
+            }
+            return array;
+        }
+        JSONObject json = new JSONObject();
+        BeanInfo beanInfo = Introspector.getBeanInfo(type);
+        PropertyDescriptor[] propDescs = beanInfo.getPropertyDescriptors();
+        Collections.sort(Arrays.asList(propDescs), COMPARATOR);
+
+        for (int i = 0; i < propDescs.length; i++) {
+            PropertyDescriptor propDesc = propDescs[i];
+            Class<?> pType = propDesc.getPropertyType();
+            if ("class".equals(propDesc.getName())) {
+                continue;
+            }
+            Object pValue = propDesc.getReadMethod().invoke(source, NULL);
+            json.put(propDesc.getName(), toJSON(pValue));
+        }
+        return json;
+
+    }
+
+    public Object transform(Object source, TransformationContext context) {
+        try {
+            return toJSON(source);
+        } catch (Exception e) {
+            throw new TransformationException(e);
+        }
+    }
+
+}

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/String2JSON.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/String2JSON.java?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/String2JSON.java (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/String2JSON.java Thu Aug  5 15:16:43 2010
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.databinding.json2x;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+
+/**
+ * @version $Rev: 916888 $ $Date: 2010-02-27 00:44:05 +0000 (Sat, 27 Feb 2010) $
+ */
+public class String2JSON extends BaseTransformer<String, Object> implements PullTransformer<String, Object> {
+
+    @Override
+    protected Class<String> getSourceType() {
+        return String.class;
+    }
+
+    @Override
+    protected Class<Object> getTargetType() {
+        return Object.class;
+    }
+
+    public Object transform(String source, TransformationContext context) {
+        try {
+            Class type = null;
+            if (context != null && context.getTargetDataType() != null) {
+                type = context.getTargetDataType().getPhysical();
+            }
+            return JSONHelper.toJSON(source, type);
+        } catch (Exception e) {
+            throw new TransformationException(e);
+        }
+    }
+
+    @Override
+    public int getWeight() {
+        return 500;
+    }
+
+    @Override
+    public String getTargetDataBinding() {
+        return JSONDataBinding.NAME;
+    }
+
+}

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/XMLStreamReader2JSON.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/XMLStreamReader2JSON.java?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/XMLStreamReader2JSON.java (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/XMLStreamReader2JSON.java Thu Aug  5 15:16:43 2010
@@ -0,0 +1,77 @@
+/*
+ * 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.databinding.json2x;
+
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+import org.apache.tuscany.sca.databinding.xml.XMLStreamSerializer;
+import org.codehaus.jettison.badgerfish.BadgerFishXMLStreamWriter;
+
+/**
+ * @version $Rev: 659284 $ $Date: 2008-05-22 23:26:18 +0100 (Thu, 22 May 2008) $
+ */
+public class XMLStreamReader2JSON extends BaseTransformer<XMLStreamReader, Object> implements
+    PullTransformer<XMLStreamReader, Object> {
+    
+    @Override
+    protected Class<XMLStreamReader> getSourceType() {
+        return XMLStreamReader.class;
+    }
+
+    @Override
+    protected Class<Object> getTargetType() {
+        return Object.class;
+    }
+
+    public Object transform(XMLStreamReader source, TransformationContext context) {
+        try {
+            StringWriter writer = new StringWriter();
+            XMLStreamWriter jsonWriter = new BadgerFishXMLStreamWriter(writer);
+            XMLStreamSerializer serializer = new XMLStreamSerializer();
+            serializer.serialize(source, jsonWriter);
+            source.close();
+            Class type = null;
+            if (context != null && context.getTargetDataType() != null) {
+                type = context.getTargetDataType().getPhysical();
+            }
+            return JSONHelper.toJSON(writer.toString(), type);
+        } catch (Exception e) {
+            throw new TransformationException(e);
+        } 
+    }
+
+    @Override
+    public int getWeight() {
+        return 500;
+    }
+
+    @Override
+    public String getTargetDataBinding() {
+        return JSONDataBinding.NAME;
+    }
+
+}

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/JSON2OMElement.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/JSON2OMElement.java?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/JSON2OMElement.java (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/JSON2OMElement.java Thu Aug  5 15:16:43 2010
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.databinding.json2x.axiom;
+
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.Transformer;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+import org.apache.tuscany.sca.databinding.json2x.JSONDataBinding;
+import org.apache.tuscany.sca.databinding.json2x.JSONHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.codehaus.jettison.json.JSONObject;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * @version $Rev: 659284 $ $Date: 2008-05-22 23:26:18 +0100 (Thu, 22 May 2008) $
+ */
+@Service(Transformer.class)
+public class JSON2OMElement extends BaseTransformer<Object, OMElement> implements PullTransformer<Object, OMElement> {
+
+    private OMFactory factory = OMAbstractFactory.getOMFactory();
+
+    @Override
+    protected Class<Object> getSourceType() {
+        return Object.class;
+    }
+
+    @Override
+    protected Class<OMElement> getTargetType() {
+        return OMElement.class;
+    }
+
+    public OMElement transform(Object source, TransformationContext context) {
+        try {
+            JSONObject json = JSONHelper.toJettison(source);
+            if (json == null) {
+                return null;
+            }
+            String ns = JSONDataBinding.ROOT_ELEMENT.getNamespaceURI();
+            String name = JSONDataBinding.ROOT_ELEMENT.getLocalPart();
+            if (context != null) {
+                DataType<?> dataType = context.getTargetDataType();
+                Object logical = dataType.getLogical();
+                if (logical instanceof XMLType) {
+                    XMLType xmlType = (XMLType)logical;
+                    if (xmlType.isElement()) {
+                        ns = xmlType.getElementName().getNamespaceURI();
+                        name = xmlType.getElementName().getLocalPart();
+                    }
+                }
+            }
+            JSONBadgerfishDataSource ds = new JSONBadgerfishDataSource(json);
+            OMNamespace namespace = factory.createOMNamespace(ns, "");
+            return factory.createOMElement(ds, name, namespace);
+        } catch (Exception e) {
+            throw new TransformationException(e);
+        }
+    }
+
+    @Override
+    public int getWeight() {
+        return 500;
+    }
+
+    @Override
+    public String getSourceDataBinding() {
+        return JSONDataBinding.NAME;
+    }
+
+}

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/JSONBadgerfishDataSource.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/JSONBadgerfishDataSource.java?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/JSONBadgerfishDataSource.java (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/JSONBadgerfishDataSource.java Thu Aug  5 15:16:43 2010
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.databinding.json2x.axiom;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.codehaus.jettison.badgerfish.BadgerFishXMLStreamReader;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+
+/**
+ * JSONDataSource keeps the JSON String inside and consumes it when needed. This is to be kept in the
+ * OMSourcedElementImpl and can be used either to expand the tree or get the JSON String directly without expanding.
+ * This uses the "Badgerfish" JSON convention.
+ * 
+ * @version $Rev: 567542 $ $Date: 2007-08-20 06:13:29 +0100 (Mon, 20 Aug 2007) $
+ */
+
+public class JSONBadgerfishDataSource extends JSONDataSource {
+
+    public JSONBadgerfishDataSource(JSONObject json) {
+        super(json);
+    }
+
+    /**
+     * Gives the StAX reader using the "Badgerfish" formatted input JSON String.
+     * 
+     * @return The XMLStreamReader according to the JSON String.
+     * @throws javax.xml.stream.XMLStreamException if there is an error while making the StAX reader.
+     */
+    @Override
+    public javax.xml.stream.XMLStreamReader getReader() throws XMLStreamException {
+        try {
+            return new BadgerFishXMLStreamReader(json);
+        } catch (JSONException e) {
+            throw new XMLStreamException(e);
+        }
+
+    }
+}

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/JSONDataSource.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/JSONDataSource.java?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/JSONDataSource.java (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/axiom/JSONDataSource.java Thu Aug  5 15:16:43 2010
@@ -0,0 +1,176 @@
+/*
+ * 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.databinding.json2x.axiom;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMOutputFormat;
+import org.codehaus.jettison.json.JSONObject;
+import org.codehaus.jettison.json.JSONTokener;
+import org.codehaus.jettison.mapped.MappedXMLInputFactory;
+
+/**
+ * JSONDataSource keeps the JSON String inside and consumes it when needed. This is to be kept in the
+ * OMSourcedElementImpl and can be used either to expand the tree or get the JSON String directly without expanding.
+ * This uses the "Mapped" JSON convention.
+ *
+ * @version $Rev: 656170 $ $Date: 2008-05-14 10:17:54 +0100 (Wed, 14 May 2008) $
+ */
+
+public class JSONDataSource implements OMDataSource {
+    protected JSONObject json;
+
+    public JSONDataSource(JSONObject json) {
+        this.json = json;
+    }
+
+    /**
+     * Writes JSON into the output stream. As this should write JSON, it directly gets the JSON string and writes it
+     * without expanding the tree.
+     * 
+     * @param outputStream the stream to be written into
+     * @param omOutputFormat format of the message, this is ignored.
+     * @throws javax.xml.stream.XMLStreamException if there is an error while writing the message in to the output
+     *             stream.
+     */
+    public void serialize(OutputStream outputStream, OMOutputFormat omOutputFormat)
+        throws javax.xml.stream.XMLStreamException {
+        try {
+            String encoding = omOutputFormat == null ? "UTF-8" : omOutputFormat.getCharSetEncoding();
+            outputStream.write(getJSONString().getBytes(encoding));
+        } catch (IOException e) {
+            throw new OMException();
+        }
+    }
+
+    /**
+     * Writes JSON through the writer. As this should write JSON, it directly gets the JSON string and writes it without
+     * expanding the tree.
+     * 
+     * @param writer Writer to be written into
+     * @param omOutputFormat format of the message, this is ignored.
+     * @throws javax.xml.stream.XMLStreamException if there is an error while writing the message through the writer.
+     */
+    public void serialize(Writer writer, OMOutputFormat omOutputFormat) throws javax.xml.stream.XMLStreamException {
+        try {
+            writer.write(getJSONString());
+        } catch (IOException e) {
+            throw new OMException();
+        }
+    }
+
+    /**
+     * Writes XML through the XMLStreamWriter. As the input data source is JSON, this method needs to get a StAX reader
+     * from that JSON String. Therefore this uses the getReader() method to get the StAX reader writes the events into
+     * the XMLStreamWriter.
+     * 
+     * @param xmlStreamWriter StAX writer to be written into
+     * @throws javax.xml.stream.XMLStreamException if there is an error while writing the message through the StAX
+     *             writer.
+     */
+    public void serialize(javax.xml.stream.XMLStreamWriter xmlStreamWriter) throws javax.xml.stream.XMLStreamException {
+        XMLStreamReader reader = getReader();
+        xmlStreamWriter.writeStartDocument();
+        while (reader.hasNext()) {
+            int x = reader.next();
+            switch (x) {
+                case XMLStreamConstants.START_ELEMENT:
+                    xmlStreamWriter.writeStartElement(reader.getPrefix(), reader.getLocalName(), reader
+                        .getNamespaceURI());
+                    int namespaceCount = reader.getNamespaceCount();
+                    for (int i = namespaceCount - 1; i >= 0; i--) {
+                        xmlStreamWriter.writeNamespace(reader.getNamespacePrefix(i), reader.getNamespaceURI(i));
+                    }
+                    int attributeCount = reader.getAttributeCount();
+                    for (int i = 0; i < attributeCount; i++) {
+                        xmlStreamWriter.writeAttribute(reader.getAttributePrefix(i),
+                                                       reader.getAttributeNamespace(i),
+                                                       reader.getAttributeLocalName(i),
+                                                       reader.getAttributeValue(i));
+                    }
+                    break;
+                case XMLStreamConstants.START_DOCUMENT:
+                    break;
+                case XMLStreamConstants.CHARACTERS:
+                    xmlStreamWriter.writeCharacters(reader.getText());
+                    break;
+                case XMLStreamConstants.CDATA:
+                    xmlStreamWriter.writeCData(reader.getText());
+                    break;
+                case XMLStreamConstants.END_ELEMENT:
+                    xmlStreamWriter.writeEndElement();
+                    break;
+                case XMLStreamConstants.END_DOCUMENT:
+                    xmlStreamWriter.writeEndDocument();
+                    break;
+                case XMLStreamConstants.SPACE:
+                    break;
+                case XMLStreamConstants.COMMENT:
+                    xmlStreamWriter.writeComment(reader.getText());
+                    break;
+                case XMLStreamConstants.DTD:
+                    xmlStreamWriter.writeDTD(reader.getText());
+                    break;
+                case XMLStreamConstants.PROCESSING_INSTRUCTION:
+                    xmlStreamWriter.writeProcessingInstruction(reader.getPITarget(), reader.getPIData());
+                    break;
+                case XMLStreamConstants.ENTITY_REFERENCE:
+                    xmlStreamWriter.writeEntityRef(reader.getLocalName());
+                    break;
+                default:
+                    throw new OMException();
+            }
+        }
+        xmlStreamWriter.writeEndDocument();
+    }
+
+    /**
+     * Gives the StAX reader using the "Mapped" formatted input JSON String.
+     * 
+     * @return The XMLStreamReader according to the JSON String.
+     * @throws javax.xml.stream.XMLStreamException if there is an error while making the StAX reader.
+     */
+
+    public javax.xml.stream.XMLStreamReader getReader() throws javax.xml.stream.XMLStreamException {
+
+        Map<String, String> nsMap = new HashMap<String, String>();
+        nsMap.put("", "");
+
+        // input factory for "Mapped" convention
+        MappedXMLInputFactory inputFactory = new MappedXMLInputFactory(nsMap);
+        String jsonString = this.getJSONString();
+        return inputFactory.createXMLStreamReader(new JSONTokener(jsonString));
+    }
+
+    // returns the json string by consuming the JSON input stream.
+    protected String getJSONString() {
+        return json.toString();
+    }
+
+}

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/jackson/InputStream2JSON.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/jackson/InputStream2JSON.java?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/jackson/InputStream2JSON.java (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/jackson/InputStream2JSON.java Thu Aug  5 15:16:43 2010
@@ -0,0 +1,49 @@
+/*
+ * 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.databinding.json2x.jackson;
+
+import java.io.InputStream;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.json2x.JSONDataBinding;
+
+/**
+ * 
+ */
+public class InputStream2JSON implements PullTransformer<InputStream, Object> {
+
+    public String getSourceDataBinding() {
+        return "application/json" + "#" + InputStream.class.getName();
+    }
+
+    public String getTargetDataBinding() {
+        return JSONDataBinding.NAME;
+    }
+
+    public int getWeight() {
+        return 10;
+    }
+
+    public Object transform(InputStream source, TransformationContext context) {
+        return JacksonHelper.createJsonParser(source);
+    }
+
+}

Added: tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/jackson/JSON2Object.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/jackson/JSON2Object.java?rev=982657&view=auto
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/jackson/JSON2Object.java (added)
+++ tuscany/sca-java-1.x/trunk/modules/databinding-json-2-x/src/main/java/org/apache/tuscany/sca/databinding/json2x/jackson/JSON2Object.java Thu Aug  5 15:16:43 2010
@@ -0,0 +1,76 @@
+/*
+ * 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.databinding.json2x.jackson;
+
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.javabeans.JavaBeansDataBinding;
+import org.apache.tuscany.sca.databinding.json2x.JSONDataBinding;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.type.TypeFactory;
+import org.codehaus.jackson.type.JavaType;
+
+/**
+ * @version $Rev: 945980 $ $Date: 2010-05-19 01:53:52 +0100 (Wed, 19 May 2010) $
+ */
+public class JSON2Object implements PullTransformer<Object, Object> {
+    private ObjectMapper mapper;
+
+    public JSON2Object() {
+        super();
+        mapper = JacksonHelper.createObjectMapper();
+    }
+
+    public Object transform(Object source, TransformationContext context) {
+        if (source == null) {
+            return null;
+        }
+
+        try {
+            JavaType javaType = TypeFactory.type(context.getTargetDataType().getGenericType());
+            if (source instanceof String) {
+                return mapper.readValue((String)source, javaType);
+            } else if (source instanceof JsonNode) {
+                return mapper.treeToValue((JsonNode)source, context.getTargetDataType().getPhysical());
+            } else if (source instanceof JsonParser) {
+                return mapper.readValue((JsonParser)source, javaType);
+            } else {
+                return mapper.readValue(source.toString(), javaType);
+            }
+        } catch (Exception e) {
+            throw new TransformationException(e);
+        }
+    }
+
+    public String getSourceDataBinding() {
+        return JSONDataBinding.NAME;
+    }
+
+    public String getTargetDataBinding() {
+        return JavaBeansDataBinding.NAME;
+    }
+
+    public int getWeight() {
+        return 5000;
+    }
+}