geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r164004 - in /geronimo/trunk/modules/axis-builder/src: java/org/apache/geronimo/axis/builder/ test/org/apache/geronimo/axis/builder/
Date Thu, 21 Apr 2005 05:03:37 GMT
Author: djencks
Date: Wed Apr 20 22:03:36 2005
New Revision: 164004

URL: http://svn.apache.org/viewcvs?rev=164004&view=rev
Log:
clean up use of SchemaInfoBuilder and allow use of restrictions of simple types in faults/exception
constructors

Modified:
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java
    geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/SchemaInfoBuilder.java
    geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ParsingTest.java

Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java?rev=164004&r1=164003&r2=164004&view=diff
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java
Wed Apr 20 22:03:36 2005
@@ -240,9 +240,9 @@
         }
 
         Map exceptionMap = WSDescriptorParser.getExceptionMap(mapping);
-        Map schemaTypeKeyToSchemaTypeMap = schemaInfoBuilder.getSchemaTypeKeyToSchemaTypeMap();
-        Map complexTypeMap = schemaInfoBuilder.getComplexTypesInWsdl();
-        Map elementMap = schemaInfoBuilder.getElementToTypeMap();
+//        Map schemaTypeKeyToSchemaTypeMap = schemaInfoBuilder.getSchemaTypeKeyToSchemaTypeMap();
+//        Map complexTypeMap = schemaInfoBuilder.getComplexTypesInWsdl();
+//        Map elementMap = schemaInfoBuilder.getElementToTypeMap();
 
         Map wsdlPortMap = service.getPorts();
         for (Iterator iterator = wsdlPortMap.entrySet().iterator(); iterator.hasNext();)
{
@@ -266,9 +266,9 @@
             List operations = portType.getOperations();
             OperationInfo[] operationInfos = new OperationInfo[operations.size()];
             if (endpointMappings.length == 0) {
-                doLightweightMapping(service.getQName(), portType, mapping, classLoader,
context, module, operations, binding, portStyle, soapVersion, operationInfos, schemaTypeKeyToSchemaTypeMap,
portName, serviceImpl, location, handlerInfos, seiPortNameToFactoryMap, seiClassNameToFactoryMap,
credentialsName);
+                doLightweightMapping(service.getQName(), portType, mapping, classLoader,
context, module, operations, binding, portStyle, soapVersion, operationInfos, schemaInfoBuilder,
portName, serviceImpl, location, handlerInfos, seiPortNameToFactoryMap, seiClassNameToFactoryMap,
credentialsName);
             } else {
-                doHeavyweightMapping(service.getQName(), portType, endpointMappings, classLoader,
context, module, operations, binding, portStyle, soapVersion, exceptionMap, complexTypeMap,
elementMap, mapping, operationInfos, schemaTypeKeyToSchemaTypeMap, portName, serviceImpl,
location, handlerInfos, seiPortNameToFactoryMap, seiClassNameToFactoryMap, credentialsName);
+                doHeavyweightMapping(service.getQName(), portType, endpointMappings, classLoader,
context, module, operations, binding, portStyle, soapVersion, exceptionMap, schemaInfoBuilder,
mapping, operationInfos, portName, serviceImpl, location, handlerInfos, seiPortNameToFactoryMap,
seiClassNameToFactoryMap, credentialsName);
             }
         }
     }
@@ -310,7 +310,7 @@
         return location;
     }
 
