You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2008/01/04 16:47:53 UTC

svn commit: r608894 [7/10] - in /incubator/cxf/trunk: ./ buildtools/src/main/resources/ common/schemas/src/main/resources/schemas/wsdl/ etc/eclipse/ maven-plugins/corba/ parent/ rt/bindings/corba/ rt/bindings/corba/src/main/java/org/apache/yoko/binding...

Added: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/IDLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/IDLProcessor.java?rev=608894&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/IDLProcessor.java (added)
+++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/IDLProcessor.java Fri Jan  4 07:47:28 2008
@@ -0,0 +1,105 @@
+/**
+ * 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.yoko.tools.processors.idl;
+
+import java.io.File;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+
+import antlr.TokenStreamHiddenTokenFilter;
+import antlr.collections.AST;
+
+import org.apache.cxf.tools.common.ToolException;
+
+import org.apache.yoko.tools.common.Processor;
+import org.apache.yoko.tools.common.ProcessorEnvironment;
+import org.apache.yoko.tools.common.ToolCorbaConstants;
+import org.apache.yoko.tools.idlpreprocessor.DefaultIncludeResolver;
+import org.apache.yoko.tools.idlpreprocessor.DefineState;
+import org.apache.yoko.tools.idlpreprocessor.IdlPreprocessorReader;
+
+public class IDLProcessor implements Processor {
+
+    protected ProcessorEnvironment env;
+
+    private IDLParser parser;
+
+    public void setEnvironment(ProcessorEnvironment penv) {
+        env = penv;
+    }
+
+    public void process() throws ToolException {
+        String location = env.get(ToolCorbaConstants.CFG_IDLFILE).toString();
+        File file = new File(location).getAbsoluteFile();
+        if (!file.exists()) {
+            throw new ToolException("IDL file " + file.getName() + " doesn't exist");
+        }
+        try {
+            URL orig = file.toURI().toURL();
+            DefaultIncludeResolver includeResolver = getDefaultIncludeResolver(file.getParentFile());
+            DefineState defineState = new DefineState(new HashMap<String, String>());
+            IdlPreprocessorReader preprocessor = new IdlPreprocessorReader(orig,
+                                                                           location,
+                                                                           includeResolver,
+                                                                           defineState);
+            IDLLexer lexer = new IDLLexer(new java.io.LineNumberReader(preprocessor));
+            lexer.setTokenObjectClass("antlr.CommonHiddenStreamToken");
+            TokenStreamHiddenTokenFilter filter =
+                new TokenStreamHiddenTokenFilter(lexer);
+            filter.discard(IDLTokenTypes.WS);
+            filter.hide(IDLTokenTypes.SL_COMMENT);
+            filter.hide(IDLTokenTypes.ML_COMMENT);
+            parser = new IDLParser(filter);
+            parser.setASTNodeClass("antlr.CommonASTWithHiddenTokens");
+            parser.specification();
+        } catch (Exception ex) {
+            throw new ToolException(ex);
+        }
+    }
+
+    public AST getIDLTree() {
+        if (parser != null) {
+            return parser.getAST();
+        } else {
+            return null;
+        }
+    }
+
+    private DefaultIncludeResolver getDefaultIncludeResolver(File currentDir) {
+        DefaultIncludeResolver includeResolver;
+        if (env.optionSet(ToolCorbaConstants.CFG_INCLUDEDIR)) {                        
+            String includedDirs = env.get(ToolCorbaConstants.CFG_INCLUDEDIR).toString();
+            StringTokenizer tok = new StringTokenizer(includedDirs, "");
+            File[] includeDirs = new File[tok.countTokens()];
+            int i = 0;
+            while (tok.hasMoreTokens()) {
+                String includeDir = tok.nextToken();
+                File infile = new File(includeDir);
+                includeDirs[i] = infile;
+                i++;
+            }
+            includeResolver = new DefaultIncludeResolver(includeDirs);
+        } else {
+            includeResolver = new DefaultIncludeResolver(currentDir);
+        }
+        return includeResolver;
+    }
+
+}

Propchange: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/IDLProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/IDLProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java?rev=608894&r1=608893&r2=608894&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java (original)
+++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java Fri Jan  4 07:47:28 2008
@@ -15,7 +15,7 @@
  * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.yoko.tools.processors.idl;
 
@@ -25,65 +25,70 @@
 import java.io.FileReader;
 import java.io.Writer;
 import java.net.URI;
-import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.StringTokenizer;
 
 import javax.wsdl.Binding;
 import javax.wsdl.Definition;
 import javax.wsdl.Port;
 import javax.wsdl.Service;
+import javax.wsdl.Types;
+import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.extensions.schema.SchemaImport;
 import javax.xml.namespace.QName;
 
 import antlr.collections.AST;
 
-import org.apache.cxf.tools.common.Processor;
 import org.apache.cxf.tools.common.ToolConstants;
-import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.util.FileWriterUtil;
 
 import org.apache.schemas.yoko.bindings.corba.AddressType;
 import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
-import org.apache.yoko.tools.common.ProcessorEnvironment;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.constants.Constants;
+import org.apache.yoko.tools.common.ReferenceConstants;
 import org.apache.yoko.tools.common.ToolCorbaConstants;
-import org.apache.yoko.tools.idlpreprocessor.DefaultIncludeResolver;
-import org.apache.yoko.tools.idlpreprocessor.DefineState;
-import org.apache.yoko.tools.idlpreprocessor.IdlPreprocessorReader;
 import org.apache.yoko.wsdl.CorbaConstants;
 import org.apache.yoko.wsdl.CorbaTypeImpl;
 
-public class IDLToWSDLProcessor implements Processor {
+public class IDLToWSDLProcessor extends IDLProcessor {
 
-    protected ToolContext toolContext;
     private String idl;
     private String schemaFilename;
     private String importSchemaFilename;
     private String logical;
     private String physical;
     private String outputDir;
-    private ProcessorEnvironment env;
     private Writer outputWriter;
     private Writer schemaOutputWriter;   
     private Writer logicalOutputWriter;
-    private Writer physicalOutputWriter;    
+    private Writer physicalOutputWriter;
+    private Map<String, File> importDefnWriters;
+    private Map<String, File> importSchemaWriters;
+    private boolean ignoreImports;
     
     public void process() throws ToolException {
+        super.process();
+        process(getIDLTree());
+    }
+
+    public void process(AST idlTree) throws ToolException {
         idl = getBaseFilename(env.get(ToolCorbaConstants.CFG_IDLFILE).toString());
-        checkFileOptions();                
+        checkFileOptions();
         try {
-            parseIDL();
+            parseIDL(idlTree);
         } catch (Exception e) {
             throw new ToolException(e);
         }
     }
 
-
-    public void setEnvironment(ToolContext toolCtx) {
-        toolContext = toolCtx;
-    }
-
     public void setOutputWriter(Writer writer) {
         outputWriter = writer;
     }
@@ -100,6 +105,21 @@
         physicalOutputWriter = writer;
     }
 
+    /**
+     * Used only for test cases to set writers for imports when using
+     * the -mns option
+     */
+    protected void setImportDefinitionWriters(Map<String, File> writers) {
+        importDefnWriters = writers;
+    }
+
+    protected void setImportSchemaWriters(Map<String, File> writers) {
+        importSchemaWriters = writers;
+    }
+
+    protected void setIgnoreImports(boolean flag) {
+        ignoreImports = flag;
+    }
     
     private void checkFileOptions() {
                 
@@ -119,26 +139,9 @@
             // deal with importing schema types 
             importSchemaFilename = env.get(ToolCorbaConstants.CFG_IMPORTSCHEMA).toString();
         }                
-    }
-    
-        
-    public void parseIDL() throws Exception {
-        String location = env.get(ToolCorbaConstants.CFG_IDLFILE).toString();
-        File file = new File(location).getAbsoluteFile();
-        if (!file.exists()) {
-            throw new Exception("IDL file " + file.getName() + " doesn't exist");
-        }
-        URL orig = file.toURI().toURL();
-        DefaultIncludeResolver includeResolver = new DefaultIncludeResolver(file.getParentFile());
-        DefineState defineState = new DefineState(new HashMap<String, String>());
-        IdlPreprocessorReader preprocessor = new IdlPreprocessorReader(orig,
-                                                                       location,
-                                                                       includeResolver,
-                                                                       defineState);
-        IDLParser parser = new IDLParser(new IDLLexer(new java.io.LineNumberReader(preprocessor)));
-        parser.specification();
-        AST idlTree = parser.getAST();
+    }    
 
