cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r686340 - in /cxf/branches/2.0.x-fixes: ./ api/src/main/java/org/apache/cxf/service/model/ rt/core/src/main/java/org/apache/cxf/catalog/ rt/core/src/main/java/org/apache/cxf/wsdl11/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ tool...
Date Fri, 15 Aug 2008 19:31:31 GMT
Author: dkulp
Date: Fri Aug 15 12:31:30 2008
New Revision: 686340

URL: http://svn.apache.org/viewvc?rev=686340&view=rev
Log:
Merged revisions 686283 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r686283 | dkulp | 2008-08-15 13:09:54 -0400 (Fri, 15 Aug 2008) | 2 lines
  
  Bunch of updates to tools to try and reuse cached schemas and stuff instead of re-parsing.
 Should make the tools a bit faster as well as use less memory.
........

Modified:
    cxf/branches/2.0.x-fixes/   (props changed)
    cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/ServiceInfo.java
    cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/ServiceSchemaInfo.java
    cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/catalog/CatalogXmlSchemaURIResolver.java
    cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaUtil.java
    cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
    cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
    cxf/branches/2.0.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractDefinitionValidator.java
    cxf/branches/2.0.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
    cxf/branches/2.0.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
    cxf/branches/2.0.x-fixes/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java
    cxf/branches/2.0.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
    cxf/branches/2.0.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/AbstractWSDLBuilder.java
    cxf/branches/2.0.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
    cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Aug 15 12:31:30 2008
@@ -1 +1 @@
-/cxf/trunk:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048,677385,678004,678009,678559,678629,678808,678852,678891,678893,679248,679597,680435,681060,681165,681813,681816,682902,682951,683089,683290,683318,684099,684790-684793,684842,684862,684895-684918,685205,685253,686237
+/cxf/trunk:673548,674485,674547,674551,674562,674601,674649,674764,674887,675644,675653,677048,677385,678004,678009,678559,678629,678808,678852,678891,678893,679248,679597,680435,681060,681165,681813,681816,682902,682951,683089,683290,683318,684099,684790-684793,684842,684862,684895-684918,685205,685253,686237,686283

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Aug 15 12:31:30 2008
@@ -1 +1 @@
-/cxf/trunk:1-684881,684883-684884,684886-684888,684890-684892,684894-684923,685205,685253,686237
+/cxf/trunk:1-684881,684883-684884,684886-684888,684890-684892,684894-684923,685205,685253,686237,686283

