summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.1/modules/databinding-jaxb
diff options
context:
space:
mode:
Diffstat (limited to 'branches/sca-java-1.1/modules/databinding-jaxb')
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/DISCLAIMER8
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/LICENSE205
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/NOTICE6
-rwxr-xr-xbranches/sca-java-1.1/modules/databinding-jaxb/pom.xml192
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java312
-rwxr-xr-xbranches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java72
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java70
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java74
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2XMLStreamReader.java73
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java173
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java116
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBExceptionHandler.java107
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java175
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXWSJavaInterfaceProcessor.java117
-rwxr-xr-xbranches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java69
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java70
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java76
-rwxr-xr-xbranches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java73
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding19
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer32
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor18
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBDataBindingTestCase.java129
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandlerTestCase.java81
-rwxr-xr-xbranches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBTestCase.java163
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBWrapperHandlerTestCase.java72
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXWSJavaInterfaceProcessorTestCase.java102
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/MyBean.java158
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/MyInterface.java29
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/MyInterfaceImpl.java67
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/POJOTestCase.java219
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault.java78
-rw-r--r--branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault_Exception.java64
-rwxr-xr-xbranches/sca-java-1.1/modules/databinding-jaxb/src/test/resources/ipo.xsd163
33 files changed, 0 insertions, 3382 deletions
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/DISCLAIMER b/branches/sca-java-1.1/modules/databinding-jaxb/DISCLAIMER
deleted file mode 100644
index d68a410903..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/DISCLAIMER
+++ /dev/null
@@ -1,8 +0,0 @@
-Apache Tuscany is an effort undergoing incubation at The Apache Software
-Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
-required of all newly accepted projects until a further review indicates that
-the infrastructure, communications, and decision making process have stabilized
-in a manner consistent with other successful ASF projects. While incubation
-status is not necessarily a reflection of the completeness or stability of the
-code, it does indicate that the project has yet to be fully endorsed by the ASF.
-
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/LICENSE b/branches/sca-java-1.1/modules/databinding-jaxb/LICENSE
deleted file mode 100644
index 8aa906c321..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/LICENSE
+++ /dev/null
@@ -1,205 +0,0 @@
-
- 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/branches/sca-java-1.1/modules/databinding-jaxb/NOTICE b/branches/sca-java-1.1/modules/databinding-jaxb/NOTICE
deleted file mode 100644
index fdfa0e9faa..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/NOTICE
+++ /dev/null
@@ -1,6 +0,0 @@
-${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/branches/sca-java-1.1/modules/databinding-jaxb/pom.xml b/branches/sca-java-1.1/modules/databinding-jaxb/pom.xml
deleted file mode 100755
index f876d58985..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/pom.xml
+++ /dev/null
@@ -1,192 +0,0 @@
-<?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.1-incubating-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <artifactId>tuscany-databinding-jaxb</artifactId>
- <name>Apache Tuscany SCA Data Binding for JAXB</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-core-spi</artifactId>
- <version>1.1-incubating-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-databinding</artifactId>
- <version>1.1-incubating-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-interface-java-xml</artifactId>
- <version>1.1-incubating-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>2.1</version>
- </dependency>
-
- <dependency>
- <groupId>javax.xml.ws</groupId>
- <artifactId>jaxws-api</artifactId>
- <!-- Set to 2.1 to make jaxws-maven-plugin happy -->
- <version>2.1</version>
- </dependency>
-
- <dependency>
- <groupId>com.sun.xml.bind</groupId>
- <artifactId>jaxb-impl</artifactId>
- <version>2.1.5</version>
- <scope>compile</scope>
- <exclusions>
- <exclusion>
- <groupId>javax.xml.stream</groupId>
- <artifactId>stax-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.jvnet.jaxb.reflection</groupId>
- <artifactId>jaxb2-reflection</artifactId>
- <version>2.1.4</version>
- <scope>compile</scope>
- </dependency>
- </dependencies>
-
- <repositories>
- <repository>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- <id>java.net</id>
- <name>java.net Maven 1.x Repository</name>
- <url>http://download.java.net/maven/1</url>
- <layout>legacy</layout>
- </repository>
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- <id>java.net</id>
- <name>java.net Maven 1.x Repository</name>
- <url>http://download.java.net/maven/1</url>
- <layout>legacy</layout>
- </pluginRepository>
- </pluginRepositories>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>javax.xml.ws</groupId>
- <artifactId>jaxws-api</artifactId>
- <version>2.1</version>
- <type>jar</type>
- </artifactItem>
- <artifactItem>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>2.1</version>
- <type>jar</type>
- </artifactItem>
- </artifactItems>
- <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>true</overWriteSnapshots>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <argLine>-Djava.endorsed.dirs=target/endorsed</argLine>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>1.0</version>
- <executions>
- <execution>
- <id>add-test-source</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-test-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>target/jaxb-source</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>com.sun.tools.xjc.maven2</groupId>
- <artifactId>maven-jaxb-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <id>generate-jaxb</id>
- <phase>generate-test-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <generatePackage>com.example.ipo.jaxb</generatePackage>
- <generateDirectory>${project.build.directory}/jaxb-source</generateDirectory>
- <schemaDirectory>${basedir}/src/test/resources</schemaDirectory>
- <includeSchemas>
- <includeSchema>ipo.xsd</includeSchema>
- </includeSchemas>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-
-</project>
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java
deleted file mode 100644
index 518a15c0b5..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * 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.jaxb;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
-import org.apache.tuscany.sca.databinding.xml.SimpleXmlNodeImpl;
-import org.apache.tuscany.sca.databinding.xml.XmlNode;
-import org.apache.tuscany.sca.databinding.xml.XmlTreeStreamReaderImpl;
-import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
-
-import com.sun.xml.bind.v2.model.annotation.RuntimeInlineAnnotationReader;
-import com.sun.xml.bind.v2.model.core.Ref;
-import com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder;
-import com.sun.xml.bind.v2.model.runtime.RuntimeClassInfo;
-import com.sun.xml.bind.v2.model.runtime.RuntimePropertyInfo;
-import com.sun.xml.bind.v2.model.runtime.RuntimeTypeInfoSet;
-import com.sun.xml.bind.v2.runtime.IllegalAnnotationsException;
-import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
-
-/**
- * @version $Rev$ $Date$
- */
-public class BeanXMLStreamReaderImpl extends XmlTreeStreamReaderImpl {
- private final static Comparator<Accessor> COMPARATOR = new Comparator<Accessor>() {
- public int compare(Accessor o1, Accessor o2) {
- return o1.getName().compareTo(o2.getName());
- }
- };
-
- private final static String XSI_PREFIX = "xsi";
- private final static String XSI_NS = "http://www.w3.org/2001/XMLSchema-instance";
-
- private final static XmlNode getXSIType(QName realType) {
- QName xsiType = new QName(XSI_NS, "type", XSI_PREFIX);
- String prefix = realType.getPrefix();
- String typeName = realType.getLocalPart();
- if (prefix != null && !prefix.equals("")) {
- typeName = prefix + ":" + realType.getLocalPart();
- }
- return new SimpleXmlNodeImpl(xsiType, XmlNode.Type.ATTRIBUTE);
- }
-
- /**
- * Represent a Map.Entry XML node
- * @version $Rev$ $Date$
- */
- public static class MapEntryXmlNodeImpl extends SimpleXmlNodeImpl implements XmlNode {
- private Map.Entry entry;
-
- public MapEntryXmlNodeImpl(Entry entry) {
- super(new QName("", "entry"), entry);
- this.entry = entry;
- }
-
- public Iterator<XmlNode> children() {
- List<XmlNode> nodes = new ArrayList<XmlNode>();
- XmlNode key = new BeanXmlNodeImpl(new QName("", "key"), entry.getKey());
- XmlNode value = new BeanXmlNodeImpl(new QName("", "value"), entry.getValue());
- nodes.add(key);
- nodes.add(value);
- return nodes.iterator();
- }
- }
-
- public static class BeanXmlNodeImpl extends SimpleXmlNodeImpl implements XmlNode {
- private static final Object[] NULL = null;
- private static final SimpleTypeMapperImpl MAPPER = new SimpleTypeMapperImpl();
-
- public BeanXmlNodeImpl(Object bean) {
- super(getName(bean == null ? null : bean.getClass()), bean);
- }
-
- public BeanXmlNodeImpl(QName name, Object bean) {
- super(name, bean);
- }
-
- private static boolean isSimpleType(Class<?> javaType) {
- return SimpleTypeMapperImpl.getXMLType(javaType) != 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);
- }
- }
-
- public Iterator<XmlNode> children() {
- if (name == null) {
- return null;
- }
- if (value == null) {
- return super.children();
- }
- if (isSimpleType(value.getClass())) {
- XmlNode textNode = new BeanXmlNodeImpl(null, value);
- return Arrays.asList(textNode).iterator();
- }
- if (Map.class.isAssignableFrom(value.getClass())) {
- List<XmlNode> entries = new ArrayList<XmlNode>();
- Map map = (Map)value;
- if (map != null) {
- for (Object e : map.entrySet()) {
- Map.Entry entry = (Map.Entry)e;
- entries.add(new MapEntryXmlNodeImpl(entry));
- }
- }
- return entries.iterator();
- }
- try {
- Map<String, Accessor> accessorMap = getAccessors(value);
- List<Accessor> accessorList = new ArrayList<Accessor>(accessorMap.values());
- Collections.sort(accessorList, COMPARATOR);
-
- List<XmlNode> props = new ArrayList<XmlNode>();
- for (Accessor accessor : accessorList) {
- Class<?> pType = accessor.getType();
-
- QName pName = new QName(name.getNamespaceURI(), accessor.getName());
- Object pValue = accessor.getValue();
- if (pType.isArray()) {
- if (pValue != null) {
- int i1 = Array.getLength(pValue);
- for (int j = 0; j < i1; j++) {
- Object o = Array.get(pValue, j);
- props.add(new BeanXmlNodeImpl(pName, o));
- }
- } else {
- // TODO: How to handle null?
- }
- } else if (Collection.class.isAssignableFrom(pType)) {
- Collection objList = (Collection)pValue;
- if (objList != null && objList.size() > 0) {
- for (Iterator j = objList.iterator(); j.hasNext();) {
- Object o = j.next();
- props.add(new BeanXmlNodeImpl(pName, o));
- }
-
- } else {
- // How to handle null
- }
- } else {
- props.add(new BeanXmlNodeImpl(pName, pValue));
- }
- }
- return props.iterator();
- } catch (Exception e) {
- throw new IllegalArgumentException(e);
- }
- }
-
- public QName getName() {
- return name;
- }
-
- public String getValue() {
- return getStringValue(value);
- }
-
- public static QName getName(Class<?> cls) {
- if (cls == null) {
- return null;
- }
- Package pkg = cls.getPackage();
- if (pkg == null) {
- return new QName("", cls.getSimpleName());
- }
- StringBuffer ns = new StringBuffer("http://");
- String[] names = pkg.getName().split("\\.");
- for (int i = names.length - 1; i >= 0; i--) {
- ns.append(names[i]);
- if (i != 0) {
- ns.append('.');
- }
- }
- ns.append('/');
- return new QName(ns.toString(), cls.getSimpleName());
- }
-
- }
-
- public BeanXMLStreamReaderImpl(QName name, Object bean) {
- super(getXmlNode(name, bean));
- }
-
- private static BeanXmlNodeImpl getXmlNode(QName name, Object bean) {
- BeanXmlNodeImpl root = null;
- if (name != null) {
- root = new BeanXmlNodeImpl(name, bean);
- } else {
- root = new BeanXmlNodeImpl(bean);
- }
- return root;
- }
-
- public static interface Accessor {
- String getName();
-
- Class<?> getType();
-
- Object getValue() throws Exception;
-
- void setValue(Object value) throws Exception;
- }
-
- private static RuntimeTypeInfoSet create(Class... classes) throws Exception {
- IllegalAnnotationsException.Builder errorListener = new IllegalAnnotationsException.Builder();
- RuntimeInlineAnnotationReader reader = new RuntimeInlineAnnotationReader();
- JAXBContextImpl context =
- new JAXBContextImpl(classes, null, Collections.<Class, Class> emptyMap(), null, false, reader, false, false);
- RuntimeModelBuilder builder =
- new RuntimeModelBuilder(context, reader, Collections.<Class, Class> emptyMap(), null);
- builder.setErrorHandler(errorListener);
- for (Class c : classes)
- builder.getTypeInfo(new Ref<Type, Class>(c));
-
- RuntimeTypeInfoSet r = builder.link();
- errorListener.check();
- return r;
- }
-
- private static class JAXBAccessor implements Accessor {
- private Object target;
- private RuntimePropertyInfo prop;
-
- public JAXBAccessor(Object target, RuntimePropertyInfo field) {
- super();
- this.target = target;
- this.prop = field;
- }
-
- public String getName() {
- return prop.getName();
- }
-
- public Object getValue() throws Exception {
- return prop.getAccessor().get(target);
- }
-
- public void setValue(Object value) throws Exception {
- prop.getAccessor().set(target, value);
- }
-
- public Class<?> getType() {
- Type type = prop.getRawType();
- if (type instanceof Class) {
- return (Class<?>)type;
- } else if (type instanceof ParameterizedType) {
- ParameterizedType pType = (ParameterizedType)type;
- type = pType.getRawType();
- if (type instanceof Class) {
- return (Class<?>)type;
- }
- }
- return Object.class;
- }
-
- }
-
- private static Map<String, Accessor> getAccessors(Object target) throws Exception {
- if (target == null) {
- return Collections.emptyMap();
- }
- Map<String, Accessor> map = new HashMap<String, Accessor>();
- Class<?> type = target.getClass();
- RuntimeTypeInfoSet set = create(type);
- RuntimeClassInfo clsInfo = (RuntimeClassInfo)set.getTypeInfo(type);
- for (RuntimePropertyInfo f : clsInfo.getProperties()) {
- map.put(f.getName(), new JAXBAccessor(target, f));
- }
- return map;
- }
-
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java
deleted file mode 100755
index d1a64a782c..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.jaxb;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.Marshaller;
-
-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.impl.DOMHelper;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-public class JAXB2Node extends BaseTransformer<Object, Node> implements PullTransformer<Object, Node> {
-
- public Node transform(Object source, TransformationContext tContext) {
-// if (source == null) {
-// return null;
-// }
- try {
- JAXBContext context = JAXBContextHelper.createJAXBContext(tContext, true);
- Marshaller marshaller = context.createMarshaller();
- // FIXME: The default Marshaller doesn't support
- // marshaller.getNode()
- Document document = DOMHelper.newDocument();
- JAXBElement<?> jaxbElement = JAXBContextHelper.createJAXBElement(tContext.getSourceDataType(), source);
- marshaller.marshal(jaxbElement, document);
- return DOMHelper.adjustElementName(tContext, document.getDocumentElement());
- } catch (Exception e) {
- throw new TransformationException(e);
- }
- }
-
- @Override
- public Class getSourceType() {
- return Object.class;
- }
-
- @Override
- public Class getTargetType() {
- return Node.class;
- }
-
- @Override
- public int getWeight() {
- return 30;
- }
-
- @Override
- public String getSourceDataBinding() {
- return JAXBDataBinding.NAME;
- }
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java
deleted file mode 100644
index 12f44b479e..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.jaxb;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.Marshaller;
-
-import org.apache.tuscany.sca.databinding.PushTransformer;
-import org.apache.tuscany.sca.databinding.TransformationContext;
-import org.apache.tuscany.sca.databinding.TransformationException;
-import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
-import org.xml.sax.ContentHandler;
-
-/**
- * @version $Rev$ $Date$
- */
-public class JAXB2SAX extends BaseTransformer<Object, ContentHandler> implements
- PushTransformer<Object, ContentHandler> {
-
- @Override
- protected Class getSourceType() {
- return Object.class;
- }
-
- @Override
- protected Class getTargetType() {
- return ContentHandler.class;
- }
-
- /**
- * @see org.apache.tuscany.sca.databinding.PushTransformer#transform(java.lang.Object, java.lang.Object, org.apache.tuscany.sca.databinding.TransformationContext)
- */
- public void transform(Object source, ContentHandler target, TransformationContext tContext) {
- try {
- JAXBContext context = JAXBContextHelper.createJAXBContext(tContext, true);
- Marshaller marshaller = context.createMarshaller();
- JAXBElement<?> jaxbElement = JAXBContextHelper.createJAXBElement(tContext.getSourceDataType(), source);
- marshaller.marshal(jaxbElement, target);
- } catch (Exception e) {
- throw new TransformationException(e);
- }
- }
-
- public int getWeight() {
- return 20;
- }
-
- @Override
- public String getSourceDataBinding() {
- return JAXBDataBinding.NAME;
- }
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java
deleted file mode 100644
index d34ee8b13c..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.jaxb;
-
-import java.io.StringWriter;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.Marshaller;
-import javax.xml.transform.stream.StreamResult;
-
-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.XMLStringDataBinding;
-
-public class JAXB2String extends BaseTransformer<Object, String> implements PullTransformer<Object, String> {
-
- public String transform(Object source, TransformationContext tContext) {
- try {
- JAXBContext context = JAXBContextHelper.createJAXBContext(tContext, true);
- Marshaller marshaller = context.createMarshaller();
- StringWriter writer = new StringWriter();
- StreamResult result = new StreamResult(writer);
- JAXBElement<?> jaxbElement = JAXBContextHelper.createJAXBElement(tContext.getSourceDataType(), source);
- marshaller.marshal(jaxbElement, result);
- return writer.toString();
- } catch (Exception e) {
- throw new TransformationException(e);
- }
- }
-
- @Override
- public Class getSourceType() {
- return Object.class;
- }
-
- @Override
- public Class getTargetType() {
- return String.class;
- }
-
- @Override
- public int getWeight() {
- return 30;
- }
-
- @Override
- public String getSourceDataBinding() {
- return JAXBDataBinding.NAME;
- }
-
- @Override
- public String getTargetDataBinding() {
- return XMLStringDataBinding.NAME;
- }
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2XMLStreamReader.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2XMLStreamReader.java
deleted file mode 100644
index 8aaee84f80..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2XMLStreamReader.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.jaxb;
-
-import javax.xml.bind.JAXBElement;
-import javax.xml.namespace.QName;
-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;
-
-public class JAXB2XMLStreamReader extends BaseTransformer<Object, XMLStreamReader> implements
- PullTransformer<Object, XMLStreamReader> {
-
- public JAXB2XMLStreamReader() {
- super();
- }
-
- public XMLStreamReader transform(Object source, TransformationContext context) {
- if (source == null) {
- return null;
- }
- try {
- QName name = null;
- Object bean = source;
- JAXBElement<?> element = JAXBContextHelper.createJAXBElement(context.getSourceDataType(), source);
- name = element.getName();
- bean = element.getValue();
- BeanXMLStreamReaderImpl reader = new BeanXMLStreamReaderImpl(name, bean);
- return reader;
- } catch (Exception e) {
- throw new TransformationException(e);
- }
- }
-
- @Override
- public Class getSourceType() {
- return Object.class;
- }
-
- @Override
- public Class getTargetType() {
- return XMLStreamReader.class;
- }
-
- @Override
- public int getWeight() {
- return 10;
- }
-
- @Override
- public String getTargetDataBinding() {
- return JAXBDataBinding.NAME;
- }
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java
deleted file mode 100644
index 968a26eb62..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * 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.jaxb;
-
-import java.beans.Introspector;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.annotation.XmlEnum;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlSchema;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.databinding.TransformationContext;
-import org.apache.tuscany.sca.databinding.TransformationException;
-import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
-import org.apache.tuscany.sca.interfacedef.DataType;
-import org.apache.tuscany.sca.interfacedef.util.XMLType;
-
-public class JAXBContextHelper {
- // TODO: Do we need to set them for source and target?
- public static final String JAXB_CLASSES = "jaxb.classes";
-
- public static final String JAXB_CONTEXT_PATH = "jaxb.contextPath";
-
- private JAXBContextHelper() {
- }
-
- public static JAXBContext createJAXBContext(TransformationContext tContext, boolean source) throws JAXBException {
- if (tContext == null)
- throw new TransformationException("JAXB context is not set for the transformation.");
-
- DataType<?> dataType = source ? tContext.getSourceDataType() : tContext.getTargetDataType();
- // FIXME: We should check the context path or classes
- // FIXME: What should we do if JAXB is an intermediate node?
-
- // String contextPath = null;
- JAXBContext context = null;
- Class<?> cls = getJavaType(dataType);
-
- context = JAXBContext.newInstance(cls);
-
- if (context == null) {
- throw new TransformationException("JAXB context is not set for the transformation.");
- }
- return context;
- }
-
- @SuppressWarnings("unchecked")
- public static JAXBElement createJAXBElement(DataType dataType, Object value) {
- if (value instanceof JAXBElement) {
- return (JAXBElement)value;
- } else {
- Class type = dataType.getPhysical();
- Object logical = dataType.getLogical();
- QName elementName = JAXBDataBinding.ROOT_ELEMENT;
- if (logical instanceof XMLType) {
- XMLType xmlType = (XMLType)logical;
- QName element = xmlType.getElementName();
- if (element != null) {
- elementName = element;
- } else {
- /**
- * Set the declared type to Object.class so that xsi:type
- * will be produced
- */
- type = Object.class;
- }
- } else {
- type = Object.class;
- }
- return new JAXBElement(elementName, type, value);
- }
- }
-
- @SuppressWarnings("unchecked")
- public static Object createReturnValue(DataType dataType, Object value) {
- Class<?> cls = getJavaType(dataType);
- if (cls == JAXBElement.class) {
- return createJAXBElement(dataType, value);
- } else {
- if (value instanceof JAXBElement) {
- return ((JAXBElement)value).getValue();
- } else {
- return value;
- }
- }
- }
-
- public static Class<?> getJavaType(DataType<?> dataType) {
- if (dataType == null) {
- return null;
- }
- Class type = dataType.getPhysical();
- if (JAXBElement.class.isAssignableFrom(type)) {
- type = Object.class;
- }
- if (type == Object.class && dataType.getLogical() instanceof XMLType) {
- XMLType xType = (XMLType)dataType.getLogical();
- Class javaType = SimpleTypeMapperImpl.getJavaType(xType.getTypeName());
- if (javaType != null) {
- type = javaType;
- }
- }
- return type;
- }
-
- public static XMLType getXmlTypeName(Class<?> javaType) {
- String namespace = null;
- String name = null;
- Package pkg = javaType.getPackage();
- if (pkg != null) {
- XmlSchema schema = pkg.getAnnotation(XmlSchema.class);
- if (schema != null) {
- namespace = schema.namespace();
- }
- }
- XmlType type = javaType.getAnnotation(XmlType.class);
- if (type != null) {
- String typeNamespace = type.namespace();
- String typeName = type.name();
-
- if (typeNamespace.equals("##default") && typeName.equals("")) {
- XmlRootElement rootElement = javaType.getAnnotation(XmlRootElement.class);
- if (rootElement != null) {
- namespace = rootElement.namespace();
- } else {
- // FIXME: The namespace should be from the referencing
- // property
- namespace = null;
- }
- } else if (typeNamespace.equals("##default")) {
- // namespace is from the package
- } else {
- namespace = typeNamespace;
- }
-
- if (typeName.equals("##default")) {
- name = Introspector.decapitalize(javaType.getSimpleName());
- } else {
- name = typeName;
- }
- } else {
- XmlEnum xmlEnum = javaType.getAnnotation(XmlEnum.class);
- if (xmlEnum != null) {
- name = Introspector.decapitalize(javaType.getSimpleName());
- }
- }
- if (name == null) {
- return null;
- }
- return new XMLType(null, new QName(namespace, name));
- }
-
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java
deleted file mode 100644
index 4e2c8d13dc..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.jaxb;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.databinding.ExceptionHandler;
-import org.apache.tuscany.sca.databinding.impl.BaseDataBinding;
-import org.apache.tuscany.sca.databinding.impl.DOMHelper;
-import org.apache.tuscany.sca.interfacedef.DataType;
-import org.apache.tuscany.sca.interfacedef.util.XMLType;
-import org.w3c.dom.Document;
-
-/**
- * JAXB DataBinding
- */
-public class JAXBDataBinding extends BaseDataBinding {
- public static final String NAME = JAXBElement.class.getName();
- public static final String[] ALIASES = new String[] {"jaxb"};
-
- public static final String ROOT_NAMESPACE = "http://tuscany.apache.org/xmlns/sca/databinding/jaxb/1.0";
- public static final QName ROOT_ELEMENT = new QName(ROOT_NAMESPACE, "root");
-
- public JAXBDataBinding() {
- super(NAME, ALIASES, JAXBElement.class);
- }
-
- @Override
- public boolean introspect(DataType dataType, Annotation[] annotations) {
- Object physical = dataType.getPhysical();
- if (!(physical instanceof Class)) {
- return false;
- }
- Class javaType = (Class)physical;
- if (JAXBElement.class.isAssignableFrom(javaType)) {
- Type type = javaType.getGenericSuperclass();
- if (type instanceof ParameterizedType) {
- ParameterizedType parameterizedType = ((ParameterizedType)type);
- Type rawType = parameterizedType.getRawType();
- if (rawType == JAXBElement.class) {
- Type actualType = parameterizedType.getActualTypeArguments()[0];
- if (actualType instanceof Class) {
- XMLType xmlType = JAXBContextHelper.getXmlTypeName((Class)actualType);
- dataType.setLogical(xmlType);
- dataType.setDataBinding(getName());
- return true;
- }
- }
- }
- if (dataType.getLogical() == null) {
- dataType.setLogical(XMLType.UNKNOWN);
- }
- dataType.setDataBinding(getName());
- return true;
- }
-
- XMLType xmlType = JAXBContextHelper.getXmlTypeName(javaType);
- if (xmlType == null) {
- return false;
- }
- dataType.setLogical(xmlType);
- dataType.setDataBinding(getName());
- return true;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Object copy(Object arg) {
- try {
- boolean isElement = false;
- Class cls = arg.getClass();
- if (arg instanceof JAXBElement) {
- isElement = true;
- cls = ((JAXBElement)arg).getDeclaredType();
- } else {
- arg = new JAXBElement(ROOT_ELEMENT, Object.class, arg);
- }
- JAXBContext context = JAXBContext.newInstance(cls);
- Document doc = DOMHelper.newDocument();
- context.createMarshaller().marshal(arg, doc);
- JAXBElement<?> element = context.createUnmarshaller().unmarshal(doc, cls);
- return isElement ? element : element.getValue();
- } catch (Exception e) {
- throw new IllegalArgumentException(e);
- }
- }
-
- @Override
- public ExceptionHandler getExceptionHandler() {
- return new JAXBExceptionHandler();
- }
-
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBExceptionHandler.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBExceptionHandler.java
deleted file mode 100644
index aa37031c04..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBExceptionHandler.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.jaxb;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.WebFault;
-
-import org.apache.tuscany.sca.databinding.ExceptionHandler;
-import org.apache.tuscany.sca.interfacedef.DataType;
-import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
-import org.apache.tuscany.sca.interfacedef.util.XMLType;
-
-/**
- * JAXB implementation of ExceptionHandler
- *
- * @version $Rev$ $Date$
- */
-public class JAXBExceptionHandler implements ExceptionHandler {
- private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
-
- /**
- * <ul>
- * <li>WrapperException(String message, FaultBean faultInfo) <br>
- * A constructor where WrapperException is replaced with the name of the
- * generated wrapper exception and FaultBean is replaced by the name of the
- * generated fault bean.
- * <li> WrapperException(String message, FaultBean faultInfo, Throwable
- * cause) <br>
- * A constructor whereWrapperException is replaced with the name of the
- * generated wrapper exception and FaultBean is replaced by the name of the
- * generated fault bean. The last argument, cause, may be used to convey
- * protocol specific fault information
- * </ul>
- */
- public Exception createException(DataType<DataType> exceptionType, String message, Object faultInfo, Throwable cause) {
- Class exceptionClass = exceptionType.getPhysical();
- DataType<?> faultBeanType = exceptionType.getLogical();
- Class faultBeanClass = faultBeanType.getPhysical();
- try {
- Constructor constructor =
- exceptionClass.getConstructor(new Class[] {String.class, faultBeanClass, Throwable.class});
- return (Exception)constructor.newInstance(new Object[] {message, faultInfo, cause});
- } catch (Throwable e) {
- throw new IllegalArgumentException(e);
- }
- }
-
- public Object getFaultInfo(Exception exception) {
- if (exception == null) {
- return null;
- }
- try {
- Method method = exception.getClass().getMethod("getFaultInfo", EMPTY_CLASS_ARRAY);
- return method.invoke(exception, (Object[])null);
- } catch (Throwable e) {
- throw new IllegalArgumentException(e);
- }
- }
-
- public DataType<?> getFaultType(DataType exDataType) {
- Class<?> exceptionType = exDataType.getPhysical();
- WebFault webFault = exceptionType.getAnnotation(WebFault.class);
- if (webFault == null) {
- return null;
- } else {
- QName element = new QName(webFault.targetNamespace(), webFault.name());
- // TODO: Need to determine the fault bean class
- // String faultBean = webFault.faultBean();
- Class faultBeanClass = null;
- try {
- Method method = exceptionType.getMethod("getFaultInfo", EMPTY_CLASS_ARRAY);
- faultBeanClass = method.getReturnType();
- } catch (NoSuchMethodException e) {
- faultBeanClass = null;
- }
- // The logical type of a fault is the QName of the element that the
- // only part in
- // the fault message references
- DataType<XMLType> faultType =
- new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, faultBeanClass, new XMLType(element, null));
- // faultType.setMetadata(ElementInfo.class.getName(), new
- // ElementInfo(element, null));
- return faultType;
- }
- }
-
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java
deleted file mode 100644
index c3e97a4818..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * 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.jaxb;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.annotation.XmlElementDecl;
-import javax.xml.bind.annotation.XmlRegistry;
-import javax.xml.bind.annotation.XmlType;
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.databinding.TransformationContext;
-import org.apache.tuscany.sca.databinding.TransformationException;
-import org.apache.tuscany.sca.databinding.WrapperHandler;
-import org.apache.tuscany.sca.interfacedef.DataType;
-import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
-import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
-import org.apache.tuscany.sca.interfacedef.util.XMLType;
-
-/**
- * JAXB WrapperHandler implementation
- */
-public class JAXBWrapperHandler implements WrapperHandler<JAXBElement<?>> {
-
- public JAXBElement<?> create(ElementInfo element, TransformationContext context) {
- try {
- // FIXME: How do we map the global element to a factory?
- String packageName = null;
- String factoryClassName = packageName + ".ObjectFactory";
- ClassLoader classLoader = context != null ? context.getClassLoader() : null;
- if (classLoader == null) {
- //FIXME Understand why we need this, the classloader should be passed in
- classLoader = Thread.currentThread().getContextClassLoader();
- }
- Class<?> factoryClass = Class.forName(factoryClassName, true, classLoader);
- assert factoryClass.isAnnotationPresent(XmlRegistry.class);
- Object factory = factoryClass.newInstance();
- QName elementName = element.getQName();
- Method method = null;
- for (Method m : factoryClass.getMethods()) {
- XmlElementDecl xmlElement = m.getAnnotation(XmlElementDecl.class);
- QName name = new QName(xmlElement.namespace(), xmlElement.name());
- if (xmlElement != null && name.equals(elementName)) {
- method = m;
- break;
- }
- }
- if (method != null) {
- Class typeClass = method.getParameterTypes()[0];
- Object value = typeClass.newInstance();
- return (JAXBElement<?>)method.invoke(factory, new Object[] {value});
- } else {
- throw new TransformationException("ObjectFactory cannot be resolved.");
- }
- } catch (Exception e) {
- throw new TransformationException(e);
- }
- }
-
- public void setChild(JAXBElement<?> wrapper, int i, ElementInfo childElement, Object value) {
- Object wrapperValue = wrapper.getValue();
- Class<?> wrapperClass = wrapperValue.getClass();
-
- XmlType xmlType = wrapperClass.getAnnotation(XmlType.class);
- String[] properties = xmlType.propOrder();
- String property = properties[i];
-
- try {
- for (Method m : wrapperClass.getMethods()) {
- if (m.getName().equals("set" + capitalize(property))) {
- m.invoke(wrapperValue, new Object[] {value});
- return;
- }
- }
- } catch (Throwable e) {
- throw new TransformationException(e);
- }
- }
-
- private static String capitalize(String name) {
- char first = Character.toUpperCase(name.charAt(0));
- return first + name.substring(1);
- }
-
- /**
- * @see org.apache.tuscany.sca.databinding.WrapperHandler#getChildren(java.lang.Object, List, TransformationContext)
- */
- public List getChildren(JAXBElement<?> wrapper, List<ElementInfo> childElements, TransformationContext context) {
- Object wrapperValue = wrapper.getValue();
- Class<?> wrapperClass = wrapperValue.getClass();
-
- XmlType xmlType = wrapperClass.getAnnotation(XmlType.class);
- String[] properties = xmlType.propOrder();
- List<Object> elements = new ArrayList<Object>();
- for (String p : properties) {
- try {
- Method method = wrapperClass.getMethod("get" + capitalize(p), (Class[])null);
- Object value = method.invoke(wrapperValue, (Object[])null);
- elements.add(value);
- } catch (Throwable e) {
- throw new TransformationException(e);
- }
- }
- return elements;
- }
-
- /**
- * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(org.apache.tuscany.sca.interfacedef.util.ElementInfo, List, org.apache.tuscany.sca.databinding.TransformationContext)
- */
- public DataType getWrapperType(ElementInfo element, List<ElementInfo> childElements, TransformationContext context) {
- try {
- // FIXME: How do we map the global element to a factory?
- String packageName = null;
- String factoryClassName = packageName + ".ObjectFactory";
- ClassLoader classLoader = context != null ? context.getClassLoader() : null;
- if (classLoader == null) {
- //FIXME Understand why we need this, the classloader should be passed in
- classLoader = Thread.currentThread().getContextClassLoader();
- }
- Class<?> factoryClass = Class.forName(factoryClassName, true, classLoader);
- assert factoryClass.isAnnotationPresent(XmlRegistry.class);
- QName elementName = element.getQName();
- Method method = null;
- for (Method m : factoryClass.getMethods()) {
- XmlElementDecl xmlElement = m.getAnnotation(XmlElementDecl.class);
- QName name = new QName(xmlElement.namespace(), xmlElement.name());
- if (xmlElement != null && name.equals(elementName)) {
- method = m;
- break;
- }
- }
- if (method != null) {
- Class typeClass = method.getParameterTypes()[0];
- DataType<XMLType> wrapperType =
- new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, typeClass, new XMLType(element));
- return wrapperType;
- }
-
- return null;
- } catch (Throwable e) {
- return null;
- }
- }
-
- /**
- * @see org.apache.tuscany.sca.databinding.WrapperHandler#isInstance(java.lang.Object, org.apache.tuscany.sca.interfacedef.util.ElementInfo, java.util.List, org.apache.tuscany.sca.databinding.TransformationContext)
- */
- public boolean isInstance(Object wrapper,
- ElementInfo element,
- List<ElementInfo> childElements,
- TransformationContext context) {
- // TODO: Implement the logic
- return true;
- }
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXWSJavaInterfaceProcessor.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXWSJavaInterfaceProcessor.java
deleted file mode 100644
index b5ac3fb47f..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXWSJavaInterfaceProcessor.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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.jaxb;
-
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jws.WebMethod;
-import javax.jws.WebService;
-
-import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
-import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
-
-/**
- * The databinding annotation processor for java interfaces
- *
- * @version $Rev$ $Date$
- */
-public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor {
-
- public JAXWSJavaInterfaceProcessor() {
- super();
- }
-
- public void visitInterface(JavaInterface contract) throws InvalidInterfaceException {
-
- Class<?> clazz = contract.getJavaClass();
- WebService webService = clazz.getAnnotation(WebService.class);
- String tns = "";
- if (webService != null) {
- tns = webService.targetNamespace();
- // Mark SEI as Remotable
- contract.setRemotable(true);
- }
- if (!contract.isRemotable()) {
- return;
- }
- Map<String, Operation> operations = new HashMap<String, Operation>();
- for (Operation op : contract.getOperations()) {
- operations.put(op.getName(), op);
- }
- for (Method method : clazz.getMethods()) {
- Operation operation = operations.get(method.getName());
-
- WebMethod webMethod = method.getAnnotation(WebMethod.class);
- if (webMethod == null) {
- return;
- }
-
- /*
- String operationName = getValue(webMethod.operationName(), operation.getName());
-
- RequestWrapper requestWrapper = method.getAnnotation(RequestWrapper.class);
- ResponseWrapper responseWrapper = method.getAnnotation(ResponseWrapper.class);
- if (requestWrapper == null) {
- return;
- }
-
- String ns = getValue(requestWrapper.targetNamespace(), tns);
- String name = getValue(requestWrapper.localName(), operationName);
- QName inputWrapper = new QName(ns, name);
-
- ns = getValue(responseWrapper.targetNamespace(), tns);
- name = getValue(responseWrapper.localName(), operationName + "Response");
-
- QName outputWrapper = new QName(ns, name);
-
- List<ElementInfo> inputElements = new ArrayList<ElementInfo>();
- for (Annotation[] annotations : method.getParameterAnnotations()) {
- for (Annotation annotation : annotations) {
- if (annotation.annotationType() == WebParam.class) {
- WebParam param = (WebParam)annotation;
- inputElements.add(new ElementInfo(new QName(param.targetNamespace(), param.name()), null));
- break;
- }
- }
- }
-
- List<ElementInfo> outputElements = new ArrayList<ElementInfo>();
- WebResult result = method.getAnnotation(WebResult.class);
- outputElements.add(new ElementInfo(new QName(result.targetNamespace(), result.name()), null));
-
- WrapperInfo wrapperInfo =
- new WrapperInfo(JAXBDataBinding.NAME, new ElementInfo(inputWrapper, null),
- new ElementInfo(outputWrapper, null), inputElements, outputElements);
- operation.setWrapper(wrapperInfo);
- */
- operation.setWrapperStyle(false);
- operation.setDataBinding(JAXBDataBinding.NAME);
- }
- }
-
- private static String getValue(String value, String defaultValue) {
- return "".equals(value) ? defaultValue : value;
- }
-
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java
deleted file mode 100755
index 05e420f1c6..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.jaxb;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-
-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.w3c.dom.Node;
-
-public class Node2JAXB extends BaseTransformer<Node, Object> implements PullTransformer<Node, Object> {
-
- public Node2JAXB() {
- super();
- }
-
- public Object transform(Node source, TransformationContext context) {
- if (source == null)
- return null;
- try {
- JAXBContext jaxbContext = JAXBContextHelper.createJAXBContext(context, false);
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- Object result = unmarshaller.unmarshal(source, JAXBContextHelper.getJavaType(context.getTargetDataType()));
- return JAXBContextHelper.createReturnValue(context.getTargetDataType(), result);
- } catch (Exception e) {
- throw new TransformationException(e);
- }
- }
-
- @Override
- public Class getSourceType() {
- return Node.class;
- }
-
- @Override
- public Class getTargetType() {
- return Object.class;
- }
-
- @Override
- public int getWeight() {
- return 30;
- }
-
- @Override
- public String getTargetDataBinding() {
- return JAXBDataBinding.NAME;
- }
-
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java
deleted file mode 100644
index 61b3075539..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.jaxb;
-
-import java.io.Reader;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.transform.stream.StreamSource;
-
-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;
-
-public class Reader2JAXB extends BaseTransformer<Reader, Object> implements
- PullTransformer<Reader, Object> {
-
- public Object transform(final Reader source, final TransformationContext context) {
- if (source == null) {
- return null;
- }
- try {
- JAXBContext jaxbContext = JAXBContextHelper.createJAXBContext(context, false);
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- StreamSource streamSource = new StreamSource(source);
- Object result = unmarshaller.unmarshal(streamSource, JAXBContextHelper.getJavaType(context.getTargetDataType()));
- return JAXBContextHelper.createReturnValue(context.getTargetDataType(), result);
- } catch (Exception e) {
- throw new TransformationException(e);
- }
- }
-
- @Override
- public Class getSourceType() {
- return Reader.class;
- }
-
- @Override
- public Class getTargetType() {
- return Object.class;
- }
-
- @Override
- public int getWeight() {
- return 30;
- }
-
- @Override
- public String getTargetDataBinding() {
- return JAXBDataBinding.NAME;
- }
-
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java
deleted file mode 100644
index 79e8dc027f..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.jaxb;
-
-import java.io.StringReader;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.transform.stream.StreamSource;
-
-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.XMLStringDataBinding;
-
-public class String2JAXB extends BaseTransformer<String, Object> implements
- PullTransformer<String, Object> {
-
- public Object transform(final String source, final TransformationContext context) {
- if (source == null) {
- return null;
- }
- try {
- JAXBContext jaxbContext = JAXBContextHelper.createJAXBContext(context, false);
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- StreamSource streamSource = new StreamSource(new StringReader(source));
- Object result = unmarshaller.unmarshal(streamSource, JAXBContextHelper.getJavaType(context.getTargetDataType()));
- return JAXBContextHelper.createReturnValue(context.getTargetDataType(), result);
- } catch (Exception e) {
- throw new TransformationException(e);
- }
- }
-
- @Override
- public Class getSourceType() {
- return String.class;
- }
-
- @Override
- public Class getTargetType() {
- return Object.class;
- }
-
- @Override
- public int getWeight() {
- return 30;
- }
-
- @Override
- public String getSourceDataBinding() {
- return XMLStringDataBinding.NAME;
- }
-
- @Override
- public String getTargetDataBinding() {
- return JAXBDataBinding.NAME;
- }
-
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java
deleted file mode 100755
index ef3112eb22..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.jaxb;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-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;
-
-public class XMLStreamReader2JAXB extends BaseTransformer<XMLStreamReader, Object> implements
- PullTransformer<XMLStreamReader, Object> {
-
- public XMLStreamReader2JAXB() {
- super();
- }
-
- public Object transform(XMLStreamReader source, TransformationContext context) {
- if (source == null) {
- return null;
- }
- try {
- JAXBContext jaxbContext = JAXBContextHelper.createJAXBContext(context, false);
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- // FIXME: [rfeng] If the java type is Object.class, the unmarshalled result will be
- // a DOM Node
- Object result = unmarshaller.unmarshal(source, JAXBContextHelper.getJavaType(context.getTargetDataType()));
- source.close();
- return JAXBContextHelper.createReturnValue(context.getTargetDataType(), result);
- } catch (Exception e) {
- throw new TransformationException(e);
- }
- }
-
- @Override
- public Class getSourceType() {
- return XMLStreamReader.class;
- }
-
- @Override
- public Class getTargetType() {
- return Object.class;
- }
-
- @Override
- public int getWeight() {
- return 10;
- }
-
- @Override
- public String getTargetDataBinding() {
- return JAXBDataBinding.NAME;
- }
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
deleted file mode 100644
index 58d6123373..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
+++ /dev/null
@@ -1,19 +0,0 @@
-# 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 classes for the databindings
-org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding;type=javax.xml.bind.JAXBElement,name=jaxb
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
deleted file mode 100644
index 4e062e4c22..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
+++ /dev/null
@@ -1,32 +0,0 @@
-# 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 classes for the transformers
-org.apache.tuscany.sca.databinding.jaxb.JAXB2Node;source=javax.xml.bind.JAXBElement,target=org.w3c.dom.Node,weight=500
-org.apache.tuscany.sca.databinding.jaxb.Node2JAXB;source=org.w3c.dom.Node,target=javax.xml.bind.JAXBElement,weight=500
-org.apache.tuscany.sca.databinding.jaxb.Reader2JAXB;source=java.io.Reader,target=javax.xml.bind.JAXBElement,weight=510
-org.apache.tuscany.sca.databinding.jaxb.XMLStreamReader2JAXB;source=javax.xml.stream.XMLStreamReader,target=javax.xml.bind.JAXBElement,weight=490
-
-org.apache.tuscany.sca.databinding.jaxb.JAXB2Node;source=java:complexType,target=org.w3c.dom.Node,weight=90000
-org.apache.tuscany.sca.databinding.jaxb.Node2JAXB;source=org.w3c.dom.Node,target=java:complexType,weight=90000
-
-org.apache.tuscany.sca.databinding.jaxb.Node2JAXB;source=org.w3c.dom.Node,target=java:simpleType,weight=90000
-org.apache.tuscany.sca.databinding.jaxb.JAXB2Node;source=java:simpleType,target=org.w3c.dom.Node,weight=90000
-
-org.apache.tuscany.sca.databinding.jaxb.XMLStreamReader2JAXB;source=javax.xml.stream.XMLStreamReader,target=java:complexType,weight=90000
-org.apache.tuscany.sca.databinding.jaxb.XMLStreamReader2JAXB;source=javax.xml.stream.XMLStreamReader,target=java:simpleType,weight=90000
-
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor b/branches/sca-java-1.1/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor
deleted file mode 100644
index 28ce24b63a..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor
+++ /dev/null
@@ -1,18 +0,0 @@
-# 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.
-
-org.apache.tuscany.sca.databinding.jaxb.JAXWSJavaInterfaceProcessor
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBDataBindingTestCase.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBDataBindingTestCase.java
deleted file mode 100644
index b121e2c99f..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBDataBindingTestCase.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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.databinding.jaxb;
-
-import java.lang.annotation.Annotation;
-
-import javax.xml.bind.JAXBElement;
-import javax.xml.namespace.QName;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding;
-import org.apache.tuscany.sca.interfacedef.DataType;
-import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
-import org.apache.tuscany.sca.interfacedef.util.XMLType;
-
-import com.example.ipo.jaxb.ObjectFactory;
-import com.example.ipo.jaxb.PurchaseOrderType;
-import com.example.ipo.jaxb.USAddress;
-import com.example.ipo.jaxb.USState;
-
-/**
- *
- */
-public class JAXBDataBindingTestCase extends TestCase {
- private JAXBDataBinding binding;
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- binding = new JAXBDataBinding();
- }
-
- /**
- * Test method for
- * {@link org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding#introspect(java.lang.Class, Annotation)}.
- */
- public final void testIntrospect() {
- DataType dataType = new DataTypeImpl<Class>(JAXBElement.class, null);
- boolean yes = binding.introspect(dataType, null);
- assertTrue(yes);
- assertTrue(dataType.getDataBinding().equals(binding.getName()));
- assertTrue(dataType.getPhysical() == JAXBElement.class && dataType.getLogical() == XMLType.UNKNOWN);
- dataType = new DataTypeImpl<Class>(MockJAXBElement.class, null);
- yes = binding.introspect(dataType, null);
- assertTrue(yes);
- assertEquals(MockJAXBElement.class, dataType.getPhysical());
- assertEquals(new QName("http://www.example.com/IPO", "PurchaseOrderType"), ((XMLType)dataType.getLogical())
- .getTypeName());
- dataType = new DataTypeImpl<Class>(USAddress.class, null);
- yes = binding.introspect(dataType, null);
- assertTrue(yes);
- assertEquals(USAddress.class, dataType.getPhysical());
- assertEquals(new QName("http://www.example.com/IPO", "USAddress"), ((XMLType)dataType.getLogical())
- .getTypeName());
- dataType = new DataTypeImpl<Class>(USState.class, null);
- yes = binding.introspect(dataType, null);
- assertTrue(yes);
- assertTrue(dataType.getDataBinding().equals(binding.getName()));
- assertEquals(USState.class, dataType.getPhysical());
- assertEquals(new QName("http://www.example.com/IPO", "USState"), ((XMLType)dataType.getLogical()).getTypeName());
-
- }
-
- private static class MockJAXBElement extends JAXBElement<PurchaseOrderType> {
-
- private static final long serialVersionUID = -2767569071002707973L;
-
- /**
- * @param elementName
- * @param type
- * @param value
- */
- public MockJAXBElement(QName elementName, Class<PurchaseOrderType> type, PurchaseOrderType value) {
- super(elementName, type, value);
- }
-
- }
-
- @SuppressWarnings("unchecked")
- public void testCopy() {
- ObjectFactory factory = new ObjectFactory();
- PurchaseOrderType poType = factory.createPurchaseOrderType();
- JAXBElement<PurchaseOrderType> po = factory.createPurchaseOrder(poType);
- JAXBElement<PurchaseOrderType> copy = (JAXBElement<PurchaseOrderType>)binding.copy(po);
- assertEquals(new QName("http://www.example.com/IPO", "purchaseOrder"), copy.getName());
- }
-
- @SuppressWarnings("unchecked")
- public void testCopyNonElement() {
- ObjectFactory factory = new ObjectFactory();
- PurchaseOrderType poType = factory.createPurchaseOrderType();
- poType.setComment("Comment");
- PurchaseOrderType copy = (PurchaseOrderType)binding.copy(poType);
- assertTrue(copy instanceof PurchaseOrderType);
- assertEquals("Comment", (copy).getComment());
- }
-
- @SuppressWarnings("unchecked")
- public void testCopyNonRoot() {
- ObjectFactory factory = new ObjectFactory();
- USAddress address = factory.createUSAddress();
- address.setCity("San Jose");
- USAddress copy = (USAddress)binding.copy(address);
- assertTrue(copy instanceof USAddress);
- assertEquals("San Jose", (copy).getCity());
-
- }
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandlerTestCase.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandlerTestCase.java
deleted file mode 100644
index 9cf40ee9a6..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBExceptionHandlerTestCase.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.databinding.jaxb;
-
-import javax.xml.namespace.QName;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.databinding.jaxb.fault.InvalidSymbolFault;
-import org.apache.tuscany.databinding.jaxb.fault.InvalidSymbolFault_Exception;
-import org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding;
-import org.apache.tuscany.sca.databinding.jaxb.JAXBExceptionHandler;
-import org.apache.tuscany.sca.interfacedef.DataType;
-import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
-import org.apache.tuscany.sca.interfacedef.util.XMLType;
-
-/**
- * Test case for JAXBExceptionHandler
- */
-public class JAXBExceptionHandlerTestCase extends TestCase {
- private static final QName ELEMENT = new QName("http://www.example.com/stock", "InvalidSymbolFault");
- private JAXBExceptionHandler handler;
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.handler = new JAXBExceptionHandler();
- }
-
- public void testGetFaultType() {
- DataType exType = new DataTypeImpl<XMLType>(InvalidSymbolFault_Exception.class, XMLType.UNKNOWN);
- DataType<?> dataType = handler.getFaultType(exType);
- assertEquals(InvalidSymbolFault.class, dataType.getPhysical());
- assertEquals(ELEMENT, ((XMLType) dataType.getLogical()).getElementName());
- assertEquals(JAXBDataBinding.NAME, dataType.getDataBinding());
- }
-
- public void testCreate() {
- DataType execType = new DataTypeImpl<XMLType>(InvalidSymbolFault_Exception.class, XMLType.UNKNOWN);
- DataType<?> faultType = handler.getFaultType(execType);
- InvalidSymbolFault fault = new InvalidSymbolFault();
- fault.setMessage("ABC");
- fault.setSymbol("IBM0");
- DataType<DataType> exType = new DataTypeImpl<DataType>(InvalidSymbolFault_Exception.class, faultType);
- Exception ex = handler.createException(exType, "Invalid symbol", fault, null);
- assertTrue(ex instanceof InvalidSymbolFault_Exception);
- InvalidSymbolFault_Exception exception = (InvalidSymbolFault_Exception)ex;
- assertEquals("Invalid symbol", exception.getMessage());
- assertSame(fault, exception.getFaultInfo());
- }
-
- public void testGetFaultInfo() {
- InvalidSymbolFault fault = new InvalidSymbolFault();
- fault.setMessage("ABC");
- fault.setSymbol("IBM0");
- InvalidSymbolFault_Exception exception = new InvalidSymbolFault_Exception("Invalid symbol", fault);
- Object faultInfo = handler.getFaultInfo(exception);
- assertSame(fault, faultInfo);
- }
-
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBTestCase.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBTestCase.java
deleted file mode 100755
index 512e1c625f..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBTestCase.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * 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.databinding.jaxb;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-
-import java.io.StringReader;
-
-import javax.xml.namespace.QName;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sca.databinding.TransformationContext;
-import org.apache.tuscany.sca.databinding.jaxb.JAXB2Node;
-import org.apache.tuscany.sca.databinding.jaxb.Node2JAXB;
-import org.apache.tuscany.sca.databinding.jaxb.Reader2JAXB;
-import org.apache.tuscany.sca.interfacedef.DataType;
-import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
-import org.apache.tuscany.sca.interfacedef.util.XMLType;
-import org.w3c.dom.Node;
-
-import com.example.ipo.jaxb.ObjectFactory;
-import com.example.ipo.jaxb.PurchaseOrderType;
-
-public class JAXBTestCase extends TestCase {
- private static final String IPO_XML =
- "<?xml version=\"1.0\"?>" + "<ipo:purchaseOrder"
- + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
- + " xmlns:ipo=\"http://www.example.com/IPO\""
- + " xsi:schemaLocation=\"http://www.example.com/IPO ipo.xsd\""
- + " orderDate=\"1999-12-01\">"
- + " <shipTo exportCode=\"1\" xsi:type=\"ipo:UKAddress\">"
- + " <name>Helen Zoe</name>"
- + " <street>47 Eden Street</street>"
- + " <city>Cambridge</city>"
- + " <postcode>CB1 1JR</postcode>"
- + " </shipTo>"
- + " <billTo xsi:type=\"ipo:USAddress\">"
- + " <name>Robert Smith</name>"
- + " <street>8 Oak Avenue</street>"
- + " <city>Old Town</city>"
- + " <state>PA</state>"
- + " <zip>95819</zip>"
- + " </billTo>"
- + " <items>"
- + " <item partNum=\"833-AA\">"
- + " <productName>Lapis necklace</productName>"
- + " <quantity>1</quantity>"
- + " <USPrice>99.95</USPrice>"
- + " <ipo:comment>Want this for the holidays</ipo:comment>"
- + " <shipDate>1999-12-05</shipDate>"
- + " </item>"
- + " </items>"
- + "</ipo:purchaseOrder>";
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- public void testTransform() throws Exception {
- Reader2JAXB t0 = new Reader2JAXB();
-
- DataType targetDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);
-
- TransformationContext tContext = createMock(TransformationContext.class);
- expect(tContext.getTargetDataType()).andReturn(targetDataType).anyTimes();
- replay(tContext);
-
- Object object1 = t0.transform(new StringReader(IPO_XML), tContext);
-
- DataType sourceDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);
-
- TransformationContext tContext1 = createMock(TransformationContext.class);
- expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
- expect(tContext1.getTargetDataType()).andReturn(null).anyTimes();
- replay(tContext1);
-
- JAXB2Node t1 = new JAXB2Node();
- Node node = t1.transform(object1, tContext1);
-
- Assert.assertNotNull(node);
-
- Node2JAXB t2 = new Node2JAXB();
- Object object2 = t2.transform(node, tContext);
- Assert.assertNotNull(object2);
-
- }
-
- public void testTransform2() throws Exception {
- Reader2JAXB t0 = new Reader2JAXB();
-
- QName root = new QName("http://www.example.com/IPO", "purchaseOrder");
- DataType targetDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(root, null));
- // targetDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);
-
- TransformationContext tContext = createMock(TransformationContext.class);
- expect(tContext.getTargetDataType()).andReturn(targetDataType).anyTimes();
- replay(tContext);
-
- Object object1 = t0.transform(new StringReader(IPO_XML), tContext);
-
- DataType sourceDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(root, null));
- // sourceDataType.setMetadata(JAXBContextHelper.JAXB_CONTEXT_PATH, contextPath);
-
- TransformationContext tContext1 = createMock(TransformationContext.class);
- expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
- expect(tContext1.getTargetDataType()).andReturn(null).anyTimes();
- replay(tContext1);
-
- JAXB2Node t1 = new JAXB2Node();
- Node node = t1.transform(object1, tContext1);
-
- Assert.assertNotNull(node);
-
- Node2JAXB t2 = new Node2JAXB();
- Object object2 = t2.transform(node, tContext);
- Assert.assertNotNull(object2);
-
- }
-
- public void testTransform3() throws Exception {
-
- DataType sourceDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);
-
- TransformationContext tContext1 = createMock(TransformationContext.class);
- expect(tContext1.getSourceDataType()).andReturn(sourceDataType).anyTimes();
- expect(tContext1.getTargetDataType()).andReturn(null).anyTimes();
- replay(tContext1);
-
- JAXB2Node t1 = new JAXB2Node();
- PurchaseOrderType po = new ObjectFactory().createPurchaseOrderType();
- Node node = t1.transform(po, tContext1);
-
- Assert.assertNotNull(node);
-
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBWrapperHandlerTestCase.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBWrapperHandlerTestCase.java
deleted file mode 100644
index 563d6232b1..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXBWrapperHandlerTestCase.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.databinding.jaxb;
-
-import java.util.List;
-
-import javax.xml.bind.JAXBElement;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sca.databinding.jaxb.JAXBWrapperHandler;
-
-import com.example.ipo.jaxb.ObjectFactory;
-import com.example.ipo.jaxb.PurchaseOrderType;
-
-/**
- * Test case for JAXBExceptionHandler
- */
-public class JAXBWrapperHandlerTestCase extends TestCase {
- // private static final QName ELEMENT = new QName("http://www.example.com/IPO", "purchaseOrder");
- private JAXBWrapperHandler handler;
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.handler = new JAXBWrapperHandler();
- }
-
- public void testCreate() {
- // ElementInfo element = new ElementInfo(ELEMENT, null);
- // JAXBElement<?> jaxbElement = handler.create(element, null);
- }
-
- public void testSetChild() {
- ObjectFactory factory = new ObjectFactory();
- PurchaseOrderType po = factory.createPurchaseOrderType();
- JAXBElement<PurchaseOrderType> wrapper = factory.createPurchaseOrder(po);
- handler.setChild(wrapper, 2, null, "Comment");
- }
-
- public void testGetChildren() {
- ObjectFactory factory = new ObjectFactory();
- PurchaseOrderType po = factory.createPurchaseOrderType();
- po.setComment("Comment");
- JAXBElement<PurchaseOrderType> wrapper = factory.createPurchaseOrder(po);
- List children = handler.getChildren(wrapper, null, null);
- assertNotNull(children);
- assertEquals(4, children.size());
- assertEquals("Comment", children.get(2));
- assertNull(children.get(0));
- }
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXWSJavaInterfaceProcessorTestCase.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXWSJavaInterfaceProcessorTestCase.java
deleted file mode 100644
index 83abdc29f5..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/JAXWSJavaInterfaceProcessorTestCase.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * 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.databinding.jaxb;
-
-import javax.jws.WebService;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sca.databinding.jaxb.JAXWSJavaInterfaceProcessor;
-import org.apache.tuscany.sca.interfacedef.impl.InterfaceImpl;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
-
-/**
- *
- */
-public class JAXWSJavaInterfaceProcessorTestCase extends TestCase {
- private JAXWSJavaInterfaceProcessor interfaceProcessor;
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- interfaceProcessor = new JAXWSJavaInterfaceProcessor();
- }
-
- /**
- * Test method for
- * {@link org.apache.tuscany.sca.databinding.jaxb.JAXWSJavaInterfaceProcessor#visitInterface(JavaInterface)}.
- */
- public final void testProcessor() throws Exception {
- JavaInterface contract = new MockJavaInterfaceImpl();
- contract.setJavaClass(WebServiceInterfaceWithoutAnnotation.class);
-
- interfaceProcessor.visitInterface(contract);
- assertFalse(contract.isRemotable());
-
- contract.setJavaClass(WebServiceInterfaceWithAnnotation.class);
- interfaceProcessor.visitInterface(contract);
- assertTrue(contract.isRemotable());
- }
-
- @WebService
- private static interface WebServiceInterfaceWithAnnotation {
-
- }
-
- private static interface WebServiceInterfaceWithoutAnnotation {
-
- }
-
- private class MockJavaInterfaceImpl extends InterfaceImpl implements JavaInterface {
- private Class<?> javaClass;
-
- public Class<?> getCallbackClass() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Class<?> getJavaClass() {
- // TODO Auto-generated method stub
- return javaClass;
- }
-
- public String getName() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void setCallbackClass(Class<?> callbackClass) {
- // TODO Auto-generated method stub
-
- }
-
- public void setJavaClass(Class<?> javaClass) {
- this.javaClass = javaClass;
- }
-
- public void setName(String className) {
- // TODO Auto-generated method stub
-
- }
- }
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/MyBean.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/MyBean.java
deleted file mode 100644
index 49fb38b1fa..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/MyBean.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * 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.databinding.jaxb;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class MyBean {
- private int age;
- private String name;
- private float[] rates = new float[] {1.0f, 2.0f};
- private List<String> notes = new ArrayList<String>();
- private Map<String, Integer> map = new HashMap<String, Integer>();
- private Object service;
- private Object otherService;
- private boolean good;
-
- public int getAge() {
- return age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List<String> getNotes() {
- return notes;
- }
-
- public void setNotes(List<String> notes) {
- this.notes = notes;
- }
-
- public float[] getRates() {
- return rates;
- }
-
- public void setRates(float[] rates) {
- this.rates = rates;
- }
-
- public Map<String, Integer> getMap() {
- return map;
- }
-
- public void setMap(Map<String, Integer> map) {
- this.map = map;
- }
-
- public Object getService() {
- return service;
- }
-
- public void setService(Object service) {
- this.service = service;
- }
-
- public Object getOtherService() {
- return otherService;
- }
-
- public void setOtherService(Object otherService) {
- this.otherService = otherService;
- }
-
- public boolean isGood() {
- return good;
- }
-
- public void setGood(boolean good) {
- this.good = good;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + age;
- result = prime * result + (good ? 1231 : 1237);
- result = prime * result + ((map == null) ? 0 : map.hashCode());
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((notes == null) ? 0 : notes.hashCode());
- result = prime * result + ((otherService == null) ? 0 : otherService.hashCode());
- result = prime * result + Arrays.hashCode(rates);
- result = prime * result + ((service == null) ? 0 : service.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final MyBean other = (MyBean)obj;
- if (age != other.age)
- return false;
- if (good != other.good)
- return false;
- if (map == null) {
- if (other.map != null)
- return false;
- } else if (!map.equals(other.map))
- return false;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- if (notes == null) {
- if (other.notes != null)
- return false;
- } else if (!notes.equals(other.notes))
- return false;
- if (otherService == null) {
- if (other.otherService != null)
- return false;
- } else if (!otherService.equals(other.otherService))
- return false;
- if (!Arrays.equals(rates, other.rates))
- return false;
- if (service == null) {
- if (other.service != null)
- return false;
- } else if (!service.equals(other.service))
- return false;
- return true;
- }
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/MyInterface.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/MyInterface.java
deleted file mode 100644
index 2fc561b577..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/MyInterface.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.databinding.jaxb;
-
-/**
- * @version $Rev$ $Date$
- */
-public interface MyInterface {
- public void setId(String id);
-
- public String getId();
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/MyInterfaceImpl.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/MyInterfaceImpl.java
deleted file mode 100644
index 928acb9f3c..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/MyInterfaceImpl.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.databinding.jaxb;
-
-/**
- * @version $Rev$ $Date$
- */
-public class MyInterfaceImpl implements MyInterface {
- private String id;
-
- /**
- * @see org.apache.tuscany.databinding.jaxb.MyInterface#getId()
- */
- public String getId() {
- return id;
- }
-
- /**
- * @see org.apache.tuscany.databinding.jaxb.MyInterface#setId(java.lang.String)
- */
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final MyInterfaceImpl other = (MyInterfaceImpl)obj;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- return true;
- }
-
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/POJOTestCase.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/POJOTestCase.java
deleted file mode 100644
index 9758292aea..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/POJOTestCase.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * 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.databinding.jaxb;
-
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.lang.reflect.Type;
-import java.util.Collection;
-import java.util.Collections;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.stream.StreamSource;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sca.databinding.TransformationContext;
-import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
-import org.apache.tuscany.sca.databinding.jaxb.JAXB2XMLStreamReader;
-
-import com.sun.xml.bind.v2.model.annotation.RuntimeInlineAnnotationReader;
-import com.sun.xml.bind.v2.model.core.Ref;
-import com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder;
-import com.sun.xml.bind.v2.model.runtime.RuntimeClassInfo;
-import com.sun.xml.bind.v2.model.runtime.RuntimePropertyInfo;
-import com.sun.xml.bind.v2.model.runtime.RuntimeTypeInfoSet;
-import com.sun.xml.bind.v2.runtime.IllegalAnnotationsException;
-import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
-
-public class POJOTestCase extends TestCase {
- public void testPOJO() throws Exception {
- JAXBContext context = JAXBContext.newInstance(MyBean.class, MyInterfaceImpl.class);
- StringWriter writer = new StringWriter();
- MyBean bean = new MyBean();
- bean.setName("Test");
- bean.setAge(20);
- bean.getNotes().add("1");
- bean.getNotes().add("2");
- bean.getMap().put("1", 1);
- MyInterface service = new MyInterfaceImpl();
- service.setId("ID001");
- bean.setService(service);
- bean.setOtherService(service);
- JAXBElement<Object> element = new JAXBElement<Object>(new QName("http://ns1", "bean"), Object.class, bean);
- context.createMarshaller().marshal(element, writer);
- // System.out.println(writer.toString());
-
- Object result = context.createUnmarshaller().unmarshal(new StringReader(writer.toString()));
- assertTrue(result instanceof JAXBElement);
- JAXBElement e2 = (JAXBElement)result;
- assertTrue(e2.getValue() instanceof MyBean);
- MyBean newBean = (MyBean)e2.getValue();
- assertEquals(bean, newBean);
- }
-
- public void testXMLStreamReader() throws Exception {
- JAXBContext context = JAXBContext.newInstance(MyBean.class, MyInterfaceImpl.class);
-
- MyBean bean = new MyBean();
- bean.setName("Test");
- bean.setAge(20);
- bean.getNotes().add("1");
- bean.getNotes().add("2");
- bean.getMap().put("1", 1);
- MyInterface service = new MyInterfaceImpl();
- service.setId("ID001");
- bean.setService(service);
- bean.setOtherService(service);
- JAXBElement<Object> element = new JAXBElement<Object>(new QName("http://ns1", "bean"), Object.class, bean);
- TransformationContext tContext = new TransformationContextImpl();
- XMLStreamReader reader = new JAXB2XMLStreamReader().transform(element, tContext);
-
-// XMLStreamReader2String t2 = new XMLStreamReader2String();
-// String xml = t2.transform(reader, null);
- // System.out.println(xml);
- Object result = context.createUnmarshaller().unmarshal(reader, MyBean.class);
- assertTrue(result instanceof JAXBElement);
- JAXBElement e2 = (JAXBElement)result;
- assertTrue(e2.getValue() instanceof MyBean);
- MyBean newBean = (MyBean)e2.getValue();
- // FIXME :To be implemented
- // assertEquals(bean, newBean);
- }
-
- public void testString() throws Exception {
- JAXBContext context = JAXBContext.newInstance(String.class);
- StringWriter writer = new StringWriter();
- JAXBElement<Object> element = new JAXBElement<Object>(new QName("http://ns1", "bean"), Object.class, "ABC");
- context.createMarshaller().marshal(element, writer);
- // System.out.println(writer.toString());
-
- Object result = context.createUnmarshaller().unmarshal(new StringReader(writer.toString()));
- assertTrue(result instanceof JAXBElement);
- JAXBElement e2 = (JAXBElement)result;
- assertEquals("ABC", e2.getValue());
- }
-
- public void testNull() throws Exception {
- JAXBContext context = JAXBContext.newInstance(String.class);
- StringWriter writer = new StringWriter();
- JAXBElement<Object> element = new JAXBElement<Object>(new QName("http://ns1", "bean"), Object.class, null);
- element.setNil(true);
- context.createMarshaller().marshal(element, writer);
- // System.out.println(writer.toString());
- StreamSource source = new StreamSource(new StringReader(writer.toString()));
- Object result = context.createUnmarshaller().unmarshal(source, String.class);
- assertTrue(result instanceof JAXBElement);
- JAXBElement e2 = (JAXBElement)result;
- assertNull(e2.getValue());
- }
-
- public void testArray() throws Exception {
- JAXBContext context = JAXBContext.newInstance(String[].class);
- StringWriter writer = new StringWriter();
- JAXBElement<Object> element =
- new JAXBElement<Object>(new QName("http://ns1", "bean"), Object.class, new String[] {"ABC", "123"});
- context.createMarshaller().marshal(element, writer);
- // System.out.println(writer.toString());
-
- Object result = context.createUnmarshaller().unmarshal(new StringReader(writer.toString()));
- assertTrue(result instanceof JAXBElement);
- JAXBElement e2 = (JAXBElement)result;
- assertTrue(e2.getValue() instanceof String[]);
- }
-
- public void testByteArray() throws Exception {
- JAXBContext context = JAXBContext.newInstance(byte[].class);
- StringWriter writer = new StringWriter();
- JAXBElement<Object> element =
- new JAXBElement<Object>(new QName("http://ns1", "bean"), Object.class, "ABC".getBytes());
- context.createMarshaller().marshal(element, writer);
- String xml = writer.toString();
- assertTrue(xml.contains("QUJD"));
- assertTrue(xml.contains("base64Binary"));
-
- Object result = context.createUnmarshaller().unmarshal(new StringReader(xml));
- assertTrue(result instanceof JAXBElement);
- JAXBElement e2 = (JAXBElement)result;
- assertTrue(e2.getValue() instanceof byte[]);
- }
-
- public void testPrimitive() throws Exception {
- JAXBContext context = JAXBContext.newInstance(int.class);
- StringWriter writer = new StringWriter();
- JAXBElement<Object> element = new JAXBElement<Object>(new QName("http://ns1", "bean"), Object.class, 1);
- context.createMarshaller().marshal(element, writer);
- // System.out.println(writer.toString());
-
- Object result = context.createUnmarshaller().unmarshal(new StringReader(writer.toString()));
- assertTrue(result instanceof JAXBElement);
- JAXBElement e2 = (JAXBElement)result;
- assertEquals(1, e2.getValue());
- }
-
- /*
- public void testException() throws Exception {
- JAXBContext context = JAXBContext.newInstance(IllegalArgumentException.class);
- StringWriter writer = new StringWriter();
- Exception e = new IllegalArgumentException("123");
- JAXBElement<Object> element = new JAXBElement<Object>(new QName("http://ns1", "bean"), Object.class, e);
- context.createMarshaller().marshal(element, writer);
- System.out.println(writer.toString());
-
- Object result = context.createUnmarshaller().unmarshal(new StringReader(writer.toString()));
- assertTrue(result instanceof JAXBElement);
- JAXBElement e2 = (JAXBElement)result;
- assertTrue(e2.getValue() instanceof Exception);
- }
- */
-
- private static RuntimeTypeInfoSet create(Class... classes) throws Exception {
- IllegalAnnotationsException.Builder errorListener = new IllegalAnnotationsException.Builder();
- RuntimeInlineAnnotationReader reader = new RuntimeInlineAnnotationReader();
- JAXBContextImpl context =
- new JAXBContextImpl(classes, null, Collections.<Class, Class> emptyMap(), null, false, reader, false, false);
- RuntimeModelBuilder builder =
- new RuntimeModelBuilder(context, reader, Collections.<Class, Class> emptyMap(), null);
- builder.setErrorHandler(errorListener);
- for (Class c : classes)
- builder.getTypeInfo(new Ref<Type, Class>(c));
-
- RuntimeTypeInfoSet r = builder.link();
- errorListener.check();
- return r;
- }
-
- public void testReflection() throws Exception {
- MyBean bean = new MyBean();
- RuntimeTypeInfoSet model = create(MyBean.class);
- RuntimeClassInfo clsInfo = (RuntimeClassInfo)model.getTypeInfo(MyBean.class);
- for (RuntimePropertyInfo p : clsInfo.getProperties()) {
- // System.out.print(p.getName());
- // System.out.println(" " + p.isCollection());
- if (p.getName().equals("notes")) {
- Collection c = (Collection)p.getAccessor().get(bean);
- c.add("123");
- }
- }
-
- }
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault.java
deleted file mode 100644
index fd21d72337..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.databinding.jaxb.fault;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-/**
- * <p>
- * Java class for anonymous complex type.
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "", propOrder = {"message", "symbol"})
-@XmlRootElement(name = "InvalidSymbolFault")
-public class InvalidSymbolFault {
-
- @XmlElement(required = true)
- protected String message;
- @XmlElement(required = true)
- protected String symbol;
-
- /**
- * Gets the value of the message property.
- *
- * @return possible object is {@link String }
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Sets the value of the message property.
- *
- * @param value allowed object is {@link String }
- */
- public void setMessage(String value) {
- this.message = value;
- }
-
- /**
- * Gets the value of the symbol property.
- *
- * @return possible object is {@link String }
- */
- public String getSymbol() {
- return symbol;
- }
-
- /**
- * Sets the value of the symbol property.
- *
- * @param value allowed object is {@link String }
- */
- public void setSymbol(String value) {
- this.symbol = value;
- }
-
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault_Exception.java b/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault_Exception.java
deleted file mode 100644
index e78889aee0..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/java/org/apache/tuscany/databinding/jaxb/fault/InvalidSymbolFault_Exception.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.databinding.jaxb.fault;
-
-import javax.xml.ws.WebFault;
-
-/**
- * This class was generated by the JAXWS SI. JAX-WS RI 2.1-02/02/2007 09:55
- * AM(vivekp)-FCS Generated source version: 2.1
- */
-@WebFault(name = "InvalidSymbolFault", targetNamespace = "http://www.example.com/stock")
-public class InvalidSymbolFault_Exception extends Exception {
- private static final long serialVersionUID = -4618497501663457633L;
-
- /**
- * Java type that goes as soapenv:Fault detail element.
- */
- private InvalidSymbolFault faultInfo;
-
- /**
- * @param faultInfo
- * @param message
- */
- public InvalidSymbolFault_Exception(String message, InvalidSymbolFault faultInfo) {
- super(message);
- this.faultInfo = faultInfo;
- }
-
- /**
- * @param faultInfo
- * @param message
- * @param cause
- */
- public InvalidSymbolFault_Exception(String message, InvalidSymbolFault faultInfo, Throwable cause) {
- super(message, cause);
- this.faultInfo = faultInfo;
- }
-
- /**
- * @return returns fault bean:
- * org.apache.tuscany.sca.test.exceptions.impl.jaxb.InvalidSymbolFault
- */
- public InvalidSymbolFault getFaultInfo() {
- return faultInfo;
- }
-
-}
diff --git a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/resources/ipo.xsd b/branches/sca-java-1.1/modules/databinding-jaxb/src/test/resources/ipo.xsd
deleted file mode 100755
index 49060636d1..0000000000
--- a/branches/sca-java-1.1/modules/databinding-jaxb/src/test/resources/ipo.xsd
+++ /dev/null
@@ -1,163 +0,0 @@
-<!--
- * W3C(c) SOFTWARE NOTICE AND LICENSE
- * http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
- *
- * This work (and included software, documentation such as READMEs, or other
- * related items) is being provided by the copyright holders under the following
- * license. By obtaining, using and/or copying this work, you (the licensee) agree
- * that you have read, understood, and will comply with the following terms and conditions.
- *
- * Permission to copy, modify, and distribute this software and its documentation,
- * with or without modification, for any purpose and without fee or royalty is
- * hereby granted, provided that you include the following on ALL copies of the
- * software and documentation or portions thereof, including modifications:
- *
- * 1. The full text of this NOTICE in a location viewable to users of the
- * redistributed or derivative work.
- * 2. Any pre-existing intellectual property disclaimers, notices, or terms
- * and conditions. If none exist, the W3C Software Short Notice should be
- * included (hypertext is preferred, text is permitted) within the body of
- * any redistributed or derivative code.
- * 3. Notice of any changes or modifications to the files, including the date
- * changes were made. (We recommend you provide URIs to the location from which
- * the code is derived.)
- *
- * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE
- * NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,
- * WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE
- * USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS,
- * COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
- *
- * COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
- * CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
- *
- * The name and trademarks of copyright holders may NOT be used in advertising or
- * publicity pertaining to the software without specific, written prior permission.
- * Title to copyright in this software and any associated documentation will at all
- * times remain with copyright holders.
--->
-
-<!--
- * Modifications for Apache Tuscany:
- * - This file combines the ipo.xsd and address.xsd information
- * from the XML Schema Primer (http://www.w3.org/TR/2004/PER-xmlschema-0-20040318/)
- * and extends the structures with UK postcode structures.
--->
-<schema targetNamespace="http://www.example.com/IPO"
- xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:ipo="http://www.example.com/IPO">
-
- <annotation>
- <documentation xml:lang="en">
- International Purchase order schema for Example.com
- Copyright 2000 Example.com. All rights reserved.
- </documentation>
- </annotation>
-
-
- <element name="purchaseOrder" type="ipo:PurchaseOrderType" />
-
- <element name="comment" type="string" />
-
- <complexType name="PurchaseOrderType">
- <sequence>
- <element name="shipTo" type="ipo:Address" />
- <element name="billTo" type="ipo:Address" />
- <element ref="ipo:comment" minOccurs="0" />
- <element name="items" type="ipo:Items" />
- </sequence>
- <attribute name="orderDate" type="date" />
- </complexType>
-
- <complexType name="Items">
- <sequence>
- <element name="item" minOccurs="0" maxOccurs="unbounded">
- <complexType>
- <sequence>
- <element name="productName" type="string" />
- <element name="quantity">
- <simpleType>
- <restriction base="positiveInteger">
- <maxExclusive value="100" />
- </restriction>
- </simpleType>
- </element>
- <element name="USPrice" type="decimal" />
- <element ref="ipo:comment" minOccurs="0" />
- <element name="shipDate" type="date"
- minOccurs="0" />
- </sequence>
- <attribute name="partNum" type="ipo:SKU"
- use="required" />
- </complexType>
- </element>
- </sequence>
- </complexType>
-
- <simpleType name="SKU">
- <restriction base="string">
- <pattern value="\d{3}-[A-Z]{2}" />
- </restriction>
- </simpleType>
-
- <complexType name="Address">
- <sequence>
- <element name="name" type="string" />
- <element name="street" type="string" />
- <element name="city" type="string" />
- </sequence>
- </complexType>
-
- <complexType name="USAddress">
- <complexContent>
- <extension base="ipo:Address">
- <sequence>
- <element name="state" type="ipo:USState" />
- <element name="zip" type="positiveInteger" />
- </sequence>
- </extension>
- </complexContent>
- </complexType>
-
- <complexType name="UKAddress">
- <complexContent>
- <extension base="ipo:Address">
- <sequence>
- <element name="postcode" type="ipo:UKPostcode" />
- </sequence>
- <attribute name="exportCode" type="positiveInteger"
- fixed="1" />
- </extension>
- </complexContent>
- </complexType>
-
- <!-- other Address derivations for more countries -->
-
- <simpleType name="USState">
- <restriction base="string">
- <enumeration value="AK" />
- <enumeration value="AL" />
- <enumeration value="AR" />
- <enumeration value="CA" />
- <enumeration value="PA" />
- <!-- and so on ... -->
- </restriction>
- </simpleType>
-
- <simpleType name="Postcode">
- <restriction base="string">
- <length value="7" fixed="true" />
- </restriction>
- </simpleType>
-
-
- <simpleType name="UKPostcode">
- <restriction base="ipo:Postcode">
- <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
- </restriction>
- </simpleType>
-
-
-
-</schema>
-