You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2007/10/22 23:08:46 UTC

svn commit: r587255 - in /incubator/cxf/branches/2.0.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java

Author: dkulp
Date: Mon Oct 22 14:08:46 2007
New Revision: 587255

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

........
  r586965 | bimargulies | 2007-10-21 18:40:17 -0400 (Sun, 21 Oct 2007) | 2 lines
  
  Add some javadoc and use some defined constants in the WSDL building code. This is a side-effect of studying the code.
........

Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
    incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java?rev=587255&r1=587254&r2=587255&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java Mon Oct 22 14:08:46 2007
@@ -73,6 +73,15 @@
 import org.apache.cxf.wsdl.WSDLConstants;
 import org.apache.cxf.wsdl.WSDLManager;
 
+/**
+ * Consume a set of service definitions and produce a WSDL model. The ServiceInfo objects
+ * contain the bindings, operations, and ports, plus XMLSchema schemas. 
+ * 
+ * Each wsdl:definition has to have a single target namespace. The first service in the list
+ * defines the TNS of the overall WSDL. If a subsequent service has a divergent TNS, then
+ * the code creates a new definition element (i.e., Definition object), and imports it into
+ * the top-level object.
+ */
 public final class ServiceWSDLBuilder {
     
     private final Map<String, String> ns2prefix;
@@ -83,25 +92,64 @@
     private int xsdCount;
     private final Bus bus;
     
+    /**
+     * Sets up the builder on a bus with a list of services.
+     * @param b the bus.
+     * @param services the services.
+     */
     public ServiceWSDLBuilder(Bus b, List<ServiceInfo> services) {
         this.services = services;
         bus = b;
         ns2prefix = new HashMap<String, String>();
     }
+    
+    /**
+     * For callers who prefer varargs, an inline list of ServiceInfo objects instead of 
+     * a List. Primarily used for tests or other callers with only one service in hand. 
+     * @param b the bus.
+     * @param services the services.
+     */
     public ServiceWSDLBuilder(Bus b, ServiceInfo ... services) {
         this(b, Arrays.asList(services));
     }
+    
+    /**
+     * Set whether to emit references to imported schema files.
+     * This is only effective for {@link #build(Map)}, which is passed additional schemas for 
+     * import. {@link #build()} resets this flag to false.
+     * @param b true to use imports.
+     */
     public void setUseSchemaImports(boolean b) {
         useSchemaImports = b;
     }
+    
+    /**
+     * Base filename for imported files.
+     * @param s pathname.
+     */
     public void setBaseFileName(String s) {
         baseFileName = s;
     }
     
+    /**
+     * Create the WSDL Definition object and return it. This function will never create
+     * imports to schemas.
+     * @return the WSDL definition.
+     * @throws WSDLException
+     */
     public Definition build() throws WSDLException {
         useSchemaImports = false;
         return build(null);
     }
+    
+    /**
+     * Create the WSDL Definition object and return it. This function respects the 
+     * setting of {@link #setUseSchemaImports(boolean)}.
+     * @param imports A set of schema imports to either reference as imports or read and 
+     * then inline.
+     * @return the WSDL definition
+     * @throws WSDLException
+     */
     public Definition build(Map<String, SchemaInfo> imports) throws WSDLException {
         try {
             definition = services.get(0).getProperty(WSDLServiceBuilder.WSDL_DEFINITION, Definition.class);
@@ -156,7 +204,12 @@
         return d;
     }
 
-
+    /** 
+     * Return a list of ExtensibilityElements for a particular component, such as a BindingFaultInfo.
+     * This perhaps should be protected.
+     * @param holder The item containing the extensibility elements.
+     * @return the extensibility elements.
+     */
     public List<ExtensibilityElement> getWSDL11Extensors(AbstractPropertiesHolder holder) {
         return holder.getExtensors(ExtensibilityElement.class);
     }
@@ -181,11 +234,11 @@
         try {
             doc = XMLUtils.newDocument();
         } catch (ParserConfigurationException e) {
-            //should not happen
+            throw new RuntimeException("DOM configuration problem", e);
         }
-        Element nd = XMLUtils.createElementNS(doc, new QName("http://www.w3.org/2001/XMLSchema",
+        Element nd = XMLUtils.createElementNS(doc, new QName(WSDLConstants.NU_SCHEMA_XSD,
                                                              "schema"));
-        nd.setAttribute("xmlns", "http://www.w3.org/2001/XMLSchema");
+        nd.setAttribute("xmlns", WSDLConstants.NU_SCHEMA_XSD);
         doc.appendChild(nd);
         
         for (SchemaInfo schemaInfo : schemas) {
@@ -200,7 +253,7 @@
                 //imports
                 String name = baseFileName + "_schema" + (++xsdCount) + ".xsd";
                 Element imp = XMLUtils.createElementNS(doc, 
-                                                       new QName("http://www.w3.org/2001/XMLSchema",
+                                                       new QName(WSDLConstants.NU_SCHEMA_XSD,
                                                                   "import"));
                 imp.setAttribute("schemaLocation", name);
                 imp.setAttribute("namespace", schemaInfo.getNamespaceURI());

Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java?rev=587255&r1=587254&r2=587255&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java Mon Oct 22 14:08:46 2007
@@ -51,6 +51,7 @@
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.wsdl.JAXBExtensionHelper;
 import org.apache.cxf.wsdl.WSDLBuilder;
+import org.apache.cxf.wsdl.WSDLConstants;
 import org.apache.cxf.wsdl.WSDLExtensibilityPlugin;
 
 public class WSDLDefinitionBuilder implements WSDLBuilder<Definition> {
@@ -79,7 +80,7 @@
         try {
             wsdlFactory = WSDLFactory.newInstance();
             registry = wsdlFactory.newPopulatedExtensionRegistry();
-            QName header = new QName("http://schemas.xmlsoap.org/wsdl/soap/", "header");
+            QName header = new QName(WSDLConstants.WSDL11_NAMESPACE, "header");
             registry.registerDeserializer(MIMEPart.class,
                                           header,
                                           new SOAPHeaderSerializer());