You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2011/02/21 20:08:57 UTC
svn commit: r1073117 [1/2] - in /cxf/trunk: parent/ rt/ rt/databinding/jibx/
rt/databinding/jibx/src/ rt/databinding/jibx/src/main/
rt/databinding/jibx/src/main/java/ rt/databinding/jibx/src/main/java/org/
rt/databinding/jibx/src/main/java/org/apache/ ...
Author: dkulp
Date: Mon Feb 21 19:08:55 2011
New Revision: 1073117
URL: http://svn.apache.org/viewvc?rev=1073117&view=rev
Log:
Squashed commit of the following:
commit 9cb8f3e8fc4a21d8d57c0c73038886b2c237b92c
Merge: efaea0e efe9bf6
Author: Daniel Kulp <dk...@apache.org>
Date: Fri Sep 17 15:36:04 2010 -0400
Merge branch 'trunk' of git://git.apache.org/cxf into jibx
commit efaea0e37f7b075fff311238591df602c03a373a
Author: Daniel Kulp <dk...@apache.org>
Date: Wed Aug 18 15:00:45 2010 -0400
grab jibx jars
commit adfb07451db13b26304f70068347f29a6968c2e6
Merge: bd7729a 3172a8a
Author: Daniel Kulp <dk...@apache.org>
Date: Wed Aug 18 14:02:49 2010 -0400
Merge branch 'trunk' of git://git.apache.org/cxf into jibx
commit bd7729ada7b2b949ed4f1faad8b8baced246601b
Author: Daniel Kulp <dk...@apache.org>
Date: Wed Aug 18 12:20:43 2010 -0400
Squashed commit of the following:
commit efd6029a449cb7f1d5fe2cb2afb04aa389d17c62
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Wed Aug 18 18:04:13 2010 +0530
Added the tests
commit e5bf4b67d0a49619a9e5abd42f3acc15cf74a5e5
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Wed Aug 18 16:19:24 2010 +0530
Fixed
commit 717778b23a9f7d14004e62f0fb2c1327475bdb81
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Wed Aug 18 16:02:06 2010 +0530
Renaming
commit 357add787c75a7ed640b2cdfea03624f587b018d
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Mon Aug 16 00:17:18 2010 +0530
Fixed few SchemaResolver issues
commit 2dc03f87f57537d6e211426af6428e6f9458a02e
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Thu Aug 12 19:24:00 2010 +0530
Added tools-plugin.xml
commit 66d36d8070e22805a1ed2511db48225da1f9fc5e
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Thu Aug 12 17:30:26 2010 +0530
deleted
commit 1c46f05d4a9c7f007fed0d035326b87f78c32cac
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Thu Aug 12 17:29:46 2010 +0530
deleted
commit f7052c619c91cb438ec3b5918143e30264219c63
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Thu Aug 12 17:27:47 2010 +0530
deleted the tests
commit aa93873781775d21959794943628fb38633226e7
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Thu Aug 12 14:34:15 2010 +0530
Added
commit 09d166bf5aaeafa7db84975fc1710b4591885dc0
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Wed Aug 11 19:31:09 2010 +0530
Deleted
commit 78b7f080f679a0957fbf05bb611e8eb20f14ca44
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Wed Aug 11 18:52:17 2010 +0530
Removed
commit ce22d150032eb307106d78e9d3fa83989bea4ab4
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Wed Aug 11 18:02:43 2010 +0530
Cleaning up
commit dbeb8839506fd9f655b3cf399800359176a499c6
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Wed Aug 11 15:35:30 2010 +0530
Added javadoc comments
commit 26a5affd57ae073940e9be718bc8d09424d0246e
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Wed Aug 11 02:42:25 2010 +0530
updating
commit 4fd2ea84dcefb002af15e3504232babf0f5c458b
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Fri Jun 18 01:04:40 2010 +0200
Modified.
commit a72115fd136a34113f882e1d75ff14ceed9ba15c
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Fri Jun 18 01:01:59 2010 +0200
Modified.
commit c9e9965563766c92c1e1f9686e1a25bff3b14e3e
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Sat May 22 02:40:38 2010 +0200
Fixed a style error.
commit b73909e6cd759b8537b1ce61d2c2146c16856d23
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Sat May 22 02:36:29 2010 +0200
Modified the poms.
commit b2f8ccd15e2101bb4f7b5ba1bb5f0109077de2fe
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Sat May 22 02:31:20 2010 +0200
Fixed check style errors.
commit 60ae176c3a6ceaf974a257f266068956e22e2874
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Sat May 22 02:27:56 2010 +0200
Fixed style check errors.
commit fd993f97da87c98deb7904eb946601527d8986a9
Author: Nilupa Bandara <nilupa@sanka-laptop.(none)>
Date: Mon May 17 00:31:33 2010 +0200
Adding the initial code
Added:
cxf/trunk/rt/databinding/jibx/
cxf/trunk/rt/databinding/jibx/pom.xml (with props)
cxf/trunk/rt/databinding/jibx/src/
cxf/trunk/rt/databinding/jibx/src/main/
cxf/trunk/rt/databinding/jibx/src/main/java/
cxf/trunk/rt/databinding/jibx/src/main/java/org/
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataBinding.java (with props)
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataReader.java (with props)
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataWriter.java (with props)
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxNullBindingFactory.java (with props)
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSchemaInitializer.java (with props)
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSimpleTypes.java (with props)
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxUtil.java (with props)
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxWrapperHelper.java (with props)
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaHelper.java (with props)
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaResolver.java (with props)
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxToolingDataBinding.java (with props)
cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxToolingProblemHandler.java (with props)
cxf/trunk/rt/databinding/jibx/src/main/resources/
cxf/trunk/rt/databinding/jibx/src/main/resources/META-INF/
cxf/trunk/rt/databinding/jibx/src/main/resources/META-INF/tools-plugin.xml (with props)
cxf/trunk/rt/databinding/jibx/src/test/
cxf/trunk/rt/databinding/jibx/src/test/java/
cxf/trunk/rt/databinding/jibx/src/test/java/org/
cxf/trunk/rt/databinding/jibx/src/test/java/org/apache/
cxf/trunk/rt/databinding/jibx/src/test/java/org/apache/cxf/
cxf/trunk/rt/databinding/jibx/src/test/java/org/apache/cxf/jibx/
cxf/trunk/rt/databinding/jibx/src/test/java/org/apache/cxf/jibx/AbstractJibxTest.java (with props)
cxf/trunk/rt/databinding/jibx/src/test/java/org/apache/cxf/jibx/PrimitiveTypesService.java (with props)
cxf/trunk/rt/databinding/jibx/src/test/java/org/apache/cxf/jibx/PrimitiveTypesTest.java (with props)
cxf/trunk/rt/databinding/jibx/src/test/java/resources/
cxf/trunk/rt/databinding/jibx/src/test/java/resources/binding.xml (with props)
cxf/trunk/rt/databinding/jibx/src/test/java/resources/com/
cxf/trunk/rt/databinding/jibx/src/test/java/resources/com/sosnoski/
cxf/trunk/rt/databinding/jibx/src/test/java/resources/com/sosnoski/ws/
cxf/trunk/rt/databinding/jibx/src/test/java/resources/com/sosnoski/ws/library/
cxf/trunk/rt/databinding/jibx/src/test/java/resources/com/sosnoski/ws/library/types/
cxf/trunk/rt/databinding/jibx/src/test/java/resources/com/sosnoski/ws/library/types/BookInformation.class
cxf/trunk/rt/databinding/jibx/src/test/java/resources/com/sosnoski/ws/library/types/JiBX_bindingBookInformation_access.class
cxf/trunk/rt/databinding/jibx/src/test/java/resources/com/sosnoski/ws/library/types/JiBX_bindingBookInformation_access2.class
cxf/trunk/rt/databinding/jibx/src/test/java/resources/com/sosnoski/ws/library/types/JiBX_bindingFactory.class
cxf/trunk/rt/databinding/jibx/src/test/java/resources/com/sosnoski/ws/library/types/JiBX_bindingMungeAdapter.class
cxf/trunk/rt/databinding/jibx/src/test/java/resources/com/sosnoski/ws/library/types/TypeInformation.class
cxf/trunk/rt/databinding/jibx/src/test/java/resources/types.xsd (with props)
cxf/trunk/rt/databinding/jibx/src/test/resources/
cxf/trunk/rt/databinding/jibx/src/test/resources/binding.xml (with props)
cxf/trunk/rt/databinding/jibx/src/test/resources/com/
cxf/trunk/rt/databinding/jibx/src/test/resources/com/sosnoski/
cxf/trunk/rt/databinding/jibx/src/test/resources/com/sosnoski/ws/
cxf/trunk/rt/databinding/jibx/src/test/resources/com/sosnoski/ws/library/
cxf/trunk/rt/databinding/jibx/src/test/resources/com/sosnoski/ws/library/types/
cxf/trunk/rt/databinding/jibx/src/test/resources/com/sosnoski/ws/library/types/BookInformation.class
cxf/trunk/rt/databinding/jibx/src/test/resources/com/sosnoski/ws/library/types/JiBX_bindingBookInformation_access.class
cxf/trunk/rt/databinding/jibx/src/test/resources/com/sosnoski/ws/library/types/JiBX_bindingBookInformation_access2.class
cxf/trunk/rt/databinding/jibx/src/test/resources/com/sosnoski/ws/library/types/JiBX_bindingFactory.class
cxf/trunk/rt/databinding/jibx/src/test/resources/com/sosnoski/ws/library/types/JiBX_bindingMungeAdapter.class
cxf/trunk/rt/databinding/jibx/src/test/resources/com/sosnoski/ws/library/types/TypeInformation.class
cxf/trunk/rt/databinding/jibx/src/test/resources/types.xsd (with props)
Modified:
cxf/trunk/parent/pom.xml
cxf/trunk/rt/pom.xml
cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Modified: cxf/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/parent/pom.xml?rev=1073117&r1=1073116&r2=1073117&view=diff
==============================================================================
--- cxf/trunk/parent/pom.xml (original)
+++ cxf/trunk/parent/pom.xml Mon Feb 21 19:08:55 2011
@@ -5,7 +5,6 @@
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
@@ -1075,6 +1074,26 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.jibx</groupId>
+ <artifactId>jibx-bind</artifactId>
+ <version>1.2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jibx</groupId>
+ <artifactId>jibx-run</artifactId>
+ <version>1.2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jibx</groupId>
+ <artifactId>jibx-schema</artifactId>
+ <version>1.2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jibx</groupId>
+ <artifactId>jibx-tools</artifactId>
+ <version>1.2.3</version>
+ </dependency>
<dependency>
<groupId>xml-resolver</groupId>
<artifactId>xml-resolver</artifactId>
Added: cxf/trunk/rt/databinding/jibx/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jibx/pom.xml?rev=1073117&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/jibx/pom.xml (added)
+++ cxf/trunk/rt/databinding/jibx/pom.xml Mon Feb 21 19:08:55 2011
@@ -0,0 +1,132 @@
+<!--
+ 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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cxf-rt-databinding-jibx</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache CXF Runtime JiBX DataBinding</name>
+ <url>http://cxf.apache.org</url>
+
+ <parent>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-parent</artifactId>
+ <version>2.4.0-SNAPSHOT</version>
+ <relativePath>../../../parent/pom.xml</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-tools-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-tools-wsdlto-core</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-testutils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-local</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxws</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-testsupport</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jibx</groupId>
+ <artifactId>jibx-bind</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jibx</groupId>
+ <artifactId>jibx-run</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jibx</groupId>
+ <artifactId>jibx-schema</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jibx</groupId>
+ <artifactId>jibx-tools</artifactId>
+ </dependency>
+ </dependencies>
+ <profiles>
+ <profile>
+ <id>jdk15</id>
+ <activation>
+ <jdk>1.5</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${stax.impl.groupId}</groupId>
+ <artifactId>${stax.impl.artifactId}</artifactId>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+</project>
Propchange: cxf/trunk/rt/databinding/jibx/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/databinding/jibx/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/trunk/rt/databinding/jibx/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataBinding.java?rev=1073117&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataBinding.java (added)
+++ cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataBinding.java Mon Feb 21 19:08:55 2011
@@ -0,0 +1,162 @@
+/**
+ * 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.cxf.jibx;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.dom.DOMSource;
+
+import org.w3c.dom.Document;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.xmlschema.SchemaCollection;
+import org.apache.cxf.databinding.AbstractDataBinding;
+import org.apache.cxf.databinding.AbstractWrapperHelper;
+import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.databinding.DataWriter;
+import org.apache.cxf.databinding.WrapperCapableDatabinding;
+import org.apache.cxf.databinding.WrapperHelper;
+import org.apache.cxf.jaxb.JAXBUtils;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.ServiceInfo;
+
+public class JibxDataBinding extends AbstractDataBinding implements WrapperCapableDatabinding {
+
+ private static final Logger LOG = LogUtils.getLogger(JibxDataBinding.class);
+
+ private static final Class<?> SUPPORTED_DATA_READER_FORMATS[] = new Class<?>[] {
+ XMLStreamReader.class
+ };
+ private static final Class<?> SUPPORTED_DATA_WRITER_FORMATS[] = new Class<?>[] {
+ XMLStreamWriter.class
+ };
+
+ @SuppressWarnings("unchecked")
+ public <T> DataReader<T> createReader(Class<T> cls) {
+ if (XMLStreamReader.class.equals(cls)) {
+ return (DataReader<T>)(new JibxDataReader());
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> DataWriter<T> createWriter(Class<T> cls) {
+ if (XMLStreamWriter.class.equals(cls)) {
+ return (DataWriter<T>)(new JibxDataWriter());
+ }
+ return null;
+ }
+
+ public Class<?>[] getSupportedReaderFormats() {
+ return SUPPORTED_DATA_READER_FORMATS;
+ }
+
+ public Class<?>[] getSupportedWriterFormats() {
+ return SUPPORTED_DATA_WRITER_FORMATS;
+ }
+
+ public void initialize(Service service) {
+ if (LOG.isLoggable(Level.FINER)) {
+ LOG.log(Level.FINER, "Initialize JiBX Databinding for [" + service.getName() + "] service");
+ }
+
+ for (ServiceInfo serviceInfo : service.getServiceInfos()) {
+ SchemaCollection schemaCollection = serviceInfo.getXmlSchemaCollection();
+ if (schemaCollection.getXmlSchemas().length > 1) {
+ // Schemas are already populated.
+ continue;
+ }
+
+ Collection<DOMSource> schemas = getSchemas();
+ if (schemas != null) {
+ for (DOMSource source : schemas) {
+ addSchemaDocument(serviceInfo, schemaCollection, (Document)source.getNode(), source
+ .getSystemId());
+ }
+ }
+
+ JibxSchemaInitializer schemaInit = new JibxSchemaInitializer(serviceInfo, schemaCollection,
+ this);
+ schemaInit.walk();
+ }
+ }
+
+ public WrapperHelper createWrapperHelper(Class<?> wrapperType, QName typeName, List<String> partNames,
+ List<String> elTypeNames, List<Class<?>> partClasses) {
+ /*
+ * Copied from org.apache.cxf.xmlbeans.XmlBeansDataBinding#createWrapperHelper method
+ */
+ List<Method> getMethods = new ArrayList<Method>(partNames.size());
+ List<Method> setMethods = new ArrayList<Method>(partNames.size());
+ List<Field> fields = new ArrayList<Field>(partNames.size());
+
+ Method allMethods[] = wrapperType.getMethods();
+
+ for (int x = 0; x < partNames.size(); x++) {
+ String partName = partNames.get(x);
+ if (partName == null) {
+ getMethods.add(null);
+ setMethods.add(null);
+ fields.add(null);
+ continue;
+ }
+
+ String getAccessor = JAXBUtils.nameToIdentifier(partName, JAXBUtils.IdentifierType.GETTER);
+ String setAccessor = JAXBUtils.nameToIdentifier(partName, JAXBUtils.IdentifierType.SETTER);
+ Method getMethod = null;
+ Method setMethod = null;
+
+ allMethods = wrapperType.getMethods();
+
+ try {
+ getMethod = wrapperType.getMethod(getAccessor, AbstractWrapperHelper.NO_CLASSES);
+ } catch (NoSuchMethodException ex) {
+ // ignore for now
+ }
+
+ for (Method method : allMethods) {
+ if (method.getParameterTypes() != null && method.getParameterTypes().length == 1
+ && (setAccessor.equals(method.getName()))) {
+ setMethod = method;
+ break;
+ }
+ }
+
+ getMethods.add(getMethod);
+ setMethods.add(setMethod);
+ // No public fields in wrapper class
+ fields.add(null);
+
+ }
+
+ return new JibxWrapperHelper(wrapperType, setMethods.toArray(new Method[setMethods.size()]),
+ getMethods.toArray(new Method[getMethods.size()]), fields
+ .toArray(new Field[fields.size()]));
+ }
+}
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataBinding.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataBinding.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataReader.java?rev=1073117&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataReader.java (added)
+++ cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataReader.java Mon Feb 21 19:08:55 2011
@@ -0,0 +1,91 @@
+/**
+ * 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.cxf.jibx;
+
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.validation.Schema;
+
+import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.message.Attachment;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.jibx.runtime.BindingDirectory;
+import org.jibx.runtime.IBindingFactory;
+import org.jibx.runtime.JiBXException;
+import org.jibx.runtime.impl.StAXReaderWrapper;
+import org.jibx.runtime.impl.UnmarshallingContext;
+
+public class JibxDataReader implements DataReader<XMLStreamReader> {
+
+ public Object read(XMLStreamReader input) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object read(MessagePartInfo part, XMLStreamReader input) {
+ Class<?> type = part.getTypeClass();
+ try {
+ UnmarshallingContext ctx = getUnmarshallingContext(input, type);
+ if (JibxSimpleTypes.isSimpleType(type)) {
+ QName stype = part.getTypeQName();
+ QName ctype = part.getConcreteName();
+ if (ctx.isAt(ctype.getNamespaceURI(), ctype.getLocalPart())) {
+ String text = ctx.parseElementText(ctype.getNamespaceURI(), ctype.getLocalPart());
+ return JibxSimpleTypes.toObject(text, stype);
+ } else {
+ throw new RuntimeException("Missing required element [" + ctype + "]");
+ }
+ } else {
+ return ctx.unmarshalElement(part.getTypeClass());
+ }
+ } catch (JiBXException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object read(QName elementQName, XMLStreamReader input, Class type) {
+ throw new UnsupportedOperationException("Not Implemented");
+ }
+
+ public void setAttachments(Collection<Attachment> attachments) {
+ }
+
+ public void setProperty(String prop, Object value) {
+ }
+
+ public void setSchema(Schema s) {
+ }
+
+ private static UnmarshallingContext getUnmarshallingContext(XMLStreamReader reader, Class jtype)
+ throws JiBXException {
+ IBindingFactory factory;
+ if (JibxSimpleTypes.isSimpleType(jtype)) {
+ factory = JibxNullBindingFactory.getFactory();
+ } else {
+ factory = BindingDirectory.getFactory(jtype);
+ }
+ UnmarshallingContext ctx = (UnmarshallingContext)factory.createUnmarshallingContext();
+ StAXReaderWrapper wrapper = new StAXReaderWrapper(reader, "Data-element", true);
+ ctx.setDocument(wrapper);
+ ctx.toTag();
+ return ctx;
+ }
+}
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataReader.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataWriter.java?rev=1073117&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataWriter.java (added)
+++ cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataWriter.java Mon Feb 21 19:08:55 2011
@@ -0,0 +1,90 @@
+/**
+ * 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.cxf.jibx;
+
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.validation.Schema;
+
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.databinding.DataWriter;
+import org.apache.cxf.message.Attachment;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.jibx.runtime.BindingDirectory;
+import org.jibx.runtime.IBindingFactory;
+import org.jibx.runtime.IMarshallable;
+import org.jibx.runtime.IMarshallingContext;
+import org.jibx.runtime.JiBXException;
+import org.jibx.runtime.impl.StAXWriter;
+
+public class JibxDataWriter implements DataWriter<XMLStreamWriter> {
+
+ public void write(Object obj, XMLStreamWriter output) {
+ }
+
+ public void write(Object obj, MessagePartInfo part, XMLStreamWriter output) {
+ Class jtype = part.getTypeClass();
+ QName stype = part.getTypeQName();
+ if (JibxSimpleTypes.isSimpleType(jtype)) {
+ try {
+ String pfx = output.getPrefix(part.getConcreteName().getNamespaceURI());
+ if (StringUtils.isEmpty(pfx)) {
+ output.writeStartElement("tns", part.getConcreteName().getLocalPart(), part
+ .getConcreteName().getNamespaceURI());
+ output.writeNamespace("tns", part.getConcreteName().getNamespaceURI());
+ } else {
+ output.writeStartElement(pfx, part.getConcreteName().getLocalPart(), part
+ .getConcreteName().getNamespaceURI());
+ }
+ output.writeCharacters(JibxSimpleTypes.toText(stype, obj));
+ output.writeEndElement();
+ } catch (XMLStreamException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ try {
+ IBindingFactory factory = BindingDirectory.getFactory(obj.getClass());
+ IMarshallingContext ctx = getMarshallingContext(obj);
+ StAXWriter writer = new StAXWriter(factory.getNamespaces(), output);
+ ctx.setXmlWriter(writer);
+ ((IMarshallable)obj).marshal(ctx);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ public void setAttachments(Collection<Attachment> attachments) {
+ }
+
+ public void setProperty(String key, Object value) {
+ }
+
+ public void setSchema(Schema s) {
+ }
+
+ private IMarshallingContext getMarshallingContext(Object object) throws JiBXException {
+ IBindingFactory factory = BindingDirectory.getFactory(object.getClass());
+ return factory.createMarshallingContext();
+ }
+}
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataWriter.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxNullBindingFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxNullBindingFactory.java?rev=1073117&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxNullBindingFactory.java (added)
+++ cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxNullBindingFactory.java Mon Feb 21 19:08:55 2011
@@ -0,0 +1,59 @@
+/**
+ * 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.cxf.jibx;
+
+import org.jibx.runtime.IBindingFactory;
+import org.jibx.runtime.impl.BindingFactoryBase;
+
+/**
+ * Dummy binding factory for conversion of simple value conversion which do not require a real JiBX binding.
+ * This code was take from Axis2 JiBX code generation tool.
+ */
+public final class JibxNullBindingFactory extends BindingFactoryBase implements IBindingFactory {
+
+ private static final String[] EMPTY_ARRAY = new String[0];
+ private static JibxNullBindingFactory instance;
+
+ private JibxNullBindingFactory() {
+ super("null", 0, 0, "", "", "", "", EMPTY_ARRAY, EMPTY_ARRAY, "", "", EMPTY_ARRAY, "", "", "", "",
+ "", EMPTY_ARRAY);
+ }
+
+ public String getCompilerDistribution() {
+ // normally only used by BindingDirectory code, so okay to punt
+ return "";
+ }
+
+ public int getCompilerVersion() {
+ // normally only used by BindingDirectory code, so okay to punt
+ return 0;
+ }
+
+ public int getTypeIndex(String type) {
+ return -1;
+ }
+
+ public static synchronized JibxNullBindingFactory getFactory() {
+ if (instance == null) {
+ instance = new JibxNullBindingFactory();
+ }
+ return instance;
+ }
+}
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxNullBindingFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxNullBindingFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSchemaInitializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSchemaInitializer.java?rev=1073117&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSchemaInitializer.java (added)
+++ cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSchemaInitializer.java Mon Feb 21 19:08:55 2011
@@ -0,0 +1,116 @@
+/**
+ * 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.cxf.jibx;
+
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.xmlschema.SchemaCollection;
+import org.apache.cxf.service.ServiceModelVisitor;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.jibx.runtime.BindingDirectory;
+import org.jibx.runtime.IBindingFactory;
+import org.jibx.runtime.JiBXException;
+
+public class JibxSchemaInitializer extends ServiceModelVisitor {
+ private static final Logger LOG = LogUtils.getLogger(JibxSchemaInitializer.class);
+ private SchemaCollection schemas;
+
+ public JibxSchemaInitializer(ServiceInfo serviceInfo, SchemaCollection schemas,
+ JibxDataBinding databinding) {
+ super(serviceInfo);
+ this.schemas = schemas;
+ }
+
+ @Override
+ public void begin(MessagePartInfo part) {
+ LOG.finest(part.getName().toString());
+ // Check to see if the WSDL information has been filled in for us.
+ if (part.getTypeQName() != null || part.getElementQName() != null) {
+ checkForExistence(part);
+ return;
+ }
+
+ Class<?> clazz = part.getTypeClass();
+ if (clazz == null) {
+ return;
+ }
+
+ boolean isFromWrapper = part.getMessageInfo().getOperation().isUnwrapped();
+ if (isFromWrapper && clazz.isArray() && !Byte.TYPE.equals(clazz.getComponentType())) {
+ clazz = clazz.getComponentType();
+ }
+ mapClass(part, clazz);
+ }
+
+ public void checkForExistence(MessagePartInfo part) {
+ QName qn = part.getElementQName();
+ if (qn != null) {
+ XmlSchemaElement el = schemas.getElementByQName(qn);
+ if (el == null) {
+ Class<?> clazz = part.getTypeClass();
+ if (clazz == null) {
+ return;
+ }
+
+ boolean isFromWrapper = part.getMessageInfo().getOperation().isUnwrapped();
+ if (isFromWrapper && clazz.isArray() && !Byte.TYPE.equals(clazz.getComponentType())) {
+ clazz = clazz.getComponentType();
+ }
+ mapClass(part, clazz);
+ }
+ }
+ }
+
+ private void mapClass(MessagePartInfo part, Class<?> clazz) {
+ if (JibxSimpleTypes.isSimpleType(clazz)) {
+ QName schemaType = JibxSimpleTypes.schemaType(clazz);
+ part.setTypeQName(schemaType);
+ part.setXmlSchema(schemas.getTypeByQName(schemaType));
+ } else {
+ try {
+ IBindingFactory factory = BindingDirectory.getFactory(clazz);
+ String[][] abstractMappings = factory.getAbstractMappings();
+ String stype = abstractMappings[0][0];
+ QName qName = JibxSimpleTypes.toQname(stype);
+
+ XmlSchema schema = schemas.getSchemaForElement(qName);
+ if (schema != null) {
+ // needs to handle element is a Global element case
+ XmlSchemaElement element = schema.getElementByName(qName);
+ part.setXmlSchema(element);
+ part.setElementQName(qName);
+ part.setConcreteName(qName);
+ part.setElement(true);
+ } else {
+ // TODO : throw an exception ?
+ }
+
+ } catch (JiBXException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+}
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSchemaInitializer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSchemaInitializer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSimpleTypes.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSimpleTypes.java?rev=1073117&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSimpleTypes.java (added)
+++ cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSimpleTypes.java Mon Feb 21 19:08:55 2011
@@ -0,0 +1,240 @@
+/**
+ * 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.cxf.jibx;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.jibx.runtime.Utility;
+
+public final class JibxSimpleTypes {
+
+ public static final String SCHEMA_NAMESPACE = "http://www.w3.org/2001/XMLSchema";
+
+ public static final QName STRING_QNAME = new QName(SCHEMA_NAMESPACE, "string");
+
+ private static Map<String, QName> simpleObjectTypeMap = new HashMap<String, QName>();
+
+ private static Map<String, QName> simplePrimitiveTypeMap = new HashMap<String, QName>();
+
+ private static Map<String, Class<?>> simpleWrapperMap = new HashMap<String, Class<?>>();
+
+ private static Map<QName, Format> simpleTypeMap = new HashMap<QName, Format>();
+
+ private static final Class<Utility> UTILITY = org.jibx.runtime.Utility.class;
+
+ private static final Class<String> INPUT_TYPE = java.lang.String.class;
+
+ static {
+ simpleObjectTypeMap.put("java.lang.Boolean", new QName(SCHEMA_NAMESPACE, "boolean"));
+ simpleObjectTypeMap.put("java.lang.Byte", new QName(SCHEMA_NAMESPACE, "byte"));
+ simpleObjectTypeMap.put("java.lang.Character", new QName(SCHEMA_NAMESPACE, "unsignedInt"));
+ simpleObjectTypeMap.put("java.lang.Double", new QName(SCHEMA_NAMESPACE, "double"));
+ simpleObjectTypeMap.put("java.lang.Float", new QName(SCHEMA_NAMESPACE, "float"));
+ simpleObjectTypeMap.put("java.lang.Integer", new QName(SCHEMA_NAMESPACE, "int"));
+ simpleObjectTypeMap.put("java.lang.Long", new QName(SCHEMA_NAMESPACE, "long"));
+ simpleObjectTypeMap.put("java.lang.Short", new QName(SCHEMA_NAMESPACE, "short"));
+ simpleObjectTypeMap.put("java.lang.String", STRING_QNAME);
+ simpleObjectTypeMap.put("java.math.BigDecimal", new QName(SCHEMA_NAMESPACE, "decimal"));
+ simpleObjectTypeMap.put("java.math.BigInteger", new QName(SCHEMA_NAMESPACE, "integer"));
+ simpleObjectTypeMap.put("java.util.Date", new QName(SCHEMA_NAMESPACE, "dateTime"));
+ // #!j2me{
+ simpleObjectTypeMap.put("java.sql.Date", new QName(SCHEMA_NAMESPACE, "date"));
+ simpleObjectTypeMap.put("java.sql.Time", new QName(SCHEMA_NAMESPACE, "time"));
+ simpleObjectTypeMap.put("java.sql.Timestamp", new QName(SCHEMA_NAMESPACE, "dateTime"));
+ simpleObjectTypeMap.put("org.joda.time.LocalDate", new QName(SCHEMA_NAMESPACE, "date"));
+ simpleObjectTypeMap.put("org.joda.time.DateMidnight", new QName(SCHEMA_NAMESPACE, "date"));
+ simpleObjectTypeMap.put("org.joda.time.LocalTime", new QName(SCHEMA_NAMESPACE, "time"));
+ simpleObjectTypeMap.put("org.joda.time.DateTime", new QName(SCHEMA_NAMESPACE, "dateTime"));
+ // #j2me}
+ simpleObjectTypeMap.put("byte[]", new QName(SCHEMA_NAMESPACE, "base64"));
+ simpleObjectTypeMap.put("org.jibx.runtime.QName", new QName(SCHEMA_NAMESPACE, "QName"));
+
+ simplePrimitiveTypeMap.put("boolean", new QName(SCHEMA_NAMESPACE, "boolean"));
+ simplePrimitiveTypeMap.put("byte", new QName(SCHEMA_NAMESPACE, "byte"));
+ simplePrimitiveTypeMap.put("char", new QName(SCHEMA_NAMESPACE, "unsignedInt"));
+ simplePrimitiveTypeMap.put("double", new QName(SCHEMA_NAMESPACE, "double"));
+ simplePrimitiveTypeMap.put("float", new QName(SCHEMA_NAMESPACE, "float"));
+ simplePrimitiveTypeMap.put("int", new QName(SCHEMA_NAMESPACE, "int"));
+ simplePrimitiveTypeMap.put("long", new QName(SCHEMA_NAMESPACE, "long"));
+ simplePrimitiveTypeMap.put("short", new QName(SCHEMA_NAMESPACE, "short"));
+
+ simpleWrapperMap.put("boolean", Boolean.TYPE);
+ simpleWrapperMap.put("byte", Byte.TYPE);
+ simpleWrapperMap.put("char", Character.TYPE);
+ simpleWrapperMap.put("double", Double.TYPE);
+ simpleWrapperMap.put("float", Float.TYPE);
+ simpleWrapperMap.put("int", Integer.TYPE);
+ simpleWrapperMap.put("long", Long.TYPE);
+ simpleWrapperMap.put("short", Short.TYPE);
+
+ buildFormat("byte", "byte", "serializeByte", "parseByte", "0", simpleTypeMap);
+ buildFormat("unsignedShort", "char", "serializeChar", "parseChar", "0", simpleTypeMap);
+ buildFormat("double", "double", "serializeDouble", "parseDouble", "0.0", simpleTypeMap);
+ buildFormat("float", "float", "serializeFloat", "parseFloat", "0.0", simpleTypeMap);
+ buildFormat("int", "int", "serializeInt", "parseInt", "0", simpleTypeMap);
+ buildFormat("long", "long", "serializeLong", "parseLong", "0", simpleTypeMap);
+ buildFormat("short", "short", "serializeShort", "parseShort", "0", simpleTypeMap);
+ buildFormat("boolean", "boolean", "serializeBoolean", "parseBoolean", "false", simpleTypeMap);
+ buildFormat("dateTime", "java.util.Date", "serializeDateTime", "deserializeDateTime", null,
+ simpleTypeMap);
+ buildFormat("date", "java.sql.Date", "serializeSqlDate", "deserializeSqlDate", null, simpleTypeMap);
+ buildFormat("time", "java.sql.Time", "serializeSqlTime", "deserializeSqlTime", null, simpleTypeMap);
+ buildFormat("base64Binary", "byte[]", "serializeBase64", "deserializeBase64", null, simpleTypeMap);
+ buildFormat("string", "java.lang.String", null, null, null, simpleTypeMap);
+ }
+
+ /**
+ * Suppress the default constructor to avoid unintentional instantiation.
+ */
+ private JibxSimpleTypes() {
+ }
+
+ private static void buildFormat(final String stype, final String jtype, final String sname,
+ final String dname, final String dflt, final Map<QName, Format> map) {
+ Format format = new Format();
+ format.setTypeName(jtype);
+ format.setSerializeMethod(sname);
+ format.setDeserializeMethod(dname);
+ format.setDefaultValue(dflt);
+ map.put(new QName(SCHEMA_NAMESPACE, stype), format);
+ }
+
+ public static Format getFormatElement(final QName type) {
+ return simpleTypeMap.get(type);
+ }
+
+ public static Object toObject(String text, final QName stype) {
+ Format format = simpleTypeMap.get(stype);
+ if (format != null) {
+ String deserializerMethod = format.getDeserializeMethod();
+ if (deserializerMethod != null) {
+ try {
+ if (text == null) {
+ text = format.getDefaultValue();
+ }
+ Method method = UTILITY.getMethod(deserializerMethod, INPUT_TYPE);
+ return method.invoke(null, new Object[] {
+ text
+ });
+ } catch (Exception e) {
+ throw new RuntimeException("", e);
+ }
+ }
+ }
+ return text;
+ }
+
+ public static String toText(final QName schemaType, final Object value) {
+ Format format = simpleTypeMap.get(schemaType);
+ if (format != null) {
+ String serializeMethod = format.getSerializeMethod();
+ if (serializeMethod != null) {
+ String jtype = format.getTypeName();
+ Class[] paraTypes = (JibxSimpleTypes.isPrimitiveType(jtype)) ? new Class[] {
+ JibxSimpleTypes.primitiveType(jtype)
+ } : new Class[] {
+ value.getClass()
+ };
+ try {
+ Method method = UTILITY.getMethod(serializeMethod, paraTypes);
+ return method.invoke(null, new Object[] {
+ value
+ }).toString();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ return value.toString();
+ }
+
+ public static boolean isSimpleType(final Class type) {
+ String jtype = type.getName();
+ return simplePrimitiveTypeMap.containsKey(jtype) || simpleObjectTypeMap.containsKey(jtype)
+ || "void".equals(jtype);
+ }
+
+ public static QName schemaType(final Class type) {
+ String jtype = type.getName();
+ QName stype = (QName)simplePrimitiveTypeMap.get(jtype);
+ if (stype == null) {
+ stype = (QName)simpleObjectTypeMap.get(jtype);
+ }
+ return stype;
+ }
+
+ public static boolean isPrimitiveType(final String type) {
+ return simpleWrapperMap.containsKey(type);
+ }
+
+ public static Class<?> primitiveType(final String type) {
+ return simpleWrapperMap.get(type);
+ }
+
+ public static QName toQname(String qname) {
+ String ns = qname.substring(1, qname.indexOf("}"));
+ String localName = qname.substring(qname.indexOf("}") + 2);
+ return new QName(ns, localName);
+ }
+
+ private static class Format {
+
+ private String typeName;
+ private String deserializeMethod;
+ private String serializeMethod;
+ private String defaultValue;
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(final String typeName) {
+ this.typeName = typeName;
+ }
+
+ public String getDeserializeMethod() {
+ return deserializeMethod;
+ }
+
+ public void setDeserializeMethod(final String deserializeMethod) {
+ this.deserializeMethod = deserializeMethod;
+ }
+
+ public String getSerializeMethod() {
+ return serializeMethod;
+ }
+
+ public void setSerializeMethod(final String serializeMethod) {
+ this.serializeMethod = serializeMethod;
+ }
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(final String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+ }
+}
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSimpleTypes.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSimpleTypes.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxUtil.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxUtil.java?rev=1073117&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxUtil.java (added)
+++ cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxUtil.java Mon Feb 21 19:08:55 2011
@@ -0,0 +1,236 @@
+/**
+ * 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.cxf.jibx;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.jibx.runtime.Utility;
+
+public final class JibxUtil {
+
+ public static final String SCHEMA_NAMESPACE = "http://www.w3.org/2001/XMLSchema";
+
+ public static final QName STRING_QNAME = new QName(SCHEMA_NAMESPACE, "string");
+
+ private static Map<String, QName> simpleObjectTypeMap = new HashMap<String, QName>();
+
+ private static Map<String, QName> simplePrimitiveTypeMap = new HashMap<String, QName>();
+
+ private static Map<String, Class<?>> simpleWrapperMap = new HashMap<String, Class<?>>();
+
+ private static Map<QName, Format> simpleTypeMap = new HashMap<QName, Format>();
+
+ private static final Class<Utility> UTILITY = org.jibx.runtime.Utility.class;
+
+ private static final Class<String> INPUT_TYPE = java.lang.String.class;
+
+ static {
+ simpleObjectTypeMap.put("java.lang.Boolean", new QName(SCHEMA_NAMESPACE, "boolean"));
+ simpleObjectTypeMap.put("java.lang.Byte", new QName(SCHEMA_NAMESPACE, "byte"));
+ simpleObjectTypeMap.put("java.lang.Character", new QName(SCHEMA_NAMESPACE, "unsignedInt"));
+ simpleObjectTypeMap.put("java.lang.Double", new QName(SCHEMA_NAMESPACE, "double"));
+ simpleObjectTypeMap.put("java.lang.Float", new QName(SCHEMA_NAMESPACE, "float"));
+ simpleObjectTypeMap.put("java.lang.Integer", new QName(SCHEMA_NAMESPACE, "int"));
+ simpleObjectTypeMap.put("java.lang.Long", new QName(SCHEMA_NAMESPACE, "long"));
+ simpleObjectTypeMap.put("java.lang.Short", new QName(SCHEMA_NAMESPACE, "short"));
+ simpleObjectTypeMap.put("java.lang.String", STRING_QNAME);
+ simpleObjectTypeMap.put("java.math.BigDecimal", new QName(SCHEMA_NAMESPACE, "decimal"));
+ simpleObjectTypeMap.put("java.math.BigInteger", new QName(SCHEMA_NAMESPACE, "integer"));
+ simpleObjectTypeMap.put("java.util.Date", new QName(SCHEMA_NAMESPACE, "dateTime"));
+ // #!j2me{
+ simpleObjectTypeMap.put("java.sql.Date", new QName(SCHEMA_NAMESPACE, "date"));
+ simpleObjectTypeMap.put("java.sql.Time", new QName(SCHEMA_NAMESPACE, "time"));
+ simpleObjectTypeMap.put("java.sql.Timestamp", new QName(SCHEMA_NAMESPACE, "dateTime"));
+ simpleObjectTypeMap.put("org.joda.time.LocalDate", new QName(SCHEMA_NAMESPACE, "date"));
+ simpleObjectTypeMap.put("org.joda.time.DateMidnight", new QName(SCHEMA_NAMESPACE, "date"));
+ simpleObjectTypeMap.put("org.joda.time.LocalTime", new QName(SCHEMA_NAMESPACE, "time"));
+ simpleObjectTypeMap.put("org.joda.time.DateTime", new QName(SCHEMA_NAMESPACE, "dateTime"));
+ // #j2me}
+ simpleObjectTypeMap.put("byte[]", new QName(SCHEMA_NAMESPACE, "base64"));
+ simpleObjectTypeMap.put("org.jibx.runtime.QName", new QName(SCHEMA_NAMESPACE, "QName"));
+
+ simplePrimitiveTypeMap.put("boolean", new QName(SCHEMA_NAMESPACE, "boolean"));
+ simplePrimitiveTypeMap.put("byte", new QName(SCHEMA_NAMESPACE, "byte"));
+ simplePrimitiveTypeMap.put("char", new QName(SCHEMA_NAMESPACE, "unsignedInt"));
+ simplePrimitiveTypeMap.put("double", new QName(SCHEMA_NAMESPACE, "double"));
+ simplePrimitiveTypeMap.put("float", new QName(SCHEMA_NAMESPACE, "float"));
+ simplePrimitiveTypeMap.put("int", new QName(SCHEMA_NAMESPACE, "int"));
+ simplePrimitiveTypeMap.put("long", new QName(SCHEMA_NAMESPACE, "long"));
+ simplePrimitiveTypeMap.put("short", new QName(SCHEMA_NAMESPACE, "short"));
+
+ simpleWrapperMap.put("boolean", Boolean.TYPE);
+ simpleWrapperMap.put("byte", Byte.TYPE);
+ simpleWrapperMap.put("char", Character.TYPE);
+ simpleWrapperMap.put("double", Double.TYPE);
+ simpleWrapperMap.put("float", Float.TYPE);
+ simpleWrapperMap.put("int", Integer.TYPE);
+ simpleWrapperMap.put("long", Long.TYPE);
+ simpleWrapperMap.put("short", Short.TYPE);
+
+ buildFormat("byte", "byte", "serializeByte", "parseByte", "0", simpleTypeMap);
+ buildFormat("unsignedShort", "char", "serializeChar", "parseChar", "0", simpleTypeMap);
+ buildFormat("double", "double", "serializeDouble", "parseDouble", "0.0", simpleTypeMap);
+ buildFormat("float", "float", "serializeFloat", "parseFloat", "0.0", simpleTypeMap);
+ buildFormat("int", "int", "serializeInt", "parseInt", "0", simpleTypeMap);
+ buildFormat("long", "long", "serializeLong", "parseLong", "0", simpleTypeMap);
+ buildFormat("short", "short", "serializeShort", "parseShort", "0", simpleTypeMap);
+ buildFormat("boolean", "boolean", "serializeBoolean", "parseBoolean", "false", simpleTypeMap);
+ buildFormat("dateTime", "java.util.Date", "serializeDateTime", "deserializeDateTime", null,
+ simpleTypeMap);
+ buildFormat("date", "java.sql.Date", "serializeSqlDate", "deserializeSqlDate", null, simpleTypeMap);
+ buildFormat("time", "java.sql.Time", "serializeSqlTime", "deserializeSqlTime", null, simpleTypeMap);
+ buildFormat("base64Binary", "byte[]", "serializeBase64", "deserializeBase64", null, simpleTypeMap);
+ buildFormat("string", "java.lang.String", null, null, null, simpleTypeMap);
+ }
+
+ private JibxUtil() {
+ }
+
+ private static void buildFormat(final String stype, final String jtype, final String sname,
+ final String dname, final String dflt, final Map<QName, Format> map) {
+ Format format = new Format();
+ format.setTypeName(jtype);
+ format.setSerializeMethod(sname);
+ format.setDeserializeMethod(dname);
+ format.setDefaultValue(dflt);
+ map.put(new QName(SCHEMA_NAMESPACE, stype), format);
+ }
+
+ public static Format getFormatElement(final QName type) {
+ return simpleTypeMap.get(type);
+ }
+
+ public static Object toObject(final String text, final QName stype) {
+ Format format = simpleTypeMap.get(stype);
+ if (format != null) {
+ String deserializerMethod = format.getDeserializeMethod();
+ if (deserializerMethod != null) {
+ try {
+ Method method = UTILITY.getMethod(deserializerMethod, INPUT_TYPE);
+ return method.invoke(null, new Object[] {
+ text
+ });
+ } catch (Exception e) {
+ throw new RuntimeException("", e);
+ }
+ }
+ }
+ return text;
+ }
+
+ public static String toText(final Object value, final QName stype) {
+ Format format = simpleTypeMap.get(stype);
+ if (format != null) {
+ String serializeMethod = format.getSerializeMethod();
+ if (serializeMethod != null) {
+ String jtype = format.getTypeName();
+ Class[] paraTypes = (JibxUtil.isPrimitiveType(jtype)) ? new Class[] {
+ JibxUtil.getPrimitiveType(jtype)
+ } : new Class[] {
+ value.getClass()
+ };
+ try {
+ Method method = UTILITY.getMethod(serializeMethod, paraTypes);
+ return method.invoke(null, new Object[] {
+ value
+ }).toString();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ return value.toString();
+ }
+
+ public static boolean isSimpleValue(final String type) {
+ return simplePrimitiveTypeMap.containsKey(type) || simpleObjectTypeMap.containsKey(type)
+ || "void".equals(type);
+ }
+
+ public static boolean isSimpleValue(final Class type) {
+ return isSimpleValue(type.getName());
+ }
+
+ public static QName getSchemaType(final String jtype) {
+ QName stype = (QName)simplePrimitiveTypeMap.get(jtype);
+ if (stype == null) {
+ stype = (QName)simpleObjectTypeMap.get(jtype);
+ }
+ return stype;
+ }
+
+ public static boolean isPrimitiveType(final String type) {
+ return simpleWrapperMap.containsKey(type);
+ }
+
+ public static Class<?> getPrimitiveType(final String type) {
+ return simpleWrapperMap.get(type);
+ }
+
+ public static QName getQName(String qname) {
+ String ns = qname.substring(1, qname.indexOf("}"));
+ String localName = qname.substring(qname.indexOf("}") + 2);
+ return new QName(ns, localName);
+ }
+
+ static class Format {
+
+ private String typeName;
+ private String deserializeMethod;
+ private String serializeMethod;
+ private String defaultValue;
+
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public void setTypeName(final String typeName) {
+ this.typeName = typeName;
+ }
+
+ public String getDeserializeMethod() {
+ return deserializeMethod;
+ }
+
+ public void setDeserializeMethod(final String deserializeMethod) {
+ this.deserializeMethod = deserializeMethod;
+ }
+
+ public String getSerializeMethod() {
+ return serializeMethod;
+ }
+
+ public void setSerializeMethod(final String serializeMethod) {
+ this.serializeMethod = serializeMethod;
+ }
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(final String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+ }
+}
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxUtil.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxWrapperHelper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxWrapperHelper.java?rev=1073117&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxWrapperHelper.java (added)
+++ cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxWrapperHelper.java Mon Feb 21 19:08:55 2011
@@ -0,0 +1,46 @@
+/**
+ * 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.cxf.jibx;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.cxf.databinding.AbstractWrapperHelper;
+
+/**
+ * JibxWrapperHelper
+ */
+public class JibxWrapperHelper extends AbstractWrapperHelper {
+
+ protected JibxWrapperHelper(Class<?> wt, Method[] sets, Method[] gets, Field[] f) {
+ super(wt, sets, gets, f);
+ }
+
+ @Override
+ protected Object createWrapperObject(Class clazz) throws Exception {
+ return clazz.newInstance();
+ }
+
+ @Override
+ protected Object getWrapperObject(Object obj) throws Exception {
+ // Wrapper object instance is indeed the true wrapper in used.
+ return obj;
+ }
+}
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxWrapperHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxWrapperHelper.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaHelper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaHelper.java?rev=1073117&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaHelper.java (added)
+++ cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaHelper.java Mon Feb 21 19:08:55 2011
@@ -0,0 +1,221 @@
+/**
+ * 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.cxf.jibx.tools;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.Types;
+import javax.wsdl.extensions.UnknownExtensibilityElement;
+import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.extensions.schema.SchemaImport;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.catalog.CatalogXmlSchemaURIResolver;
+import org.apache.cxf.common.xmlschema.SchemaCollection;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.jibx.schema.ISchemaResolver;
+
+public class JibxSchemaHelper {
+
+ private final Map<String, Element> schemaList;
+ private final Map<String, String> catalogResolved = new HashMap<String, String>();
+ private final Bus bus;
+
+ public JibxSchemaHelper(final Bus b, final Map<String, Element> s) {
+ this.bus = b;
+ this.schemaList = s;
+ }
+
+ public void getSchemas(final Definition def, final SchemaCollection schemaCol,
+ List<ISchemaResolver> resolvers) {
+ List<Definition> defList = new ArrayList<Definition>();
+ parseImports(def, defList);
+ extractSchema(def, schemaCol, resolvers);
+ // added
+ getSchemaList(def);
+
+ Map<Definition, Definition> done = new IdentityHashMap<Definition, Definition>();
+ done.put(def, def);
+ for (Definition def2 : defList) {
+ if (!done.containsKey(def2)) {
+ extractSchema(def2, schemaCol, resolvers);
+ // added
+ getSchemaList(def2);
+ done.put(def2, def2);
+ }
+ }
+ }
+
+ private void extractSchema(Definition def, SchemaCollection schemaCol, List<ISchemaResolver> resolvers) {
+ Types typesElement = def.getTypes();
+ if (typesElement != null) {
+ int schemaCount = 1;
+ for (Object obj : typesElement.getExtensibilityElements()) {
+ org.w3c.dom.Element schemaElem = null;
+ if (obj instanceof Schema) {
+ Schema schema = (Schema)obj;
+ schemaElem = schema.getElement();
+ } else if (obj instanceof UnknownExtensibilityElement) {
+ org.w3c.dom.Element elem = ((UnknownExtensibilityElement)obj).getElement();
+ if (elem.getLocalName().equals("schema")) {
+ schemaElem = elem;
+ }
+ }
+ if (schemaElem != null) {
+ synchronized (schemaElem.getOwnerDocument()) {
+ for (Object prefix : def.getNamespaces().keySet()) {
+ String ns = (String)def.getNamespaces().get(prefix);
+ if ("".equals(prefix)) {
+ if (!schemaElem.hasAttribute("xmlns")) {
+ Attr attr = schemaElem.getOwnerDocument()
+ .createAttributeNS(javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
+ "xmlns");
+ attr.setValue(ns);
+ schemaElem.setAttributeNodeNS(attr);
+ }
+ } else if (!schemaElem.hasAttribute("xmlns:" + prefix)) {
+ String namespace = javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+ Attr attr = schemaElem.getOwnerDocument()
+ .createAttributeNS(namespace, "xmlns:" + prefix);
+ attr.setValue(ns);
+ schemaElem.setAttributeNodeNS(attr);
+ }
+ }
+ String systemId = def.getDocumentBaseURI() + "#types" + schemaCount;
+
+ schemaCol.setBaseUri(def.getDocumentBaseURI());
+ CatalogXmlSchemaURIResolver schemaResolver = new CatalogXmlSchemaURIResolver(bus);
+ schemaCol.setSchemaResolver(schemaResolver);
+
+ XmlSchema xmlSchema = schemaCol.read(schemaElem, systemId);
+ catalogResolved.putAll(schemaResolver.getResolvedMap());
+
+ JibxSchemaResolver resolver = new JibxSchemaResolver(systemId, xmlSchema, schemaCol);
+ resolvers.add(resolver);
+
+ // SchemaInfo schemaInfo = new SchemaInfo(xmlSchema.getTargetNamespace());
+ // schemaInfo.setSchema(xmlSchema);
+ // schemaInfo.setSystemId(systemId);
+ // schemaInfo.setElement(schemaElem);
+ // schemaInfos.add(schemaInfo);
+ schemaCount++;
+ }
+ }
+ }
+ }
+ }
+
+ private void parseImports(Definition def, List<Definition> defList) {
+ List<Import> importList = new ArrayList<Import>();
+
+ Collection<List<Import>> ilist = CastUtils.cast(def.getImports().values());
+ for (List<Import> list : ilist) {
+ importList.addAll(list);
+ }
+ for (Import impt : importList) {
+ if (!defList.contains(impt.getDefinition())) {
+ defList.add(impt.getDefinition());
+ parseImports(impt.getDefinition(), defList);
+ }
+ }
+ }
+
+ // Workaround for getting the elements
+ private void getSchemaList(Definition def) {
+ Types typesElement = def.getTypes();
+ if (typesElement != null) {
+ Iterator ite = typesElement.getExtensibilityElements().iterator();
+ while (ite.hasNext()) {
+ Object obj = ite.next();
+ if (obj instanceof Schema) {
+ Schema schema = (Schema)obj;
+ addSchema(schema.getDocumentBaseURI(), schema);
+ }
+ }
+ }
+ }
+
+ private void addSchema(String docBaseURI, Schema schema) {
+ // String docBaseURI = schema.getDocumentBaseURI();
+ Element schemaEle = schema.getElement();
+ if (schemaList.get(docBaseURI) == null) {
+ schemaList.put(docBaseURI, schemaEle);
+ } else if (schemaList.get(docBaseURI) != null && schemaList.containsValue(schemaEle)) {
+ // do nothing
+ } else {
+ String tns = schema.getDocumentBaseURI() + "#"
+ + schema.getElement().getAttribute("targetNamespace");
+ if (schemaList.get(tns) == null) {
+ schemaList.put(tns, schema.getElement());
+ }
+ }
+
+ Map<String, List> imports = CastUtils.cast(schema.getImports());
+ if (imports != null && imports.size() > 0) {
+ Collection<String> importKeys = imports.keySet();
+ for (String importNamespace : importKeys) {
+
+ List<SchemaImport> schemaImports = CastUtils.cast(imports.get(importNamespace));
+
+ for (SchemaImport schemaImport : schemaImports) {
+ Schema tempImport = schemaImport.getReferencedSchema();
+ String key = schemaImport.getSchemaLocationURI();
+ if (importNamespace == null && tempImport != null) {
+ importNamespace = tempImport.getDocumentBaseURI();
+ }
+
+ if (tempImport != null && !catalogResolved.containsKey(key)) {
+ key = tempImport.getDocumentBaseURI();
+ }
+
+ if (tempImport != null && !isSchemaParsed(key, importNamespace)
+ && !schemaList.containsValue(tempImport.getElement())) {
+ addSchema(key, tempImport);
+ }
+ }
+
+ }
+ }
+ }
+
+ private boolean isSchemaParsed(String baseUri, String ns) {
+ if (schemaList.get(baseUri) != null) {
+ Element ele = schemaList.get(baseUri);
+ String tns = ele.getAttribute("targetNamespace");
+ if (ns.equals(tns)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaHelper.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaResolver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaResolver.java?rev=1073117&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaResolver.java (added)
+++ cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaResolver.java Mon Feb 21 19:08:55 2011
@@ -0,0 +1,86 @@
+/**
+ * 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.cxf.jibx.tools;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.xml.sax.InputSource;
+
+import org.apache.cxf.common.xmlschema.SchemaCollection;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.resolver.URIResolver;
+import org.jibx.schema.ISchemaResolver;
+
+/**
+ * A Wrapper class that acts as a wrapper when passing schema instances to JiBX code generation framework.
+ */
+public class JibxSchemaResolver implements ISchemaResolver {
+ private String id;
+ private String name;
+ private XmlSchema schema;
+ private SchemaCollection collection;
+
+ public JibxSchemaResolver(String id, XmlSchema schema, SchemaCollection collection) {
+ this.id = id;
+ setName(id);
+ this.schema = schema;
+ this.collection = collection;
+ }
+
+ public InputStream getContent() throws IOException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ schema.write(bos);
+ return new ByteArrayInputStream(bos.toByteArray());
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ private void setName(String uri) {
+ this.name = uri.substring(uri.lastIndexOf('/') + 1);
+ }
+
+ public String getName() {
+ return name; // Fot the time being
+ }
+
+ public ISchemaResolver resolve(String loc, String tns) throws IOException {
+ URIResolver resolver = collection.getXmlSchemaCollection().getSchemaResolver();
+ InputSource source = resolver.resolveEntity(tns, loc, id);
+
+ SchemaCollection schemaCol = new SchemaCollection();
+ schemaCol.setSchemaResolver(resolver);
+ XmlSchema read = schemaCol.getXmlSchemaCollection().read(source);
+
+ String uri = loc;
+ try {
+ URL url = new URL(new URL(id), loc);
+ uri = url.toURI().toString();
+ } catch (Exception e) {
+ // do nothing
+ }
+ return new JibxSchemaResolver(uri, read, schemaCol);
+ }
+}
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaResolver.java
------------------------------------------------------------------------------
svn:keywords = Rev Date