+    public void parseIDL(AST idlTree) throws Exception {
         if (env.isVerbose()) {
             System.out.println(idlTree.toStringTree());
         }               
@@ -154,8 +157,15 @@
         // corba typemap namespace
         String corbatypemaptns = (String) env.get(ToolCorbaConstants.CFG_CORBATYPEMAP_NAMESPACE);
         
+        outputDir = ".";
+
         try {
             WSDLASTVisitor visitor = new WSDLASTVisitor(tns, schemans, corbatypemaptns);
+            visitor.getManager().setIgnoreImports(ignoreImports);
+            if (env.optionSet(ToolConstants.CFG_OUTPUTDIR)) {
+                outputDir =  (String) env.get(ToolConstants.CFG_OUTPUTDIR);
+            }
+            visitor.setOutputDir(outputDir); 
             Definition def = visitor.getDefinition();
             if (env.optionSet(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE)) {
                 visitor.setSequenceOctetType((String) env.get(ToolCorbaConstants.CFG_SEQUENCE_OCTET_TYPE));
@@ -169,6 +179,20 @@
                 visitor.setBoundedStringOverride(true);
             }
             
+            if (env.optionSet(ToolCorbaConstants.CFG_MODULETONS)) {
+                String mapping = (String) env.get(ToolCorbaConstants.CFG_MODULETONS);
+                //parse the mapping & set a map of module to namespace mapping in the visitor
+                visitor.setModuleToNSMapping(getModuleToNSMapping(mapping));
+            }
+            
+            if (env.optionSet(ToolCorbaConstants.CFG_QUALIFIED)) {
+                visitor.setQualified(true);
+            }
+            
+            if (env.optionSet(ToolCorbaConstants.CFG_POLYMORPHIC_FACTORIES)) {
+                visitor.setSupportPolymorphicFactories(true);
+            }
+
             if (env.optionSet(ToolCorbaConstants.CFG_SCHEMA)) {
                 visitor.setSchemaGenerated(true);
                 // generate default namespace for schema if -T is used alone.
@@ -178,13 +202,18 @@
                                                                                      + "-types");
                 }
             }
-            
+
+            if (env.optionSet(ToolCorbaConstants.CFG_EXCLUDEMODULES)) {
+                String modules = (String) env.get(ToolCorbaConstants.CFG_EXCLUDEMODULES);
+                //parse the mapping & set a map of module to namespace mapping in the visitor
+                visitor.setExcludedModules(getExcludedModules(modules));
+            }
             visitor.visit(idlTree);  
-                      
+            
             cleanUpTypeMap(visitor.getTypeMap());
             
             Binding[] bindings = visitor.getCorbaBindings();
-            generateCORBAService(def, bindings);
+            generateCORBAService(def, bindings, visitor.getModuleToNSMapper().isDefaultMapping());
             writeDefinitions(visitor);           
         } catch (Exception ex) {           
             throw new ToolException(ex.getMessage(), ex);
@@ -199,14 +228,7 @@
     //     - File names have no path specified so use current directory.
     //     - File names have full path specified.
     private void writeDefinitions(WSDLASTVisitor visitor) 
-        throws Exception {
-        
-        Object obj = env.get(ToolConstants.CFG_OUTPUTDIR);
-        outputDir = ".";
-        if (obj != null) {
-            outputDir =  obj.toString();
-        }
-                        
+        throws Exception {                              
         if (env.optionSet(ToolCorbaConstants.CFG_LOGICAL)
             || env.optionSet(ToolCorbaConstants.CFG_PHYSICAL)
             || env.optionSet(ToolCorbaConstants.CFG_SCHEMA)
@@ -245,9 +267,6 @@
                 if (schemaOutputWriter == null) {            
                     schemaOutputWriter = createOutputWriter(schemaFilename); 
                 }    
-                File file = new File(schemaFilename);                
-                URI uri = file.toURI();
-                schemaFilename = uri.toString();                                           
             }
                         
             if (importSchemaFilename != null) {
@@ -255,16 +274,70 @@
                 visitor.setImportSchema(importSchemaFilename);
             }                     
                         
-            visitor.setOutputDir(outputDir);   
             visitor.writeDefinitions(outputWriter, schemaOutputWriter,
                                      logicalOutputWriter, physicalOutputWriter, 
                                      schemaFilename, logical, physical);
         } else {
             if (outputWriter == null) {
-                outputWriter = getOutputWriter(idl + ".wsdl", outputDir); 
+                String outputFile = idl + ".wsdl";
+                if (env.optionSet(ToolCorbaConstants.CFG_WSDLOUTPUTFILE)) {
+                    outputFile = (String) env.get(ToolCorbaConstants.CFG_WSDLOUTPUTFILE);
+                    if (!outputFile.endsWith(".wsdl")) {
+                        outputFile = outputFile + ".wsdl";
+                    }
+                }
+                outputWriter = getOutputWriter(outputFile, outputDir); 
             }
-            visitor.writeDefinition(outputWriter);
-        }         
+            Definition defn = visitor.getDefinition();
+            if (!visitor.getModuleToNSMapper().isDefaultMapping()) {
+                addTypeMapSchemaImports(defn, visitor);
+                visitor.getManager().attachDeferredSchemasToWSDL();
+            }
+            
+            visitor.writeDefinition(defn, outputWriter);
+            writeImportedDefinitionsAndSchemas(visitor);
+        }
+    }
+
+    private void writeImportedDefinitionsAndSchemas(WSDLASTVisitor visitor)
+        throws Exception {
+        Map<File, Definition> defns = visitor.getManager().getImportedWSDLDefinitions();
+        Map<File, XmlSchema> schemas = visitor.getManager().getImportedXmlSchemas();
+
+        if (importDefnWriters != null) {
+            assert importDefnWriters.size() == defns.size();
+        }
+        if (importSchemaWriters != null) {
+            assert importSchemaWriters.size() == schemas.size();
+        }
+        
+        int count = 0;
+        for (java.util.Iterator<File> it = defns.keySet().iterator(); it.hasNext();) {
+            File file = it.next();
+            Definition defn = defns.get(file);
+            Writer writer = null;
+            if (importDefnWriters != null) {
+                writer = getOutputWriter(importDefnWriters.get(defn.getTargetNamespace()));
+            }
+            if (writer == null) {
+                writer = getOutputWriter(file);
+            }
+            visitor.writeDefinition(defn, writer);
+            writer.close();
+        }
+        for (java.util.Iterator<File> it = schemas.keySet().iterator(); it.hasNext();) {
+            File file = it.next();
+            XmlSchema schema = schemas.get(file);
+            Writer writer = null;
+            if (importSchemaWriters != null) {
+                writer = getOutputWriter(importSchemaWriters.get(schema.getTargetNamespace()));
+            }
+            if (writer == null) {
+                writer = getOutputWriter(file);
+            }
+            visitor.writeSchema(schema, writer);
+            writer.close();
+        }
     }
     
     // Get the imported schema file.
@@ -339,14 +412,15 @@
             return fw.getWriter("", filename); 
         }       
     }
-    
-    public void setEnvironment(ProcessorEnvironment penv) {
-        env = penv;
-    }
 
-    public ProcessorEnvironment getEnvironment() {
-        return env;
-    }
+    public Writer getOutputWriter(File file) throws Exception {        
+        if (env.optionSet(ToolCorbaConstants.CFG_WSDL_ENCODING)) { 
+            String encoding = env.get(ToolCorbaConstants.CFG_WSDL_ENCODING).toString();            
+            return FileWriterUtil.getWriter(file, encoding); 
+        } else {
+            return FileWriterUtil.getWriter(file);
+        }       
+    }    
 
     public String getBaseFilename(String ifile) {
         String fileName = ifile;
@@ -361,15 +435,70 @@
         return fileName;
     }
 
