cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r760861 - in /cxf/trunk: ./ api/src/main/java/org/apache/cxf/databinding/ api/src/main/java/org/apache/cxf/io/ common/common/src/main/java/org/apache/cxf/staxutils/ common/wstx-msv-validation/ common/wstx-msv-validation/src/main/java/org/ap...
Date Wed, 01 Apr 2009 11:49:23 GMT
Author: bimargulies
Date: Wed Apr  1 11:49:22 2009
New Revision: 760861

URL: http://svn.apache.org/viewvc?rev=760861&view=rev
Log:
Progress toward Aegis schema validation. Sadly, this now hits a bug in the validation support
in woodstox.

Added:
    cxf/trunk/api/src/main/java/org/apache/cxf/io/StaxValidationManager.java
      - copied, changed from r760066, cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxValidationManager.java
    cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/EmbeddedSchema.java
  (with props)
    cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/cxf-extension-wstx-msv-validation.xml
  (with props)
    cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/cxf.extension
Removed:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxValidationManager.java
Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataBindingValidation2.java
    cxf/trunk/common/wstx-msv-validation/pom.xml
    cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/ResolvingGrammarReaderController.java
    cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/Stax2ValidationUtils.java
    cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/W3CMultiSchemaFactory.java
    cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/WoodstoxValidationImpl.java
    cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/bus-extensions.xml
    cxf/trunk/parent/pom.xml
    cxf/trunk/pom.xml
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataReader.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataWriter.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java
    cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataBindingValidation2.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataBindingValidation2.java?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataBindingValidation2.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/databinding/DataBindingValidation2.java Wed
Apr  1 11:49:22 2009
@@ -19,17 +19,13 @@
 
 package org.apache.cxf.databinding;
 
-import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.cxf.service.model.ServiceInfo;
 
 /**
  * If a DataReader<T> implements this interface, it prefers to be supplied with schema
- * for validation via an XmlSchemaCollection instead of via a packaged Schema object.
+ * for validation via a service model instead of via a packaged Schema object.
  */
 public interface DataBindingValidation2 {
-    /**
-     * 
-     * @param schema
-     */
-    void setSchema(XmlSchemaCollection schema);
+    void setValidationServiceModel(ServiceInfo serviceInfo);
 
 }