Modified: cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/ServiceInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/ServiceInfo.java?rev=686340&r1=686339&r2=686340&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/ServiceInfo.java
(original)
+++ cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/ServiceInfo.java
Fri Aug 15 12:31:30 2008
@@ -147,7 +147,7 @@
     }
 
     public List<SchemaInfo> getSchemas() {
-        return Collections.unmodifiableList(schemas);
+        return schemas;
     }
 
     public SchemaCollection getXmlSchemaCollection() {

Modified: cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/ServiceSchemaInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/ServiceSchemaInfo.java?rev=686340&r1=686339&r2=686340&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/ServiceSchemaInfo.java
(original)
+++ cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/service/model/ServiceSchemaInfo.java
Fri Aug 15 12:31:30 2008
@@ -21,6 +21,9 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+
+import org.w3c.dom.Element;
 
 import org.apache.cxf.common.xmlschema.SchemaCollection;
 
@@ -31,6 +34,7 @@
 public class ServiceSchemaInfo {
     private SchemaCollection schemaCollection;
     private List<SchemaInfo> schemaInfoList;
+    private Map<String, Element> schemaElementList;
     
     public SchemaCollection getSchemaCollection() {
         return schemaCollection;
@@ -44,5 +48,10 @@
     public void setSchemaInfoList(List<SchemaInfo> schemaInfoList) {
         this.schemaInfoList = new ArrayList<SchemaInfo>(schemaInfoList);
     }
-
+    public Map<String, Element> getSchemaElementList() {
+        return schemaElementList;
+    }
+    public void setSchemaElementList(Map<String, Element> l) {
+        schemaElementList = l;
+    }
 }

Modified: cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/catalog/CatalogXmlSchemaURIResolver.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/catalog/CatalogXmlSchemaURIResolver.java?rev=686340&r1=686339&r2=686340&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/catalog/CatalogXmlSchemaURIResolver.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/catalog/CatalogXmlSchemaURIResolver.java
Fri Aug 15 12:31:30 2008
@@ -20,6 +20,8 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.xml.sax.InputSource;
 
@@ -36,11 +38,16 @@
 
     private ExtendedURIResolver resolver;
     private Catalog catalogResolver;
+    private Map<String, String> resolved = new HashMap<String, String>();
 
     public CatalogXmlSchemaURIResolver(OASISCatalogManager catalogManager) {
         this.resolver = new ExtendedURIResolver();
         this.catalogResolver = catalogManager.getCatalog();
     }
+    
+    public Map<String, String> getResolvedMap() {
+        return resolved;
+    }
 
     public InputSource resolveEntity(String targetNamespace, String schemaLocation, String
baseUri) {
         String resolvedSchemaLocation = null;
@@ -61,6 +68,7 @@
         if (resolvedSchemaLocation == null) {
             in = this.resolver.resolve(schemaLocation, baseUri);
         } else {
+            resolved.put(schemaLocation, resolvedSchemaLocation);
             in = this.resolver.resolve(resolvedSchemaLocation, baseUri);
         }
 

Modified: cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaUtil.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaUtil.java?rev=686340&r1=686339&r2=686340&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaUtil.java (original)
+++ cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/SchemaUtil.java Fri
Aug 15 12:31:30 2008
@@ -21,6 +21,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -47,21 +48,29 @@
 
 public final class SchemaUtil {
     private final Map<String, Element> schemaList;
+    private final Map<String, String> catalogResolved = new HashMap<String, String>();
     private final Bus bus;
-    private Map<String, String> catalogResolvedMap;
-
 
     public SchemaUtil(final Bus b, final Map<String, Element> s) {
         this.bus = b;
         this.schemaList = s;
     }
-
     public void getSchemas(final Definition def, final ServiceInfo serviceInfo) {
         SchemaCollection schemaCol = serviceInfo.getXmlSchemaCollection();
+        getSchemas(def, schemaCol, serviceInfo);
+    }
+    public void getSchemas(final Definition def, 
+                           SchemaCollection schemaCol, 
+                           ServiceInfo serviceInfo) {
+        getSchemas(def, schemaCol, serviceInfo.getSchemas());
+    }
 
+    public void getSchemas(final Definition def, 
+                           final SchemaCollection schemaCol,
+                           List<SchemaInfo> schemas) {
         List<Definition> defList = new ArrayList<Definition>();
         parseImports(def, defList);
-        extractSchema(def, schemaCol, serviceInfo);
+        extractSchema(def, schemaCol, schemas);
         // added
         getSchemaList(def);
         
@@ -69,7 +78,7 @@
         done.put(def, def);
         for (Definition def2 : defList) {
             if (!done.containsKey(def2)) {
-                extractSchema(def2, schemaCol, serviceInfo);
+                extractSchema(def2, schemaCol, schemas);
                 // added
                 getSchemaList(def2);
                 done.put(def2, def2);
@@ -77,7 +86,7 @@
         }
     }
 
-    private void extractSchema(Definition def, SchemaCollection schemaCol, ServiceInfo serviceInfo)
{
+    private void extractSchema(Definition def, SchemaCollection schemaCol, List<SchemaInfo>
schemaInfos) {
         Types typesElement = def.getTypes();
         if (typesElement != null) {
             int schemaCount = 1;
@@ -109,11 +118,12 @@
                         schemaCol.setSchemaResolver(schemaResolver);
                         
                         XmlSchema xmlSchema = schemaCol.read(schemaElem, systemId);
+                        catalogResolved.putAll(schemaResolver.getResolvedMap());
                         SchemaInfo schemaInfo = new SchemaInfo(xmlSchema.getTargetNamespace());
                         schemaInfo.setElement(schemaElem);
                         schemaInfo.setSchema(xmlSchema);
                         schemaInfo.setSystemId(systemId);
-                        serviceInfo.addSchema(schemaInfo);
+                        schemaInfos.add(schemaInfo);
                         schemaCount++;
                     }
                 }
@@ -179,10 +189,11 @@
                     if (importNamespace == null && tempImport != null) {
                         importNamespace = tempImport.getDocumentBaseURI();
                     }
-                    if ((catalogResolvedMap == null || !catalogResolvedMap.containsKey(key))

-                        && tempImport != null) {                 
+                    
+                    if (tempImport != null && !catalogResolved.containsKey(key))
{                 
                         key = tempImport.getDocumentBaseURI();
                     }
+                    
                     if (tempImport != null
                         && !isSchemaParsed(key, importNamespace)
                         && !schemaList.containsValue(tempImport.getElement())) {
@@ -204,8 +215,4 @@
         }
         return false;
     }
-
-    public void setCatalogResolvedMap(Map<String, String> resolvedMap) {
-        catalogResolvedMap = resolvedMap;
-    }
 }

Modified: cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?rev=686340&r1=686339&r2=686340&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
Fri Aug 15 12:31:30 2008
@@ -101,7 +101,6 @@
     private static final Logger LOG = LogUtils.getL7dLogger(WSDLServiceBuilder.class);
     private Bus bus;
     private Map<String, Element> schemaList = new HashMap<String, Element>();
-    private Map<String, String> catalogResolvedMap;
 
     public WSDLServiceBuilder(Bus bus) {
         this.bus = bus;
@@ -205,13 +204,6 @@
 
         buildInterface(service, p);
 
-        WSDLManager wsdlManager = bus.getExtension(WSDLManager.class); 
-        if (wsdlManager != null) {
-            ServiceSchemaInfo serviceSchemaInfo = new ServiceSchemaInfo();
-            serviceSchemaInfo.setSchemaCollection(service.getXmlSchemaCollection());
-            serviceSchemaInfo.setSchemaInfoList(service.getSchemas());
-            wsdlManager.putSchemasForDefinition(def, serviceSchemaInfo);
-        }
         return service;
     }
 
@@ -244,7 +236,7 @@
                 service.setProperty(WSDL_DEFINITION, def);
                 service.setProperty(WSDL_SERVICE, serv);
                 getSchemas(def, service);
-                
+
                 service.setProperty(WSDL_SCHEMA_ELEMENT_LIST, this.schemaList);
                 service.setTargetNamespace(def.getTargetNamespace());
                 service.setName(serv.getQName());
@@ -276,9 +268,9 @@
         
         if (serviceSchemaInfo == null) {
             SchemaUtil schemaUtil = new SchemaUtil(bus, this.schemaList);
-            schemaUtil.setCatalogResolvedMap(this.catalogResolvedMap);
             schemaUtil.getSchemas(def, serviceInfo);
             serviceSchemaInfo = new ServiceSchemaInfo();
+            serviceSchemaInfo.setSchemaElementList(this.schemaList);
             serviceSchemaInfo.setSchemaCollection(serviceInfo.getXmlSchemaCollection());
             serviceSchemaInfo.setSchemaInfoList(serviceInfo.getSchemas());
             if (wsdlManager != null) {
@@ -286,6 +278,7 @@
             }
         } else {
             serviceInfo.setServiceSchemaInfo(serviceSchemaInfo);
+            schemaList.putAll(serviceSchemaInfo.getSchemaElementList());
         }
     }
 
@@ -704,8 +697,4 @@
         }
     }
     
-    public void setCatalogResolvedMap(Map<String, String> resolvedMap) {
-        catalogResolvedMap = resolvedMap;
-    }
-
 }

Modified: cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?rev=686340&r1=686339&r2=686340&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
Fri Aug 15 12:31:30 2008
@@ -133,7 +133,7 @@
         }
     }
     