-    private void doHeavyweightMapping(QName serviceName, PortType portType, ServiceEndpointInterfaceMappingType[]
endpointMappings, ClassLoader classLoader, DeploymentContext context, Module module, List
operations, Binding binding, Style portStyle, SOAPConstants soapVersion, Map exceptionMap,
Map complexTypeMap, Map elementMap, JavaWsdlMappingType mapping, OperationInfo[] operationInfos,
Map schemaTypeKeyToSchemaTypeMap, String portName, Object serviceImpl, URL location, List
handlerInfos, Map seiPortNameToFactoryMap, Map seiClassNameToFactoryMap, String credentialsName)
throws DeploymentException {
+    private void doHeavyweightMapping(QName serviceName, PortType portType, ServiceEndpointInterfaceMappingType[]
endpointMappings, ClassLoader classLoader, DeploymentContext context, Module module, List
operations, Binding binding, Style portStyle, SOAPConstants soapVersion, Map exceptionMap,
SchemaInfoBuilder schemaInfoBuilder, JavaWsdlMappingType mapping, OperationInfo[] operationInfos,
String portName, Object serviceImpl, URL location, List handlerInfos, Map seiPortNameToFactoryMap,
Map seiClassNameToFactoryMap, String credentialsName) throws DeploymentException {
         Class serviceEndpointInterface;
         SEIFactory seiFactory;
         //complete jaxrpc mapping file supplied
@@ -346,20 +346,20 @@
                 throw new DeploymentException("No BindingOperation for operation: " + operationName
+ ", input: " + operation.getInput().getName() + ", output: " + (operation.getOutput() ==
null ? "<none>" : operation.getOutput().getName()));
             }
             ServiceEndpointMethodMappingType methodMapping = WSDescriptorParser.getMethodMappingForOperation(operationName,
methodMappings);
-            HeavyweightOperationDescBuilder operationDescBuilder = new HeavyweightOperationDescBuilder(bindingOperation,
mapping, methodMapping, portStyle, exceptionMap, complexTypeMap, elementMap, javaXmlTypeMappings,
classLoader, enhancedServiceEndpointClass);
+            HeavyweightOperationDescBuilder operationDescBuilder = new HeavyweightOperationDescBuilder(bindingOperation,
mapping, methodMapping, portStyle, exceptionMap, schemaInfoBuilder, javaXmlTypeMappings, classLoader,
enhancedServiceEndpointClass);
             OperationInfo operationInfo = operationDescBuilder.buildOperationInfo(soapVersion);
             operationInfos[i++] = operationInfo;
             wrapperElementQNames.addAll(operationDescBuilder.getWrapperElementQNames());
         }
         List typeMappings = new ArrayList();
         Map typeDescriptors = new HashMap();
-        buildTypeInfoHeavyweight(wrapperElementQNames, javaXmlTypeMappings, schemaTypeKeyToSchemaTypeMap,
classLoader, typeMappings, typeDescriptors);
+        buildTypeInfoHeavyweight(wrapperElementQNames, javaXmlTypeMappings, schemaInfoBuilder.getSchemaTypeKeyToSchemaTypeMap(),
classLoader, typeMappings, typeDescriptors);
         seiFactory = createSEIFactory(serviceName, portName, enhancedServiceEndpointClass,
serviceImpl, typeMappings, typeDescriptors, location, operationInfos, handlerInfos, credentialsName,
context, classLoader);
         seiPortNameToFactoryMap.put(portName, seiFactory);
         seiClassNameToFactoryMap.put(serviceEndpointInterface.getName(), seiFactory);
     }
 
-    private void doLightweightMapping(QName serviceName, PortType portType, JavaWsdlMappingType
mapping, ClassLoader classLoader, DeploymentContext context, Module module, List operations,
Binding binding, Style portStyle, SOAPConstants soapVersion, OperationInfo[] operationInfos,
Map schemaTypeKeyToSchemaTypeMap, String portName, Object serviceImpl, URL location, List
handlerInfos, Map seiPortNameToFactoryMap, Map seiClassNameToFactoryMap, String credentialsName)
throws DeploymentException {
+    private void doLightweightMapping(QName serviceName, PortType portType, JavaWsdlMappingType
mapping, ClassLoader classLoader, DeploymentContext context, Module module, List operations,
Binding binding, Style portStyle, SOAPConstants soapVersion, OperationInfo[] operationInfos,
SchemaInfoBuilder schemaInfoBuilder, String portName, Object serviceImpl, URL location, List
handlerInfos, Map seiPortNameToFactoryMap, Map seiClassNameToFactoryMap, String credentialsName)
throws DeploymentException {
         Class serviceEndpointInterface;
         SEIFactory seiFactory;
         //lightweight jaxrpc mapping supplied
@@ -376,13 +376,14 @@
         }
         List typeMappings = new ArrayList();
         Map typeDescriptors = new HashMap();
-        buildTypeInfoLightWeight(schemaTypeKeyToSchemaTypeMap, mapping, classLoader, typeMappings,
typeDescriptors);
+        buildTypeInfoLightWeight(schemaInfoBuilder, mapping, classLoader, typeMappings, typeDescriptors);
         seiFactory = createSEIFactory(serviceName, portName, enhancedServiceEndpointClass,
serviceImpl, typeMappings, typeDescriptors, location, operationInfos, handlerInfos, credentialsName,
context, classLoader);
         seiPortNameToFactoryMap.put(portName, seiFactory);
         seiClassNameToFactoryMap.put(serviceEndpointInterface.getName(), seiFactory);
     }
 
