Author: bimargulies Date: Sun Oct 21 15:40:17 2007 New Revision: 586965 URL: http://svn.apache.org/viewvc?rev=586965&view=rev Log: 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/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java?rev=586965&r1=586964&r2=586965&view=diff ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java (original) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ServiceWSDLBuilder.java Sun Oct 21 15:40:17 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 [EMAIL PROTECTED] #build(Map)}, which is passed additional schemas for + * import. [EMAIL PROTECTED] #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 [EMAIL PROTECTED] #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/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java?rev=586965&r1=586964&r2=586965&view=diff ============================================================================== --- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java (original) +++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLDefinitionBuilder.java Sun Oct 21 15:40:17 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());