-    private void initializePorts() {        
+    private void initializePorts() {   
         WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
         Service service = sf.create();
         for (ServiceInfo si : service.getServiceInfos()) { 

Modified: cxf/branches/2.0.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractDefinitionValidator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractDefinitionValidator.java?rev=686340&r1=686339&r2=686340&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractDefinitionValidator.java
(original)
+++ cxf/branches/2.0.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/AbstractDefinitionValidator.java
Fri Aug 15 12:31:30 2008
@@ -28,7 +28,7 @@
 
 public abstract class AbstractDefinitionValidator extends AbstractValidator {
     
-    protected final Definition def;
+    protected Definition def;
     protected ToolContext env;
     
     private final Bus bus;

Modified: cxf/branches/2.0.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java?rev=686340&r1=686339&r2=686340&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
(original)
+++ cxf/branches/2.0.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
Fri Aug 15 12:31:30 2008
@@ -37,6 +37,7 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
 
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
@@ -47,13 +48,13 @@
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.resource.URIResolver;
 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.util.URIParserUtil;
 import org.apache.cxf.tools.validator.AbstractValidator;
+import org.apache.cxf.wsdl.WSDLManager;
 import org.apache.xml.resolver.Catalog;
 
 public class WSDL11Validator extends AbstractDefinitionValidator {
@@ -87,7 +88,7 @@
             if (nw == null) {
                 nw = wsdl;
             }
-            return XMLUtils.parse(new InputSource(URIParserUtil.getAbsoluteURI(nw)));
+            return new Stax2DOM().getDocument(URIParserUtil.getAbsoluteURI(nw));
         } catch (FileNotFoundException fe) {
             LOG.log(Level.WARNING, "Can not find the wsdl " + wsdl + "to validate");
             return null;
@@ -111,15 +112,22 @@
         if (doc == null) {
             return true;
         }
-        WSDLRefValidator wsdlRefValidator = new WSDLRefValidator(wsdl, doc, getBus());
-        wsdlRefValidator.setSuppressWarnings(env.optionSet(ToolConstants.CFG_SUPPRESS_WARNINGS));
-        Definition wsdlDef = wsdlRefValidator.getDefinition();        
+        if (this.def == null) {
+            try {
+                this.def = getBus().getExtension(WSDLManager.class).getDefinition(wsdl);
+            } catch (WSDLException e) {
+                throw new ToolException(e);
+            }
+        }
+        
+        WSDLRefValidator wsdlRefValidator = new WSDLRefValidator(this.def, doc, getBus());
+        wsdlRefValidator.setSuppressWarnings(env.optionSet(ToolConstants.CFG_SUPPRESS_WARNINGS));
       
         validators.add(wsdlRefValidator);
-
+        
         if (env.optionSet(ToolConstants.CFG_VALIDATE_WSDL)) {
-            validators.add(new UniqueBodyPartsValidator(wsdlDef));
-            validators.add(new WSIBPValidator(wsdlDef));
-            validators.add(new MIMEBindingValidator(wsdlDef));
+            validators.add(new UniqueBodyPartsValidator(this.def));
+            validators.add(new WSIBPValidator(this.def));
+            validators.add(new MIMEBindingValidator(this.def));
         }
 
         for (AbstractValidator validator : validators) {

Modified: cxf/branches/2.0.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java?rev=686340&r1=686339&r2=686340&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
(original)
+++ cxf/branches/2.0.x-fixes/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDLRefValidator.java
Fri Aug 15 12:31:30 2008
@@ -23,6 +23,7 @@
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -35,17 +36,18 @@
 import javax.wsdl.BindingOperation;
 import javax.wsdl.Definition;
 import javax.wsdl.Fault;
+import javax.wsdl.Import;
 import javax.wsdl.Operation;
 import javax.wsdl.Part;
 import javax.wsdl.Port;
 import javax.wsdl.PortType;
 import javax.wsdl.Service;
-import javax.wsdl.WSDLException;
 import javax.xml.namespace.QName;
 import javax.xml.stream.Location;
 import javax.xml.xpath.XPathConstants;
 
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
 import org.apache.cxf.Bus;
@@ -54,7 +56,10 @@
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.XPathUtils;
+import org.apache.cxf.service.model.SchemaInfo;
+import org.apache.cxf.service.model.ServiceSchemaInfo;
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.validator.internal.model.FailureLocation;
 import org.apache.cxf.tools.validator.internal.model.XBinding;
@@ -70,7 +75,7 @@
 import org.apache.cxf.tools.validator.internal.model.XService;
 import org.apache.cxf.wsdl.WSDLConstants;
 import org.apache.cxf.wsdl.WSDLManager;
-import org.apache.cxf.wsdl11.WSDLDefinitionBuilder;
+import org.apache.cxf.wsdl11.SchemaUtil;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaType;
 
@@ -85,57 +90,69 @@
     private ValidationResult vResults = new ValidationResult();
 
     private Definition definition;
+    private Document baseDoc;
 
     private List<Definition> importedDefinitions;
-    private List<SchemaCollection> schemas = new ArrayList<SchemaCollection>();
     private SchemaCollection schemaCollection = new SchemaCollection();
 
     private boolean suppressWarnings;
 
-    public WSDLRefValidator() {
-    }
-
-    public WSDLRefValidator(final String wsdl) {
-        this(wsdl, null);
-    }
-
-    public WSDLRefValidator(final String wsdl, final Document doc) {
+    public WSDLRefValidator(Definition wsdl, Document doc) {
         this(wsdl, doc, BusFactory.getDefaultBus());
     }
 
-    public WSDLRefValidator(final String wsdl, final Document doc, final Bus b) {
-        WSDLDefinitionBuilder wsdlBuilder = new WSDLDefinitionBuilder(b);
-
+    public WSDLRefValidator(Definition wsdl, Document doc, Bus bus) {
+        this.definition = wsdl;
+        baseDoc = doc;
+        importedDefinitions = new ArrayList<Definition>();
+        parseImports(wsdl);
+        processSchemas(bus);
+    }
+    private void getSchemas(Bus bus) {
+        Map<String, Element> schemaList = new HashMap<String, Element>();
+        SchemaUtil schemaUtil = new SchemaUtil(bus, schemaList);
+        List<SchemaInfo> si = new ArrayList<SchemaInfo>();
+        schemaUtil.getSchemas(definition, schemaCollection, si);
+        ServiceSchemaInfo ssi = new ServiceSchemaInfo();
+        ssi.setSchemaCollection(schemaCollection);
+        ssi.setSchemaInfoList(si);
+        ssi.setSchemaElementList(schemaList);
+        bus.getExtension(WSDLManager.class).putSchemasForDefinition(definition, ssi);
+    }
+    private void processSchemas(Bus bus) {
         try {
-            this.definition = wsdlBuilder.build(wsdl);
-            WSDLManager mgr = b.getExtension(WSDLManager.class);
-            mgr.removeDefinition(this.definition);
-
-            if (wsdlBuilder.getImportedDefinitions().size() > 0) {
-                importedDefinitions = new ArrayList<Definition>();
-                importedDefinitions.addAll(wsdlBuilder.getImportedDefinitions());
-            }
-        } catch (Exception e) {
-            if (e.getCause() instanceof WSDLException) {
-                throw new ToolException(e.getCause().getMessage());
+            ServiceSchemaInfo info = bus.getExtension(WSDLManager.class)
+                .getSchemasForDefinition(definition);
+            if (info == null) {
+                getSchemas(bus);
+            } else {
+                schemaCollection = info.getSchemaCollection();                
             }
-            throw new ToolException(e);
-        }
-
-        try {
-            schemas.add(ValidatorUtil.getSchema(this.definition));
             checkTargetNamespace(this.definition.getTargetNamespace());
-            if (importedDefinitions != null) {
-                for (Definition d : importedDefinitions) {
-                    checkTargetNamespace(d.getTargetNamespace());
-                    schemas.add(ValidatorUtil.getSchema(d));
-                }
-            }
         } catch (Exception ex) {
             throw new ToolException(ex);
+        }        
+    }
+    private Collection<Import> getImports(final Definition wsdlDef) {
+        Collection<Import> importList = new ArrayList<Import>();
+        Map imports = wsdlDef.getImports();
+        for (Iterator iter = imports.keySet().iterator(); iter.hasNext();) {
+            String uri = (String)iter.next();
+            List<Import> lst = CastUtils.cast((List)imports.get(uri));
+            importList.addAll(lst);
+        }
+        return importList;
+    }
+    private void parseImports(Definition def) {
+        for (Import impt : getImports(def)) {
+            if (!importedDefinitions.contains(impt.getDefinition())) {
+                importedDefinitions.add(impt.getDefinition());
+                parseImports(impt.getDefinition());
+            }
         }
     }
 
+    
     private void checkTargetNamespace(String path) {
         try {
             if (new URL(path).getPath().indexOf(":") != -1) {
@@ -159,6 +176,9 @@
     }
 
     private Document getWSDLDocument() throws Exception {
+        if (baseDoc != null) {
+            return baseDoc;
+        }
         return getWSDLDocument(this.definition.getDocumentBaseURI());
     }
 
@@ -564,7 +584,7 @@
 
         if (namespace.equals(WSDLConstants.NU_SCHEMA_XSD)) {
             if (isElement) {
-                XmlSchemaElement  schemaEle =
+                XmlSchemaElement schemaEle =
                     schemaCollection.getElementByQName(new QName(WSDLConstants.NU_SCHEMA_XSD,
name));
                 partvalid = schemaEle != null ? true : false;
             } else {
@@ -579,20 +599,12 @@
 
         } else {
             if (isElement) {
-                for (SchemaCollection schema : schemas) {
-                    if (schema != null && schema.getElementByQName(
-                            new QName(namespace, name)) != null) {
-                        partvalid = true;
-                        break;
-                    }
+                if (schemaCollection.getElementByQName(new QName(namespace, name)) != null)
{
+                    partvalid = true;
                 }
             } else {
-                for (SchemaCollection schema : schemas) {
-                    if (schema != null && schema.getTypeByQName(
-                            new QName(namespace, name)) != null) {
-                        partvalid = true;
-                        break;
-                    }
+                if (schemaCollection.getTypeByQName(new QName(namespace, name)) != null)
{
+                    partvalid = true;
                 }
             }
         }

Modified: cxf/branches/2.0.x-fixes/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java?rev=686340&r1=686339&r2=686340&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java
(original)
+++ cxf/branches/2.0.x-fixes/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDLRefValidatorTest.java
Fri Aug 15 12:31:30 2008
@@ -21,19 +21,28 @@
 
 import java.util.HashSet;
 import java.util.Set;
+import javax.wsdl.Definition;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.i18n.Message;
-import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.validator.internal.model.XNode;
+import org.apache.cxf.wsdl11.WSDLDefinitionBuilder;
 import org.junit.Assert;
 import org.junit.Test;
 
 public class WSDLRefValidatorTest extends Assert {
 
+    private Definition getWSDL(String wsdl) throws Exception {
+        Bus b = BusFactory.getDefaultBus();
+        WSDLDefinitionBuilder wsdlBuilder = new WSDLDefinitionBuilder(b);
+        return wsdlBuilder.build(wsdl);
+    }
+    
     @Test
     public void testNoService() throws Exception {
         String wsdl = getClass().getResource("resources/b.wsdl").toURI().toString();
-        WSDLRefValidator validator = new WSDLRefValidator(wsdl);
+        WSDLRefValidator validator = new WSDLRefValidator(getWSDL(wsdl), null);
         assertFalse(validator.isValid());
         ValidationResult results = validator.getValidationResults();
         assertEquals(0, results.getWarnings().size());
@@ -42,7 +51,7 @@
     @Test
     public void testWSDLImport1() throws Exception {
         String wsdl = getClass().getResource("resources/a.wsdl").toURI().toString();
-        WSDLRefValidator validator = new WSDLRefValidator(wsdl);
+        WSDLRefValidator validator = new WSDLRefValidator(getWSDL(wsdl), null);
         validator.isValid();
         ValidationResult results = validator.getValidationResults();
         assertEquals(2, results.getErrors().size());
@@ -61,7 +70,7 @@
     @Test
     public void testWSDLImport2() throws Exception {
         String wsdl = getClass().getResource("resources/physicalpt.wsdl").toURI().toString();
-        WSDLRefValidator validator = new WSDLRefValidator(wsdl);
+        WSDLRefValidator validator = new WSDLRefValidator(getWSDL(wsdl), null);
         assertTrue(validator.isValid());
         String expected = "/wsdl:definitions[@targetNamespace='http://schemas.apache.org/yoko/idl/OptionsPT']"
             + "/wsdl:portType[@name='foo.bar']";
@@ -77,7 +86,7 @@
     @Test
     public void testNoTypeRef() throws Exception {
         String wsdl = getClass().getResource("resources/NoTypeRef.wsdl").toURI().toString();
-        WSDLRefValidator validator = new WSDLRefValidator(wsdl);
+        WSDLRefValidator validator = new WSDLRefValidator(getWSDL(wsdl), null);
         assertFalse(validator.isValid());
         assertEquals(3, validator.getValidationResults().getErrors().size());
 
@@ -98,13 +107,13 @@
     @Test
     public void testNoBindingWSDL() throws Exception {
         String wsdl = getClass().getResource("resources/nobinding.wsdl").toURI().toString();
-        WSDLRefValidator validator = new WSDLRefValidator(wsdl);
+        WSDLRefValidator validator = new WSDLRefValidator(getWSDL(wsdl), null);
         validator.isValid();
         ValidationResult results = validator.getValidationResults();
 
         assertEquals(0, results.getWarnings().size());
 
-        WSDLRefValidator v = new WSDLRefValidator(wsdl);
+        WSDLRefValidator v = new WSDLRefValidator(getWSDL(wsdl), null);
         v.setSuppressWarnings(true);
         assertTrue(v.isValid());
     }
@@ -112,7 +121,7 @@
     @Test
     public void testLogicalWSDL() throws Exception {
         String wsdl = getClass().getResource("resources/logical.wsdl").toURI().toString();
-        WSDLRefValidator validator = new WSDLRefValidator(wsdl);
+        WSDLRefValidator validator = new WSDLRefValidator(getWSDL(wsdl), null);
         validator.isValid();
         ValidationResult results = validator.getValidationResults();
         
@@ -129,15 +138,14 @@
 
     @Test
     public void testNotAWsdl() throws Exception {
-        String wsdl = getClass().getResource("resources/c.xsd").toURI().toString();
         try {        
-            WSDLRefValidator validator = new WSDLRefValidator(wsdl);
+            String wsdl = getClass().getResource("resources/c.xsd").toURI().toString();
+            WSDLRefValidator validator = new WSDLRefValidator(getWSDL(wsdl), null);
             validator.isValid();
         } catch (Exception e) {
-            assertTrue(e instanceof ToolException);
             String expected = "WSDLException (at /xs:schema): faultCode=INVALID_WSDL: "
                 + "Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions'.";
-            assertEquals(expected, e.getMessage());
+            assertTrue(e.getMessage().contains(expected));
         }
     }
 
@@ -145,7 +153,7 @@
     public void testXSDAnyType() throws Exception {
         String wsdl = getClass().getResource("resources/anytype.wsdl").toURI().toString();
         try {
-            WSDLRefValidator validator = new WSDLRefValidator(wsdl);
+            WSDLRefValidator validator = new WSDLRefValidator(getWSDL(wsdl), null);
             assertTrue(validator.isValid());
         } catch (Exception e) {
             fail("Valid wsdl, no exception should be thrown" + e.getMessage());

Modified: cxf/branches/2.0.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java?rev=686340&r1=686339&r2=686340&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
(original)
+++ cxf/branches/2.0.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
Fri Aug 15 12:31:30 2008
@@ -121,7 +121,8 @@
                     builder.setContext(context);
                     builder.setBus(getBus());
                     context.put(Bus.class, getBus());
-                    builder.build(URIParserUtil.getAbsoluteURI(wsdlURL));
+                    wsdlURL = URIParserUtil.getAbsoluteURI(wsdlURL);
+                    builder.build(wsdlURL);
                     builder.customize();
                     Definition definition = builder.getWSDLModel();
 
@@ -130,7 +131,6 @@
                     builder.validate(definition);
 
                     WSDLServiceBuilder serviceBuilder = new WSDLServiceBuilder(getBus());
-                    serviceBuilder.setCatalogResolvedMap(builder.getCataLogResolvedMap());
                     String serviceName = (String)context.get(ToolConstants.CFG_SERVICENAME);
 
                     if (serviceName != null) {

Modified: cxf/branches/2.0.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/AbstractWSDLBuilder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/AbstractWSDLBuilder.java?rev=686340&r1=686339&r2=686340&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/AbstractWSDLBuilder.java
(original)
+++ cxf/branches/2.0.x-fixes/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/core/AbstractWSDLBuilder.java
Fri Aug 15 12:31:30 2008
@@ -19,8 +19,6 @@
 
 package org.apache.cxf.tools.wsdlto.core;
 
-import java.util.Map;
-
 import org.apache.cxf.Bus;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
@@ -44,5 +42,4 @@
 
     public abstract T getWSDLModel();
     
-    public abstract Map<String, String> getCataLogResolvedMap();
 }

Modified: cxf/branches/2.0.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java?rev=686340&r1=686339&r2=686340&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
(original)
+++ cxf/branches/2.0.x-fixes/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
Fri Aug 15 12:31:30 2008
@@ -146,7 +146,7 @@
         Set<String> keys = schemaLists.keySet();
         for (String key : keys) {
             Element ele = schemaLists.get(key);
-            this.removeImportElement(ele);
+            ele = removeImportElement(ele);
             String tns = ele.getAttribute("targetNamespace");
             if (StringUtils.isEmpty(tns)) {
                 continue;
@@ -353,11 +353,15 @@
         return null;
     }
 
-    private void removeImportElement(Element element) {
+    private Element removeImportElement(Element element) {
         NodeList nodeList = element.getElementsByTagNameNS(ToolConstants.SCHEMA_URI, "import");
+        if (nodeList.getLength() == 0) {
+            return element;
+        }
+        element = (Element)cloneNode(element.getOwnerDocument(), element, true);
+        nodeList = element.getElementsByTagNameNS(ToolConstants.SCHEMA_URI, "import");
         List<Node> ns = new ArrayList<Node>();
         for (int tmp = 0; tmp < nodeList.getLength(); tmp++) {
-
             Node importNode = nodeList.item(tmp);
             ns.add(importNode);
         }
@@ -365,7 +369,7 @@
             Node schemaNode = item.getParentNode();
             schemaNode.removeChild(item);
         }
-
+        return element;
     }
 
     public Node cloneNode(Document document, Node node, boolean deep) throws DOMException
{

Modified: cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java?rev=686340&r1=686339&r2=686340&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java
(original)
+++ cxf/branches/2.0.x-fixes/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/wsdl11/JAXWSDefinitionBuilder.java
Fri Aug 15 12:31:30 2008
@@ -20,7 +20,6 @@
 package org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11;
 
 
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -68,7 +67,6 @@
 
     private List<InputSource> jaxbBindings;
     private Element handlerChain;
-    private Map<String, String> cataLogResolvedMap = new HashMap<String, String>();
 
     public JAXWSDefinitionBuilder() {
     }
@@ -107,11 +105,11 @@
     }
 
     public void customize() {
-        WSDLManager mgr = bus.getExtension(WSDLManager.class);
         if (!context.containsKey(ToolConstants.CFG_BINDING)) {
-            mgr.removeDefinition(wsdlDefinition);
             return;
         }
+        WSDLManager mgr = bus.getExtension(WSDLManager.class);
+        mgr.removeDefinition(wsdlDefinition);
         cusParser = new CustomizationParser();
         cusParser.parse(context);
 
@@ -132,8 +130,6 @@
                                      (String)context.get(ToolConstants.CFG_WSDLURL));
             throw new RuntimeException(msg.toString(), e);
         }
-        
-        mgr.removeDefinition(wsdlDefinition); 
 
     }
 
@@ -187,10 +183,7 @@
         reader.setFeature("javax.wsdl.verbose", false);
         reader.setExtensionRegistry(mgr.getExtensionRegistry());       
 
-        Definition def = reader.readWSDL(wsdlLocator);
-        cataLogResolvedMap.putAll(wsdlLocator.getResolvedMap());
-        return def;
-
+        return reader.readWSDL(wsdlLocator);
     }
 
     public Definition getWSDLModel() {
@@ -208,7 +201,4 @@
         return new WSDL11Validator(def, context, bus).isValid();
     }
     
-    public Map<String, String> getCataLogResolvedMap() {
-        return this.cataLogResolvedMap;
-    }
 }



Mime
View raw message