Copied: cxf/trunk/api/src/main/java/org/apache/cxf/io/StaxValidationManager.java (from r760066,
cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxValidationManager.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/io/StaxValidationManager.java?p2=cxf/trunk/api/src/main/java/org/apache/cxf/io/StaxValidationManager.java&p1=cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxValidationManager.java&r1=760066&r2=760861&rev=760861&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxValidationManager.java
(original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/io/StaxValidationManager.java Wed Apr  1 11:49:22
2009
@@ -17,12 +17,13 @@
  * under the License.
  */
 
-package org.apache.cxf.staxutils;
+package org.apache.cxf.io;
 
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
 
-import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.cxf.service.model.ServiceInfo;
 
 /**
  * This interface defines a bus service for Stax validation.
@@ -35,6 +36,7 @@
      * @param schemas
      * @throws XMLStreamException 
      */
-    void setupValidation(XMLStreamReader reader, XmlSchemaCollection schemas) throws XMLStreamException;
+    void setupValidation(XMLStreamReader reader, ServiceInfo serviceInfo) throws XMLStreamException;
+    void setupValidation(XMLStreamWriter writer, ServiceInfo serviceInfo) throws XMLStreamException;
 
 }

Modified: cxf/trunk/common/wstx-msv-validation/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/common/wstx-msv-validation/pom.xml?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/common/wstx-msv-validation/pom.xml (original)
+++ cxf/trunk/common/wstx-msv-validation/pom.xml Wed Apr  1 11:49:22 2009
@@ -54,37 +54,15 @@
     <dependency>
       <groupId>org.codehaus.woodstox</groupId>
       <artifactId>woodstox-core-asl</artifactId>
-      <version>4.0.2</version>
     </dependency>
     <dependency>
-      <groupId>msv</groupId>
-      <artifactId>relaxngDatatype</artifactId>
-      <version>20050913</version>
-    </dependency>
-    <dependency>
-      <groupId>msv</groupId>
-      <artifactId>isorelax</artifactId>
-      <version>20050913</version>
-    </dependency>
-    <dependency>
-      <groupId>msv</groupId>
-      <artifactId>msv</artifactId>
-      <version>20050913</version>
-    </dependency>
-    <dependency>
-      <groupId>msv</groupId>
-      <artifactId>xsdlib</artifactId>
-      <version>20050913</version>
+      <groupId>net.java.dev.msv</groupId>
+      <artifactId>msv-core</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.ws.commons.schema</groupId>
       <artifactId>XmlSchema</artifactId>
     </dependency>
-    <dependency>
-      <groupId>${stax.impl.groupId}</groupId>
-      <artifactId>${stax.impl.artifactId}</artifactId>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
   <scm>
     <connection>scm:svn:http://svn.apache.org/repos/asf/cxf/trunk/common/wstx-msv-validation</connection>

Added: cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/EmbeddedSchema.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/EmbeddedSchema.java?rev=760861&view=auto
==============================================================================
--- cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/EmbeddedSchema.java
(added)
+++ cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/EmbeddedSchema.java
Wed Apr  1 11:49:22 2009
@@ -0,0 +1,49 @@
+/**
+ * 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.wstx_msv_validation;
+
+import org.w3c.dom.Element;
+
+/**
+ * A schema in a DOM Element. This is used in the WSDLSchemaReader to handle inter-schema
cross-references. XS
+ */
+public class EmbeddedSchema {
+
+    private String systemId;
+    private Element schemaElement;
+
+    /**
+     * Create object to represent one of the schemas in a WSDL
+     * 
+     * @param systemId schema system Id.
+     * @param schemaElement Element for the schema.
+     */
+    public EmbeddedSchema(String systemId, Element schemaElement) {
+        this.systemId = systemId;
+        this.schemaElement = schemaElement;
+    }
+
+    public String getSystemId() {
+        return systemId;
+    }
+
+    public Element getSchemaElement() {
+        return schemaElement;
+    }
+}

Propchange: cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/EmbeddedSchema.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/EmbeddedSchema.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/ResolvingGrammarReaderController.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/ResolvingGrammarReaderController.java?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/ResolvingGrammarReaderController.java
(original)
+++ cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/ResolvingGrammarReaderController.java
Wed Apr  1 11:49:22 2009
@@ -24,23 +24,30 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSResourceResolver;
+
 import org.xml.sax.InputSource;
 import org.xml.sax.Locator;
 import org.xml.sax.SAXException;
 
-import com.sun.msv.reader.GrammarReaderController;
+import com.sun.msv.reader.GrammarReaderController2;
+import com.sun.msv.reader.xmlschema.DOMLSInputImpl;
 
 import org.apache.cxf.common.logging.LogUtils;
 
 /**
- * Catch error messages and resolve schema locations. 
+ * Catch error messages and resolve schema locations.
  */
-public class ResolvingGrammarReaderController implements GrammarReaderController {
+public class ResolvingGrammarReaderController implements GrammarReaderController2, LSResourceResolver
{
     private static final Logger LOG = LogUtils.getL7dLogger(ResolvingGrammarReaderController.class);
 
-    private Map<String, InputSource> sources;
+    private Map<String, EmbeddedSchema> sources;
+
+    private String baseURI;
 
-    public ResolvingGrammarReaderController(Map<String, InputSource> sources) {
+    public ResolvingGrammarReaderController(String baseURI, Map<String, EmbeddedSchema>
sources) {
+        this.baseURI = baseURI;
         this.sources = sources;
     }
 
@@ -61,7 +68,21 @@
     }
 
     public InputSource resolveEntity(String publicId, String systemId) throws SAXException,
IOException {
-        // CXF never trucks with publicId's.
-        return sources.get(systemId);
+        return null;
+    }
+
+    public LSResourceResolver getLSResourceResolver() {
+        return this;
+    }
+
+    public LSInput resolveResource(String type, String namespaceURI, String publicId, String
systemId,
+                                   String resolveBaseURI) {
+        EmbeddedSchema embeddedSchema = sources.get(namespaceURI);
+        if (embeddedSchema != null) {
+            return new DOMLSInputImpl(this.baseURI, embeddedSchema.getSystemId(), embeddedSchema
+                .getSchemaElement());
+        } else {
+            return null;
+        }
     }
 }

Modified: cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/Stax2ValidationUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/Stax2ValidationUtils.java?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/Stax2ValidationUtils.java
(original)
+++ cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/Stax2ValidationUtils.java
Wed Apr  1 11:49:22 2009
@@ -19,31 +19,24 @@
 
 package org.apache.cxf.wstx_msv_validation;
 
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.StringWriter;
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.logging.Logger;
 
+import javax.xml.XMLConstants;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
+import javax.xml.stream.XMLStreamWriter;
 
-import org.w3c.dom.Document;
-
-import org.xml.sax.InputSource;
+import org.w3c.dom.Element;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.service.model.SchemaInfo;
+import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.staxutils.DepthXMLStreamReader;
 import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
-import org.apache.ws.commons.schema.XmlSchemaSerializer;
-import org.apache.ws.commons.schema.XmlSchemaSerializer.XmlSchemaSerializerException;
-import org.apache.ws.commons.schema.utils.NamespaceMap;
 import org.codehaus.stax2.XMLStreamReader2;
+import org.codehaus.stax2.XMLStreamWriter2;
 import org.codehaus.stax2.validation.XMLValidationSchema;
 
 /**
@@ -54,34 +47,28 @@
     private static final Logger LOG = LogUtils.getL7dLogger(Stax2ValidationUtils.class);
     
     public Stax2ValidationUtils() {
-        throw new RuntimeException("Not ready");
+        new W3CMultiSchemaFactory(); // will throw if wrong woodstox. 
     }
     
     /** {@inheritDoc}
      * @throws XMLStreamException */
     public void setupValidation(XMLStreamReader reader, 
-                                XmlSchemaCollection schemas) throws XMLStreamException {
+                                ServiceInfo serviceInfo) throws XMLStreamException {
         // Gosh, this is bad, but I don't know a better solution, unless we're willing 
         // to require the stax2 API no matter what.
-        if (reader instanceof DepthXMLStreamReader) {
-            reader = ((DepthXMLStreamReader)reader).getReader();
+        XMLStreamReader effectiveReader = reader;
+        if (effectiveReader instanceof DepthXMLStreamReader) {
+            effectiveReader = ((DepthXMLStreamReader)reader).getReader();
         }
-        XMLStreamReader2 reader2 = (XMLStreamReader2)reader;
-        XMLValidationSchema vs = getValidator(schemas);
+        final XMLStreamReader2 reader2 = (XMLStreamReader2)effectiveReader;
+        XMLValidationSchema vs = getValidator(serviceInfo);
         reader2.validateAgainst(vs);
-
-
     }
-    
-    private Reader getSchemaAsStream(DOMSource source) {
-        StringWriter writer = new StringWriter();
-        StreamResult result = new StreamResult(writer);
-        try {
-            TransformerFactory.newInstance().newTransformer().transform(source, result);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-        return new StringReader(writer.toString());
+
+    public void setupValidation(XMLStreamWriter writer, ServiceInfo serviceInfo) throws XMLStreamException
{
+        XMLStreamWriter2 writer2 = (XMLStreamWriter2)writer;
+        XMLValidationSchema vs = getValidator(serviceInfo);
+        writer2.validateAgainst(vs);
     }
 
     /**
@@ -90,38 +77,34 @@
      * @return
      * @throws XMLStreamException
      */
-    private XMLValidationSchema getValidator(XmlSchemaCollection schemas) throws XMLStreamException
{
-        Map<String, InputSource> sources = new TreeMap<String, InputSource>();
-        XmlSchemaSerializer serializer = new XmlSchemaSerializer();
-        NamespaceMap namespaceContext = new NamespaceMap();
-        for (XmlSchema sch : schemas.getXmlSchemas()) {
+    private XMLValidationSchema getValidator(ServiceInfo serviceInfo) throws XMLStreamException
{
+        Map<String, EmbeddedSchema> sources = new TreeMap<String, EmbeddedSchema>();
+
+        for (SchemaInfo schemaInfo : serviceInfo.getSchemas()) {
+            XmlSchema sch = schemaInfo.getSchema();
             String uri = sch.getTargetNamespace();
+            if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(uri)) {
+                continue;
+            }
             LOG.info(uri);
 
-            if (sch.getNamespaceContext() == null) {
-                sch.setNamespaceContext(namespaceContext);
-            }
-            Document[] serialized;
-            try {
-                serialized = serializer.serializeSchema(sch, false);
-            } catch (XmlSchemaSerializerException e) {
-                throw new RuntimeException(e);
-            }
-            DOMSource domSource = new DOMSource(serialized[0]);
-            Reader schemaReader = getSchemaAsStream(domSource);
-            InputSource inputSource = new InputSource(schemaReader);
+            Element serialized = schemaInfo.getElement();
             String schemaSystemId = sch.getSourceURI();
             if (null == schemaSystemId) {
                 schemaSystemId = sch.getTargetNamespace();
             }
-            inputSource.setSystemId(schemaSystemId);
-            sources.put(schemaSystemId, inputSource);
+            
+            EmbeddedSchema embeddedSchema = 
+                new EmbeddedSchema(schemaSystemId, serialized);
+            sources.put(sch.getTargetNamespace(), embeddedSchema);
         }
         
         W3CMultiSchemaFactory factory = new W3CMultiSchemaFactory();
         XMLValidationSchema vs;
-        vs = factory.loadSchemas(sources);
+        // I don't think that we need the baseURI.
+        vs = factory.loadSchemas(null, sources);
         return vs;
     }
 
+
 }

Modified: cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/W3CMultiSchemaFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/W3CMultiSchemaFactory.java?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/W3CMultiSchemaFactory.java
(original)
+++ cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/W3CMultiSchemaFactory.java
Wed Apr  1 11:49:22 2009
@@ -27,6 +27,7 @@
 
 import javax.xml.parsers.SAXParserFactory;
 import javax.xml.stream.XMLStreamException;
+import javax.xml.transform.dom.DOMSource;
 
 import org.xml.sax.InputSource;
 
@@ -51,14 +52,17 @@
         super(XMLValidationSchema.SCHEMA_ID_W3C_SCHEMA);
     }
     
-    public XMLValidationSchema loadSchemas(Map<String, InputSource> sources) throws
XMLStreamException {
+    public XMLValidationSchema loadSchemas(String baseURI, 
+                                           Map<String, EmbeddedSchema> sources) throws
XMLStreamException {
         parserFactory = getSaxFactory();
         
-        ResolvingGrammarReaderController ctrl = new ResolvingGrammarReaderController(sources);
+        ResolvingGrammarReaderController ctrl = new ResolvingGrammarReaderController(baseURI,
sources);
         xmlSchemaReader = new XMLSchemaReader(ctrl, parserFactory);
         multiSchemaReader = new MultiSchemaReader(xmlSchemaReader);
-        for (InputSource source : sources.values()) {
-            multiSchemaReader.parse(source);
+        for (EmbeddedSchema source : sources.values()) {
+            DOMSource domSource = new DOMSource(source.getSchemaElement());
+            domSource.setSystemId(source.getSystemId());
+            multiSchemaReader.parse(domSource);
         }
         
         XMLSchemaGrammar grammar = multiSchemaReader.getResult();

Modified: cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/WoodstoxValidationImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/WoodstoxValidationImpl.java?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/WoodstoxValidationImpl.java
(original)
+++ cxf/trunk/common/wstx-msv-validation/src/main/java/org/apache/cxf/wstx_msv_validation/WoodstoxValidationImpl.java
Wed Apr  1 11:49:22 2009
@@ -23,11 +23,11 @@
 import javax.annotation.Resource;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.cxf.Bus;
-import org.apache.cxf.staxutils.StaxValidationManager;
-
-import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.cxf.io.StaxValidationManager;
+import org.apache.cxf.service.model.ServiceInfo;
 
 /**
  * 
@@ -61,7 +61,11 @@
     /** {@inheritDoc}
      * @throws XMLStreamException */
     public void setupValidation(XMLStreamReader reader, 
-                                XmlSchemaCollection schemas) throws XMLStreamException {
-        utils.setupValidation(reader, schemas);
+                                ServiceInfo serviceInfo) throws XMLStreamException {
+        utils.setupValidation(reader, serviceInfo);
+    }
+
+    public void setupValidation(XMLStreamWriter writer, ServiceInfo serviceInfo) throws XMLStreamException
{
+        utils.setupValidation(writer, serviceInfo);
     }
 }

Modified: cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/bus-extensions.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/bus-extensions.xml?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/bus-extensions.xml
(original)
+++ cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/bus-extensions.xml
Wed Apr  1 11:49:22 2009
@@ -19,5 +19,5 @@
 -->
 <extensions xmlns="http://cxf.apache.org/bus/extension">
     <extension class="org.apache.cxf.wstx_msv_validation.WoodstoxValidationImpl"
-           interface="org.apache.cxf.staxutils.StaxValidationManager"/>
+           interface="org.apache.cxf.io.StaxValidationManager"/>
 </extensions>

Added: cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/cxf-extension-wstx-msv-validation.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/cxf-extension-wstx-msv-validation.xml?rev=760861&view=auto
==============================================================================
--- cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/cxf-extension-wstx-msv-validation.xml
(added)
+++ cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/cxf-extension-wstx-msv-validation.xml
Wed Apr  1 11:49:22 2009
@@ -0,0 +1,30 @@
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+	<bean id="org.apache.cxf.wstx_msv_validation.WoodstoxValidationImpl"
+		class="org.apache.cxf.wstx_msv_validation.WoodstoxValidationImpl"
+		>
+		<property name="bus" ref="cxf"/>
+	</bean>
+
+</beans>

Propchange: cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/cxf-extension-wstx-msv-validation.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/cxf-extension-wstx-msv-validation.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/cxf-extension-wstx-msv-validation.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/cxf.extension
URL: http://svn.apache.org/viewvc/cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/cxf.extension?rev=760861&view=auto
==============================================================================
--- cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/cxf.extension (added)
+++ cxf/trunk/common/wstx-msv-validation/src/main/resources/META-INF/cxf/cxf.extension Wed
Apr  1 11:49:22 2009
@@ -0,0 +1 @@
+META-INF/cxf/cxf-extension-wstx-msv-validation.xml
\ No newline at end of file

Modified: cxf/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/parent/pom.xml?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/parent/pom.xml (original)
+++ cxf/trunk/parent/pom.xml Wed Apr  1 11:49:22 2009
@@ -52,6 +52,7 @@
         <jaxb.xjc.version>2.1.9</jaxb.xjc.version>
         <jdom.version>1.0</jdom.version>
         <jetty.version>6.1.15</jetty.version>
+	<msv.version>2009.1-SNAPSHOT</msv.version>
         <rhino.version>1.7R1</rhino.version>
         <saaj.version>1.3</saaj.version>
         <spring.version>2.5.5</spring.version>
@@ -1063,7 +1064,17 @@
 	      <artifactId>xercesImpl</artifactId>
 	      <version>2.9.1</version>
 	    </dependency>
-
+	    <!-- if we use the new woodstox artifact, we're using the new version -->
+	    <dependency>
+	      <groupId>org.codehaus.woodstox</groupId>
+	      <artifactId>woodstox-core-asl</artifactId>
+	      <version>4.0.3</version>
+	    </dependency>
+	    <dependency>
+	      <groupId>net.java.dev.msv</groupId>
+	      <artifactId>msv-core</artifactId>
+	      <version>${msv.version}</version>
+	    </dependency>
         </dependencies>
     </dependencyManagement>
 
@@ -1117,7 +1128,7 @@
             <properties>
                 <stax.impl.groupId>org.codehaus.woodstox</stax.impl.groupId>
                 <stax.impl.artifactId>woodstox-core-asl</stax.impl.artifactId>
-                <stax.impl.version>4.0.2</stax.impl.version>
+                <stax.impl.version>4.0.3</stax.impl.version>
             </properties>
         </profile>
         <profile>

Modified: cxf/trunk/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/pom.xml?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/pom.xml (original)
+++ cxf/trunk/pom.xml Wed Apr  1 11:49:22 2009
@@ -44,6 +44,20 @@
         <compiler.fork>false</compiler.fork>
     </properties>
 
+    <!-- java.net for msv snapshots -->
+    <repositories>
+      <repository>
+	<id>maven2-repository.dev.java.net</id>
+	<releases>
+	  <enabled>false</enabled>
+	</releases>
+	<snapshots>
+	  <enabled>true</enabled>
+      </snapshots>
+	<name>Java.net Repository for Maven</name>
+	<url>http://download.java.net/maven/2/</url>
+      </repository>
+    </repositories>
 
     <distributionManagement>
         <repository>

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
Wed Apr  1 11:49:22 2009
@@ -108,8 +108,7 @@
              * service info. 
              */
             if (reader instanceof DataBindingValidation2) {
-                ((DataBindingValidation2)reader).setSchema(service.getServiceInfos().get(0)
-                                                          .getXmlSchemaCollection().getXmlSchemaCollection());
+                ((DataBindingValidation2)reader).setValidationServiceModel(service.getServiceInfos().get(0));
             }
         }
     }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
Wed Apr  1 11:49:22 2009
@@ -162,7 +162,7 @@
     public <T> DataWriter<T> createWriter(Class<T> cls) {
         ensureInitialized();
         if (cls.equals(XMLStreamWriter.class)) {
-            return (DataWriter<T>)new XMLStreamDataWriter(this);
+            return (DataWriter<T>)new XMLStreamDataWriter(this, getBus());
         } else if (cls.equals(Node.class)) {
             return (DataWriter<T>)new ElementDataWriter(this);
         } else {

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataReader.java?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataReader.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataReader.java
Wed Apr  1 11:49:22 2009
@@ -33,7 +33,7 @@
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.service.model.MessagePartInfo;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.cxf.service.model.ServiceInfo;
 
 /**
  * 
@@ -94,8 +94,6 @@
         reader.setSchema(s);
     }
 
-    public void setSchema(XmlSchemaCollection schema) {
-        // TODO Auto-generated method stub
-        
+    public void setValidationServiceModel(ServiceInfo serviceInfo) {
     }
 }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataWriter.java?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataWriter.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataWriter.java
Wed Apr  1 11:49:22 2009
@@ -41,8 +41,8 @@
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.staxutils.W3CDOMStreamWriter;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
 
 public class ElementDataWriter implements DataWriter<Element>, DataBindingValidation2
{
 
@@ -114,10 +114,6 @@
         return properties.get(key);
     }
 
-    public void setSchema(XmlSchemaCollection schema) {
-        // TODO Auto-generated method stub
-        
+    public void setValidationServiceModel(ServiceInfo serviceInfo) {
     }
-
-
 }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataReader.java
Wed Apr  1 11:49:22 2009
@@ -30,17 +30,18 @@
 import org.apache.cxf.databinding.DataBindingValidation2;
 import org.apache.cxf.databinding.DataReader;
 import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.io.StaxValidationManager;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.service.model.MessagePartInfo;
-import org.apache.cxf.staxutils.StaxValidationManager;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.cxf.service.model.ServiceInfo;
 
 public class XMLStreamDataReader implements DataReader<XMLStreamReader>, DataBindingValidation2
{
 
     private AegisDatabinding databinding;
     private AegisXMLStreamDataReader reader;
     private Bus bus;
-    private XmlSchemaCollection schemas;
+    private ServiceInfo serviceInfo;
+    private boolean validate;
     
     public XMLStreamDataReader(AegisDatabinding databinding, Bus bus) {
         this.bus = bus;
@@ -51,10 +52,10 @@
     public Object read(MessagePartInfo part, XMLStreamReader input) {
         Type type = databinding.getType(part);
         try {
-            if (schemas != null) {
+            if (validate) {
                 StaxValidationManager mgr = bus.getExtension(StaxValidationManager.class);
                 if (mgr != null) {
-                    mgr.setupValidation(input, schemas);
+                    mgr.setupValidation(input, serviceInfo);
                 }
             }
             return reader.read(input, type); 
@@ -87,7 +88,8 @@
         reader.setSchema(s);
     }
 
-    public void setSchema(XmlSchemaCollection validationSchemas) {
-        this.schemas = validationSchemas; 
+    public void setValidationServiceModel(ServiceInfo serviceModel) {
+        serviceInfo = serviceModel;
+        validate = true;
     }
 }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/XMLStreamDataWriter.java
Wed Apr  1 11:49:22 2009
@@ -23,9 +23,11 @@
 import java.util.Map;
 import java.util.logging.Logger;
 
+import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.validation.Schema;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.aegis.Context;
 import org.apache.cxf.aegis.DatabindingException;
 import org.apache.cxf.aegis.type.Type;
@@ -37,9 +39,10 @@
 import org.apache.cxf.databinding.DataBindingValidation2;
 import org.apache.cxf.databinding.DataWriter;
 import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.io.StaxValidationManager;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.service.model.MessagePartInfo;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 
 public class XMLStreamDataWriter implements DataWriter<XMLStreamWriter>, DataBindingValidation2
{
@@ -47,13 +50,14 @@
     private static final Logger LOG = LogUtils.getL7dLogger(XMLStreamDataReader.class);
 
     private AegisDatabinding databinding;
-
     private Collection<Attachment> attachments;
-    
     private Map<String, Object> properties;
+    private ServiceInfo validationServiceInfo;
+    private Bus bus;
     
-    public XMLStreamDataWriter(AegisDatabinding databinding) {
+    public XMLStreamDataWriter(AegisDatabinding databinding, Bus bus) {
         this.databinding = databinding;
+        this.bus = bus;
     }
 
     public void setAttachments(Collection<Attachment> attachments) {
@@ -70,6 +74,17 @@
             throw new Fault(new Message("NO_MESSAGE_FOR_PART", LOG, part));
         }
         
+        if (validationServiceInfo != null) {
+            StaxValidationManager mgr = bus.getExtension(StaxValidationManager.class);
+            if (mgr != null) {
+                try {
+                    mgr.setupValidation(output, validationServiceInfo);
+                } catch (XMLStreamException e) {
+                    throw new Fault(e);
+                }
+            }
+        }
+        
         Context context = new Context(databinding.getAegisContext());
         
         context.setAttachments(attachments);
@@ -118,10 +133,7 @@
         return properties.get(key);
     }
 
-    public void setSchema(XmlSchemaCollection schema) {
-        // TODO Auto-generated method stub
-        
+    public void setValidationServiceModel(ServiceInfo serviceInfo) {
+        validationServiceInfo = serviceInfo;
     }
-
-
 }

Modified: cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java?rev=760861&r1=760860&r2=760861&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java
(original)
+++ cxf/trunk/rt/databinding/xmlbeans/src/main/java/org/apache/cxf/xmlbeans/DataReaderImpl.java
Wed Apr  1 11:49:22 2009
@@ -35,7 +35,7 @@
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.service.model.MessagePartInfo;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.xmlbeans.SchemaType;
 import org.apache.xmlbeans.XmlAnySimpleType;
 import org.apache.xmlbeans.XmlObject;
@@ -44,7 +44,7 @@
 
 public class DataReaderImpl implements DataReader<XMLStreamReader> , DataBindingValidation2
{
     private static final Logger LOG = LogUtils.getLogger(XmlBeansDataBinding.class);
-    private XmlSchemaCollection schemas;
+    private boolean validate;
     
     public DataReaderImpl() {
     }
@@ -74,7 +74,7 @@
                     
                     SchemaType st = (SchemaType)part.getProperty(SchemaType.class.getName());
                     XmlOptions options = new XmlOptions();
-                    if (schemas != null) {
+                    if (validate) {
                         options.setValidateOnSet();
                     }
                     if (st != null && !st.isDocumentType() && !isOutClass)
{
@@ -84,7 +84,6 @@
                     obj = meth.invoke(null, reader, options);                    
                     break;
                 } catch (Exception e) {
-                    e.printStackTrace();
                     throw new Fault(new Message("UNMARSHAL_ERROR", LOG, part.getTypeClass()),
e);
                 }
             }
@@ -124,8 +123,7 @@
             try {
                 reader.next();
             } catch (XMLStreamException e) {
-                // TODO Auto-generated catch block
-                e.printStackTrace();
+                throw new RuntimeException(e);
             }
         }
         return obj;
@@ -145,8 +143,7 @@
     public void setSchema(Schema s) {
     }
 
-    public void setSchema(XmlSchemaCollection validationSchemas) {
-        this.schemas = validationSchemas; 
+    public void setValidationServiceModel(ServiceInfo serviceModel) {
+        validate = true;
     }
-
 }



Mime
View raw message