cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r614769 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/databinding/ rt/core/src/main/java/org/apache/cxf/databinding/source/ rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ rt/databinding/jaxb/src/main/java...
Date Thu, 24 Jan 2008 02:24:39 GMT
Author: bimargulies
Date: Wed Jan 23 18:24:37 2008
New Revision: 614769

URL: http://svn.apache.org/viewvc?rev=614769&view=rev
Log:
Try a second time to clean up the dueling AbstractDataBindings.

Removed:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/AbstractDataBinding.java
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
    incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java?rev=614769&r1=614768&r2=614769&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java
(original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractDataBinding.java
Wed Jan 23 18:24:37 2008
@@ -19,17 +19,107 @@
 
 package org.apache.cxf.databinding;
 
+import java.util.Collection;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
+import javax.xml.transform.dom.DOMSource;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.common.xmlschema.SchemaCollection;
+import org.apache.cxf.service.model.SchemaInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.ws.commons.schema.XmlSchema;
 
 /**
  * Supply default implementations, as appropriate, for DataBinding. 
  */
 public abstract class AbstractDataBinding implements DataBinding {
     protected int mtomThreshold;
+    
+    private Collection<DOMSource> schemas;
+    private Map<String, String> namespaceMap;
+
+    public Collection<DOMSource> getSchemas() {
+        return schemas;
+    }
+
+    public void setSchemas(Collection<DOMSource> schemas) {
+        this.schemas = schemas;
+    }
 
-    /** {@inheritDoc}*/
+    public XmlSchema addSchemaDocument(ServiceInfo serviceInfo, SchemaCollection col, Document
d,
+                                          String systemId) {
+        String ns = d.getDocumentElement().getAttribute("targetNamespace");
+        if (StringUtils.isEmpty(ns)) {
+            ns = serviceInfo.getInterface().getName().getNamespaceURI();
+            d.getDocumentElement().setAttribute("targetNamespace", ns);
+        }
+
+        NodeList nodes = d.getDocumentElement().getChildNodes();
+        for (int i = 0; i < nodes.getLength(); i++) {
+            Node n = nodes.item(i);
+            if (n instanceof Element) {
+                Element e = (Element)n;
+                if (e.getLocalName().equals("import")) {
+                    e.removeAttribute("schemaLocation");
+                }
+            }
+        }
+        SchemaInfo schema = new SchemaInfo(serviceInfo, ns);
+        schema.setSystemId(systemId);
+        XmlSchema xmlSchema = col.read(d, null);
+        schema.setSchema(xmlSchema);
+        serviceInfo.addSchema(schema);
+        return xmlSchema;
+    }
+    
+    /**
+      * @return Returns the namespaceMap.
+     */
+    public Map<String, String> getNamespaceMap() {
+        return namespaceMap;
+    }
+
+    /**
+     * @param namespaceMap The namespaceMap to set.
+     */
+    public void setNamespaceMap(Map<String, String> namespaceMap) {
+        // make some checks. This is a map from namespace to prefix, but we want unique prefixes.
+        if (namespaceMap != null) {
+            Set<String> prefixesSoFar = new HashSet<String>();
+            for (Map.Entry<String, String> mapping : namespaceMap.entrySet()) {
+                if (prefixesSoFar.contains(mapping.getValue())) {
+                    throw new IllegalArgumentException("Duplicate prefix " + mapping.getValue());
+                }
+            }
+        }
+        this.namespaceMap = namespaceMap;
+    }
+
+    /** 
+     * Provide explicit mappings to ReflectionServiceFactory.
+     * {@inheritDoc}
+     * */
     public Map<String, String> getDeclaredNamespaceMappings() {
-        return null;
+        return this.namespaceMap;
+    }
+
+    protected static void checkNamespaceMap(Map<String, String> namespaceMap) {
+        // make some checks. This is a map from namespace to prefix, but we want unique prefixes.
+        if (namespaceMap != null) {
+            Set<String> prefixesSoFar = new HashSet<String>();
+            for (Map.Entry<String, String> mapping : namespaceMap.entrySet()) {
+                if (prefixesSoFar.contains(mapping.getValue())) {
+                    throw new IllegalArgumentException("Duplicate prefix " + mapping.getValue());
+                }
+            }
+        }
     }
 
     public int getMtomThreshold() {

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java?rev=614769&r1=614768&r2=614769&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
Wed Jan 23 18:24:37 2008
@@ -50,9 +50,9 @@
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.SOAPConstants;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
+import org.apache.cxf.databinding.AbstractDataBinding;
 import org.apache.cxf.databinding.DataReader;
 import org.apache.cxf.databinding.DataWriter;
-import org.apache.cxf.databinding.source.AbstractDataBinding;
 import org.apache.cxf.frontend.MethodDispatcher;
 import org.apache.cxf.frontend.SimpleMethodDispatcher;
 import org.apache.cxf.helpers.CastUtils;

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java?rev=614769&r1=614768&r2=614769&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
Wed Jan 23 18:24:37 2008
@@ -62,9 +62,9 @@
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
+import org.apache.cxf.databinding.AbstractDataBinding;
 import org.apache.cxf.databinding.DataReader;
 import org.apache.cxf.databinding.DataWriter;
-import org.apache.cxf.databinding.source.AbstractDataBinding;
 import org.apache.cxf.jaxb.io.DataReaderImpl;
 import org.apache.cxf.jaxb.io.DataWriterImpl;
 import org.apache.cxf.service.Service;

Modified: incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java?rev=614769&r1=614768&r2=614769&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java
(original)
+++ incubator/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/XmlBeansDataBinding.java
Wed Jan 23 18:24:37 2008
@@ -31,10 +31,9 @@
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
-import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.databinding.AbstractDataBinding;
 import org.apache.cxf.databinding.DataReader;
 import org.apache.cxf.databinding.DataWriter;
-import org.apache.cxf.databinding.source.AbstractDataBinding;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.ServiceInfo;
 
@@ -42,7 +41,7 @@
 /**
  * 
  */
-public class XmlBeansDataBinding extends AbstractDataBinding implements DataBinding {
+public class XmlBeansDataBinding extends AbstractDataBinding {
     private static final Logger LOG = LogUtils.getLogger(XmlBeansDataBinding.class);
 
     private static final Class<?> SUPPORTED_READER_FORMATS[] = new Class<?>[]
{XMLStreamReader.class};

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java?rev=614769&r1=614768&r2=614769&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
Wed Jan 23 18:24:37 2008
@@ -31,8 +31,8 @@
 import org.apache.cxf.BusException;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.databinding.AbstractDataBinding;
 import org.apache.cxf.databinding.DataBinding;
-import org.apache.cxf.databinding.source.AbstractDataBinding;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
 import org.apache.cxf.endpoint.Server;



Mime
View raw message