diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-07-31 02:04:22 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-07-31 02:04:22 +0000 |
commit | 27c3c5897baa5822d3ce64459d1190696c691612 (patch) | |
tree | 33ff008a8b1766b33e6d6322f762bc0d0e6f3065 /java/sca/modules/binding-ws-wsdlgen | |
parent | 0f7ea2884eb1563a7ddec2b76939bce8e8b001e5 (diff) |
Get the instance of DocumentBuilderFactory from the registry instead of creating a new instance
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@799488 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/binding-ws-wsdlgen')
4 files changed, 17 insertions, 7 deletions
diff --git a/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java b/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java index b391a66c20..d94290a641 100644 --- a/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java +++ b/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java @@ -28,6 +28,7 @@ import javax.wsdl.PortType; import javax.wsdl.WSDLException; import javax.wsdl.xml.WSDLWriter; import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilderFactory; import org.apache.tuscany.sca.assembly.AbstractContract; import org.apache.tuscany.sca.assembly.Component; @@ -188,6 +189,7 @@ public class BindingWSDLGenerator { DataBindingExtensionPoint dataBindings = extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class); WSDLFactory wsdlFactory = modelFactories.getFactory(WSDLFactory.class); XSDFactory xsdFactory = modelFactories.getFactory(XSDFactory.class); + DocumentBuilderFactory documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class); if (((Contract)contract).getInterfaceContract(wsBinding) == null) { // can happen if incorrect component service name @@ -207,6 +209,7 @@ public class BindingWSDLGenerator { dataBindings, wsdlFactory, xsdFactory, + documentBuilderFactory, monitor); } else { try { @@ -289,6 +292,7 @@ public class BindingWSDLGenerator { DataBindingExtensionPoint dataBindings, WSDLFactory wsdlFactory, XSDFactory xsdFactory, + DocumentBuilderFactory documentBuilderFactory, Monitor monitor) { WSDLInterfaceContract wsdlContract = wsdlFactory.createWSDLInterfaceContract(); @@ -301,7 +305,7 @@ public class BindingWSDLGenerator { Definition def = null; try { Interface2WSDLGenerator wsdlGenerator = - new Interface2WSDLGenerator(requiresSOAP12, resolver, dataBindings, xsdFactory, monitor); + new Interface2WSDLGenerator(requiresSOAP12, resolver, dataBindings, xsdFactory, documentBuilderFactory, monitor); def = wsdlGenerator.generate(iface, wsdlDefinition); } catch (WSDLException e) { throw new WSDLGenerationException(e); diff --git a/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java b/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java index ec22ec0073..a1e9075009 100644 --- a/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java +++ b/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java @@ -95,6 +95,7 @@ public class Interface2WSDLGenerator { private WSDLFactory factory; private DataBindingExtensionPoint dataBindings; private WSDLDefinitionGenerator definitionGenerator; + private DocumentBuilderFactory documentBuilderFactory; private boolean requiresSOAP12; private ModelResolver resolver; private XSDFactory xsdFactory; @@ -104,10 +105,12 @@ public class Interface2WSDLGenerator { ModelResolver resolver, DataBindingExtensionPoint dataBindings, XSDFactory xsdFactory, + DocumentBuilderFactory documentBuilderFactory, Monitor monitor) throws WSDLException { super(); this.requiresSOAP12 = requiresSOAP12; - this.resolver = resolver; + this.resolver = resolver; + this.documentBuilderFactory = documentBuilderFactory; definitionGenerator = new WSDLDefinitionGenerator(requiresSOAP12); this.dataBindings = dataBindings; this.xsdFactory = xsdFactory; @@ -535,8 +538,6 @@ public class Interface2WSDLGenerator { return (Schema)definition.getExtensionRegistry().createExtension(Types.class, SCHEMA_QNAME); } - private DocumentBuilderFactory documentBuilderFactory; - public Document createDocument() { Document document; try { diff --git a/java/sca/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java b/java/sca/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java index c9bfce5865..dafa1497a8 100644 --- a/java/sca/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java +++ b/java/sca/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java @@ -18,6 +18,8 @@ */ package org.apache.tuscany.sca.binding.ws.wsdlgen; +import javax.xml.parsers.DocumentBuilderFactory; + import junit.framework.TestCase; import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; @@ -48,6 +50,7 @@ public class BindingWSDLGeneratorTestCase extends TestCase { org.apache.tuscany.sca.core.FactoryExtensionPoint modelFactories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()); WSDLFactory wsdlFactory = modelFactories.getFactory(WSDLFactory.class); XSDFactory xsdFactory = modelFactories.getFactory(XSDFactory.class); + DocumentBuilderFactory documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class); JavaInterfaceFactory factory = new DefaultJavaInterfaceFactory(); JavaInterfaceContract javaIC = factory.createJavaInterfaceContract(); JavaInterface iface = factory.createJavaInterface(HelloWorld.class); @@ -56,7 +59,7 @@ public class BindingWSDLGeneratorTestCase extends TestCase { new JAXWSJavaInterfaceProcessor(dataBindings, faultExceptionMapper, null).visitInterface(iface); new DataBindingJavaInterfaceProcessor(dataBindings).visitInterface(iface); javaIC.setInterface(iface); - WSDLInterfaceContract wsdlIC = BindingWSDLGenerator.createWSDLInterfaceContract(javaIC, false, new XSDModelResolver(null, null), dataBindings, wsdlFactory, xsdFactory, null); + WSDLInterfaceContract wsdlIC = BindingWSDLGenerator.createWSDLInterfaceContract(javaIC, false, new XSDModelResolver(null, null), dataBindings, wsdlFactory, xsdFactory, documentBuilderFactory, null); assertNotNull(wsdlIC); WSDLInterface wsdlInterface = (WSDLInterface)wsdlIC.getInterface(); assertNotNull(wsdlInterface); @@ -69,7 +72,7 @@ public class BindingWSDLGeneratorTestCase extends TestCase { new JAXWSJavaInterfaceProcessor(dataBindings, faultExceptionMapper, null).visitInterface(iface2); new DataBindingJavaInterfaceProcessor(dataBindings).visitInterface(iface2); javaIC2.setInterface(iface2); - WSDLInterfaceContract wsdlIC2 = BindingWSDLGenerator.createWSDLInterfaceContract(javaIC2, false, new XSDModelResolver(null, null), dataBindings, wsdlFactory, xsdFactory, null); + WSDLInterfaceContract wsdlIC2 = BindingWSDLGenerator.createWSDLInterfaceContract(javaIC2, false, new XSDModelResolver(null, null), dataBindings, wsdlFactory, xsdFactory, documentBuilderFactory, null); assertNotNull(wsdlIC2); } diff --git a/java/sca/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java b/java/sca/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java index 670c3a4003..a55bf6de8a 100644 --- a/java/sca/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java +++ b/java/sca/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java @@ -23,6 +23,7 @@ import java.io.StringWriter; import javax.wsdl.Definition; import javax.wsdl.xml.WSDLWriter; +import javax.xml.parsers.DocumentBuilderFactory; import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint; @@ -56,9 +57,10 @@ public class Interface2WSDLGeneratorTestCase { new DataBindingJavaInterfaceProcessor(dataBindings).visitInterface(iface); DefaultFactoryExtensionPoint modelFactories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()); WSDLFactory wFactory = new DefaultWSDLFactory(modelFactories); + DocumentBuilderFactory documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class); WSDLDefinition wsdlDefinition = wFactory.createWSDLDefinition(); XSDFactory factory = new DefaultXSDFactory(); - Interface2WSDLGenerator generator = new Interface2WSDLGenerator(false, new XSDModelResolver(null, null), dataBindings, factory, null); + Interface2WSDLGenerator generator = new Interface2WSDLGenerator(false, new XSDModelResolver(null, null), dataBindings, factory, documentBuilderFactory, null); Definition definition = generator.generate(iface, wsdlDefinition); // print the generated WSDL file and inline schemas |