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 11:20:42 UTC
[3/3] cxf git commit: [CXF-7194] Removing rt-databindings-jixb
[CXF-7194] Removing rt-databindings-jixb
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/52ccbfa5
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/52ccbfa5
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/52ccbfa5
Branch: refs/heads/master
Commit: 52ccbfa5e9fe59662eb8e534c79d4cd48a370703
Parents: 69891e8
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Fri Dec 23 11:20:21 2016 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Fri Dec 23 11:20:21 2016 +0000
----------------------------------------------------------------------
rt/databinding/jibx/pom.xml | 96 ----
.../org/apache/cxf/jibx/JibxDataBinding.java | 160 -------
.../org/apache/cxf/jibx/JibxDataReader.java | 97 ----
.../org/apache/cxf/jibx/JibxDataWriter.java | 99 ----
.../apache/cxf/jibx/JibxNullBindingFactory.java | 58 ---
.../apache/cxf/jibx/JibxSchemaInitializer.java | 116 -----
.../org/apache/cxf/jibx/JibxSimpleTypes.java | 240 ----------
.../main/java/org/apache/cxf/jibx/JibxUtil.java | 236 ----------
.../org/apache/cxf/jibx/JibxWrapperHelper.java | 46 --
.../apache/cxf/jibx/tools/JibxSchemaHelper.java | 230 ----------
.../cxf/jibx/tools/JibxSchemaResolver.java | 95 ----
.../cxf/jibx/tools/JibxToolingDataBinding.java | 446 -------------------
.../jibx/tools/JibxToolingProblemHandler.java | 68 ---
.../main/resources/META-INF/tools-plugin.xml | 22 -
.../org/apache/cxf/jibx/AbstractJibxTest.java | 113 -----
.../apache/cxf/jibx/PrimitiveTypesService.java | 76 ----
.../org/apache/cxf/jibx/PrimitiveTypesTest.java | 78 ----
.../jibx/src/test/java/resources/binding.xml | 15 -
.../ws/library/types/BookInformation.class | Bin 4124 -> 0 bytes
.../JiBX_bindingBookInformation_access.class | Bin 2610 -> 0 bytes
.../JiBX_bindingBookInformation_access2.class | Bin 2612 -> 0 bytes
.../ws/library/types/JiBX_bindingFactory.class | Bin 2133 -> 0 bytes
.../types/JiBX_bindingMungeAdapter.class | Bin 1991 -> 0 bytes
.../ws/library/types/TypeInformation.class | Bin 736 -> 0 bytes
.../jibx/src/test/java/resources/types.xsd | 32 --
.../jibx/src/test/resources/binding.xml | 15 -
.../ws/library/types/BookInformation.class | Bin 4124 -> 0 bytes
.../JiBX_bindingBookInformation_access.class | Bin 2610 -> 0 bytes
.../JiBX_bindingBookInformation_access2.class | Bin 2612 -> 0 bytes
.../ws/library/types/JiBX_bindingFactory.class | Bin 2133 -> 0 bytes
.../types/JiBX_bindingMungeAdapter.class | Bin 1991 -> 0 bytes
.../ws/library/types/TypeInformation.class | Bin 736 -> 0 bytes
.../jibx/src/test/resources/types.xsd | 14 -
rt/databinding/pom.xml | 1 -
systests/databinding/pom.xml | 5 -
systests/jaxrs/pom.xml | 5 -
systests/jibx/databinding-jibx/pom.xml | 328 --------------
.../cxf/systest/jibx/ClientServerJibxTest.java | 144 ------
.../apache/cxf/systest/jibx/GreeterImpl.java | 76 ----
.../cxf/systest/jibx/PutLastTradePriceImpl.java | 62 ---
.../org/apache/cxf/systest/jibx/Server.java | 58 ---
.../java/org/apache/cxf/systest/jibx/cxf.xml | 32 --
.../jibx/doc_lit_bare.wsdl | 114 -----
.../jibx/hello_world.wsdl | 169 -------
systests/jibx/jaxrs-jibx/pom.xml | 329 --------------
.../systest/jaxrs/BookDataBindingServer.java | 82 ----
.../cxf/systest/jaxrs/JAXRSDataBindingTest.java | 54 ---
.../cxf/systest/jaxrs/jibx/JibxResource.java | 37 --
.../jaxrs_databinding/WEB-INF/beans.xml | 39 --
.../resources/jaxrs_databinding/WEB-INF/web.xml | 45 --
.../src/test/resources/jibx/types.xsd | 9 -
systests/jibx/pom.xml | 38 --
systests/pom.xml | 1 -
53 files changed, 3980 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/52ccbfa5/rt/databinding/jibx/pom.xml
----------------------------------------------------------------------
diff --git a/rt/databinding/jibx/pom.xml b/rt/databinding/jibx/pom.xml
deleted file mode 100644
index 36b07ce..0000000
--- a/rt/databinding/jibx/pom.xml
+++ /dev/null
@@ -1,96 +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-jibx</artifactId>
- <packaging>bundle</packaging>
- <name>Apache CXF Runtime JiBX DataBinding</name>
- <description>Apache CXF Runtime JiBX 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>
- <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>
- </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.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>
-</project>
http://git-wip-us.apache.org/repos/asf/cxf/blob/52ccbfa5/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataBinding.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataBinding.java b/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataBinding.java
deleted file mode 100644
index 21c3802..0000000
--- a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataBinding.java
+++ /dev/null
@@ -1,160 +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.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.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 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());
-
- 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;
-
- Method[] 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()]));
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/52ccbfa5/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataReader.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataReader.java b/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataReader.java
deleted file mode 100644
index 6df2952..0000000
--- a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataReader.java
+++ /dev/null
@@ -1,97 +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.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) {
- try {
- UnmarshallingContext ctx = getUnmarshallingContext(input, type);
- return ctx.unmarshalElement(type);
- } catch (JiBXException e) {
- throw new RuntimeException(e);
- }
- }
-
- 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;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/52ccbfa5/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataWriter.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataWriter.java b/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataWriter.java
deleted file mode 100644
index 9498caf..0000000
--- a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxDataWriter.java
+++ /dev/null
@@ -1,99 +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.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) {
- 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 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();
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/52ccbfa5/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxNullBindingFactory.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxNullBindingFactory.java b/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxNullBindingFactory.java
deleted file mode 100644
index 5a49ea2..0000000
--- a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxNullBindingFactory.java
+++ /dev/null
@@ -1,58 +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.jibx;
-
-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 {
-
- 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;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/52ccbfa5/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSchemaInitializer.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSchemaInitializer.java b/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSchemaInitializer.java
deleted file mode 100644
index 85ef7f6..0000000
--- a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSchemaInitializer.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.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);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/52ccbfa5/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSimpleTypes.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSimpleTypes.java b/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSimpleTypes.java
deleted file mode 100644
index daaf872..0000000
--- a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxSimpleTypes.java
+++ /dev/null
@@ -1,240 +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.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 = simplePrimitiveTypeMap.get(jtype);
- if (stype == null) {
- stype = 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;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/52ccbfa5/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxUtil.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxUtil.java b/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxUtil.java
deleted file mode 100644
index 96ffc60..0000000
--- a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxUtil.java
+++ /dev/null
@@ -1,236 +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.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 = simplePrimitiveTypeMap.get(jtype);
- if (stype == null) {
- stype = 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;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/52ccbfa5/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxWrapperHelper.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxWrapperHelper.java b/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxWrapperHelper.java
deleted file mode 100644
index 011ba80..0000000
--- a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/JibxWrapperHelper.java
+++ /dev/null
@@ -1,46 +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.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;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/52ccbfa5/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaHelper.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaHelper.java b/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaHelper.java
deleted file mode 100644
index b2a2d92..0000000
--- a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaHelper.java
+++ /dev/null
@@ -1,230 +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.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;
-
-public class JibxSchemaHelper {
-
- private final Map<String, Element> schemaList;
- private List<JibxSchemaResolver> resolvers;
- 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<JibxSchemaResolver> r) {
- this.resolvers = r;
- List<Definition> defList = new ArrayList<Definition>();
- parseImports(def, defList);
- extractSchema(def, schemaCol);
- // 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);
- // added
- getSchemaList(def2);
- done.put(def2, def2);
- }
- }
- }
-
- private void extractSchema(Definition def, SchemaCollection schemaCol) {
- 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, schemaElem);
- 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();
- String name = docBaseURI;
- for (JibxSchemaResolver r : resolvers) {
- if (schemaEle == r.getElement()) {
- name = r.getId();
- }
- }
-
- if (schemaList.get(name) == null) {
- schemaList.put(name, 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;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/52ccbfa5/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaResolver.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaResolver.java b/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaResolver.java
deleted file mode 100644
index d062f65..0000000
--- a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxSchemaResolver.java
+++ /dev/null
@@ -1,95 +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.jibx.tools;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import org.w3c.dom.Element;
-
-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 Element element;
- private SchemaCollection collection;
-
- public JibxSchemaResolver(String id, XmlSchema schema, SchemaCollection collection, Element element) {
- this.id = id;
- setName(id);
- this.schema = schema;
- this.collection = collection;
- this.element = element;
- }
-
- public InputStream getContent() throws IOException {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- schema.write(bos);
- return new ByteArrayInputStream(bos.toByteArray());
- }
-
- public String getId() {
- return id;
- }
-
- public Element getElement() {
- return element;
- }
-
- private void setName(String uri) {
- this.name = uri;
- //this.name = uri.substring(uri.lastIndexOf('/') + 1);
- }
-
- public String getName() {
- return name;
- }
-
- 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, null);
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/52ccbfa5/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxToolingDataBinding.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxToolingDataBinding.java b/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxToolingDataBinding.java
deleted file mode 100644
index 561f2d5..0000000
--- a/rt/databinding/jibx/src/main/java/org/apache/cxf/jibx/tools/JibxToolingDataBinding.java
+++ /dev/null
@@ -1,446 +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.jibx.tools;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.wsdl.Definition;
-import javax.wsdl.WSDLException;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
-import javax.xml.namespace.QName;
-
-import org.w3c.dom.Element;
-
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.common.util.URIParserUtil;
-import org.apache.cxf.common.xmlschema.SchemaCollection;
-import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.tools.common.ClassUtils;
-import org.apache.cxf.tools.common.ToolConstants;
-import org.apache.cxf.tools.common.ToolContext;
-import org.apache.cxf.tools.common.ToolException;
-import org.apache.cxf.tools.common.model.DefaultValueWriter;
-import org.apache.cxf.tools.util.ClassCollector;
-import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
-import org.jibx.binding.Compile;
-import org.jibx.binding.Utility;
-import org.jibx.binding.model.BindingElement;
-import org.jibx.binding.model.BindingHolder;
-import org.jibx.binding.model.BindingOrganizer;
-import org.jibx.binding.model.BindingUtils;
-import org.jibx.binding.model.MappingElement;
-import org.jibx.binding.model.ModelVisitor;
-import org.jibx.binding.model.NamespaceElement;
-import org.jibx.binding.model.TreeContext;
-import org.jibx.binding.model.ValueElement;
-import org.jibx.runtime.JiBXException;
-import org.jibx.schema.codegen.CodeGen;
-import org.jibx.schema.codegen.PackageHolder;
-import org.jibx.schema.codegen.PackageOrganizer;
-import org.jibx.schema.codegen.StringObjectPair;
-import org.jibx.schema.codegen.custom.SchemaCustom;
-import org.jibx.schema.codegen.custom.SchemasetCustom;
-import org.jibx.schema.validation.ProblemMultiHandler;
-import org.jibx.util.DummyClassLocator;
-
-
-public class JibxToolingDataBinding implements DataBindingProfile {
-
- private JibxToolingProblemHandler problemHandler = new JibxToolingProblemHandler();
- private Map<String, Element> schemaMap = new HashMap<String, Element>();
- private List<JibxSchemaResolver> resolvers = new ArrayList<JibxSchemaResolver>();
-
- private Map<org.jibx.runtime.QName, MappingElement> types = new HashMap<org.jibx.runtime.QName,
- MappingElement>();
- private Map<org.jibx.runtime.QName, MappingElement> elements = new HashMap<org.jibx.runtime.QName,
- MappingElement>();
-
- public DefaultValueWriter createDefaultValueWriter(QName qn, boolean element) {
- return null;
- }
-
- public DefaultValueWriter createDefaultValueWriterForWrappedElement(QName wrapperElement, QName qn) {
- return null;
- }
-
- public void generate(ToolContext context) throws ToolException {
- try {
- JiBXCodeGen codegen = new JiBXCodeGen();
-
- ProblemMultiHandler handler = new ProblemMultiHandler();
- handler.addHandler(problemHandler);
- codegen.setProblemHandler(handler);
-
- // Setting the source (or the output) directory
- String sourcePath = (String)context.get(ToolConstants.CFG_OUTPUTDIR);
- if (sourcePath == null) {
- sourcePath = (new File(".")).getAbsolutePath();
- }
- File generatePath = new File(sourcePath);
- if (!generatePath.exists()) {
- generatePath.mkdir();
- }
- codegen.setGeneratePath(generatePath);
- String wsdlUrl = URIParserUtil.getAbsoluteURI((String)context.get(ToolConstants.CFG_WSDLURL));
- if (wsdlUrl.contains("/")) {
- wsdlUrl = wsdlUrl.substring(wsdlUrl.lastIndexOf('/'));
- }
- if (wsdlUrl.toLowerCase().endsWith(".wsdl")) {
- wsdlUrl = wsdlUrl.substring(0, wsdlUrl.length() - 5);
- }
- wsdlUrl += ".xml";
- File jibxDir = new File(generatePath, "jibx_bindings/");
- jibxDir.mkdirs();
- codegen.setBindingName("jibx_bindings/" + wsdlUrl);
-
- String classPath = (String)context.get(ToolConstants.CFG_CLASSDIR);
- if (classPath == null) {
- classPath = (new File(".")).getAbsolutePath();
- }
- File compilePath = new File(classPath);
- if (!compilePath.exists()) {
- compilePath.mkdir();
- }
- codegen.setCompilePath(compilePath);
-
- // Set schema resolver list
-
- codegen.setFileset(resolvers);
-
- // Set Customization
- String[] bindingFiles = (String[])context.get(ToolConstants.CFG_BINDING);
- SchemasetCustom customRoot;
- if (bindingFiles == null || bindingFiles.length == 0) {
- customRoot = defaultSchemasetCustom(schemaMap);
- } else {
- customRoot = SchemasetCustom.loadCustomizations(bindingFiles[0], handler);
- }
- // force to retrain types information in the generated binding model
- forceTypes(customRoot);
- codegen.setCustomRoot(customRoot);
-
- codegen.generate();
-
- if (Boolean.valueOf((String)context.get(ToolConstants.CFG_COMPILE))) {
- if (context.get(ToolConstants.CFG_SOURCEDIR) == null) {
- context.put(ToolConstants.CFG_SOURCEDIR, generatePath.getAbsolutePath());
- }
- if (context.get(ToolConstants.CFG_CLASSDIR) == null) {
- context.put(ToolConstants.CFG_CLASSDIR, compilePath.getAbsolutePath());
- }
-
- ClassCollector collector = new ClassCollector();
- addGeneratedSourceFiles(codegen.getPackageOrganizer(), collector);
- context.put(ClassCollector.class, collector);
-
- // compile generated source files
- (new ClassUtils()).compile(context);
-
- // jibx binding compiler
- codegen.compile();
- }
-
- Map<QName, Object> formats = new HashMap<QName, Object>();
- BindingUtils.getDefinitions(codegen.getRootBinding(), types, elements, formats);
-
- Iterator<?> it = codegen.getBindingOrganizer().iterateBindings();
- while (it.hasNext()) {
- BindingHolder o = (BindingHolder)it.next();
- if (o != null) {
- getDefinitions(o, types, elements);
- }
- }
-
- } catch (Exception e) {
- problemHandler.handleSevere("", e);
- }
- }
- public static void getDefinitions(final BindingHolder holder,
- final Map<org.jibx.runtime.QName, MappingElement> types,
- final Map<org.jibx.runtime.QName, MappingElement> elems) {
- TreeContext ctx = new TreeContext(new DummyClassLocator());
- ModelVisitor visitor = new ModelVisitor() {
- public boolean visit(MappingElement mapping) {
- org.jibx.runtime.QName qname = mapping.getTypeQName();
- if (qname != null) {
- types.put(qname, mapping);
- }
- String name = mapping.getName();
- if (name != null) {
- NamespaceElement ns = mapping.getNamespace();
- if (ns == null) {
- qname = new org.jibx.runtime.QName(holder.getElementDefaultNamespace(), name);
- } else {
- qname = new org.jibx.runtime.QName(mapping.getNamespace().getUri(), name);
- }
- elems.put(qname, mapping);
- }
- return false;
- }
- };
- ctx.tourTree(holder.getBinding(), visitor);
- }
- public String getType(QName qn, boolean element) {
- MappingElement mappingElement = element ? elements.get(jibxQName(qn)) : types.get(jibxQName(qn));
- return (mappingElement == null) ? null : mappingElement.getClassName();
- }
-
- public String getWrappedElementType(QName wrapperElement, QName item) {
- MappingElement mappingElement = elements.get(jibxQName(wrapperElement));
- return (mappingElement == null) ? null : itemType(mappingElement, item);
- }
-
- public void initialize(ToolContext context) throws ToolException {
- context.put(ToolConstants.RUNTIME_DATABINDING_CLASS,
- "org.apache.cxf.jibx.JibxDataBinding.class");
-
- String wsdlUrl = (String)context.get(ToolConstants.CFG_WSDLURL);
- initializeJiBXCodeGenerator(wsdlUrl);
- }
-
- private void initializeJiBXCodeGenerator(String wsdlUrl) {
-
- try {
- loadWsdl(wsdlUrl, this.schemaMap, this.resolvers);
- } catch (WSDLException e) {
- problemHandler.handleSevere("Error in loading wsdl file at :" + wsdlUrl, e);
- }
- }
-
- private static void loadWsdl(String wsdlUrl, Map<String, Element> schemaMap,
- List<JibxSchemaResolver> resolvers) throws WSDLException {
- WSDLFactory factory = WSDLFactory.newInstance();
- WSDLReader reader = factory.newWSDLReader();
- Definition parentDef = reader.readWSDL(wsdlUrl);
-
- JibxSchemaHelper util = new JibxSchemaHelper(BusFactory.getDefaultBus(), schemaMap);
- util.getSchemas(parentDef, new SchemaCollection(), resolvers);
- }
-
- private static org.jibx.runtime.QName jibxQName(QName qname) {
- return new org.jibx.runtime.QName(qname.getNamespaceURI(), qname.getLocalPart());
- }
-
- private static String itemType(MappingElement mappingElement, QName qName) {
- String localPart = qName.getLocalPart();
- for (Iterator<?> childIterator = mappingElement.childIterator(); childIterator.hasNext();) {
- Object child = childIterator.next();
- if (child instanceof ValueElement) {
- ValueElement valueElement = (ValueElement)child;
- if (localPart.equals(valueElement.getName())) {
- return valueElement.getDeclaredType();
- }
- }
- // TODO
- /*
- * else if (child instanceof ) { .. } else if () { .. }
- */
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- private SchemasetCustom defaultSchemasetCustom(Map<String, Element> smap) {
- SchemasetCustom customRoot = new SchemasetCustom((SchemasetCustom)null);
- Set<String> schemaIds = smap.keySet();
- for (String schemaId : schemaIds) {
- SchemaCustom schemaCustom = new SchemaCustom(customRoot);
- schemaCustom.setName(schemaId);
- schemaCustom.setForceTypes(Boolean.TRUE);
- schemaCustom.setNamespace(smap.get(schemaId).getAttribute("targetNamespace"));
- customRoot.getChildren().add(schemaCustom);
- }
- for (JibxSchemaResolver r : resolvers) {
- if (!schemaIds.contains(r.getId())) {
- SchemaCustom schemaCustom = new SchemaCustom(customRoot);
- schemaCustom.setName(r.getName());
- schemaCustom.setNamespace(r.getElement().getAttribute("targetNamespace"));
- schemaCustom.setForceTypes(Boolean.TRUE);
- customRoot.getChildren().add(schemaCustom);
- }
- }
- return customRoot;
- }
-
- private static void forceTypes(SchemasetCustom customRoot) {
- List<?> children = customRoot.getChildren();
- for (Object child : children) {
- SchemaCustom schemaCustom = (SchemaCustom)child;
- schemaCustom.setForceTypes(Boolean.TRUE);
- }
- }
-
- private static void addGeneratedSourceFiles(PackageOrganizer o, ClassCollector collector) {
- List<PackageHolder> packages = CastUtils.cast(o.getPackages());
- for (PackageHolder pkgHolder : packages) {
- if (pkgHolder.getTopClassCount() > 0) {
- String pkgName = pkgHolder.getName();
- StringObjectPair[] classFields = pkgHolder.getClassFields();
- for (int i = 0; i < classFields.length; i++) {
- String fullname = classFields[i].getKey();
- if (fullname.contains("$")) { // CHECK
- continue;
- }
- collector.addTypesClassName(pkgName, fullname.replace(pkgName, ""), fullname);
- }
- }
- }
- }
-
- /**
- * A helper class to manage JiBX specific code generation parameters and initiate code generation. Every
- * member variable is a parameter for JiBX code generator and carries a default value in case it is not
- * set by CXF code generator framework.
- */
- static class JiBXCodeGen {
- private ProblemMultiHandler problemHandler;
- private SchemasetCustom customRoot;
- private URL schemaRoot;
- private File generatePath;
- private boolean verbose;
- private String usingNamespace;
- private String nonamespacePackage;
- private String bindingName = "binding";
- private List<?> fileset;
- private List<?> includePaths = new ArrayList<Object>();
- private File modelFile;
- private BindingElement rootBinding;
- private File compilePath;
- private PackageOrganizer packageOrganizer;
- private BindingOrganizer bindingOrganizer;
-
- public void setProblemHandler(ProblemMultiHandler problemHandler) {
- this.problemHandler = problemHandler;
- }
-
- public BindingOrganizer getBindingOrganizer() {
- return bindingOrganizer;
- }
-
- public void setCustomRoot(SchemasetCustom customRoot) {
- this.customRoot = customRoot;
- }
-
- public void setSchemaRoot(URL schemaRoot) {
- this.schemaRoot = schemaRoot;
- }
-
- public void setGeneratePath(File generatePath) {
- this.generatePath = generatePath;
- }
-
- public void setVerbose(boolean verbose) {
- this.verbose = verbose;
- }
-
- public void setUsingNamespace(String usingNamespace) {
- this.usingNamespace = usingNamespace;
- }
-
- public void setNonamespacePackage(String nonamespacePackage) {
- this.nonamespacePackage = nonamespacePackage;
- }
-
- public void setBindingName(String bindingName) {
- this.bindingName = bindingName;
- }
-
- public void setFileset(List<?> fileset) {
- this.fileset = fileset;
- }
-
- public void setIncludePaths(List<?> includePaths) {
- this.includePaths = includePaths;
- }
-
- public void setModelFile(File modelFile) {
- this.modelFile = modelFile;
- }
-
- /**
- * Returns the {@link BindingElement} instance that contains binding information of generated code.
- * Hence it is <strong>only meaningful<strong> after executing {@link #generate()} method.
- *
- * @return the binding element instance that contains binding info of generated code
- */
- public BindingElement getRootBinding() {
- return rootBinding;
- }
-
- public PackageOrganizer getPackageOrganizer() {
- return packageOrganizer;
- }
-
- public void setCompilePath(File compilePath) {
- this.compilePath = compilePath;
- }
-
- /**
- * Generates code based on parameters set. Once the code is generated {@link #rootBinding} is set
- * which can be retrieved by {@link #getRootBinding()}
- *
- * @throws JiBXException if thrown by JiBX code generator
- * @throws IOException if thrown by JiBX code generator
- */
- public void generate() throws JiBXException, IOException {
- CodeGen codegen = new CodeGen(customRoot, schemaRoot, generatePath);
-
- codegen.generate(verbose, usingNamespace, nonamespacePackage, bindingName, fileset, includePaths,
- modelFile, problemHandler);
- setPostGenerateInfo(codegen);
- }
-
- public void compile() throws JiBXException {
- Compile compiler = new Compile();
- String path = generatePath.getAbsolutePath();
- if (!path.endsWith(File.separator)) {
- path = path + File.separator;
- }
-
- List<String> clsPath = new ArrayList<String>();
- clsPath.add(compilePath.getAbsolutePath());
- clsPath.addAll(Arrays.asList(Utility.getClassPaths()));
-
- String[] clsPathSet = clsPath.toArray(new String[clsPath.size()]);
- String[] bindingSet = new String[] {
- path + bindingName + ".xml"
- };
-
- compiler.compile(clsPathSet, bindingSet);
- }
-
- private void setPostGenerateInfo(CodeGen codegen) {
- this.bindingOrganizer = codegen.getBindingDirectory();
- this.rootBinding = codegen.getRootBinding();
- this.packageOrganizer = codegen.getPackageDirectory();
- }
-
- }
-}