1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.support.definition.support;
14
15 import java.util.Collection;
16 import java.util.HashSet;
17 import java.util.Set;
18
19 import javax.xml.namespace.QName;
20
21 import org.apache.xmlbeans.SchemaType;
22 import org.apache.xmlbeans.SchemaTypeLoader;
23 import org.apache.xmlbeans.SchemaTypeSystem;
24 import org.apache.xmlbeans.XmlBeans;
25
26 import com.eviware.soapui.impl.support.AbstractInterface;
27 import com.eviware.soapui.impl.support.definition.DefinitionLoader;
28 import com.eviware.soapui.impl.wsdl.support.xsd.SchemaException;
29 import com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils;
30
31 public abstract class XmlSchemaBasedInterfaceDefinition<T extends AbstractInterface> extends
32 AbstractInterfaceDefinition<T>
33 {
34 private SchemaTypeSystem schemaTypes;
35 private SchemaTypeLoader schemaTypeLoader;
36
37 public XmlSchemaBasedInterfaceDefinition( T iface )
38 {
39 super( iface );
40 }
41
42 public SchemaTypeLoader getSchemaTypeLoader()
43 {
44 return schemaTypeLoader;
45 }
46
47 public SchemaTypeSystem getSchemaTypeSystem()
48 {
49 return schemaTypes;
50 }
51
52 public boolean hasSchemaTypes()
53 {
54 return schemaTypes != null;
55 }
56
57 public Collection<String> getDefinedNamespaces() throws Exception
58 {
59 Set<String> namespaces = new HashSet<String>();
60
61 SchemaTypeSystem schemaTypes = getSchemaTypeSystem();
62 if( schemaTypes != null )
63 {
64 namespaces.addAll( SchemaUtils.extractNamespaces( getSchemaTypeSystem(), true ) );
65 }
66
67 namespaces.add( getTargetNamespace() );
68
69 return namespaces;
70 }
71
72 public SchemaType findType( QName typeName )
73 {
74 return getSchemaTypeLoader().findType( typeName );
75 }
76
77 public void loadSchemaTypes( DefinitionLoader loader ) throws SchemaException
78 {
79 schemaTypes = SchemaUtils.loadSchemaTypes( loader.getBaseURI(), loader );
80 schemaTypeLoader = XmlBeans.typeLoaderUnion( new SchemaTypeLoader[] { schemaTypes,
81 XmlBeans.getBuiltinTypeSystem() } );
82 }
83 }