You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2016/12/23 15:56:44 UTC
[3/3] cxf git commit: [CXF-7195] Removing rt-databindings-xmlbeans
[CXF-7195] Removing rt-databindings-xmlbeans
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/40380d8e
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/40380d8e
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/40380d8e
Branch: refs/heads/master
Commit: 40380d8e57cdea0d909f3a9ee207628831c202fa
Parents: 969a10c
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Fri Dec 23 15:55:56 2016 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Fri Dec 23 15:55:56 2016 +0000
----------------------------------------------------------------------
.../features/src/main/resources/features.xml | 5 -
rt/databinding/pom.xml | 1 -
rt/databinding/xmlbeans/pom.xml | 205 -------
.../org/apache/cxf/xmlbeans/DataReaderImpl.java | 167 ------
.../org/apache/cxf/xmlbeans/DataWriterImpl.java | 227 --------
.../org/apache/cxf/xmlbeans/Message.properties | 22 -
.../apache/cxf/xmlbeans/NodeDataWriterImpl.java | 61 ---
.../cxf/xmlbeans/XmlBeansDataBinding.java | 176 ------
.../cxf/xmlbeans/XmlBeansSchemaInitializer.java | 328 -----------
.../cxf/xmlbeans/XmlBeansWrapperHelper.java | 103 ----
.../xmlbeans/tools/XMLBeansSchemaTypeUtils.java | 123 -----
.../tools/XMLBeansToolingDataBinding.java | 545 -------------------
.../resources/META-INF/cxf/java2wsbeans.xml | 22 -
.../main/resources/META-INF/tools-plugin.xml | 22 -
.../cxf/xmlbeans/AbstractXmlBeansTest.java | 218 --------
.../apache/cxf/xmlbeans/CustomFault.aegis.xml | 6 -
.../org/apache/cxf/xmlbeans/CustomFault.java | 39 --
.../cxf/xmlbeans/DocumentStyleRequest.xml | 12 -
.../apache/cxf/xmlbeans/DocumentStyleTest.java | 78 ---
.../org/apache/cxf/xmlbeans/FaultRequest.xml | 7 -
.../org/apache/cxf/xmlbeans/GetForecasts.xml | 4 -
.../org/apache/cxf/xmlbeans/GetWeatherByZip.xml | 9 -
.../apache/cxf/xmlbeans/GreeterMineImpl.java | 48 --
.../org/apache/cxf/xmlbeans/IDRefRequest.xml | 9 -
.../org/apache/cxf/xmlbeans/IDRefService.java | 33 --
.../apache/cxf/xmlbeans/IDRefServiceTest.java | 50 --
.../cxf/xmlbeans/MultipleSchemaInNSTest.java | 80 ---
.../cxf/xmlbeans/MultipleSchemaService.java | 33 --
.../apache/cxf/xmlbeans/PrimitiveTypesTest.java | 71 ---
.../org/apache/cxf/xmlbeans/TestService.java | 66 ---
.../org/apache/cxf/xmlbeans/TypesService.java | 77 ---
.../org/apache/cxf/xmlbeans/WeatherService.java | 47 --
.../apache/cxf/xmlbeans/WeatherService2.java | 59 --
.../cxf/xmlbeans/WeatherService2Test.java | 66 ---
.../org/apache/cxf/xmlbeans/WrappedRequest.xml | 12 -
.../apache/cxf/xmlbeans/WrappedStyleTest.java | 104 ----
.../cxf/xmlbeans/XMLBeansServiceTest.java | 107 ----
.../org/apache/cxf/xmlbeans/XmlBeansTest.java | 94 ----
.../apache/cxf/xmlbeans/basic/BasicTest.java | 61 ---
.../apache/cxf/xmlbeans/basic/TestService.java | 47 --
.../org/apache/cxf/xmlbeans/basic/bean11.xml | 16 -
.../test/java/org/apache/cxf/xmlbeans/cxf.xml | 34 --
.../test/java/org/apache/cxf/xmlbeans/cxf2.xml | 36 --
.../apache/cxf/xmlbeans/rpc/GetWeatherData.xml | 6 -
.../apache/cxf/xmlbeans/rpc/SetWeatherData.xml | 10 -
.../xmlbeans/rpc/WeatherServiceRPCLitTest.java | 90 ---
.../org/apache/cxf/xmlbeans/sampleRequest.xml | 29 -
.../org/apache/cxf/xmlbeans/soap11fault.xml | 11 -
.../org/apache/cxf/xmlbeans/undeclaredns.xml | 4 -
.../org/apache/cxf/xmlbeans/xmlbeanstest.wsdl | 54 --
.../src/test/resources/wsdl/xmlbeanstest.wsdl | 54 --
rt/databinding/xmlbeans/src/test/xsd/Base.xsd | 31 --
.../xmlbeans/src/test/xsd/Request.xsd | 35 --
.../xmlbeans/src/test/xsd/Response.xsd | 35 --
.../xmlbeans/src/test/xsd/WeatherForecast.xsd | 72 ---
.../xmlbeans/src/test/xsd/XmlBeanTest.xsd | 60 --
.../xmlbeans/src/test/xsd/anyschema.xsd | 66 ---
rt/databinding/xmlbeans/src/test/xsd/idref.xsd | 24 -
.../xmlbeans/src/test/xsd/included.xsd | 33 --
rt/databinding/xmlbeans/src/test/xsd/sample.xsd | 16 -
rt/rs/extensions/providers/pom.xml | 6 -
systests/databinding/pom.xml | 15 -
.../xmlbeans/ClientServerXmlBeansTest.java | 272 ---------
.../cxf/systest/xmlbeans/GreeterImpl.java | 91 ----
.../systest/xmlbeans/PutLastTradePriceImpl.java | 62 ---
.../org/apache/cxf/systest/xmlbeans/Server.java | 58 --
.../cxf/systest/xmlbeans/ServerNoWsdl.java | 59 --
.../org/apache/cxf/systest/xmlbeans/cxf.xml | 32 --
.../apache/cxf/systest/xmlbeans/cxf_no_wsdl.xml | 33 --
69 files changed, 4788 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/40380d8e/osgi/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/osgi/karaf/features/src/main/resources/features.xml b/osgi/karaf/features/src/main/resources/features.xml
index 90ce5e5..b73b921 100644
--- a/osgi/karaf/features/src/main/resources/features.xml
+++ b/osgi/karaf/features/src/main/resources/features.xml
@@ -298,11 +298,6 @@
<feature version="${project.version}">cxf-wsdl</feature>
<bundle start-level="40">mvn:org.apache.cxf/cxf-rt-databinding-jaxb/${project.version}</bundle>
</feature>
- <feature name="cxf-databinding-xmlbeans" version="${project.version}">
- <feature version="${project.version}">cxf-core</feature>
- <bundle start-level="30" dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xmlbeans/${cxf.xmlbeans.bundle.version}</bundle>
- <bundle start-level="40">mvn:org.apache.cxf/cxf-rt-databinding-xmlbeans/${project.version}</bundle>
- </feature>
<feature name="cxf-features-clustering" version="${project.version}">
<feature version="${project.version}">cxf-core</feature>
<bundle start-level="40">mvn:org.apache.cxf/cxf-rt-features-clustering/${project.version}</bundle>
http://git-wip-us.apache.org/repos/asf/cxf/blob/40380d8e/rt/databinding/pom.xml
----------------------------------------------------------------------
diff --git a/rt/databinding/pom.xml b/rt/databinding/pom.xml
index 6f8e30a..e48ebac 100644
--- a/rt/databinding/pom.xml
+++ b/rt/databinding/pom.xml
@@ -31,7 +31,6 @@
</parent>
<modules>
<module>jaxb</module>
- <module>xmlbeans</module>
<module>aegis</module>
</modules>
</project>
http://git-wip-us.apache.org/repos/asf/cxf/blob/40380d8e/rt/databinding/xmlbeans/pom.xml
----------------------------------------------------------------------
diff --git a/rt/databinding/xmlbeans/pom.xml b/rt/databinding/xmlbeans/pom.xml
deleted file mode 100644
index 0615480..0000000
--- a/rt/databinding/xmlbeans/pom.xml
+++ /dev/null
@@ -1,205 +0,0 @@
-<?xml version="1.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.
--->
-<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-xmlbeans</artifactId>
- <packaging>bundle</packaging>
- <name>Apache CXF Runtime XmlBeans DataBinding</name>
- <description>Apache CXF Runtime XmlBeans DataBinding</description>
- <url>http://cxf.apache.org</url>
- <parent>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-parent</artifactId>
- <version>3.2.0-SNAPSHOT</version>
- <relativePath>../../../parent/pom.xml</relativePath>
- </parent>
- <properties>
- <cxf.spi-dir>spi-2.1</cxf.spi-dir>
- <cxf.osgi.import>
- !repackage
- </cxf.osgi.import>
- </properties>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-tools-common</artifactId>
- <version>${project.version}</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-tools-wsdlto-core</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-testutils</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.xmlbeans</groupId>
- <artifactId>xmlbeans</artifactId>
- <exclusions>
- <exclusion>
- <groupId>stax</groupId>
- <artifactId>stax-api</artifactId>
- </exclusion>
- </exclusions>
- </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-jetty</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.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>xmlbeans-maven-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>xmlbeans-test</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <schemaDirectory>src/test/xsd</schemaDirectory>
- <sourceGenerationDirectory>${project.build.directory}/generated/src/test/java</sourceGenerationDirectory>
- <classGenerationDirectory>${project.build.directory}/generated/src/test/resources</classGenerationDirectory>
- <!--noJavac>true</noJavac-->
- <javaSource>1.7</javaSource>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-codegen-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <id>generate-test-sources</id>
- <phase>generate-test-sources</phase>
- <configuration>
- <fork>${cxf.codegenplugin.forkmode}</fork>
- <testSourceRoot>target/generated/src/test/java</testSourceRoot>
- <testWsdlRoot>src/test/resources/wsdl</testWsdlRoot>
- <wsdlOptions>
- <wsdlOption>
- <wsdl>src/test/resources/wsdl/xmlbeanstest.wsdl</wsdl>
- <dataBinding>xmlbeans</dataBinding>
- <extraargs>
- <arg>-classdir</arg>
- <arg>${basedir}/target/generated/src/test/resources</arg>
- </extraargs>
- </wsdlOption>
- </wsdlOptions>
- </configuration>
- <goals>
- <goal>wsdl2java</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <profiles>
- <profile>
- <id>setup.eclipse</id>
- <build>
- <defaultGoal>process-test-sources</defaultGoal>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>setup.eclipse.project.sdo</id>
- <phase>process-test-sources</phase>
- <configuration>
- <target>
- <!-- XmlBeans generated code uses raw List types -->
- <propertyfile file="${basedir}/.settings/org.eclipse.jdt.core.prefs">
- <entry key="org.eclipse.jdt.core.compiler.problem.rawTypeReference" value="ignore" />
- </propertyfile>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
http://git-wip-us.apache.org/repos/asf/cxf/blob/40380d8e/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java
----------------------------------------------------------------------
diff --git a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java
deleted file mode 100755
index f1b6ab2..0000000
--- a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java
+++ /dev/null
@@ -1,167 +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.cxf.xmlbeans;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.logging.Logger;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.validation.Schema;
-
-import org.apache.cxf.common.i18n.Message;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.databinding.DataReader;
-import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.message.Attachment;
-import org.apache.cxf.service.model.MessagePartInfo;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.XmlAnySimpleType;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
-
-
-public class DataReaderImpl implements DataReader<XMLStreamReader> {
- private static final Logger LOG = LogUtils.getLogger(XmlBeansDataBinding.class);
- private boolean validate;
-
- public DataReaderImpl() {
- }
-
- public Object read(XMLStreamReader input) {
- return read(null, input);
- }
-
- public Object read(MessagePartInfo part, XMLStreamReader reader) {
- Class<?> typeClass = part.getTypeClass();
- boolean unwrap = false;
- if (!XmlObject.class.isAssignableFrom(typeClass)) {
- typeClass = (Class<?>)part.getProperty(XmlAnySimpleType.class.getName());
- unwrap = true;
- }
- return doRead(reader,
- part.getTypeClass(),
- typeClass,
- (SchemaType)part.getProperty(SchemaType.class.getName()),
- unwrap);
- }
-
- public Object read(QName name, XMLStreamReader reader, Class<?> typeClass) {
- SchemaType st = null;
- try {
- Field f = typeClass.getField("type");
- if (Modifier.isStatic(f.getModifiers())) {
- st = (SchemaType)f.get(null);
- }
- } catch (Exception es) {
- es.printStackTrace();
- return null;
- }
-
- return doRead(reader,
- typeClass,
- typeClass,
- st,
- false);
- }
-
- private Object doRead(XMLStreamReader reader, Class<?> partTypeClass,
- Class<?> typeClass, SchemaType st, boolean unwrap) {
- boolean isOutClass = false;
- Class<?> encClass = typeClass.getEnclosingClass();
- if (encClass != null) {
- typeClass = encClass;
- isOutClass = true;
- }
- Class<?> cls[] = typeClass.getDeclaredClasses();
- Object obj = null;
- for (Class<?> c : cls) {
- if ("Factory".equals(c.getSimpleName())) {
- try {
- XmlOptions options = new XmlOptions();
- if (validate) {
- options.setValidateOnSet();
- }
- if (st != null && !st.isDocumentType() && !isOutClass) {
- options.setLoadReplaceDocumentElement(null);
- }
- Method meth = c.getMethod("parse", XMLStreamReader.class, XmlOptions.class);
- obj = meth.invoke(null, reader, options);
- break;
- } catch (Exception e) {
- throw new Fault(new Message("UNMARSHAL_ERROR", LOG, partTypeClass, e));
- }
- }
- }
- if (unwrap && obj != null) {
- try {
- Class<?> tc = partTypeClass;
- String methName;
- if (tc.equals(Integer.TYPE) || tc.equals(Integer.class)) {
- methName = "getIntValue";
- } else if (tc.equals(byte[].class)) {
- methName = "byteArrayValue";
- } else {
- String tp = tc.getSimpleName();
- tp = Character.toUpperCase(tp.charAt(0)) + tp.substring(1);
- methName = "get" + tp + "Value";
- }
- Method m = obj.getClass().getMethod(methName);
- obj = m.invoke(obj);
- } catch (Exception e) {
- e.printStackTrace();
- }
- } else if (isOutClass) {
- for (Method m : encClass.getDeclaredMethods()) {
- if (m.getName().startsWith("get")
- && m.getParameterTypes().length == 0
- && m.getReturnType().equals(partTypeClass)) {
- try {
- obj = m.invoke(obj);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- }
- if (reader.getEventType() == XMLStreamReader.END_ELEMENT) {
- try {
- reader.next();
- } catch (XMLStreamException e) {
- throw new RuntimeException(e);
- }
- }
- return obj;
- }
-
- public void setAttachments(Collection<Attachment> attachments) {
- }
-
- public void setProperty(String prop, Object value) {
- }
-
- public void setSchema(Schema s) {
- validate = s != null;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/40380d8e/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java
----------------------------------------------------------------------
diff --git a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java
deleted file mode 100755
index fdf2ed4..0000000
--- a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataWriterImpl.java
+++ /dev/null
@@ -1,227 +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.cxf.xmlbeans;
-
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.logging.Logger;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-import javax.xml.validation.Schema;
-
-import org.w3c.dom.Comment;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.databinding.DataWriter;
-import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.message.Attachment;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.message.MessageUtils;
-import org.apache.cxf.service.model.MessagePartInfo;
-import org.apache.cxf.staxutils.StaxUtils;
-import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.XmlAnySimpleType;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.XmlTokenSource;
-import org.apache.xmlbeans.impl.values.XmlObjectBase;
-
-public class DataWriterImpl implements DataWriter<XMLStreamWriter> {
- private static final Logger LOG = LogUtils.getLogger(XmlBeansDataBinding.class);
- private Schema schema;
- private Message message;
-
- public DataWriterImpl() {
- }
-
- public void write(Object obj, XMLStreamWriter output) {
- write(obj, null, output);
- }
-
- public void write(Object obj, MessagePartInfo part, XMLStreamWriter output) {
- try {
- Class<?> typeClass = part != null ? part.getTypeClass() : null;
- if (typeClass == null) {
- typeClass = obj.getClass();
- }
- if (!XmlObject.class.isAssignableFrom(typeClass) && part != null) {
- typeClass = (Class<?>)part.getProperty(XmlAnySimpleType.class.getName());
-
- Class<?> cls[] = typeClass.getDeclaredClasses();
- for (Class<?> c : cls) {
- if ("Factory".equals(c.getSimpleName())) {
- try {
- SchemaType st = (SchemaType)part.getProperty(SchemaType.class.getName());
- XmlOptions options = new XmlOptions();
- if (schema != null) {
- options.setValidateOnSet();
- }
- if (!st.isDocumentType()) {
- options.setLoadReplaceDocumentElement(null);
- }
- Method meth = c.getMethod("newValue", Object.class);
- obj = meth.invoke(null, obj);
- break;
- } catch (Exception e) {
- throw new Fault("UNMARSHAL_ERROR", LOG, e, part.getTypeClass());
- }
- }
- }
- }
-
-
- if (obj != null) {
- XmlOptions options = new XmlOptions();
- if (schema != null) {
- options.setValidateOnSet();
- }
- if (message != null
- && MessageUtils.getContextualBoolean(message,
- XmlBeansDataBinding.XMLBEANS_NAMESPACE_HACK,
- false)) {
- Object dom;
- if (obj instanceof XmlObjectBase) {
- XmlObjectBase source = (XmlObjectBase)obj;
- dom = source.newDomNode(options);
- } else {
- XmlTokenSource source = (XmlTokenSource)obj;
- dom = source.newDomNode(options);
- }
-
- if (dom instanceof Document) {
- org.w3c.dom.Element e = ((Document)dom).getDocumentElement();
- StaxUtils.copy(e, output);
- } else if (dom instanceof DocumentFragment) {
- DocumentFragment frag = (DocumentFragment) dom;
- Node node = frag.getFirstChild();
- while (node != null) {
- if (node instanceof Element) {
- StaxUtils.copy((Element)node, output);
- } else if (node instanceof Comment) {
- output.writeComment(((Comment)node).getData());
- } else if (node instanceof Text) {
- output.writeCharacters(((Text)node).getData());
- }
- node = node.getNextSibling();
- }
- } else {
- throw new Fault("Invalid document type returned: " + dom.toString(), LOG);
- }
- return;
- }
-
- XMLStreamReader reader;
- if (obj instanceof XmlObjectBase) {
- XmlObjectBase source = (XmlObjectBase)obj;
- reader = source.newCursorForce().newXMLStreamReader(options);
- } else {
- XmlTokenSource source = (XmlTokenSource)obj;
- reader = source.newCursor().newXMLStreamReader(options);
- }
- SchemaType st = part == null ? null
- : (SchemaType)part.getProperty(SchemaType.class.getName());
- if (st == null) {
- try {
- Field f = typeClass.getField("type");
- if (Modifier.isStatic(f.getModifiers())) {
- st = (SchemaType)f.get(null);
- if (part != null) {
- part.setProperty(SchemaType.class.getName(), st);
- }
- }
- } catch (Exception es) {
- //ignore
- es.printStackTrace();
- }
- }
- if (reader.getEventType() == XMLStreamReader.START_DOCUMENT) {
- reader.next();
- }
-
- if (st != null && !st.isDocumentType()
- || reader.getEventType() == XMLStreamReader.CHARACTERS) {
-
- QName elementName = part != null ? part.getConcreteName() : st.getName();
-
- if (StringUtils.isEmpty(elementName.getNamespaceURI())) {
- output.writeStartElement(elementName.getLocalPart());
-
- } else {
- String pfx = output.getPrefix(elementName.getNamespaceURI());
- if (StringUtils.isEmpty(pfx)) {
- output.writeStartElement("tns",
- elementName.getLocalPart(),
- elementName.getNamespaceURI());
- output.writeNamespace("tns", elementName.getNamespaceURI());
- } else {
- output.writeStartElement(pfx,
- elementName.getLocalPart(),
- elementName.getNamespaceURI());
- }
- }
- StaxUtils.copy(reader, output, false);
- output.writeEndElement();
- } else {
- StaxUtils.copy(reader, output, false);
- }
- } else if (needToRender(part)) {
- output.writeStartElement(part.getConcreteName().getNamespaceURI(),
- part.getConcreteName().getLocalPart());
- output.writeEndElement();
- }
- } catch (XMLStreamException e) {
- throw new Fault("MARSHAL_ERROR", LOG, e, obj);
- }
- }
-
- private boolean needToRender(MessagePartInfo part) {
- if (part != null && part.getXmlSchema() instanceof XmlSchemaElement) {
- XmlSchemaElement element = (XmlSchemaElement)part.getXmlSchema();
- return element.isNillable() && element.getMinOccurs() > 0;
- }
- return false;
- }
-
- public void setAttachments(Collection<Attachment> attachments) {
- }
-
- public void setProperty(String key, Object value) {
- if (Message.class.getName().equals(key)) {
- message = (Message)value;
- }
- }
-
- public void setSchema(Schema schema) {
- this.schema = schema;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/40380d8e/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/Message.properties
----------------------------------------------------------------------
diff --git a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/Message.properties b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/Message.properties
deleted file mode 100644
index 8ec7015..0000000
--- a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/Message.properties
+++ /dev/null
@@ -1,22 +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.
-#
-#
-MARSHAL_ERROR = Marshalling Error: {0}
-UNMARSHAL_ERROR = Unmarshalling Error: {0}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf/blob/40380d8e/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/NodeDataWriterImpl.java
----------------------------------------------------------------------
diff --git a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/NodeDataWriterImpl.java b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/NodeDataWriterImpl.java
deleted file mode 100644
index b31973c..0000000
--- a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/NodeDataWriterImpl.java
+++ /dev/null
@@ -1,61 +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.cxf.xmlbeans;
-
-
-import java.util.Collection;
-import javax.xml.validation.Schema;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-import org.apache.cxf.databinding.DataWriter;
-import org.apache.cxf.message.Attachment;
-import org.apache.cxf.service.model.MessagePartInfo;
-import org.apache.cxf.staxutils.W3CDOMStreamWriter;
-
-public class NodeDataWriterImpl implements DataWriter<Node> {
- DataWriterImpl writer;
-
- public NodeDataWriterImpl() {
- writer = new DataWriterImpl();
- }
-
- public void write(Object obj, Node output) {
- write(obj, null, output);
- }
-
- public void write(Object obj, MessagePartInfo part, Node output) {
- W3CDOMStreamWriter domWriter = new W3CDOMStreamWriter((Element)output);
- writer.write(obj, part, domWriter);
- }
-
- public void setAttachments(Collection<Attachment> attachments) {
- writer.setAttachments(attachments);
- }
-
- public void setProperty(String key, Object value) {
- writer.setProperty(key, value);
- }
-
- public void setSchema(Schema s) {
- writer.setSchema(s);
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/40380d8e/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java
----------------------------------------------------------------------
diff --git a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java
deleted file mode 100644
index f2f7767..0000000
--- a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java
+++ /dev/null
@@ -1,176 +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.cxf.xmlbeans;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-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 org.w3c.dom.Node;
-
-import org.apache.cxf.common.jaxb.JAXBUtils;
-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.service.Service;
-import org.apache.cxf.service.model.ServiceInfo;
-
-
-
-
-/**
- *
- */
-public class XmlBeansDataBinding extends AbstractDataBinding implements WrapperCapableDatabinding {
- public static final String XMLBEANS_NAMESPACE_HACK
- = XmlBeansDataBinding.class.getName() + ".NamespaceHack";
-
-
- private static final Logger LOG = LogUtils.getLogger(XmlBeansDataBinding.class);
-
- private static final Class<?> SUPPORTED_READER_FORMATS[] = new Class<?>[] {XMLStreamReader.class};
- private static final Class<?> SUPPORTED_WRITER_FORMATS[]
- = new Class<?>[] {XMLStreamWriter.class, Node.class};
-
-
- @SuppressWarnings("unchecked")
- public <T> DataWriter<T> createWriter(Class<T> c) {
- if (c == XMLStreamWriter.class) {
- return (DataWriter<T>)new DataWriterImpl();
- } else if (c == Node.class) {
- return (DataWriter<T>)new NodeDataWriterImpl();
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public <T> DataReader<T> createReader(Class<T> c) {
- DataReader<T> dr = null;
- if (c == XMLStreamReader.class) {
- dr = (DataReader<T>)new DataReaderImpl();
- }
- return dr;
- }
-
-
- /**
- * XmlBeans has no declared namespace prefixes.
- * {@inheritDoc}
- */
- public Map<String, String> getDeclaredNamespaceMappings() {
- return null;
- }
-
- public Class<?>[] getSupportedReaderFormats() {
- return SUPPORTED_READER_FORMATS;
- }
-
- public Class<?>[] getSupportedWriterFormats() {
- return SUPPORTED_WRITER_FORMATS;
- }
-
- public void initialize(Service service) {
- if (LOG.isLoggable(Level.FINER)) {
- LOG.log(Level.FINER, "Creating XmlBeansDatabinding for " + service.getName());
- }
- for (ServiceInfo serviceInfo : service.getServiceInfos()) {
- SchemaCollection col = serviceInfo.getXmlSchemaCollection();
-
- if (col.getXmlSchemas().length > 1) {
- // someone has already filled in the types
- continue;
- }
-
- XmlBeansSchemaInitializer schemaInit
- = new XmlBeansSchemaInitializer(serviceInfo, col, this);
- schemaInit.walk();
- }
- }
-
- public WrapperHelper createWrapperHelper(Class<?> wrapperType, QName wrapperName, List<String> partNames,
- List<String> elTypeNames, List<Class<?>> partClasses) {
-
- List<Method> getMethods = new ArrayList<Method>(partNames.size());
- List<Method> setMethods = new ArrayList<Method>(partNames.size());
- List<Field> fields = new ArrayList<Field>(partNames.size());
-
- 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;
- Class<?> valueClass = XmlBeansWrapperHelper.getXMLBeansValueType(wrapperType);
- Method[] allMethods = valueClass.getMethods();
-
- try {
- getMethod = valueClass.getMethod(getAccessor, AbstractWrapperHelper.NO_CLASSES);
- } catch (NoSuchMethodException ex) {
- try {
- getMethod = valueClass.getMethod(getAccessor + "Array", AbstractWrapperHelper.NO_CLASSES);
- getAccessor += "Array";
- setAccessor += "Array";
- } catch (NoSuchMethodException ex2) {
- //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);
- // There is no filed in the XMLBeans type class
- fields.add(null);
-
- }
-
- return new XmlBeansWrapperHelper(wrapperType,
- setMethods.toArray(new Method[setMethods.size()]),
- getMethods.toArray(new Method[getMethods.size()]),
- fields.toArray(new Field[fields.size()]));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/40380d8e/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
----------------------------------------------------------------------
diff --git a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
deleted file mode 100755
index 1b28cec..0000000
--- a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansSchemaInitializer.java
+++ /dev/null
@@ -1,328 +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.cxf.xmlbeans;
-
-
-import java.io.InputStream;
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.xml.namespace.QName;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import org.xml.sax.InputSource;
-
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.common.xmlschema.SchemaCollection;
-import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.helpers.XPathUtils;
-import org.apache.cxf.service.ServiceModelVisitor;
-import org.apache.cxf.service.model.MessagePartInfo;
-import org.apache.cxf.service.model.ServiceInfo;
-import org.apache.cxf.staxutils.StaxUtils;
-import org.apache.cxf.wsdl.WSDLConstants;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.ws.commons.schema.XmlSchemaException;
-import org.apache.ws.commons.schema.XmlSchemaType;
-import org.apache.ws.commons.schema.resolver.URIResolver;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.SchemaTypeSystem;
-import org.apache.xmlbeans.XmlAnySimpleType;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.impl.schema.BuiltinSchemaTypeSystem;
-import org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl;
-
-/**
- * Walks the service model and sets up the element/type names.
- */
-class XmlBeansSchemaInitializer extends ServiceModelVisitor {
-
- public static final String XML_BEANS_SCHEMA_PREFIX = "schema"
- + SchemaTypeSystemImpl.METADATA_PACKAGE_GEN + "/src/";
- private static final Logger LOG = LogUtils.getLogger(XmlBeansSchemaInitializer.class);
- private static final Map<Class<?>, Class<? extends XmlAnySimpleType>> CLASS_MAP
- = new HashMap<Class<?>, Class<? extends XmlAnySimpleType>>();
- private SchemaCollection schemas;
- private XmlBeansDataBinding dataBinding;
- private Map<String, XmlSchema> schemaMap
- = new HashMap<String, XmlSchema>();
- private URIResolver schemaResolver;
-
- static {
- CLASS_MAP.put(String.class, org.apache.xmlbeans.XmlString.class);
- CLASS_MAP.put(Integer.class, org.apache.xmlbeans.XmlInt.class);
- CLASS_MAP.put(Integer.TYPE, org.apache.xmlbeans.XmlInt.class);
- CLASS_MAP.put(Short.class, org.apache.xmlbeans.XmlShort.class);
- CLASS_MAP.put(Short.TYPE, org.apache.xmlbeans.XmlShort.class);
- CLASS_MAP.put(Byte.class, org.apache.xmlbeans.XmlByte.class);
- CLASS_MAP.put(Byte.TYPE, org.apache.xmlbeans.XmlByte.class);
- CLASS_MAP.put(Float.class, org.apache.xmlbeans.XmlFloat.class);
- CLASS_MAP.put(Float.TYPE, org.apache.xmlbeans.XmlFloat.class);
- CLASS_MAP.put(Double.class, org.apache.xmlbeans.XmlDouble.class);
- CLASS_MAP.put(Double.TYPE, org.apache.xmlbeans.XmlDouble.class);
- CLASS_MAP.put(Long.class, org.apache.xmlbeans.XmlLong.class);
- CLASS_MAP.put(Long.TYPE, org.apache.xmlbeans.XmlLong.class);
- CLASS_MAP.put(Boolean.class, org.apache.xmlbeans.XmlBoolean.class);
- CLASS_MAP.put(Boolean.TYPE, org.apache.xmlbeans.XmlBoolean.class);
- CLASS_MAP.put(BigDecimal.class, org.apache.xmlbeans.XmlDecimal.class);
- CLASS_MAP.put(BigInteger.class, org.apache.xmlbeans.XmlInteger.class);
- CLASS_MAP.put(Date.class, org.apache.xmlbeans.XmlDate.class);
- CLASS_MAP.put(Calendar.class, org.apache.xmlbeans.XmlDate.class);
- CLASS_MAP.put(byte[].class, org.apache.xmlbeans.XmlBase64Binary.class);
- }
-
- XmlBeansSchemaInitializer(ServiceInfo serviceInfo,
- SchemaCollection col,
- XmlBeansDataBinding db) {
- super(serviceInfo);
- schemas = col;
- dataBinding = db;
- schemaResolver = serviceInfo.getXmlSchemaCollection().getXmlSchemaCollection().getSchemaResolver();
- }
-
- public class XMLSchemaResolver implements URIResolver {
- final SchemaTypeSystem sts;
- XMLSchemaResolver(SchemaTypeSystem sts) {
- this.sts = sts;
- }
-
- public InputSource resolveEntity(String targetNamespace, String schemaLocation, String baseUri) {
- InputStream ins = sts.getSourceAsStream(schemaLocation);
- if (ins != null) {
- return new InputSource(ins);
- }
- return null;
- }
- }
-
- XmlSchema addSchemaElement(SchemaTypeSystem sts, Document doc,
- Element elem, String file) throws URISyntaxException {
- doc.appendChild(elem);
-
- elem = DOMUtils.getFirstElement(elem);
- while (elem != null) {
- if (elem.getLocalName().equals("import")) {
- URI uri = new URI(file);
- String loc = elem.getAttribute("schemaLocation");
- if (!StringUtils.isEmpty(loc)) {
- URI locUri = uri.resolve(loc);
- String newLoc = locUri.toString();
- getSchema(sts, newLoc);
- }
- }
- elem = DOMUtils.getNextElement(elem);
- }
- XmlSchema schema = dataBinding.addSchemaDocument(serviceInfo,
- schemas,
- doc,
- file);
- doc.removeChild(doc.getDocumentElement());
- schemaMap.put(file, schema);
-
- return schema;
- }
- protected XmlSchema getSchema(SchemaTypeSystem sts, String file) {
- if (schemaMap.containsKey(file)) {
- return schemaMap.get(file);
- }
-
- try {
- InputSource fileSource = schemaResolver.resolveEntity(null,
- file,
- null);
- String systemId = removePrefix(fileSource.getSystemId(),
- XML_BEANS_SCHEMA_PREFIX);
-
- return getSchemaInternal(sts, systemId);
- } catch (XmlSchemaException e) {
- if (LOG.isLoggable(Level.FINEST)) {
- LOG.log(Level.FINEST,
- "The XML catalog is not configured to map the file [" + file + "] ", e);
- }
- }
- return getSchemaInternal(sts, file);
- }
-
- protected XmlSchema getSchemaInternal(SchemaTypeSystem sts, String file) {
- InputStream ins = sts.getSourceAsStream(file);
- if (ins == null) {
- return null;
- }
- try {
- //temporary marker to make sure recursive imports don't blow up
- schemaMap.put(file, null);
-
- Document doc = StaxUtils.read(ins);
- Element elem = doc.getDocumentElement();
- doc.removeChild(elem);
-
- if ("schema".equals(elem.getLocalName())
- && "http://www.w3.org/2001/XMLSchema".equals(elem.getNamespaceURI())) {
- return addSchemaElement(sts, doc, elem, file);
- }
- Map<String, String> ns = new HashMap<String, String>();
- ns.put("wsdl", WSDLConstants.NS_WSDL11);
- ns.put("xsd", WSDLConstants.NS_SCHEMA_XSD);
- XPathUtils xpath = new XPathUtils(ns);
- NodeList list = xpath.getValueList("/wsdl:definitions/wsdl:types/xsd:schema", elem);
- for (int x = 0; x < list.getLength(); x++) {
- addSchemaElement(sts, doc, (Element)list.item(x), file + "#1");
- }
- return null;
- } catch (Exception e) {
- throw new RuntimeException("Failed to find schema for: " + file, e);
- }
- }
- /**
- * Removes the prefix ending with the given suffix. For instance, the value
- * XYZ where the prefix is Y, the result will be Z. The removed string is XY.
- *
- * @param value the value from where the returned string is extracted
- * @param prefixSuffix the prefix
- * @return the rest of the string
- */
- protected String removePrefix(String value, String prefixSuffix) {
- return value.substring(value.indexOf(prefixSuffix) + prefixSuffix.length());
- }
-
- @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);
- }
- private void mapClass(MessagePartInfo part, Class<?> clazz) {
-
- if (!XmlObject.class.isAssignableFrom(clazz)) {
-
- Class<? extends XmlAnySimpleType> type = CLASS_MAP.get(clazz);
- if (type == null) {
- LOG.log(Level.SEVERE, clazz.getName() + " was not found in class map");
- return;
- }
- SchemaTypeSystem sts = BuiltinSchemaTypeSystem.get();
- SchemaType st2 = sts.typeForClassname(type.getName());
-
- part.setProperty(SchemaType.class.getName(), st2);
- part.setProperty(XmlAnySimpleType.class.getName(), type);
- part.setTypeQName(st2.getName());
- XmlSchemaType xmlSchema = schemas.getTypeByQName(st2.getName());
- part.setXmlSchema(xmlSchema);
- return;
- }
-
- try {
- Field field = clazz.getField("type");
- SchemaType st = (SchemaType)field.get(null);
- part.setProperty(SchemaType.class.getName(), st);
-
- SchemaTypeSystem sts = st.getTypeSystem();
- schemas.getXmlSchemaCollection().setSchemaResolver(new XMLSchemaResolver(sts));
- String sourceName = st.getSourceName();
- XmlSchema schema = getSchema(sts, sourceName);
- if (schema != null) {
- if (st.isDocumentType()) {
- XmlSchemaElement sct = schema.getElementByName(st.getDocumentElementName());
- part.setXmlSchema(sct);
- part.setElement(true);
- part.setElementQName(st.getDocumentElementName());
- part.setConcreteName(st.getDocumentElementName());
- } else if (st.getComponentType() == SchemaType.ELEMENT) {
- XmlSchemaElement sct = schema.getElementByName(st.getName());
- part.setXmlSchema(sct);
- part.setElement(true);
- } else {
- XmlSchemaType sct = schema.getTypeByName(st.getName());
- part.setTypeQName(st.getName());
- part.setXmlSchema(sct);
- part.setElement(false);
- }
- } else {
- if (st.isDocumentType()) {
- part.setElement(true);
- part.setElementQName(st.getDocumentElementName());
- part.setConcreteName(st.getDocumentElementName());
- part.setXmlSchema(schemas.getElementByQName(st.getDocumentElementName()));
- } else if (st.getComponentType() == SchemaType.ELEMENT) {
- part.setElement(true);
- part.setElementQName(st.getName());
- part.setConcreteName(st.getName());
- part.setXmlSchema(schemas.getElementByQName(st.getName()));
- } else {
- part.setTypeQName(st.getName());
- part.setElement(false);
- part.setXmlSchema(schemas.getTypeByQName(st.getName()));
- }
- }
- } catch (RuntimeException ex) {
- throw ex;
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
-
- 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);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/40380d8e/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java
----------------------------------------------------------------------
diff --git a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java
deleted file mode 100644
index c98de9b..0000000
--- a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansWrapperHelper.java
+++ /dev/null
@@ -1,103 +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.cxf.xmlbeans;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import org.apache.cxf.databinding.AbstractWrapperHelper;
-import org.apache.xmlbeans.XmlOptions;
-
-
-public class XmlBeansWrapperHelper extends AbstractWrapperHelper {
-
- public XmlBeansWrapperHelper(Class<?> wt, Method[] sets, Method[] gets, Field[] f) {
- super(wt, sets, gets, f);
-
- }
-
- @Override
- protected Object createWrapperObject(Class<?> typeClass) throws Exception {
- Class<?> cls[] = typeClass.getDeclaredClasses();
- Method newType = null;
- for (Method method : typeClass.getMethods()) {
- if (method.getName().startsWith("addNew")) {
- newType = method;
- break;
- }
- }
- Object obj = null;
- for (Class<?> c : cls) {
- if ("Factory".equals(c.getSimpleName())) {
- if (validate) {
- // set the validation option here
- Method method = c.getMethod("newInstance", XmlOptions.class);
- XmlOptions options = new XmlOptions();
- options.setValidateOnSet();
- obj = method.invoke(null, options);
- } else {
- Method method = c.getMethod("newInstance", NO_CLASSES);
- obj = method.invoke(null, NO_PARAMS);
- }
- if (newType != null) {
- // create the value object
- obj = newType.invoke(obj, NO_PARAMS);
- }
- break;
- }
- }
-
- return obj;
- }
-
- @Override
- protected Object getWrapperObject(Object object) throws Exception {
- Method m = getXMLBeansValueMethod(wrapperType);
- Method method = null;
- if (m == null) {
- Class<?> valueClass = getXMLBeansValueType(wrapperType);
- // we need get the real Object first
- method = wrapperType.getMethod("get" + valueClass.getSimpleName(), NO_CLASSES);
- } else {
- method = wrapperType.getMethod("get" + m.getName().substring(6), NO_CLASSES);
- }
- return method.invoke(object, NO_PARAMS);
- }
- public static Method getXMLBeansValueMethod(Class<?> wrapperType) {
- for (Method method : wrapperType.getMethods()) {
- if (method.getName().startsWith("addNew")) {
- return method;
- }
- }
- return null;
- }
-
- public static Class<?> getXMLBeansValueType(Class<?> wrapperType) {
- Class<?> result = wrapperType;
- for (Method method : wrapperType.getMethods()) {
- if (method.getName().startsWith("addNew")) {
- result = method.getReturnType();
- break;
- }
- }
- return result;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/40380d8e/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansSchemaTypeUtils.java
----------------------------------------------------------------------
diff --git a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansSchemaTypeUtils.java b/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansSchemaTypeUtils.java
deleted file mode 100644
index 9c326a9..0000000
--- a/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/tools/XMLBeansSchemaTypeUtils.java
+++ /dev/null
@@ -1,123 +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.cxf.xmlbeans.tools;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.xmlbeans.SchemaType;
-
-/**
- * This class will help us to map the
- * <a href="http://xmlbeans.apache.org/docs/2.0.0/guide/conXMLBeansSupportBuiltInSchemaTypes.html">
- * XMLBeans Builtin Type</a> into Natural Java Type
- *
- *
- */
-public final class XMLBeansSchemaTypeUtils {
- private static final Map<String, String> BUILTIN_TYPES_MAP;
- static {
- BUILTIN_TYPES_MAP = new HashMap<String, String>();
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlObject", "org.apache.xmlbeans.XmlObject");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlAnySimpleType", "String");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlAnyURI", "String");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlBase64Binary", "byte[]");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlBoolean", "boolean");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlByte", "byte");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlDate", "java.util.Calendar");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlDateTime", "java.util.Calendar");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlDecimal", "java.math.BigDecimal");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlDouble", "double");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlDuration", "org.apache.xmlbeans.GDuration");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlENTITIES", "String");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlENTITY", "String");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlFloat", "float");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlGDay", "java.util.Calendar");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlGMonth", "java.util.Calendar");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlGMonthDay", "java.util.Calendar");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlGYear", "java.util.Calendar");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlGYearMonth", "java.util.Calendar");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlHexBinary", "byte[]");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlID", "String");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlIDREF", "String");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlIDREFS", "String");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlInt", "int");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlInteger", "java.math.BigInteger");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlLanguage", "String");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlLong", "long");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlName", "String");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlNCNAME", "String");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlNegativeInteger", "java.math.BigInteger");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlNMTOKEN", "String");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlNMTOKENS", "String");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlNonNegativeInteger", "java.math.BigInteger");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlNonPositiveInteger", "java.math.BigInteger");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlNormalizedString", "String");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlNOTATION", "org.apache.xmlbeans.XmlNOTATION");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlPositiveInteger", "java.math.BigInteger");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlQName", "javax.xml.namespace.QName");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlShort", "short");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlString", "String");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlTime", "java.util.Calendar");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlToken", "String");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlUnsignedByte", "short");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlUnsignedInt", "long");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlUnsignedLong", "java.math.BigInteger");
- BUILTIN_TYPES_MAP.put("org.apache.xmlbeans.XmlUnsignedShort", "int");
- }
-
- private XMLBeansSchemaTypeUtils() {
- // helper class
- }
-
- public static String getNaturalJavaClassName(SchemaType st) {
- SchemaType schemaType = st;
- String result = null;
- if (st.getBaseEnumType() != null && !hasBase(st)) {
- return st.getFullJavaName().replace('$', '.') + ".Enum";
- } else if (st.isSimpleType() && !st.isBuiltinType()) {
- schemaType = st.getBaseType();
- while (schemaType != null && !schemaType.isBuiltinType()) {
- schemaType = schemaType.getBaseType();
- }
- }
- if (schemaType != null && schemaType.isBuiltinType()) {
- result = BUILTIN_TYPES_MAP.get(schemaType.getFullJavaName());
- } else if (schemaType != null) {
- result = schemaType.getFullJavaName().replace('$', '.');
- }
- return result;
-
- }
- private static boolean hasBase(SchemaType sType) {
- boolean hasBase;
- SchemaType baseEnumType = sType.getBaseEnumType();
- if (baseEnumType.isAnonymousType() && baseEnumType.isSkippedAnonymousType()) {
- if (sType.getContentBasedOnType() != null) {
- hasBase = sType.getContentBasedOnType().getBaseType() != baseEnumType;
- } else {
- hasBase = sType.getBaseType() != baseEnumType;
- }
- } else {
- hasBase = baseEnumType != sType;
- }
- return hasBase;
- }
-}