-    public void generateCORBAService(Definition def, Binding[] bindings) throws Exception {
+    private Map<String, String> getServiceNames(Binding[] bindings, boolean isDefaultMapping) {
+        Map<String, String> serviceNames = new HashMap<String, String>();
         for (int i = 0; i < bindings.length; i++) {
-            String portTypeName = bindings[i].getPortType().getQName().getLocalPart();
-            QName serviceName = new QName(def.getTargetNamespace(),
-                                          portTypeName + "CORBAService");
-            Service service = def.createService();
-            service.setQName(serviceName);
+            QName portTypeName = bindings[i].getPortType().getQName();
+            String ns = portTypeName.getNamespaceURI();
+            if (!isDefaultMapping && !serviceNames.containsKey(ns)) {
+                String[] bindingTokens = bindings[i].getQName().getLocalPart().split("\\.");
+                if (bindingTokens.length > 1) {
+                    String name = "";
+                    for (int j = 0; j < bindingTokens.length - 2; j++) {
+                        name += bindingTokens[j] + ".";
+                    }
+                    name += bindingTokens[bindingTokens.length - 2] + "CORBAService";
+                    serviceNames.put(ns, name);
+                } else {
+                    serviceNames.put(ns, idl + "CORBAService");
+                }
+            }
+        }
+        return serviceNames;
+    }
+
+    public void generateCORBAService(Definition def,
+                                     Binding[] bindings,
+                                     boolean isDefaultMapping)
+        throws Exception {
+        Map<String, Service> serviceMap = new HashMap<String, Service>();
+        Map<String, String> serviceNames = getServiceNames(bindings, isDefaultMapping);
+        for (int i = 0; i < bindings.length; i++) {
+            QName portTypeName = bindings[i].getPortType().getQName();
+            Service service;
+            if (isDefaultMapping) {
+                service = def.createService();
+                service.setQName(new QName(def.getTargetNamespace(),
+                                           portTypeName.getLocalPart() + "CORBAService"));
+                def.addService(service);
+            } else {
+                String ns = portTypeName.getNamespaceURI();
+                String serviceName = serviceNames.get(ns);
+                service = serviceMap.get(ns);
+                if (service == null) {
+                    service = def.createService();
+                    serviceMap.put(ns, service);
+                    String[] serviceTokens = serviceName.split("\\.");
+                    String serviceToken = serviceTokens[serviceTokens.length - 1];
+                    QName serviceQName = new QName(def.getTargetNamespace(), serviceToken);
+                    Service existingService = def.getService(serviceQName);
+                    if (existingService != null) {
+                        String existingServiceNS =
+                            ((Port) existingService.getPorts().values().iterator().next())
+                            .getBinding().getPortType().getQName().getNamespaceURI();
+                        existingService.setQName(new QName(def.getTargetNamespace(),
+                                                           serviceNames.get(existingServiceNS)));
+                        serviceMap.put(existingServiceNS, existingService);
+                        service.setQName(new QName(def.getTargetNamespace(),
+                                                   serviceName));
+                    } else {
+                        service.setQName(serviceQName);
+                    }
+                    def.addService(service);
+                }
+            }
             Port port = def.createPort();
-            port.setName(portTypeName + "CORBAPort");
+            port.setName(portTypeName.getLocalPart() + "CORBAPort");
             AddressType address =
                 (AddressType) def.getExtensionRegistry().createExtension(Port.class,
                                                                          CorbaConstants.NE_CORBA_ADDRESS);
@@ -395,7 +524,6 @@
             port.addExtensibilityElement(address);
             service.addPort(port);
             port.setBinding(bindings[i]);
-            def.addService(service);
         }
     }
 
@@ -410,6 +538,150 @@
                 }
             }
         }
+    }
+    
+    public void addTypeMapSchemaImports(Definition def, WSDLASTVisitor visitor) {
+        List<CorbaTypeImpl> types = visitor.getTypeMap().getStructOrExceptionOrUnion();
+        ModuleToNSMapper mapper = visitor.getModuleToNSMapper();
+        WSDLSchemaManager manager = visitor.getManager();
+        Collection namespaces = def.getNamespaces().values();
+        Set<Map.Entry<String, String>> userModuleMappings = mapper.getUserMapping().entrySet();
+        
+        if (types != null) {
+            for (int i = 0; i < types.size(); i++) {
+                CorbaTypeImpl type = types.get(i);
+                QName schemaType = type.getType();
+                if (schemaType != null) {
+                    String typeNamespace = schemaType.getNamespaceURI();
+                    try {
+                        // WS-Addressing namespace is a special case.  We need to import the schema from 
+                        // a remote location.
+                        if (!namespaces.contains(typeNamespace) 
+                            && typeNamespace.equals(ReferenceConstants.WSADDRESSING_NAMESPACE)) {
+                            
+                            // build up the ws-addressing schema import
+                            Schema wsdlSchema = 
+                                (Schema)def.getExtensionRegistry().createExtension(Types.class,
+                                                     new QName(Constants.URI_2001_SCHEMA_XSD, "schema"));
+                            SchemaImport schemaimport =  wsdlSchema.createImport();
+                            schemaimport.setNamespaceURI(ReferenceConstants.WSADDRESSING_NAMESPACE);
+                            schemaimport.setSchemaLocationURI(ReferenceConstants.WSADDRESSING_LOCATION);
+                            wsdlSchema.addImport(schemaimport);
+                            
+                            // add the import and the prefix to the definition
+                            def.getTypes().addExtensibilityElement(wsdlSchema);
+                            def.getNamespaces().put(ReferenceConstants.WSADDRESSING_PREFIX, typeNamespace);
+                        } else if (!namespaces.contains(typeNamespace)) {
+                            String prefix = getModulePrefixForNamespace(userModuleMappings, mapper, 
+                                                                        typeNamespace);
+                            //prefix = mapper.mapNSToPrefix(typeNamespace);
+                            XmlSchema schema = manager.getXmlSchema(typeNamespace);
+                            // TODO: REVISIT - Is this the only way we can create the file name for the
+                            // imported schema?
+                            String importFile = visitor.getOutputDir()
+                                + System.getProperty("file.separator")
+                                + prefix + ".xsd";
+                            manager.addWSDLSchemaImport(def, typeNamespace, importFile);
+                            manager.getImportedXmlSchemas().put(new File(importFile), schema);
+                            def.getNamespaces().put(prefix, typeNamespace);
+                        }
+                    } catch (Exception ex) {
+                        throw new ToolException("Unable to add schema import for namespace"
+                                                + typeNamespace);
+                    }
+                }
+            }
+        }
+    }
+    
+    private String getModulePrefixForNamespace(Set<Map.Entry<String, String>> map, 
+                                               ModuleToNSMapper mapper, String namespace) {
+        String prefix = null;
+        
+        for (Iterator<Map.Entry<String, String>> iter = map.iterator(); iter.hasNext();) {
+            Map.Entry<String, String> entry = iter.next();
+            if (entry.getValue().equals(namespace)) {
+                prefix = entry.getKey().replace(ToolCorbaConstants.MODULE_SEPARATOR, "_");
+                break;
+            }
+        }
+        
+        if (prefix == null) {
+            prefix = mapper.mapNSToPrefix(namespace);   
+        }
+        
+        return prefix;
+    }
+
+    private Map<String, String> getModuleToNSMapping(String mapping) {
+        Map<String, String> map = new HashMap<String, String>();
+        if ((mapping != null) && (mapping.length() > 0)) {
+            if ((mapping.startsWith("[")) && (mapping.endsWith("]"))) {
+                mapping = mapping.substring(1, mapping.length() - 1);
+                StringTokenizer tokens = new StringTokenizer(mapping, ",;");
+                while (tokens.hasMoreTokens()) {
+                    String token = tokens.nextToken();
+                    int pos = token.indexOf("=");
+                    if (pos == -1) {
+                        throw new RuntimeException("Mapping of idl modules to namespaces "
+                                                   + "is not specified correctly."
+                                                   + "Missing a equals(=) sign for specifying "
+                                                   + "the custom mapping."
+                                                   + "(" + token + ")");
+                    }
+                    map.put(token.substring(0, pos), token.substring(pos + 1));
+                }
+            } else if (mapping.startsWith(":")) {
+                mapping = mapping.substring(1);
+                try {
+                    BufferedReader reader = new BufferedReader(new FileReader(mapping));
+                    String token = reader.readLine();
+                    while (token != null) {
+                        int pos = token.indexOf("=");
+                        if (pos == -1) {
+                            throw new RuntimeException("Mapping of idl modules to namespaces "
+                                                       + "is not specified correctly in the file "
+                                                       + mapping + "."
+                                                       + "Missing a equals(=) sign for specifying "
+                                                       + "the custom mapping."
+                                                       + "(" + token + ")");
+                        }
+                        map.put(token.substring(0, pos), token.substring(pos + 1));
+                        token = reader.readLine();
+                    }
+                } catch (Exception ex) {
+                    throw new RuntimeException("Incorrect properties file for mns mapping - " + mapping
+                                               + ". Cause: " + ex.getMessage());
+                }
+            } else {
+                throw new RuntimeException("Option mns should have a start([) & close(]) bracket"
+                                           + " or a properties file"
+                                           + " to customize the mapping of modules to namespaces");
+            }
+        }
+        return map;
+    }
+
+    private Map<String, List> getExcludedModules(String modules) {
+        Map<String, List> exModules = new HashMap<String, List>();
+        if ((modules != null) && (modules.length() > 0)) {
+            if ((modules.startsWith("[")) && (modules.endsWith("]"))) {
+                modules = modules.substring(1, modules.length() - 1);
+                StringTokenizer tokens = new StringTokenizer(modules, ",;");
+                while (tokens.hasMoreTokens()) {
+                    String token = tokens.nextToken();
+                    //Revisit, Do we also take in the imports of the wsdl/schema?
+                    exModules.put(token, new ArrayList());
+                }               
+            } else if (modules.startsWith(":")) {
+                //TO DO
+            } else {
+                throw new RuntimeException("Option ex should have a start([) & close(]) bracket"
+                                           + " or a properties file"
+                                           + " to specify the exclusion of modules");
+            }
+        }
+        return exModules;
     }
     
 }