-    private void buildTypeInfoLightWeight(Map schemaTypeKeyToSchemaTypeMap, JavaWsdlMappingType
mapping, ClassLoader classLoader, List typeMappings, Map typeDescriptors) throws DeploymentException
{
+    private void buildTypeInfoLightWeight(SchemaInfoBuilder schemaInfoBuilder, JavaWsdlMappingType
mapping, ClassLoader classLoader, List typeMappings, Map typeDescriptors) throws DeploymentException
{
+        Map schemaTypeKeyToSchemaTypeMap = schemaInfoBuilder.getSchemaTypeKeyToSchemaTypeMap();
         for (Iterator iterator = schemaTypeKeyToSchemaTypeMap.entrySet().iterator(); iterator.hasNext();)
{
             Map.Entry entry = (Map.Entry) iterator.next();
             SchemaTypeKey key = (SchemaTypeKey) entry.getKey();

Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java?rev=164004&r1=164003&r2=164004&view=diff
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java
Wed Apr 20 22:03:36 2005
@@ -28,7 +28,6 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.jar.JarFile;
-
 import javax.wsdl.Binding;
 import javax.wsdl.BindingInput;
 import javax.wsdl.BindingOperation;
@@ -139,8 +138,6 @@
         Map exceptionMap = WSDescriptorParser.getExceptionMap(portInfo.getJavaWsdlMapping());
         SchemaInfoBuilder schemaInfoBuilder = portInfo.getSchemaInfoBuilder();
         Map schemaTypeKeyToSchemaTypeMap = schemaInfoBuilder.getSchemaTypeKeyToSchemaTypeMap();
-        Map complexTypeMap = schemaInfoBuilder.getComplexTypesInWsdl();
-        Map elementMap = schemaInfoBuilder.getElementToTypeMap();
 
         JavaServiceDesc serviceDesc = new JavaServiceDesc();
 
@@ -169,7 +166,7 @@
             validateLightweightMapping(portInfo.getDefinition());
         }
 
-        Set wrapperElementQNames = buildOperations(binding, serviceEndpointInterface, isLightweight,
portInfo, exceptionMap, complexTypeMap, elementMap, classLoader, serviceDesc);
+        Set wrapperElementQNames = buildOperations(binding, serviceEndpointInterface, isLightweight,
portInfo, exceptionMap, classLoader, serviceDesc);
 
         TypeMappingRegistryImpl tmr = new TypeMappingRegistryImpl();
         tmr.doRegisterFromVersion("1.3");
@@ -180,7 +177,7 @@
         serviceDesc.setTypeMapping(typeMapping);
 
         Map classToTypeDescInfo = new HashMap();
-        
+
         if (isLightweight) {
             buildLightweightTypes(schemaTypeKeyToSchemaTypeMap, portInfo, classLoader, typeMapping,
classToTypeDescInfo);
         } else {
@@ -301,13 +298,13 @@
         }
     }
 
-    private static Set buildOperations(Binding binding, Class serviceEndpointInterface, boolean
lightweight, PortInfo portInfo, Map exceptionMap, Map complexTypeMap, Map elementMap, ClassLoader
classLoader, JavaServiceDesc serviceDesc) throws DeploymentException {
+    private static Set buildOperations(Binding binding, Class serviceEndpointInterface, boolean
lightweight, PortInfo portInfo, Map exceptionMap, ClassLoader classLoader, JavaServiceDesc
serviceDesc) throws DeploymentException {
         Set wrappedElementQNames = new HashSet();
 
         SOAPBinding soapBinding = (SOAPBinding) SchemaInfoBuilder.getExtensibilityElement(SOAPBinding.class,
binding.getExtensibilityElements());
         String portStyleString = soapBinding.getStyle();
         Style portStyle = Style.getStyle(portStyleString);
-        
+
         List bindingOperations = binding.getBindingOperations();
         for (int i = 0; i < bindingOperations.size(); i++) {
             BindingOperation bindingOperation = (BindingOperation) bindingOperations.get(i);
@@ -321,7 +318,7 @@
                 ServiceEndpointMethodMappingType[] methodMappings = portInfo.getServiceEndpointInterfaceMapping().getServiceEndpointMethodMappingArray();
                 ServiceEndpointMethodMappingType methodMapping = WSDescriptorParser.getMethodMappingForOperation(operationName,
methodMappings);
                 JavaXmlTypeMappingType[] javaXmlTypeMappingTypes = portInfo.getJavaWsdlMapping().getJavaXmlTypeMappingArray();
-                operationDescBuilder = new HeavyweightOperationDescBuilder(bindingOperation,
portInfo.getJavaWsdlMapping(), methodMapping, portStyle, exceptionMap, complexTypeMap, elementMap,
javaXmlTypeMappingTypes, classLoader, serviceEndpointInterface);
+                operationDescBuilder = new HeavyweightOperationDescBuilder(bindingOperation,
portInfo.getJavaWsdlMapping(), methodMapping, portStyle, exceptionMap, portInfo.getSchemaInfoBuilder(),
javaXmlTypeMappingTypes, classLoader, serviceEndpointInterface);
                 Set wrappedElementQNamesForOper = ((HeavyweightOperationDescBuilder) operationDescBuilder).getWrapperElementQNames();
                 wrappedElementQNames.addAll(wrappedElementQNamesForOper);
             }

Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java?rev=164004&r1=164003&r2=164004&view=diff
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java
Wed Apr 20 22:03:36 2005
@@ -68,8 +68,7 @@
 
 
     private final Map exceptionMap;
-    private final Map complexTypeMap;
-    private final Map elementMap;
+    private final SchemaInfoBuilder schemaInfoBuilder;
     private final ClassLoader classLoader;
     private final boolean rpcStyle;
     private final boolean documentStyle;
@@ -89,13 +88,12 @@
      */
     private final Set wrapperElementQNames = new HashSet();
 
-    public HeavyweightOperationDescBuilder(BindingOperation bindingOperation, JavaWsdlMappingType
mapping, ServiceEndpointMethodMappingType methodMapping, Style defaultStyle, Map exceptionMap,
Map complexTypeMap, Map elementMap, JavaXmlTypeMappingType[] javaXmlTypeMappingTypes, ClassLoader
classLoader, Class serviceEndpointInterface) throws DeploymentException {
+    public HeavyweightOperationDescBuilder(BindingOperation bindingOperation, JavaWsdlMappingType
mapping, ServiceEndpointMethodMappingType methodMapping, Style defaultStyle, Map exceptionMap,
SchemaInfoBuilder schemaInfoBuilder, JavaXmlTypeMappingType[] javaXmlTypeMappingTypes, ClassLoader
classLoader, Class serviceEndpointInterface) throws DeploymentException {
         super(bindingOperation);
         this.mapping = mapping;
         this.methodMapping = methodMapping;
         this.exceptionMap = exceptionMap;
-        this.complexTypeMap = complexTypeMap;
-        this.elementMap = elementMap;
+        this.schemaInfoBuilder = schemaInfoBuilder;
         for (int i = 0; i < javaXmlTypeMappingTypes.length; i++) {
             JavaXmlTypeMappingType javaXmlTypeMappingType = javaXmlTypeMappingTypes[i];
             String javaClassName = javaXmlTypeMappingType.getJavaType().getStringValue().trim();
@@ -200,7 +198,7 @@
         if (wrappedStyle) {
             Part inputPart = getWrappedPart(input);
             QName name = inputPart.getElementName();
-            SchemaType operationType = (SchemaType) complexTypeMap.get(name);
+            SchemaType operationType = (SchemaType) schemaInfoBuilder.getComplexTypesInWsdl().get(name);
 
             Set expectedInParams = new HashSet();
 
@@ -261,7 +259,7 @@
         if (null != output && wrappedStyle) {
             Part inputPart = getWrappedPart(output);
             QName name = inputPart.getElementName();
-            SchemaType operationType = (SchemaType) complexTypeMap.get(name);
+            SchemaType operationType = (SchemaType) schemaInfoBuilder.getComplexTypesInWsdl().get(name);
 
             Set expectedOutParams = new HashSet();
 
@@ -349,12 +347,12 @@
                 throw new DeploymentException("Neither type nor element name supplied for
part: " + part);
             }
         } else {
-            faultTypeQName = (QName) elementMap.get(part.getElementName());
+            faultTypeQName = (QName) schemaInfoBuilder.getElementToTypeMap().get(part.getElementName());
             if (faultTypeQName == null) {
-                throw new DeploymentException("Can not find type for: element: " + part.getElementName()
+ ", known elements: " + elementMap);
+                throw new DeploymentException("Can not find type for: element: " + part.getElementName()
+ ", known elements: " + schemaInfoBuilder.getElementToTypeMap());
             }
         }
-        SchemaType complexType = (SchemaType) complexTypeMap.get(faultTypeQName);
+        SchemaType complexType = (SchemaType) schemaInfoBuilder.getComplexTypesInWsdl().get(faultTypeQName);
         boolean isComplex = complexType != null;
         FaultDesc faultDesc = new FaultDesc(faultQName, className, faultTypeQName, isComplex);
 
@@ -380,8 +378,11 @@
 
                 QName elementTypeQName = elementType.getName();
                 if (elementTypeQName != null) {
-                    if (complexTypeMap.containsKey(elementType)) {
+                    if (schemaInfoBuilder.getComplexTypesInWsdl().containsKey(elementType))
{
                         String javaClassName = (String) publicTypes.get(elementTypeQName);
+                        if (javaClassName == null) {
+                            throw new DeploymentException("No class mapped for element type:
" + elementType);
+                        }
                         javaElementType = getJavaClass(javaClassName);
                     } else {
                         javaElementType = (Class) qnameToClassMap.get(elementTypeQName);
@@ -394,7 +395,21 @@
                     //anonymous type qname is constructed using rules 1.b and 2.b
                     String anonymousQName = complexType.getName().getNamespaceURI() + ":>"
+ complexType.getName().getLocalPart() + ">" + elementName;
                     String javaClassName = (String) anonymousTypes.get(anonymousQName);
-                    javaElementType = getJavaClass(javaClassName);
+                    if (javaClassName == null) {
+                        if (elementType.isSimpleType()) {
+                            //maybe it's a restriction of a built in simple type
+                            SchemaType baseType = elementType.getBaseType();
+                            QName simpleTypeQName = baseType.getName();
+                            javaElementType = (Class) qnameToClassMap.get(simpleTypeQName);
+                            if (javaElementType == null) {
+                                throw new DeploymentException("Unknown simple type: " + elementType
+ " of name: " + elementName + " and QName: " + simpleTypeQName);
+                            }
+                        } else {
+                            throw new DeploymentException("No class mapped for anonymous
type: " + anonymousQName);
+                        }
+                    } else {
+                        javaElementType = getJavaClass(javaClassName);
+                    }
                 }
                 //todo faultTypeQName is speculative
                 //todo outheader might be true!
@@ -607,7 +622,7 @@
         }
 
         //use complexTypeMap
-        boolean isComplexType = complexTypeMap.containsKey(paramTypeQName);
+        boolean isComplexType = schemaInfoBuilder.getComplexTypesInWsdl().containsKey(paramTypeQName);
         String paramJavaTypeName = paramMapping.getParamType().getStringValue().trim();
         boolean isInOnly = mode == ParameterDesc.IN;
         Class actualParamJavaType = WSDescriptorParser.getHolderType(paramJavaTypeName, isInOnly,
paramTypeQName, isComplexType, mapping, classLoader);
@@ -632,7 +647,7 @@
 
         wrapperElementQNames.add(name);
 
-        SchemaType operationType = (SchemaType) complexTypeMap.get(name);
+        SchemaType operationType = (SchemaType) schemaInfoBuilder.getComplexTypesInWsdl().get(name);
         if (null == operationType) {
             throw new DeploymentException("No global element named " + name + " for operation
" + operationName);
         }

Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/SchemaInfoBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/SchemaInfoBuilder.java?rev=164004&r1=164003&r2=164004&view=diff
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/SchemaInfoBuilder.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/SchemaInfoBuilder.java
Wed Apr 20 22:03:36 2005
@@ -75,6 +75,7 @@
 public class SchemaInfoBuilder {
     private static final Log log = LogFactory.getLog(SchemaInfoBuilder.class);
     private static final SchemaTypeSystem basicTypeSystem;
+    private static final String[] errorNames = {"Error", "Warning", "Info"};
 
     static {
         URL url = WSDescriptorParser.class.getClassLoader().getResource("soap_encoding_1_1.xsd");
@@ -100,35 +101,52 @@
     private final JarFile moduleFile;
     private final Definition definition;
     private final Stack uris = new Stack();
-    private final Map schemaTypeKeyToSchemaTypeMap;
     private final Map wsdlMap = new HashMap();
+    private final Map schemaTypeKeyToSchemaTypeMap;
+    private final Map complexTypeMap;
+    private final Map elementMap;
+    private final Map simpleTypeMap;
+    private final Map portMap;
+
 
     public SchemaInfoBuilder(JarFile moduleFile, URI wsdlUri) throws DeploymentException
{
-        this.moduleFile = moduleFile;
-        uris.push(wsdlUri);
-        definition = readWsdl(moduleFile, wsdlUri);
-        SchemaTypeSystem schemaTypeSystem = compileSchemaTypeSystem(definition);
-        schemaTypeKeyToSchemaTypeMap = buildSchemaTypeKeyToSchemaTypeMap(schemaTypeSystem);
+        this(moduleFile, wsdlUri, null, null);
     }
 
     public SchemaInfoBuilder(JarFile moduleFile, Definition definition) throws DeploymentException
{
-        this.definition = definition;
-        this.moduleFile = moduleFile;
-        try {
-            URI uri = new URI(definition.getDocumentBaseURI());
-            uris.push(uri);
-        } catch (URISyntaxException e) {
-            throw new DeploymentException("Could not locate definition", e);
-        }
-        SchemaTypeSystem schemaTypeSystem = compileSchemaTypeSystem(definition);
-        schemaTypeKeyToSchemaTypeMap = buildSchemaTypeKeyToSchemaTypeMap(schemaTypeSystem);
+        this(moduleFile, null, definition, null);
+    }
+
+    SchemaInfoBuilder(JarFile moduleFile, URI uri, SchemaTypeSystem schemaTypeSystem) throws
DeploymentException {
+        this(moduleFile, uri, null, schemaTypeSystem);
     }
 
-    SchemaInfoBuilder(JarFile moduleFile, URI uri, SchemaTypeSystem schemaTypeSystem) {
-        this.definition = null;
+    SchemaInfoBuilder(JarFile moduleFile, URI uri, Definition definition, SchemaTypeSystem
schemaTypeSystem) throws DeploymentException {
         this.moduleFile = moduleFile;
-        uris.push(uri);
+        if (uri != null) {
+            uris.push(uri);
+            if (definition == null && schemaTypeSystem == null) {
+                definition = readWsdl(moduleFile, uri);
+            }
+        } else if (definition != null) {
+            try {
+                uri = new URI(definition.getDocumentBaseURI());
+                uris.push(uri);
+            } catch (URISyntaxException e) {
+                throw new DeploymentException("Could not locate definition", e);
+            }
+        } else {
+            throw new DeploymentException("You must supply uri or definition");
+        }
+        if (schemaTypeSystem == null) {
+            schemaTypeSystem = compileSchemaTypeSystem(definition);
+        }
+        this.definition = definition;
         schemaTypeKeyToSchemaTypeMap = buildSchemaTypeKeyToSchemaTypeMap(schemaTypeSystem);
+        complexTypeMap = buildComplexTypeMap();
+        simpleTypeMap = buildSimpleTypeMap();
+        elementMap = buildElementMap();
+        portMap = buildPortMap();
     }
 
     public Map getSchemaTypeKeyToSchemaTypeMap() {
@@ -143,9 +161,90 @@
         return wsdlMap;
     }
 
-    private static final String[] errorNames = {
-        "Error", "Warning", "Info"
-    };
+    /**
+     * Find all the complex types in the previously constructed schema analysis.
+     * Put them in a map from complex type QName to schema fragment.
+     *
+     * @return
+     */
+    public Map getComplexTypesInWsdl() {
+        return complexTypeMap;
+    }
+
+    private Map buildComplexTypeMap() {
+        Map complexTypeMap = new HashMap();
+        for (Iterator iterator = schemaTypeKeyToSchemaTypeMap.entrySet().iterator(); iterator.hasNext();)
{
+            Map.Entry entry = (Map.Entry) iterator.next();
+            SchemaTypeKey key = (SchemaTypeKey) entry.getKey();
+            if (!key.isSimpleType() && !key.isAnonymous()) {
+                QName qName = key.getqName();
+                SchemaType schemaType = (SchemaType) entry.getValue();
+                complexTypeMap.put(qName, schemaType);
+            }
+        }
+        return complexTypeMap;
+    }
+
+    public Map getElementToTypeMap() {
+        return elementMap;
+    }
+
+    private Map buildElementMap() {
+        Map elementToTypeMap = new HashMap();
+        for (Iterator iterator = schemaTypeKeyToSchemaTypeMap.entrySet().iterator(); iterator.hasNext();)
{
+            Map.Entry entry = (Map.Entry) iterator.next();
+            SchemaTypeKey key = (SchemaTypeKey) entry.getKey();
+            if (key.isElement()) {
+                QName elementQName = key.getqName();
+                SchemaType schemaType = (SchemaType) entry.getValue();
+                QName typeQName = schemaType.getName();
+                elementToTypeMap.put(elementQName, typeQName);
+            }
+        }
+        return elementToTypeMap;
+    }
+
+    /**
+     * Gets a map of all the javax.wsdl.Port instance in the WSDL definition keyed by the
port's QName
+     * <p/>
+     * WSDL 1.1 spec: 2.6 "The name attribute provides a unique name among all ports defined
within in the enclosing WSDL document."
+     *
+     * @return
+     */
+
+    public Map getPortMap() {
+        return portMap;
+    }
+
+    private Map buildPortMap() {
+        HashMap ports = new HashMap();
+        if (definition != null) {
+            Collection services = definition.getServices().values();
+            for (Iterator iterator = services.iterator(); iterator.hasNext();) {
+                Service service = (Service) iterator.next();
+                ports.putAll(service.getPorts());
+            }
+        }
+        return ports;
+    }
+
+    public Map getSimpleTypeMap() {
+        return simpleTypeMap;
+    }
+
+    private Map buildSimpleTypeMap() {
+        Map simpleTypeMap = new HashMap();
+        for (Iterator iterator = schemaTypeKeyToSchemaTypeMap.entrySet().iterator(); iterator.hasNext();)
{
+            Map.Entry entry = (Map.Entry) iterator.next();
+            SchemaTypeKey key = (SchemaTypeKey) entry.getKey();
+            if (key.isSimpleType() && !key.isAnonymous()) {
+                QName qName = key.getqName();
+                SchemaType schemaType = (SchemaType) entry.getValue();
+                simpleTypeMap.put(qName, schemaType);
+            }
+        }
+        return simpleTypeMap;
+    }
 
     public SchemaTypeSystem compileSchemaTypeSystem(Definition definition) throws DeploymentException
{
         List schemaList = new ArrayList();
@@ -265,7 +364,7 @@
      * @param schemaTypeSystem
      * @return
      */
-    public Map buildSchemaTypeKeyToSchemaTypeMap(SchemaTypeSystem schemaTypeSystem) {
+    private Map buildSchemaTypeKeyToSchemaTypeMap(SchemaTypeSystem schemaTypeSystem) {
         Map qnameMap = new HashMap();
         SchemaType[] globalTypes = schemaTypeSystem.globalTypes();
         for (int i = 0; i < globalTypes.length; i++) {
@@ -351,10 +450,14 @@
                 addArrayForms(schemaParticle, elementName, qnameMap, elementType);
             }
         } else {
-            SchemaParticle[] children = schemaParticle.getParticleChildren();
-            for (int i = 0; i < children.length; i++) {
-                SchemaParticle child = children[i];
-                addSchemaParticle(child, key, qnameMap);
+            try {
+                SchemaParticle[] children = schemaParticle.getParticleChildren();
+                for (int i = 0; i < children.length; i++) {
+                    SchemaParticle child = children[i];
+                    addSchemaParticle(child, key, qnameMap);
+                }
+            } catch (NullPointerException e) {
+                //ignore xmlbeans bug
             }
         }
     }
@@ -385,58 +488,6 @@
         }
     }
 
-    /**
-     * Find all the complex types in the previously constructed schema analysis.
-     * Put them in a map from complex type QName to schema fragment.
-     *
-     * @return
-     */
-    public Map getComplexTypesInWsdl() {
-        Map complexTypeMap = new HashMap();
-        for (Iterator iterator = schemaTypeKeyToSchemaTypeMap.entrySet().iterator(); iterator.hasNext();)
{
-            Map.Entry entry = (Map.Entry) iterator.next();
-            SchemaTypeKey key = (SchemaTypeKey) entry.getKey();
-            if (!key.isSimpleType() && !key.isAnonymous()) {
-                QName qName = key.getqName();
-                SchemaType schemaType = (SchemaType) entry.getValue();
-                complexTypeMap.put(qName, schemaType);
-            }
-        }
-        return complexTypeMap;
-    }
-
-    public Map getElementToTypeMap() {
-        Map elementToTypeMap = new HashMap();
-        for (Iterator iterator = schemaTypeKeyToSchemaTypeMap.entrySet().iterator(); iterator.hasNext();)
{
-            Map.Entry entry = (Map.Entry) iterator.next();
-            SchemaTypeKey key = (SchemaTypeKey) entry.getKey();
-            if (key.isElement()) {
-                QName elementQName = key.getqName();
-                SchemaType schemaType = (SchemaType) entry.getValue();
-                QName typeQName = schemaType.getName();
-                elementToTypeMap.put(elementQName, typeQName);
-            }
-        }
-        return elementToTypeMap;
-    }
-
-    /**
-     * Gets a map of all the javax.wsdl.Port instance in the WSDL definition keyed by the
port's QName
-     * <p/>
-     * WSDL 1.1 spec: 2.6 "The name attribute provides a unique name among all ports defined
within in the enclosing WSDL document."
-     *
-     * @return
-     */
-
-    public Map getPortMap() {
-        HashMap ports = new HashMap();
-        Collection services = definition.getServices().values();
-        for (Iterator iterator = services.iterator(); iterator.hasNext();) {
-            Service service = (Service) iterator.next();
-            ports.putAll(service.getPorts());
-        }
-        return ports;
-    }
 
     public Definition readWsdl(JarFile moduleFile, URI wsdlURI) throws DeploymentException
{
         Definition definition;

Modified: geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ParsingTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ParsingTest.java?rev=164004&r1=164003&r2=164004&view=diff
==============================================================================
--- geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ParsingTest.java
(original)
+++ geronimo/trunk/modules/axis-builder/src/test/org/apache/geronimo/axis/builder/ParsingTest.java
Wed Apr 20 22:03:36 2005
@@ -22,6 +22,8 @@
 import java.util.ArrayList;
 import java.util.Map;
 import java.util.Iterator;
+import java.net.URI;
+import java.net.URISyntaxException;
 
 import junit.framework.TestCase;
 import org.apache.xmlbeans.XmlObject;
@@ -61,7 +63,7 @@
         assertEquals(3, map.size());
     }
 
-    private Map parse(File schema1) throws IOException, XmlException, DeploymentException
{
+    private Map parse(File schema1) throws IOException, XmlException, DeploymentException,
URISyntaxException {
         XmlObject xmlObject = SchemaConversionUtils.parse(schema1.toURL());
         Collection errors = new ArrayList();
         XmlOptions xmlOptions = new XmlOptions();
@@ -77,7 +79,7 @@
         } catch (XmlException e) {
             throw new DeploymentException("Could not compile schema type system", e);
         }
-        schemaInfoBuilder = new SchemaInfoBuilder(null, null, schemaTypeSystem);
+        schemaInfoBuilder = new SchemaInfoBuilder(null, new URI(""), schemaTypeSystem);
         Map map = schemaInfoBuilder.getSchemaTypeKeyToSchemaTypeMap();
         for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) {
             Map.Entry entry = (Map.Entry) iterator.next();



Mime
View raw message