You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/09/29 19:26:54 UTC
svn commit: r580611 - in /incubator/tuscany/java/sca/modules:
interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/
interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/
interface-wsdl-xml/src/test/java/org...
Author: rfeng
Date: Sat Sep 29 10:26:53 2007
New Revision: 580611
URL: http://svn.apache.org/viewvc?rev=580611&view=rev
Log:
Reduce the memory consumption by disabling the schema loading from WSDL4J and using XSDModelResolver to host the XMLSchemaCollection
Added:
incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/AbstractWSDLTestCase.java (with props)
Removed:
incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/TestModelResolver.java
Modified:
incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java
incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java
incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/XSDModelResolver.java
incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java
incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java
incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java
incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessorTestCase.java
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/XSDefinition.java
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/XSDefinitionImpl.java
Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java?rev=580611&r1=580610&r2=580611&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java Sat Sep 29 10:26:53 2007
@@ -148,6 +148,7 @@
try {
XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
int eventType = reader.getEventType();
+ int index = 0;
while (true) {
if (eventType == XMLStreamConstants.START_ELEMENT) {
if (WSDL11.equals(reader.getName())) {
@@ -162,6 +163,8 @@
XSDefinition xsd = factory.createXSDefinition();
xsd.setUnresolved(true);
xsd.setNamespace(tns);
+ xsd.setLocation(URI.create(doc.toURI() + "#" + index));
+ index++;
// The definition is marked as resolved but not loaded
xsd.setUnresolved(false);
xsd.setSchema(null);
Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java?rev=580611&r1=580610&r2=580611&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java Sat Sep 29 10:26:53 2007
@@ -21,8 +21,10 @@
import java.io.IOException;
import java.io.InputStream;
+import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -30,7 +32,11 @@
import javax.wsdl.Definition;
import javax.wsdl.Types;
import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.ExtensionDeserializer;
import javax.wsdl.extensions.ExtensionRegistry;
+import javax.wsdl.extensions.UnknownExtensibilityElement;
+import javax.wsdl.extensions.UnknownExtensionDeserializer;
import javax.wsdl.extensions.schema.Schema;
import javax.wsdl.xml.WSDLLocator;
import javax.wsdl.xml.WSDLReader;
@@ -47,7 +53,7 @@
import org.apache.tuscany.sca.contribution.service.ContributionRuntimeException;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.tuscany.sca.interfacedef.wsdl.XSDefinition;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -61,6 +67,21 @@
* @version $Rev: 557916 $ $Date: 2007-07-20 01:04:40 -0700 (Fri, 20 Jul 2007) $
*/
public class WSDLModelResolver implements ModelResolver {
+ //Schema element names
+ public static final String ELEM_SCHEMA = "schema";
+
+ //Schema uri
+ public static final String NS_URI_XSD_1999 = "http://www.w3.org/1999/XMLSchema";
+ public static final String NS_URI_XSD_2000 = "http://www.w3.org/2000/10/XMLSchema";
+ public static final String NS_URI_XSD_2001 = "http://www.w3.org/2001/XMLSchema";
+
+ //Schema qnames
+ public static final QName Q_ELEM_XSD_1999 = new QName(NS_URI_XSD_1999, ELEM_SCHEMA);
+ public static final QName Q_ELEM_XSD_2000 = new QName(NS_URI_XSD_2000, ELEM_SCHEMA);
+ public static final QName Q_ELEM_XSD_2001 = new QName(NS_URI_XSD_2001, ELEM_SCHEMA);
+ public static final List<QName> XSD_QNAME_LIST =
+ Arrays.asList(new QName[] {Q_ELEM_XSD_1999, Q_ELEM_XSD_2000, Q_ELEM_XSD_2001});
+
private Contribution contribution;
private Map<String, List<WSDLDefinition>> map = new HashMap<String, List<WSDLDefinition>>();
@@ -78,6 +99,11 @@
this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
wsdlExtensionRegistry = this.wsdl4jFactory.newPopulatedExtensionRegistry();
+ // REVIEW: [rfeng] Disable the schema extension for WSDL4J to avoid aggressive loading
+ ExtensionDeserializer deserializer = new UnknownExtensionDeserializer();
+ for (QName schema : XSD_QNAME_LIST) {
+ wsdlExtensionRegistry.registerDeserializer(Types.class, schema, deserializer);
+ }
}
/**
@@ -155,6 +181,11 @@
public void addModel(Object resolved) {
WSDLDefinition definition = (WSDLDefinition)resolved;
+ for (XSDefinition d : definition.getXmlSchemas()) {
+ if (contribution != null) {
+ contribution.getModelResolver().addModel(d);
+ }
+ }
List<WSDLDefinition> list = map.get(definition.getNamespace());
if (list == null) {
list = new ArrayList<WSDLDefinition>();
@@ -185,12 +216,12 @@
}
if (definitions.size() == 1) {
WSDLDefinition d = definitions.get(0);
- loadOnDemand(d, d.getInlinedSchemas());
+ loadOnDemand(d);
return d;
}
WSDLDefinition aggregated = wsdlFactory.createWSDLDefinition();
for (WSDLDefinition d : definitions) {
- loadOnDemand(d, aggregated.getInlinedSchemas());
+ loadOnDemand(d);
}
Definition facade = wsdl4jFactory.newDefinition();
String ns = definitions.get(0).getNamespace();
@@ -244,13 +275,12 @@
/**
* Load the WSDL definition on demand
* @param def
- * @param schemaCollection
*/
- private void loadOnDemand(WSDLDefinition def, XmlSchemaCollection schemaCollection) {
+ private void loadOnDemand(WSDLDefinition def) {
if (def.getDefinition() == null && def.getLocation() != null) {
// Load the definition on-demand
try {
- loadDefinition(def, schemaCollection);
+ loadDefinition(def);
} catch (ContributionReadException e) {
throw new RuntimeException(e);
}
@@ -263,11 +293,9 @@
* Load the WSDL definition and inline schemas
*
* @param wsdlDef
- * @param schemaCollection
* @throws ContributionReadException
*/
- private void loadDefinition(WSDLDefinition wsdlDef, XmlSchemaCollection schemaCollection)
- throws ContributionReadException {
+ private void loadDefinition(WSDLDefinition wsdlDef) throws ContributionReadException {
if (wsdlDef.getDefinition() != null || wsdlDef.getLocation() == null) {
return;
}
@@ -287,7 +315,7 @@
wsdlDef.setDefinition(definition);
//Read inline schemas
- readInlineSchemas(definition, schemaCollection);
+ readInlineSchemas(wsdlDef, definition);
} catch (WSDLException e) {
throw new ContributionReadException(e);
} catch (IOException e) {
@@ -295,42 +323,63 @@
}
}
+ private Document promote(Element element) {
+ Document doc = (Document)element.getOwnerDocument().cloneNode(false);
+ Element schema = (Element)doc.importNode(element, true);
+ doc.appendChild(schema);
+ Node parent = element.getParentNode();
+ while (parent instanceof Element) {
+ Element root = (Element)parent;
+ NamedNodeMap nodeMap = root.getAttributes();
+ for (int i = 0; i < nodeMap.getLength(); i++) {
+ Attr attr = (Attr)nodeMap.item(i);
+ String name = attr.getName();
+ if ("xmlns".equals(name) || name.startsWith("xmlns:")) {
+ if (schema.getAttributeNode(name) == null) {
+ schema.setAttributeNodeNS((Attr)doc.importNode(attr, true));
+ }
+ }
+ }
+ parent = parent.getParentNode();
+ }
+ doc.setDocumentURI(element.getOwnerDocument().getDocumentURI());
+ return doc;
+ }
+
/**
* Populate the inline schemas including those from the imported definitions
*
* @param definition
* @param schemaCollection
*/
- private void readInlineSchemas(Definition definition, XmlSchemaCollection schemaCollection) {
+ private void readInlineSchemas(WSDLDefinition wsdlDefinition, Definition definition) {
+ if (contribution == null) {
+ // Check null for test cases
+ return;
+ }
Types types = definition.getTypes();
if (types != null) {
- schemaCollection.setSchemaResolver(new XSDModelResolver.URIResolverImpl(contribution));
int index = 0;
for (Object ext : types.getExtensibilityElements()) {
- if (ext instanceof Schema) {
- Element element = ((Schema)ext).getElement();
- Document doc = (Document) element.getOwnerDocument().cloneNode(false);
- Element schema = (Element)doc.importNode(element, true);
- doc.appendChild(schema);
- Node parent = element.getParentNode();
- while (parent instanceof Element) {
- Element root = (Element)parent;
- NamedNodeMap nodeMap = root.getAttributes();
- for (int i = 0; i < nodeMap.getLength(); i++) {
- Attr attr = (Attr)nodeMap.item(i);
- String name = attr.getName();
- if ("xmlns".equals(name) || name.startsWith("xmlns:")) {
- if (schema.getAttributeNode(name) == null) {
- schema.setAttributeNodeNS((Attr)doc.importNode(attr, true));
- }
- }
- }
- parent = parent.getParentNode();
+ ExtensibilityElement extElement = (ExtensibilityElement)ext;
+ Element element = null;
+ if (XSD_QNAME_LIST.contains(extElement.getElementType())) {
+ if (extElement instanceof Schema) {
+ element = ((Schema)extElement).getElement();
+ } else if (extElement instanceof UnknownExtensibilityElement) {
+ element = ((UnknownExtensibilityElement)extElement).getElement();
}
- String baseURI = ((Schema)ext).getDocumentBaseURI();
- doc.setDocumentURI(baseURI);
- schemaCollection.setBaseUri(baseURI);
- schemaCollection.read(doc, baseURI + "#" + index, null);
+ }
+ if (element != null) {
+ Document doc = promote(element);
+ XSDefinition xsDefinition = wsdlFactory.createXSDefinition();
+ xsDefinition.setUnresolved(true);
+ xsDefinition.setNamespace(element.getAttribute("targetNamespace"));
+ xsDefinition.setDocument(doc);
+ xsDefinition.setLocation(URI.create(doc.getDocumentURI() + "#" + index));
+ XSDefinition resolved =
+ contribution.getModelResolver().resolveModel(XSDefinition.class, xsDefinition);
+ wsdlDefinition.setInlinedSchemas(resolved.getSchemaCollection());
index++;
}
}
@@ -341,7 +390,7 @@
javax.wsdl.Import anImport = (javax.wsdl.Import)i;
// Read inline schemas
if (anImport.getDefinition() != null) {
- readInlineSchemas(anImport.getDefinition(), schemaCollection);
+ readInlineSchemas(wsdlDefinition, anImport.getDefinition());
}
}
}
Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/XSDModelResolver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/XSDModelResolver.java?rev=580611&r1=580610&r2=580611&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/XSDModelResolver.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/XSDModelResolver.java Sat Sep 29 10:26:53 2007
@@ -82,10 +82,18 @@
public <T> T resolveModel(Class<T> modelClass, T unresolved) {
+ XSDefinition definition = (XSDefinition)unresolved;
// Lookup a definition for the given namespace
- String namespace = ((XSDefinition)unresolved).getNamespace();
+ String namespace = definition.getNamespace();
List<XSDefinition> list = map.get(namespace);
- XSDefinition resolved;
+ if (list != null && definition.getDocument() != null) {
+ // Set the document for the inline schema
+ int index = list.indexOf(definition);
+ if (index != -1) {
+ list.get(index).setDocument(definition.getDocument());
+ }
+ }
+ XSDefinition resolved = null;
try {
resolved = aggregate(list);
} catch (IOException e) {
@@ -114,10 +122,26 @@
}
private void loadOnDemand(XSDefinition definition) throws IOException {
- if (definition.getSchema() == null && definition.getLocation() != null) {
+ if (definition.getSchema() != null) {
+ return;
+ }
+ if (definition.getDocument() != null) {
+ String uri = null;
+ if (definition.getLocation() != null) {
+ uri = definition.getLocation().toString();
+ }
+ XmlSchema schema = schemaCollection.read(definition.getDocument(), uri, null);
+ definition.setSchemaCollection(schemaCollection);
+ definition.setSchema(schema);
+ } else if (definition.getLocation() != null) {
+ if (definition.getLocation().getFragment() != null) {
+ // It's an inline schema
+ return;
+ }
// Read an XSD document
InputSource xsd = XMLDocumentHelper.getInputSource(definition.getLocation().toURL());
XmlSchema schema = schemaCollection.read(xsd, null);
+ definition.setSchemaCollection(schemaCollection);
definition.setSchema(schema);
}
}
@@ -159,7 +183,7 @@
aggregated.setSchema(facade);
aggregated.setNamespace(ns);
aggregated.setUnresolved(false);
-
+
// FIXME: [rfeng] This is hacky
definitions.clear();
definitions.add(aggregated);
@@ -171,7 +195,7 @@
*/
public static class URIResolverImpl implements URIResolver {
private Contribution contribution;
-
+
public URIResolverImpl(Contribution contribution) {
this.contribution = contribution;
}
Added: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/AbstractWSDLTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/AbstractWSDLTestCase.java?rev=580611&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/AbstractWSDLTestCase.java (added)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/AbstractWSDLTestCase.java Sat Sep 29 10:26:53 2007
@@ -0,0 +1,67 @@
+/*
+ * 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.tuscany.sca.interfacedef.wsdl;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.impl.ContributionImpl;
+import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolverExtensionPoint;
+import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLDocumentProcessor;
+import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLModelResolver;
+import org.apache.tuscany.sca.interfacedef.wsdl.xml.XSDModelResolver;
+
+/**
+ * Test case for WSDLOperation
+ */
+public abstract class AbstractWSDLTestCase extends TestCase {
+ protected WSDLDocumentProcessor processor;
+ protected ModelResolver resolver;
+ protected WSDLFactory wsdlFactory;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ Contribution contribution = new ContributionImpl() {
+ };
+ ModelResolverExtensionPoint modelResolvers = new DefaultModelResolverExtensionPoint();
+ ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint();
+ wsdlFactory = new DefaultWSDLFactory();
+ factories.addFactory(wsdlFactory);
+ javax.wsdl.factory.WSDLFactory wsdl4jFactory = javax.wsdl.factory.WSDLFactory.newInstance();
+ factories.addFactory(wsdlFactory);
+ factories.addFactory(wsdl4jFactory);
+ resolver = new ExtensibleModelResolver(contribution, modelResolvers, factories);
+ contribution.setModelResolver(resolver);
+ modelResolvers.addResolver(WSDLDefinition.class, WSDLModelResolver.class);
+ modelResolvers.addResolver(XSDefinition.class, XSDModelResolver.class);
+
+ processor = new WSDLDocumentProcessor(factories);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/AbstractWSDLTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/AbstractWSDLTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java?rev=580611&r1=580610&r2=580611&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java Sat Sep 29 10:26:53 2007
@@ -27,32 +27,22 @@
import javax.xml.namespace.QName;
import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint;
-import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
-import org.apache.tuscany.sca.interfacedef.wsdl.DefaultWSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.AbstractWSDLTestCase;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
-import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
-import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLDocumentProcessor;
-import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLModelResolver;
/**
* Test case for InterfaceWSDLIntrospectorImpl
*/
-public class WSDLInterfaceIntrospectorTestCase extends TestCase {
+public class WSDLInterfaceIntrospectorTestCase extends AbstractWSDLTestCase {
private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
- private WSDLDocumentProcessor registry;
- private WSDLFactory wsdlFactory;
private PortType portType;
- private ModelResolver resolver;
private WSDLDefinition definition;
/**
@@ -61,18 +51,12 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint();
- wsdlFactory = new DefaultWSDLFactory();
- factories.addFactory(wsdlFactory);
- javax.wsdl.factory.WSDLFactory wsdl4jFactory = javax.wsdl.factory.WSDLFactory.newInstance();
- factories.addFactory(wsdl4jFactory);
- registry = new WSDLDocumentProcessor(factories);
- resolver = new TestModelResolver();
+
URL url = getClass().getResource("../xml/stockquote.wsdl");
- definition = registry.read(null, new URI("stockquote.wsdl"), url);
- WSDLModelResolver wsdlResolver = new WSDLModelResolver(null, factories);
- wsdlResolver.addModel(definition);
- definition = wsdlResolver.resolveModel(WSDLDefinition.class, definition); portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
+ definition = processor.read(null, new URI("stockquote.wsdl"), url);
+ resolver.addModel(definition);
+ definition = resolver.resolveModel(WSDLDefinition.class, definition);
+ portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
}
@SuppressWarnings("unchecked")
Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java?rev=580611&r1=580610&r2=580611&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java Sat Sep 29 10:26:53 2007
@@ -28,55 +28,28 @@
import javax.xml.namespace.QName;
import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint;
-import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
-import org.apache.tuscany.sca.interfacedef.wsdl.DefaultWSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.AbstractWSDLTestCase;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
-import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
import org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl;
-import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLDocumentProcessor;
-import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLModelResolver;
/**
* Test case for WSDLOperation
*/
-public class WSDLOperationIntrospectorTestCase extends TestCase {
+public class WSDLOperationIntrospectorTestCase extends AbstractWSDLTestCase {
private static final QName PORTTYPE_NAME =
new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
- private WSDLDocumentProcessor processor;
- private WSDLModelResolver wsdlResolver;
- private ModelResolver resolver;
- private WSDLFactory wsdlFactory;
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- wsdlFactory = new DefaultWSDLFactory();
- ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint();
- factories.addFactory(wsdlFactory);
- javax.wsdl.factory.WSDLFactory wsdl4jFactory = javax.wsdl.factory.WSDLFactory.newInstance();
- factories.addFactory(wsdl4jFactory);
- processor = new WSDLDocumentProcessor(factories);
- wsdlResolver = new WSDLModelResolver(null, factories);
- resolver = new TestModelResolver();
- }
@SuppressWarnings("unchecked")
public final void testWrappedOperation() throws Exception {
URL url = getClass().getResource("../xml/stockquote.wsdl");
WSDLDefinition definition = processor.read(null, new URI("stockquote.wsdl"), url);
- wsdlResolver.addModel(definition);
- definition = wsdlResolver.resolveModel(WSDLDefinition.class, definition);
+ resolver.addModel(definition);
+ definition = resolver.resolveModel(WSDLDefinition.class, definition);
PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
Operation operation = portType.getOperation("getLastTradePrice", null, null);
@@ -105,8 +78,8 @@
public final void testUnwrappedOperation() throws Exception {
URL url = getClass().getResource("../xml/unwrapped-stockquote.wsdl");
WSDLDefinition definition = processor.read(null, new URI("unwrapped-stockquote.wsdl"), url);
- wsdlResolver.addModel(definition);
- definition = wsdlResolver.resolveModel(WSDLDefinition.class, definition);
+ resolver.addModel(definition);
+ definition = resolver.resolveModel(WSDLDefinition.class, definition);
PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
Operation operation = portType.getOperation("getLastTradePrice1", null, null);
@@ -123,8 +96,8 @@
public final void testInvalidWSDL() throws Exception {
URL url = getClass().getResource("../xml/invalid-stockquote.wsdl");
WSDLDefinition definition = processor.read(null, new URI("invalid-stockquote.wsdl"), url);
- wsdlResolver.addModel(definition);
- definition = wsdlResolver.resolveModel(WSDLDefinition.class, definition);
+ resolver.addModel(definition);
+ definition = resolver.resolveModel(WSDLDefinition.class, definition);
PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
Operation operation = portType.getOperation("getLastTradePrice", null, null);
Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java?rev=580611&r1=580610&r2=580611&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java Sat Sep 29 10:26:53 2007
@@ -27,50 +27,22 @@
import javax.xml.namespace.QName;
import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint;
-import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.interfacedef.wsdl.DefaultWSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.AbstractWSDLTestCase;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
-import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
import org.apache.tuscany.sca.interfacedef.wsdl.impl.WSDLOperationIntrospectorImpl;
-import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLDocumentProcessor;
-import org.apache.tuscany.sca.interfacedef.wsdl.xml.WSDLModelResolver;
/**
* Test case for WSDLOperation
*/
-public class WrapperStyleOperationTestCase extends TestCase {
+public class WrapperStyleOperationTestCase extends AbstractWSDLTestCase {
private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType");
- private WSDLDocumentProcessor registry;
- private ModelResolver resolver;
- private WSDLFactory wsdlFactory;
- private WSDLModelResolver wsdlResolver;
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint();
- wsdlFactory = new DefaultWSDLFactory();
- factories.addFactory(wsdlFactory);
- javax.wsdl.factory.WSDLFactory wsdl4jFactory = javax.wsdl.factory.WSDLFactory.newInstance();
- factories.addFactory(wsdl4jFactory);
- registry = new WSDLDocumentProcessor(factories);
- resolver = new TestModelResolver();
- wsdlResolver = new WSDLModelResolver(null, factories);
- }
-
public final void testWrappedOperation() throws Exception {
URL url = getClass().getResource("../xml/stockquote.wsdl");
- WSDLDefinition definition = registry.read(null, new URI("stockquote.wsdl"), url);
- wsdlResolver.addModel(definition);
- definition = wsdlResolver.resolveModel(WSDLDefinition.class, definition);
+ WSDLDefinition definition = processor.read(null, new URI("stockquote.wsdl"), url);
+ resolver.addModel(definition);
+ definition = resolver.resolveModel(WSDLDefinition.class, definition);
PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
Operation operation = portType.getOperation("getLastTradePrice", null, null);
WSDLOperationIntrospectorImpl op = new WSDLOperationIntrospectorImpl(wsdlFactory, operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver);
@@ -81,9 +53,9 @@
public final void testUnwrappedOperation() throws Exception {
URL url = getClass().getResource("../xml/unwrapped-stockquote.wsdl");
- WSDLDefinition definition = registry.read(null, new URI("unwrapped-stockquote.wsdl"), url);
- wsdlResolver.addModel(definition);
- definition = wsdlResolver.resolveModel(WSDLDefinition.class, definition);
+ WSDLDefinition definition = processor.read(null, new URI("unwrapped-stockquote.wsdl"), url);
+ resolver.addModel(definition);
+ definition = resolver.resolveModel(WSDLDefinition.class, definition);
PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME);
Operation operation = portType.getOperation("getLastTradePrice1", null, null);
WSDLOperationIntrospectorImpl op = new WSDLOperationIntrospectorImpl(wsdlFactory, operation, definition.getInlinedSchemas(), "org.w3c.dom.Node", resolver);
Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessorTestCase.java?rev=580611&r1=580610&r2=580611&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessorTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessorTestCase.java Sat Sep 29 10:26:53 2007
@@ -28,11 +28,8 @@
import junit.framework.Assert;
-import org.apache.tuscany.sca.contribution.DefaultModelFactoryExtensionPoint;
-import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
-import org.apache.tuscany.sca.interfacedef.wsdl.DefaultWSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.AbstractWSDLTestCase;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
-import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -40,22 +37,14 @@
/**
* @version $Rev$ $Date$
*/
-public class WSDLDocumentProcessorTestCase {
- private WSDLDocumentProcessor processor;
- private WSDLFactory wsdlFactory;
- private javax.wsdl.factory.WSDLFactory wsdl4jFactory;
+public class WSDLDocumentProcessorTestCase extends AbstractWSDLTestCase {
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
- ModelFactoryExtensionPoint modelFactories = new DefaultModelFactoryExtensionPoint();
- wsdlFactory = new DefaultWSDLFactory();
- modelFactories.addFactory(wsdlFactory);
- wsdl4jFactory = javax.wsdl.factory.WSDLFactory.newInstance();
- modelFactories.addFactory(wsdl4jFactory);
- processor = new WSDLDocumentProcessor(modelFactories);
+ super.setUp();
}
/**
@@ -67,20 +56,21 @@
@Test
public void testWSDL() throws Exception {
+
URL url = getClass().getResource("/wsdl/helloworld-service.wsdl");
WSDLDefinition definition = processor.read(null, URI.create("wsdl/helloworld-service.wsdl"), url);
+
Assert.assertNull(definition.getDefinition());
Assert.assertEquals("http://helloworld", definition.getNamespace());
URL url1 = getClass().getResource("/wsdl/helloworld-interface.wsdl");
WSDLDefinition definition1 = processor.read(null, URI.create("wsdl/helloworld-interface.wsdl"), url1);
Assert.assertNull(definition1.getDefinition());
Assert.assertEquals("http://helloworld", definition1.getNamespace());
- ModelFactoryExtensionPoint factories = new DefaultModelFactoryExtensionPoint();
- factories.addFactory(wsdlFactory);
- factories.addFactory(wsdl4jFactory);
- WSDLModelResolver resolver = new WSDLModelResolver(null, factories);
+
resolver.addModel(definition);
resolver.addModel(definition1);
+ resolver.resolveModel(WSDLDefinition.class, definition);
+ resolver.resolveModel(WSDLDefinition.class, definition1);
WSDLDefinition resolved = resolver.resolveModel(WSDLDefinition.class, definition);
List imports = (List)definition.getDefinition().getImports().get("http://helloworld");
Assert.assertNotNull(imports);
Modified: incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java?rev=580611&r1=580610&r2=580611&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java Sat Sep 29 10:26:53 2007
@@ -53,6 +53,8 @@
*/
XmlSchemaCollection getInlinedSchemas();
+ void setInlinedSchemas(XmlSchemaCollection schemaCollection);
+
/**
* Returns the namespace of this WSDL definition.
* @return the namespace of this WSDL definition
Modified: incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/XSDefinition.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/XSDefinition.java?rev=580611&r1=580610&r2=580611&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/XSDefinition.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/XSDefinition.java Sat Sep 29 10:26:53 2007
@@ -23,6 +23,8 @@
import org.apache.tuscany.sca.assembly.Base;
import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.w3c.dom.Document;
/**
* Represents an XML Schema definition.
@@ -30,19 +32,22 @@
* @version $Rev$ $Date$
*/
public interface XSDefinition extends Base {
-
+ XmlSchemaCollection getSchemaCollection();
+
+ void setSchemaCollection(XmlSchemaCollection schemaCollection);
+
/**
* Returns the XmlSchema definition model
* @return the XmlSchema definition model
*/
XmlSchema getSchema();
-
+
/**
* Sets the XmlSchema definition model
* @param definition the XmlSchema definition model
*/
void setSchema(XmlSchema definition);
-
+
/**
* Returns the namespace of this XmlSchema definition.
* @return the namespace of this XmlSchema definition
@@ -54,7 +59,28 @@
* @param namespace the namespace of this XmlSchema definition
*/
void setNamespace(String namespace);
-
+
+ /**
+ * Get the location of the XSD
+ * @return
+ */
URI getLocation();
+
+ /**
+ * Set the location of the XSD
+ * @param uri
+ */
void setLocation(URI uri);
+
+ /**
+ * Get the DOM representation of the XSD
+ * @return
+ */
+ Document getDocument();
+
+ /**
+ * Set the DOM representation of the XSD
+ * @param document
+ */
+ void setDocument(Document document);
}
Modified: incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java?rev=580611&r1=580610&r2=580611&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java Sat Sep 29 10:26:53 2007
@@ -35,14 +35,14 @@
* @version $Rev$ $Date$
*/
public class WSDLDefinitionImpl implements WSDLDefinition {
-
+
private Definition definition;
private String namespace;
private URI location;
- private XmlSchemaCollection inlineSchemas = new XmlSchemaCollection();
+ private XmlSchemaCollection inlinedSchemas = new XmlSchemaCollection();
private List<XSDefinition> schemas = new ArrayList<XSDefinition>();
private boolean unresolved;
-
+
protected WSDLDefinitionImpl() {
}
@@ -53,9 +53,9 @@
public void setDefinition(Definition definition) {
this.definition = definition;
}
-
+
public XmlSchemaCollection getInlinedSchemas() {
- return inlineSchemas;
+ return inlinedSchemas;
}
public boolean isUnresolved() {
@@ -65,7 +65,7 @@
public void setUnresolved(boolean undefined) {
this.unresolved = undefined;
}
-
+
public String getNamespace() {
if (isUnresolved()) {
return namespace;
@@ -75,7 +75,7 @@
return namespace;
}
}
-
+
public void setNamespace(String namespace) {
if (!isUnresolved()) {
throw new IllegalStateException();
@@ -83,7 +83,7 @@
this.namespace = namespace;
}
}
-
+
/*
@Override
public int hashCode() {
@@ -126,6 +126,50 @@
*/
public void setLocation(URI url) {
this.location = url;
+ }
+
+ /**
+ * @param inlineSchemas the inlineSchemas to set
+ */
+ public void setInlinedSchemas(XmlSchemaCollection inlinedSchemas) {
+ this.inlinedSchemas = inlinedSchemas;
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((location == null) ? 0 : location.hashCode());
+ result = prime * result + ((namespace == null) ? 0 : namespace.hashCode());
+ return result;
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof WSDLDefinitionImpl))
+ return false;
+ final WSDLDefinitionImpl other = (WSDLDefinitionImpl)obj;
+ if (location == null) {
+ if (other.location != null)
+ return false;
+ } else if (!location.equals(other.location))
+ return false;
+ if (namespace == null) {
+ if (other.namespace != null)
+ return false;
+ } else if (!namespace.equals(other.namespace))
+ return false;
+ return true;
}
}
Modified: incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/XSDefinitionImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/XSDefinitionImpl.java?rev=580611&r1=580610&r2=580611&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/XSDefinitionImpl.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/XSDefinitionImpl.java Sat Sep 29 10:26:53 2007
@@ -23,6 +23,8 @@
import org.apache.tuscany.sca.interfacedef.wsdl.XSDefinition;
import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.w3c.dom.Document;
/**
* Represents a XML schema definition.
@@ -30,21 +32,22 @@
* @version $Rev$ $Date$
*/
public class XSDefinitionImpl implements XSDefinition {
-
- private XmlSchema definition;
+ private XmlSchemaCollection schemaCollection;
+ private XmlSchema schema;
private String namespace;
private URI location;
+ private Document document;
private boolean unresolved;
protected XSDefinitionImpl() {
}
public XmlSchema getSchema() {
- return definition;
+ return schema;
}
public void setSchema(XmlSchema definition) {
- this.definition = definition;
+ this.schema = definition;
}
public boolean isUnresolved() {
@@ -58,8 +61,8 @@
public String getNamespace() {
if (isUnresolved()) {
return namespace;
- } else if (definition != null) {
- return definition.getTargetNamespace();
+ } else if (schema != null) {
+ return schema.getTargetNamespace();
} else {
return namespace;
}
@@ -85,5 +88,70 @@
*/
public void setLocation(URI location) {
this.location = location;
+ }
+
+ /**
+ * @return the document
+ */
+ public Document getDocument() {
+ return document;
+ }
+
+ /**
+ * @param document the document to set
+ */
+ public void setDocument(Document document) {
+ this.document = document;
+ }
+
+ /**
+ * @return the schemaCollection
+ */
+ public XmlSchemaCollection getSchemaCollection() {
+ return schemaCollection;
+ }
+
+ /**
+ * @param schemaCollection the schemaCollection to set
+ */
+ public void setSchemaCollection(XmlSchemaCollection schemaCollection) {
+ this.schemaCollection = schemaCollection;
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((location == null) ? 0 : location.hashCode());
+ result = prime * result + ((namespace == null) ? 0 : namespace.hashCode());
+ return result;
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof XSDefinitionImpl))
+ return false;
+ final XSDefinitionImpl other = (XSDefinitionImpl)obj;
+ if (location == null) {
+ if (other.location != null)
+ return false;
+ } else if (!location.equals(other.location))
+ return false;
+ if (namespace == null) {
+ if (other.namespace != null)
+ return false;
+ } else if (!namespace.equals(other.namespace))
+ return false;
+ return true;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org