Added: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ModuleToNSMapper.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ModuleToNSMapper.java?rev=608894&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ModuleToNSMapper.java (added)
+++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ModuleToNSMapper.java Fri Jan  4 07:47:28 2008
@@ -0,0 +1,135 @@
+/**
+ * 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.yoko.tools.processors.idl;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.yoko.tools.common.ToolCorbaConstants;
+
+public class ModuleToNSMapper {
+
+    Map<String, String> userMap;
+    Map<String, List> exModules;
+    boolean defaultMapping = true;
+
+    public ModuleToNSMapper() {
+        userMap = new HashMap<String, String>();
+        exModules = new HashMap<String, List>();
+    }
+
+    public void setDefaultMapping(boolean flag) {
+        defaultMapping = flag;
+    }
+
+    public boolean isDefaultMapping() {
+        return defaultMapping;
+    }
+
+    public void setUserMapping(Map<String, String> map) {
+        userMap = map;
+    }
+    
+    public Map<String, String> getUserMapping() {
+        return userMap;
+    }
+
+    public void setExcludedModuleMap(Map<String, List> map) {
+        exModules = map;
+    }
+    
+    public Map<String, List> getExcludedModuleMap() {
+        return exModules;
+    }
+
+    public Iterator getExcludedModules() {
+        return exModules.keySet().iterator();
+    }
+
+    public List getExcludedImports(String module) {
+        return exModules.get(module);
+    }
+
+    public boolean containsExcludedModule(String module) {
+        return exModules.containsKey(module);
+    }
+    
+    public String map(String scopeStr, String separator) {
+        Scope scope = new Scope(scopeStr, separator);
+        return map(scope);
+    }
+    
+    public String map(Scope scope) {
+        return map(scope, ToolCorbaConstants.MODULE_SEPARATOR);
+    }
+
+    public String map(Scope scope, String separator) {
+        if (defaultMapping) {
+            return null;
+        } else {
+            String uri = userMap.get(scope.toString(separator));
+            if (uri == null) {
+                //try the parent scope for mapping
+                Scope currentScope = scope;
+                String parentURI = null;
+                uri = "";
+                while (parentURI == null && !currentScope.toString().equals("")
+                       && currentScope != currentScope.getParent()) {
+                    parentURI = userMap.get(currentScope.toString(separator));
+                    if (parentURI == null) {
+                        if (!uri.equals("")) {
+                            uri = "/" + uri;
+                        }
+                        uri = currentScope.tail() + uri;
+                    }
+                    currentScope = currentScope.getParent();
+                }
+                if (parentURI != null) {
+                    if (!parentURI.endsWith("/")) {
+                        parentURI = parentURI + "/";
+                    }
+                    uri = parentURI + uri;
+                } else {
+                    uri = "urn:" + uri;
+                }
+            }
+            return uri;
+        }
+    }
+    
+    public String mapToQName(Scope scope) {
+        if (defaultMapping) {
+            return scope.toString();
+        } else {
+            return scope.tail();
+        }
+    }
+
+    public String mapNSToPrefix(String nsURI) {
+        int pos = nsURI.indexOf(":");
+        if (pos != -1) {
+            nsURI = nsURI.substring(pos + 1);
+        }
+        return nsURI.replaceAll("/", "_");      
+    }
+
+}

Propchange: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ModuleToNSMapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ModuleToNSMapper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ModuleVisitor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ModuleVisitor.java?rev=608894&r1=608893&r2=608894&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ModuleVisitor.java (original)
+++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ModuleVisitor.java Fri Jan  4 07:47:28 2008
@@ -15,31 +15,45 @@
  * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.yoko.tools.processors.idl;
 
+import javax.wsdl.Definition;
+
 import antlr.collections.AST;
 
-public class ModuleVisitor extends VisitorBase {
-    
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.yoko.tools.common.ToolCorbaConstants;
+
+public class ModuleVisitor extends VisitorBase {       
+
     public ModuleVisitor(Scope scope,
+                         Definition defn,
+                         XmlSchema schemaRef,
                          WSDLASTVisitor wsdlASTVisitor) {
-        super(scope, wsdlASTVisitor);
+        super(scope, defn, schemaRef, wsdlASTVisitor);
     }
     
     public void visit(AST node) {
         // <module> ::= "module" <identifier> "{" <definition>+ "}"
         
         AST identifierNode = node.getFirstChild();
-        AST definitionNode = identifierNode.getNextSibling();
-        
+        AST definitionNode = identifierNode.getNextSibling();        
+
         while (definitionNode != null) {
-            DefinitionVisitor definitionVisitor =
-                new DefinitionVisitor(new Scope(getScope(), identifierNode),
-                                      wsdlVisitor);
+            Scope moduleScope = new Scope(getScope(), identifierNode);
+            if (!mapper.containsExcludedModule(moduleScope.toString(ToolCorbaConstants.MODULE_SEPARATOR))) {
+                DefinitionVisitor definitionVisitor =
+                    new DefinitionVisitor(moduleScope,
+                                          definition,
+                                          schema,
+                                          wsdlVisitor);
 
-            definitionVisitor.visit(definitionNode);
+                definitionVisitor.visit(definitionNode);
+            } else {
+                //REVISIT, need to import excluded references.
+            }
             
             definitionNode = definitionNode.getNextSibling();
         }

Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ObjectReferenceVisitor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ObjectReferenceVisitor.java?rev=608894&r1=608893&r2=608894&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ObjectReferenceVisitor.java (original)
+++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ObjectReferenceVisitor.java Fri Jan  4 07:47:28 2008
@@ -15,7 +15,7 @@
  * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.yoko.tools.processors.idl;
 
@@ -53,22 +53,23 @@
 
 public class ObjectReferenceVisitor extends VisitorBase {
     
-    private Definition wsdlDefinition;
     private WSDLASTVisitor objRefWsdlVisitor;
     
     public ObjectReferenceVisitor(Scope scope,
+                                  Definition defn,
+                                  XmlSchema schemaRef,
                                   WSDLASTVisitor wsdlVisitor) {
-        super(scope, wsdlVisitor);
-        wsdlDefinition = wsdlVisitor.getDefinition();
+        super(scope, defn, schemaRef, wsdlVisitor);
         objRefWsdlVisitor = wsdlVisitor;
         
     }
 
-    public static boolean accept(Scope scope, XmlSchema s, Definition def, AST node) {
+    public static boolean accept(Scope scope, XmlSchema s, 
+                                 Definition def, AST node, WSDLASTVisitor wsdlVisitor) {
         boolean result = false;
         if (node.getType() == IDLTokenTypes.LITERAL_Object) {
             result = true;
-        } else if (node.getType() == IDLTokenTypes.IDENT && hasBinding(scope, s, def, node)) {
+        } else if (node.getType() == IDLTokenTypes.IDENT && hasBinding(scope, s, def, node, wsdlVisitor)) {
             result = true;
         }
         return result;
@@ -76,34 +77,7 @@
     
     public void visit(AST node) {
         if (!objRefWsdlVisitor.getDeclaredWSAImport()) {
-            // We need to add an import statement to include the WS addressing types
-            XmlSchemaImport wsaImport = new XmlSchemaImport();
-            wsaImport.setNamespace(ReferenceConstants.WSADDRESSING_NAMESPACE);
-            wsaImport.setSchemaLocation(ReferenceConstants.WSADDRESSING_LOCATION);
-            schema.getItems().add(wsaImport);
-            
-            // Add the addressing namespace to the WSDLs list of namespaces.
-            wsdlDefinition.addNamespace(ReferenceConstants.WSADDRESSING_PREFIX,
-                                        ReferenceConstants.WSADDRESSING_NAMESPACE);
-            
-            try {
-                // This is used to get the correct prefix in the schema section of
-                // the wsdl.  If we don't have this, then this namespace gets an 
-                // arbitrary prefix (e.g. ns5 instead of wsa).
-                NamespaceMap nsMap = (NamespaceMap)schema.getNamespaceContext();
-                if (nsMap == null) {
-                    nsMap = new NamespaceMap();
-                    nsMap.add(ReferenceConstants.WSADDRESSING_PREFIX, 
-                              ReferenceConstants.WSADDRESSING_NAMESPACE);
-                    schema.setNamespaceContext(nsMap);
-                } else {
-                    nsMap.add(ReferenceConstants.WSADDRESSING_PREFIX, 
-                              ReferenceConstants.WSADDRESSING_NAMESPACE);
-                }
-            } catch (ClassCastException ex) {
-                // Consume the exception.  It is still OK with the default prefix, 
-                // just not as clear.
-            }
+            addWSAddressingImport(schema);
         }
         objRefWsdlVisitor.setDeclaredWSAImport(true);
         
@@ -160,10 +134,15 @@
                     customScope = new Scope(currentScope, node);
                 }
 
-                referenceName = new QName(schema.getTargetNamespace(), customScope.toString() + "Ref");
+                if (mapper.isDefaultMapping()) {
+                    referenceName = new QName(schema.getTargetNamespace(), customScope.toString() + "Ref");
+                } else {
+                    String tns = mapper.map(customScope.getParent());
+                    referenceName = new QName(tns, customScope.tail() + "Ref");
+                }
 
                 repositoryID = customScope.toIDLRepositoryID();
-                bindingName = getBindingQNameByID(wsdlDefinition, repositoryID);
+                bindingName = getBindingQNameByID(definition, repositoryID, objRefWsdlVisitor);
                 currentScope = currentScope.getParent();
 
             }
@@ -174,16 +153,26 @@
            // Global scope is our last chance to resolve the node
             if (ScopedNameVisitor.isFullyScopedName(node)) {
                 customScope = ScopedNameVisitor.getFullyScopedName(new Scope(), node);
-                referenceName = new QName(schema.getTargetNamespace(),
-                                                customScope.toString() + "Ref");           
+                if (mapper.isDefaultMapping()) {
+                    referenceName = new QName(schema.getTargetNamespace(),
+                                              customScope.toString() + "Ref");
+                } else {
+                    String tns = mapper.map(customScope.getParent());
+                    referenceName = new QName(tns, customScope.tail() + "Ref");
+                }
             } else {
                 //customScope = currentScope;
                 customScope = new Scope(new Scope(), node);
-                referenceName = new QName(schema.getTargetNamespace(),
-                                               customScope.toString() + "Ref");               
+                if (mapper.isDefaultMapping()) {
+                    referenceName = new QName(schema.getTargetNamespace(),
+                                              customScope.toString() + "Ref");
+                } else {
+                    String tns = mapper.map(customScope.getParent());
+                    referenceName = new QName(tns, customScope.tail() + "Ref");
+                }
             }
             repositoryID = customScope.toIDLRepositoryID();
-            bindingName = getBindingQNameByID(wsdlDefinition, repositoryID);
+            bindingName = getBindingQNameByID(definition, repositoryID, objRefWsdlVisitor);
         }
         
         if (bindingName == null) {
@@ -199,7 +188,7 @@
         
         // Check to see if we have already defined an element for this reference type.  If
         // we have, then there is no need to add it to the schema again.
-        isDuplicateReference(referenceName, bindingName, wsaType);        
+        isDuplicateReference(referenceName, bindingName, customScope, wsaType, node);        
 
         setSchemaType(wsaType);
         
@@ -218,11 +207,27 @@
         } 
     }
     
-    private void isDuplicateReference(QName referenceName, QName bindingName, 
-                                 XmlSchemaType wsaType) {
+    private void isDuplicateReference(QName referenceName, QName bindingName, Scope refScope, 
+                                      XmlSchemaType wsaType, AST node) {
+        XmlSchema refSchema = null;
+        if (!mapper.isDefaultMapping()) {
+            String tns = mapper.map(refScope.getParent());
+            String refSchemaFileName = getWsdlVisitor().getOutputDir()
+                + System.getProperty("file.separator")
+                + refScope.getParent().toString("_") + ".xsd";
+            refSchema = manager.getXmlSchema(tns);
+            if (refSchema == null) {
+                refSchema = manager.createXmlSchema(tns, wsdlVisitor.getSchemas());
+            }
+            addWSAddressingImport(refSchema);
+            manager.addXmlSchemaImport(schema, refSchema, refSchemaFileName);
+        } else {
+            refSchema = schema;
+        }
+        
         // Check to see if we have already defined an element for this reference type.  If
         // we have, then there is no need to add it to the schema again.
-        if (!isReferenceSchemaTypeDefined(referenceName)) {
+        if (!isReferenceSchemaTypeDefined(referenceName, refSchema)) {
             // We need to add a new element definition to the schema section of our WSDL.
             // For custom endpoint types, this should contain an annotation which points
             // to the binding which will be used for this endpoint type.
@@ -251,8 +256,8 @@
             
             refElement.setAnnotation(annotation);
 
-            schema.getElements().add(referenceName, refElement);
-            schema.getItems().add(refElement);
+            refSchema.getElements().add(referenceName, refElement);
+            refSchema.getItems().add(refElement);
         }        
     }
     
@@ -270,8 +275,9 @@
         return false;
     }
 
-    private boolean isReferenceSchemaTypeDefined(QName objectReferenceName) {
-        XmlSchemaObjectCollection schemaObjects = schema.getItems();
+    private boolean isReferenceSchemaTypeDefined(QName objectReferenceName,
+                                                 XmlSchema refSchema) {
+        XmlSchemaObjectCollection schemaObjects = refSchema.getItems();
 
         for (Iterator iter = schemaObjects.getIterator(); iter.hasNext();) {
             java.lang.Object schemaObj = iter.next();
@@ -288,11 +294,64 @@
         return false;
     }
     
-    private static QName getBindingQNameByID(Definition wsdlDef, String repositoryID) {
+    private void addWSAddressingImport(XmlSchema s) {
+        boolean alreadyImported = false;
+        for (Iterator i = s.getIncludes().getIterator(); i.hasNext();) {
+            java.lang.Object o = i.next();
+            if (o instanceof XmlSchemaImport) {
+                XmlSchemaImport schemaImport = (XmlSchemaImport)o;
+                if (schemaImport.getNamespace().equals(ReferenceConstants.WSADDRESSING_NAMESPACE)) {
+                    alreadyImported = true;
+                    break;
+                }
+            }
+        }
+        
+        if (!alreadyImported) {
+            // We need to add an import statement to include the WS addressing types
+            XmlSchemaImport wsaImport = new XmlSchemaImport();
+            wsaImport.setNamespace(ReferenceConstants.WSADDRESSING_NAMESPACE);
+            wsaImport.setSchemaLocation(ReferenceConstants.WSADDRESSING_LOCATION);
+            s.getItems().add(wsaImport);
+            s.getIncludes().add(wsaImport);
+        }
+        
+        // Add the addressing namespace to the WSDLs list of namespaces.
+        definition.addNamespace(ReferenceConstants.WSADDRESSING_PREFIX,
+                                ReferenceConstants.WSADDRESSING_NAMESPACE);
+        
+        try {
+            // This is used to get the correct prefix in the schema section of
+            // the wsdl.  If we don't have this, then this namespace gets an 
+            // arbitrary prefix (e.g. ns5 instead of wsa).
+            NamespaceMap nsMap = (NamespaceMap)s.getNamespaceContext();
+            if (nsMap == null) {
+                nsMap = new NamespaceMap();
+                nsMap.add(ReferenceConstants.WSADDRESSING_PREFIX, 
+                          ReferenceConstants.WSADDRESSING_NAMESPACE);
+                s.setNamespaceContext(nsMap);
+            } else {
+                nsMap.add(ReferenceConstants.WSADDRESSING_PREFIX, 
+                          ReferenceConstants.WSADDRESSING_NAMESPACE);
+            }
+        } catch (ClassCastException ex) {
+            // Consume the exception.  It is still OK with the default prefix, 
+            // just not as clear.
+        }
+        
+    }
+    
+    private static QName getBindingQNameByID(Definition wsdlDef, String repositoryID, 
+                                             WSDLASTVisitor wsdlVisitor) {
         // We need to find the binding which corresponds with the given repository ID.
         // This is specified in the schema definition for a custom endpoint 
         // reference type.
         Collection bindings = wsdlDef.getBindings().values();
+        if (bindings.isEmpty() && !wsdlVisitor.getModuleToNSMapper().isDefaultMapping()) {
+            // If we are not using the default mapping, then the binding definitions are not 
+            // located in the current Definition object, but nistead in the root Definition 
+            bindings = wsdlVisitor.getDefinition().getBindings().values();
+        }
         
         for (Iterator iter = bindings.iterator(); iter.hasNext();) {
             Binding b = (Binding)iter.next();
@@ -302,9 +361,16 @@
                 java.lang.Object element = extIter.next();
                 
                 if (element instanceof BindingType) {
-                    BindingType bt = (BindingType)element;
-                    if (bt.getRepositoryID().equals(repositoryID)) { 
-                        return b.getQName();    
+                    BindingType bt = (BindingType)element;                    
+                    if (bt.getRepositoryID().equals(repositoryID)) {
+                        if (wsdlVisitor.getSupportPolymorphicFactories()) {
+                            return new QName(b.getQName().getNamespaceURI(),
+                                             "InferFromTypeId",
+                                             b.getQName().getPrefix());
+            
+                        } else {
+                            return b.getQName();
+                        }
                     }
                 }
             }
@@ -317,8 +383,6 @@
                                                ScopeNameCollection scopedNames, WSDLASTVisitor wsdlVisitor) {
         boolean isForward = false;
         Scope currentScope = scope;
-        Scope fqName = null;
-
         
         // Check for forward declaration from local scope outwards
         if ((node.getFirstChild() == null)
@@ -335,7 +399,7 @@
                     isForward = true;
                 }
                 currentScope = currentScope.getParent();
-                fqName = scopedName;
+                //fqName = scopedName;
             }            
         }
         // Check for forward declaration in global scope
@@ -350,7 +414,7 @@
             if (scopedNames.getScope(scopedName) != null) {                
                 isForward = true;
             }
-            fqName = scopedName;
+            //fqName = scopedName;
         }                
 
         return isForward;
@@ -402,9 +466,8 @@
         setSchemaType(result);
     }
 
-
-    
-    private static boolean hasBinding(Scope scope, XmlSchema s, Definition def, AST node) {
+    private static boolean hasBinding(Scope scope, XmlSchema s, Definition def, 
+                                      AST node, WSDLASTVisitor wsdlVisitor) {
         boolean result = false;
         QName bindingName = null;
         String repositoryID = null;
@@ -420,7 +483,7 @@
                     customScope = new Scope(currentScope, node);                    
                 }
                 repositoryID = customScope.toIDLRepositoryID();
-                bindingName = getBindingQNameByID(def, repositoryID);
+                bindingName = getBindingQNameByID(def, repositoryID, wsdlVisitor);
                 currentScope = currentScope.getParent();
             }
         }
@@ -433,7 +496,7 @@
                 customScope = new Scope(new Scope(), node);
             }
             repositoryID = customScope.toIDLRepositoryID();
-            bindingName = getBindingQNameByID(def, repositoryID);
+            bindingName = getBindingQNameByID(def, repositoryID, wsdlVisitor);
         }
         
         if (bindingName != null) {
@@ -442,5 +505,4 @@
 
         return result;
     }
-
 }

Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/OperationDeferredAction.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/OperationDeferredAction.java?rev=608894&r1=608893&r2=608894&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/OperationDeferredAction.java (original)
+++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/OperationDeferredAction.java Fri Jan  4 07:47:28 2008
@@ -15,7 +15,7 @@
  * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.yoko.tools.processors.idl;
 
@@ -25,26 +25,23 @@
 import org.apache.yoko.tools.common.ReferenceConstants;
 import org.apache.yoko.wsdl.CorbaTypeImpl;
 
-public class OperationDeferredAction extends DeferredActionBase {
+public class OperationDeferredAction implements SchemaDeferredAction {
 
     protected ArgType argType;
     protected XmlSchemaElement element;
         
-    public OperationDeferredAction(Scope fqName) {
-        super(fqName);
+    public OperationDeferredAction() {
     };
         
-    public OperationDeferredAction(ArgType arg, Scope scope) {
-        super(scope);
+    public OperationDeferredAction(ArgType arg) {
         argType = arg;         
     }
     
-    public OperationDeferredAction(XmlSchemaElement elem, Scope scope) {
-        super(scope);
+    public OperationDeferredAction(XmlSchemaElement elem) {
         element = elem;               
     }        
     
-    public void doDeferredAction(XmlSchemaType stype, CorbaTypeImpl ctype) {
+    public void execute(XmlSchemaType stype, CorbaTypeImpl ctype) {
         if (argType != null) {
             argType.setIdltype(ctype.getQName());
         }
@@ -57,6 +54,7 @@
     }
        
 }
+
 
 
 

Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/OperationVisitor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/OperationVisitor.java?rev=608894&r1=608893&r2=608894&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/OperationVisitor.java (original)
+++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/OperationVisitor.java Fri Jan  4 07:47:28 2008
@@ -15,7 +15,7 @@
  * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.yoko.tools.processors.idl;
 
@@ -41,10 +41,8 @@
 import org.apache.schemas.yoko.bindings.corba.ArgType;
 import org.apache.schemas.yoko.bindings.corba.OperationType;
 import org.apache.schemas.yoko.bindings.corba.RaisesType;
-import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
 
 import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaSequence;
@@ -64,7 +62,6 @@
     private static final String INOUT_PARAMETER = "inoutparameter";
     private static final String RETURN_PARAMETER = "return";
     
-    private Definition definition;
     private ExtensionRegistry extReg;
     private PortType portType;
     private Binding binding;
@@ -78,18 +75,21 @@
     private OperationType corbaOperation;
     
     public OperationVisitor(Scope scope,
+                            Definition defn,
+                            XmlSchema schemaRef,
                             WSDLASTVisitor wsdlVisitor,
                             PortType wsdlPortType,
                             Binding wsdlBinding) {
-        super(scope, wsdlVisitor);
-        definition = wsdlVisitor.getDefinition();
+        super(scope, defn, schemaRef, wsdlVisitor);
         extReg = definition.getExtensionRegistry();
         portType = wsdlPortType;
         binding = wsdlBinding;
     }
     
-    public static boolean accept(Scope scope, XmlSchemaCollection schemas, XmlSchema schema,
-                                 TypeMappingType typeMap, Definition def, AST node, 
+    public static boolean accept(Scope scope,
+                                 Definition def,
+                                 XmlSchema schema,
+                                 AST node,
                                  WSDLASTVisitor wsdlVisitor) {
         boolean result = false;
         AST node2 = node.getFirstChild();
@@ -101,9 +101,9 @@
                 type == IDLTokenTypes.LITERAL_void
                 || PrimitiveTypesVisitor.accept(node2)
                 || StringVisitor.accept(node2)
-                || ScopedNameVisitor.accept(scope, schemas, schema, 
-                                            typeMap, def, node2, wsdlVisitor)
-                || ObjectReferenceVisitor.accept(scope, schema, def, node2);
+                || ScopedNameVisitor.accept(scope, def, schema, node2, wsdlVisitor)
+                //REVISIT, change this to be def & then schema
+                || ObjectReferenceVisitor.accept(scope, schema, def, node2, wsdlVisitor);
         }
         return result;
     }
@@ -118,8 +118,8 @@
         // <parameter_dcls> ::= "(" <param_dcl> {"," <param_dcl>}* ")"
         //                    | "(" ")"
         // <raises_expr> ::= "raises" "(" <scoped_name> {"," <scoped_name>}* ")"
-        // <context_expr> ::= "context" "(" <string_literal> {"," <string_literal>}* ")"
-     
+        // <context_expr> ::= "context" "(" <string_literal> {"," <string_literal>}* ")"     
+
         QName operationQName = new QName(schema.getTargetNamespace(), node.toString());
         boolean isDuplicate = false;
         if (schema.getElements().contains(operationQName)) {
@@ -169,6 +169,8 @@
         while (ParamDclVisitor.accept(node)) {
 
             ParamDclVisitor visitor = new ParamDclVisitor(getScope(),
+                                                          definition,
+                                                          schema,
                                                           wsdlVisitor,
                                                           inputWrappingSequence,
                                                           outputWrappingSequence,
@@ -186,13 +188,18 @@
             while (node != null) {            
                 // 
                 ScopedNameVisitor visitor = new ScopedNameVisitor(getScope(),
+                                                                  definition,
+                                                                  schema,
                                                                   wsdlVisitor);                
                 visitor.setExceptionMode(true);
                 visitor.visit(node);                
                 CorbaTypeImpl corbaType = visitor.getCorbaType();
-                createFaultMessage(corbaType, operation, bindingOperation, 
-                                   visitor.getFullyQualifiedName());
-                
+                XmlSchemaType schemaType = visitor.getSchemaType();
+                //REVISIT, schema type ends with Type for exceptions, so strip it to get the element name.
+                int pos = schemaType.getQName().getLocalPart().indexOf("Type");
+                QName elementQName = new QName(schemaType.getQName().getNamespaceURI(),
+                                               schemaType.getQName().getLocalPart().substring(0, pos));
+                createFaultMessage(corbaType, operation, bindingOperation, elementQName);                
                 node = node.getNextSibling();
                 visitor.setExceptionMode(false);
             }
@@ -235,8 +242,17 @@
 
 
     public Message generateInputMessage(Operation operation, BindingOperation bindingOperation) {
-        Message msg = definition.createMessage(); 
-        msg.setQName(new QName(definition.getTargetNamespace(), operation.getName()));
+        Message msg = definition.createMessage();
+        QName msgName;
+        if (!mapper.isDefaultMapping()) {
+            //mangle the message name
+            //REVISIT, do we put in the entire scope for mangling
+            msgName = new QName(definition.getTargetNamespace(),
+                                getScope().tail() + "." + operation.getName());
+        } else {
+            msgName = new QName(definition.getTargetNamespace(), operation.getName()); 
+        }
+        msg.setQName(msgName);
         msg.setUndefined(false);
         
         String inputName = operation.getName() + REQUEST_SUFFIX;
@@ -257,8 +273,17 @@
 
     public Message generateOutputMessage(Operation operation, BindingOperation bindingOperation) {
         Message msg = definition.createMessage(); 
-        msg.setQName(new QName(definition.getTargetNamespace(),
-                               operation.getName() + RESPONSE_SUFFIX));
+        QName msgName;
+        if (!mapper.isDefaultMapping()) {
+            //mangle the message name
+            //REVISIT, do we put in the entire scope for mangling
+            msgName = new QName(definition.getTargetNamespace(),
+                                getScope().tail() + "." + operation.getName() + RESPONSE_SUFFIX);
+        } else {
+            msgName = new QName(definition.getTargetNamespace(),
+                                operation.getName() + RESPONSE_SUFFIX); 
+        }
+        msg.setQName(msgName);
         msg.setUndefined(false);
         
         String outputName = operation.getName() + RESPONSE_SUFFIX;
@@ -333,7 +358,7 @@
             }
         } else {
             wsdlVisitor.getDeferredActions().
-                add(new OperationDeferredAction(element, fqName));  
+                add(fqName, new OperationDeferredAction(element));  
         }
         
         schemaSequence.getItems().add(element);
@@ -346,7 +371,9 @@
             // nothing to do here, move along
             return;
         } else {
-            ParamTypeSpecVisitor visitor = new ParamTypeSpecVisitor(getScope(), 
+            ParamTypeSpecVisitor visitor = new ParamTypeSpecVisitor(getScope(),
+                                                                    definition,
+                                                                    schema,
                                                                     wsdlVisitor);
 
             visitor.visit(node);
@@ -367,7 +394,7 @@
             param.setIdltype(corbaType.getQName());
         } else {
             wsdlVisitor.getDeferredActions().
-                add(new OperationDeferredAction(param, fqName));
+                add(fqName, new OperationDeferredAction(param));
         }
         corbaOperation.setReturn(param);
     }
@@ -375,19 +402,17 @@
     private void createFaultMessage(CorbaTypeImpl corbaType,
                                     Operation operation, 
                                     BindingOperation bindingOperation,
-                                    Scope fqName) {
+                                    QName elementQName) {
         String exceptionName = corbaType.getQName().getLocalPart();        
 
-        // message
-        Message faultMsg = definition.createMessage();        
-        faultMsg.setQName(new QName(definition.getTargetNamespace(), exceptionName));        
-        faultMsg.setUndefined(false);
-
-        // message - part
-        Part part = definition.createPart();
-        part.setName("exception");            
-        part.setElementName(new QName(schema.getTargetNamespace(), exceptionName));        
-        faultMsg.addPart(part);
+        Definition faultDef = manager.getWSDLDefinition(elementQName.getNamespaceURI());
+        if (faultDef == null) {
+            faultDef = definition;
+        }
+        Message faultMsg = faultDef.getMessage(new QName(faultDef.getTargetNamespace(), exceptionName));
+        if (faultMsg == null) {
+            throw new RuntimeException("Fault message for exception " + exceptionName + " not found");
+        }
 
         // porttype - operation - fault
         Fault fault = definition.createFault();
@@ -398,14 +423,16 @@
         // binding - operation - corba:operation - corba:raises
         RaisesType raisesType = new RaisesType();        
         raisesType.setException(new QName(typeMap.getTargetNamespace(),
-                                              exceptionName));
+                                          exceptionName));
         corbaOperation.getRaises().add(raisesType);
 
         // binding - operation - fault
         BindingFault bindingFault = definition.createBindingFault();        
         bindingFault.setName(faultMsg.getQName().getLocalPart());        
-        bindingOperation.addBindingFault(bindingFault);
+        bindingOperation.addBindingFault(bindingFault);    
 
-        definition.addMessage(faultMsg);        
+        //add the fault element namespace to the definition
+        String nsURI = elementQName.getNamespaceURI();
+        manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(nsURI), nsURI);    
     }
 }

Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ParamDclVisitor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ParamDclVisitor.java?rev=608894&r1=608893&r2=608894&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ParamDclVisitor.java (original)
+++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ParamDclVisitor.java Fri Jan  4 07:47:28 2008
@@ -15,16 +15,19 @@
  * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.yoko.tools.processors.idl;
 
+import javax.wsdl.Definition;
+
 import antlr.collections.AST;
 
 import org.apache.schemas.yoko.bindings.corba.ModeType;
 import org.apache.schemas.yoko.bindings.corba.OperationType;
 import org.apache.schemas.yoko.bindings.corba.ParamType;
 
+import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaSequence;
 import org.apache.ws.commons.schema.XmlSchemaType;
@@ -39,11 +42,13 @@
     private OperationType corbaOperation;
     
     public ParamDclVisitor(Scope scope,
+                           Definition defn,
+                           XmlSchema schemaRef,
                            WSDLASTVisitor wsdlVisitor,
                            XmlSchemaSequence inWrapSeq,
                            XmlSchemaSequence outWrapSeq,
                            OperationType corbaOp) {
-        super(scope, wsdlVisitor);
+        super(scope, defn, schemaRef, wsdlVisitor);
         inWrappingSequence = inWrapSeq;
         outWrappingSequence = outWrapSeq;
         corbaOperation = corbaOp;
@@ -68,8 +73,9 @@
 
         AST typeNode = node.getFirstChild();
         AST nameNode = TypesUtils.getCorbaTypeNameNode(typeNode);
-        
-        ParamTypeSpecVisitor visitor = new ParamTypeSpecVisitor(getScope(), 
+        ParamTypeSpecVisitor visitor = new ParamTypeSpecVisitor(getScope(),
+                                                                definition,
+                                                                schema,
                                                                 wsdlVisitor);
         visitor.visit(typeNode);
         XmlSchemaType schemaType = visitor.getSchemaType();
@@ -105,9 +111,22 @@
         XmlSchemaElement element = new XmlSchemaElement();
         element.setName(name);
         if (schemaType == null) {
-            ParamDeferredAction elementAction = 
-                new ParamDeferredAction(element, fullyQualifiedName);
-            wsdlVisitor.getDeferredActions().add(elementAction);
+            ParamDeferredAction elementAction;
+            if (mapper.isDefaultMapping()) {
+                elementAction = new ParamDeferredAction(element);
+            } else {
+                elementAction = new ParamDeferredAction(element,
+                                                        fullyQualifiedName.getParent(),
+                                                        schema,
+                                                        schemas,
+                                                        manager,
+                                                        mapper);
+            }
+            wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction);
+
+            //ParamDeferredAction elementAction = 
+            //    new ParamDeferredAction(element);
+            //wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction);
         } else {
             element.setSchemaTypeName(schemaType.getQName());
             if (schemaType.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
@@ -125,9 +144,9 @@
         param.setMode(mode);
         if (corbaType ==  null) {            
             ParamDeferredAction paramAction = 
-                new ParamDeferredAction(param, fullyQualifiedName);
-            wsdlVisitor.getDeferredActions().add(paramAction);
-        } else {
+                new ParamDeferredAction(param);
+            wsdlVisitor.getDeferredActions().add(fullyQualifiedName, paramAction);
+        } else {            
             param.setIdltype(corbaType.getQName());
         }
         corbaOperation.getParam().add(param);

Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ParamDeferredAction.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ParamDeferredAction.java?rev=608894&r1=608893&r2=608894&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ParamDeferredAction.java (original)
+++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ParamDeferredAction.java Fri Jan  4 07:47:28 2008
@@ -15,40 +15,59 @@
  * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.yoko.tools.processors.idl;
 
+import java.util.Iterator;
+
 import org.apache.schemas.yoko.bindings.corba.ParamType;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaImport;
 import org.apache.ws.commons.schema.XmlSchemaType;
 import org.apache.yoko.tools.common.ReferenceConstants;
 import org.apache.yoko.wsdl.CorbaTypeImpl;
 
-public class ParamDeferredAction extends DeferredActionBase {
+public class ParamDeferredAction implements SchemaDeferredAction {
 
     protected ParamType param;
     protected XmlSchemaElement element;
+    protected XmlSchema schema;
+    protected XmlSchemaCollection schemas;
+    protected Scope typeScope;
+    protected WSDLSchemaManager manager;
+    protected ModuleToNSMapper mapper;
     
-    
-    public ParamDeferredAction(ParamType defParam, XmlSchemaElement elem,
-                                  Scope scope) {                           
-        super(scope);
+    public ParamDeferredAction(ParamType defParam, XmlSchemaElement elem) {
         param = defParam;
         element = elem;        
     }
     
-    public ParamDeferredAction(ParamType defParam, Scope scope) {                           
-        super(scope);
+    public ParamDeferredAction(ParamType defParam) {
         param = defParam;         
     }
     
-    public ParamDeferredAction(XmlSchemaElement elem, Scope scope) {                           
-        super(scope);
+    public ParamDeferredAction(XmlSchemaElement elem) {
         element = elem;               
     }
     
-    public void doDeferredAction(XmlSchemaType stype, CorbaTypeImpl ctype) {
+    public ParamDeferredAction(XmlSchemaElement elem, 
+                               Scope ts,
+                               XmlSchema xmlSchema,
+                               XmlSchemaCollection xmlSchemas,
+                               WSDLSchemaManager man,
+                               ModuleToNSMapper map) {
+        element = elem;
+        schema = xmlSchema;
+        schemas = xmlSchemas;
+        typeScope = ts;
+        manager = man;
+        mapper = map;
+    }
+    
+    public void execute(XmlSchemaType stype, CorbaTypeImpl ctype) {
         if (param != null) {
             param.setIdltype(ctype.getQName());
         }
@@ -57,10 +76,43 @@
             if (stype.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
                 element.setNillable(true);
             }
+     
+            if (manager == null) {
+                return;
+            }
+            
+            // Now we need to make sure we are importing any types we need
+            XmlSchema importedSchema = null;
+            if (stype.getQName().getNamespaceURI().equals(ReferenceConstants.WSADDRESSING_NAMESPACE)) {
+                boolean alreadyImported = false;
+                for (Iterator i = schema.getIncludes().getIterator(); i.hasNext();) {
+                    java.lang.Object o = i.next();
+                    if (o instanceof XmlSchemaImport) {
+                        XmlSchemaImport schemaImport = (XmlSchemaImport)o;
+                        if (schemaImport.getNamespace().equals(ReferenceConstants.WSADDRESSING_NAMESPACE)) {
+                            alreadyImported = true;
+                            break;
+                        }
+                    }
+                }
+                    
+                if (!alreadyImported) {
+                    // We need to add an import statement to include the WS addressing types
+                    XmlSchemaImport wsaImport = new XmlSchemaImport();
+                    wsaImport.setNamespace(ReferenceConstants.WSADDRESSING_NAMESPACE);
+                    wsaImport.setSchemaLocation(ReferenceConstants.WSADDRESSING_LOCATION);
+                    schema.getItems().add(wsaImport);
+                    schema.getIncludes().add(wsaImport);
+                }
+            } else if (!stype.getQName().getNamespaceURI().equals(schema.getTargetNamespace())) {
+                importedSchema = manager.getXmlSchema(mapper.map(typeScope));
+                manager.addXmlSchemaImport(schema, importedSchema, typeScope.toString("_"));
+            }
         }        
     }
        
 }
+
 
 
 

Modified: incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java?rev=608894&r1=608893&r2=608894&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java (original)
+++ incubator/cxf/trunk/tools/corba/src/main/java/org/apache/yoko/tools/processors/idl/ParamTypeSpecVisitor.java Fri Jan  4 07:47:28 2008
@@ -15,22 +15,21 @@
  * KIND, either express or implied. See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.yoko.tools.processors.idl;
 
 import javax.wsdl.Definition;
-
 import antlr.collections.AST;
+import org.apache.ws.commons.schema.XmlSchema;
 
 public class ParamTypeSpecVisitor extends VisitorBase {
 
-    private Definition wsdlDefinition;
-    
     public ParamTypeSpecVisitor(Scope scope,
+                                Definition defn,
+                                XmlSchema schemaRef,
                                 WSDLASTVisitor wsdlVisitor) {
-        super(scope, wsdlVisitor);
-        wsdlDefinition = wsdlVisitor.getDefinition();
+        super(scope, defn, schemaRef, wsdlVisitor);
     }
 
     public void visit(AST node) {
@@ -45,19 +44,15 @@
         
         if (PrimitiveTypesVisitor.accept(node)) {
             // base_type_spec
-            visitor = new PrimitiveTypesVisitor(getScope(), schemas);
-            
+            visitor = new PrimitiveTypesVisitor(getScope(), definition, schema, schemas);            
         } else if (StringVisitor.accept(node)) {
             // string_type_spec
             // wstring_type_spec
-            visitor = new StringVisitor(getScope(), wsdlVisitor, null);
+            visitor = new StringVisitor(getScope(), definition, schema, wsdlVisitor, null);
 
-        } else if (ScopedNameVisitor.accept(getScope(), schemas, schema, 
-                                            typeMap, 
-                                            wsdlVisitor.getDefinition(),
-                                            node, wsdlVisitor)) {
+        } else if (ScopedNameVisitor.accept(getScope(), definition, schema, node, wsdlVisitor)) {
             // scoped_name
-            visitor = new ScopedNameVisitor(getScope(), wsdlVisitor);
+            visitor = new ScopedNameVisitor(getScope(), definition, schema, wsdlVisitor);
                
         } else {
             throw new RuntimeException("[ParamTypeSpecVisitor] Invalid IDL: unknown element "
@@ -65,7 +60,6 @@
         }
         
         visitor.visit(node);
-
         setSchemaType(visitor.getSchemaType());
         setCorbaType(visitor.getCorbaType());
         setFullyQualifiedName(visitor.getFullyQualifiedName());