incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r553869 - in /incubator/yoko/trunk/tools/src: main/java/org/apache/yoko/tools/ main/java/org/apache/yoko/tools/common/ main/java/org/apache/yoko/tools/common/toolspec/toolspecs/ main/java/org/apache/yoko/tools/processors/idl/ main/java/org/...
Date Fri, 06 Jul 2007 13:01:28 GMT
Author: bravi
Date: Fri Jul  6 06:01:27 2007
New Revision: 553869

URL: http://svn.apache.org/viewvc?view=rev&rev=553869
Log:
[YOKO-396] - Fixes to the wsdltoidl to handle wsdl's with bindings other than corba binding.
Also some fixes to the wsdltoidl options.

Added:
    incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_multiplebinding.idl
Removed:
    incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_test1.idl
    incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_test2.idl
Modified:
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/WSDLToIDL.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/toolspec/toolspecs/wsdl2idl.xml
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaProcessor.java
    incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java
    incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToIDLGenerationTest.java

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java?view=diff&rev=553869&r1=553868&r2=553869
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java Fri Jul
 6 06:01:27 2007
@@ -89,7 +89,7 @@
                 ex.printStackTrace();
             }
             throw new ToolException(ex.getMessage(), ex.getCause());
-        }       
+        }
     }
 
     private void initialise(ProcessorEnvironment env) throws ToolException {

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/WSDLToIDL.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/WSDLToIDL.java?view=diff&rev=553869&r1=553868&r2=553869
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/WSDLToIDL.java (original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/WSDLToIDL.java Fri Jul
 6 06:01:27 2007
@@ -69,7 +69,7 @@
                     env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
                 }
                 env.put(ToolConstants.CFG_CMD_ARG, args);
-
+                    
                 CommandDocument doc = super.getCommandDocument();
                 if (doc.hasParameter("corba")) {
                     env.put(ToolCorbaConstants.CFG_CORBA, Boolean.TRUE);
@@ -100,7 +100,7 @@
                 ex.printStackTrace();
             }
             throw new ToolException(ex.getMessage(), ex.getCause());
-        }       
+        }
     }
 
     private void initialise(ProcessorEnvironment env) throws ToolException {
@@ -120,15 +120,10 @@
             env.put(ToolConstants.CFG_NAMESPACE, doc.getParameter("namespace"));
         }
         if (env.optionSet(ToolCorbaConstants.CFG_WSDLOUTPUTFILE)) {
-            env.put(ToolCorbaConstants.CFG_WSDLOUTPUT, doc.getParameter("wsdloutputfile"));
+            env.put(ToolCorbaConstants.CFG_WSDLOUTPUTFILE, doc.getParameter("wsdloutputfile"));
         }        
-        if (env.optionSet(ToolConstants.CFG_OUTPUTFILE)) {
-            String[] outputs = doc.getParameters("outputfile");
-            String filelist = null;
-            for (int i = 0; i < outputs.length; i++) {
-                filelist = outputs[i] + ", ";                
-            }
-            env.put(ToolCorbaConstants.CFG_IDLOUTPUT, filelist);
+        if (env.optionSet(ToolCorbaConstants.CFG_IDLOUTPUTFILE)) {
+            env.put(ToolCorbaConstants.CFG_IDLOUTPUTFILE, doc.getParameter("idloutputfile"));
         }
         
         if (env.optionSet(ToolConstants.CFG_OUTPUTDIR)) {

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java?view=diff&rev=553869&r1=553868&r2=553869
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/ToolCorbaConstants.java
Fri Jul  6 06:01:27 2007
@@ -25,8 +25,7 @@
     public static final String CFG_CORBA = "corba";
     public static final String CFG_IDL = "idl";
     public static final String CFG_WSDLOUTPUTFILE = "wsdloutputfile";
-    public static final String CFG_WSDLOUTPUT = "wsdlOutput";
-    public static final String CFG_IDLOUTPUT = "idlOutput";   
+    public static final String CFG_IDLOUTPUTFILE = "idloutputfile";   
 
     public static final String CFG_IDLFILE = "idl";
     public static final String CFG_TNS = "tns";

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/toolspec/toolspecs/wsdl2idl.xml
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/toolspec/toolspecs/wsdl2idl.xml?view=diff&rev=553869&r1=553868&r2=553869
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/toolspec/toolspecs/wsdl2idl.xml
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/common/toolspec/toolspecs/wsdl2idl.xml
Fri Jul  6 06:01:27 2007
@@ -78,8 +78,8 @@
         </associatedArgument>
       </option>
 
-      <option id="outputfile" maxOccurs="unbounded">
-        <annotation>The idl output file name(s). Comma separated</annotation>
+      <option id="idloutputfile" maxOccurs="1">
+        <annotation>The idl output file name.</annotation>
         <switch>o</switch>
         <associatedArgument placement="afterSpace">
           <annotation>output-file</annotation>

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java?view=diff&rev=553869&r1=553868&r2=553869
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/idl/IDLToWSDLProcessor.java
Fri Jul  6 06:01:27 2007
@@ -139,7 +139,7 @@
         parser.specification();
         AST idlTree = parser.getAST();
 
-        if (!env.isVerbose()) {
+        if (env.isVerbose()) {
             System.out.println(idlTree.toStringTree());
         }               
 

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaProcessor.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaProcessor.java?view=diff&rev=553869&r1=553868&r2=553869
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaProcessor.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToCorbaProcessor.java
Fri Jul  6 06:01:27 2007
@@ -204,8 +204,8 @@
     }
 
     private void setOutputFile() {
-        wsdlOutput = (String)env.get(ToolCorbaConstants.CFG_WSDLOUTPUT);
-        idlOutput = (String)env.get(ToolCorbaConstants.CFG_IDLOUTPUT);
+        wsdlOutput = (String)env.get(ToolCorbaConstants.CFG_WSDLOUTPUTFILE);
+        idlOutput = (String)env.get(ToolCorbaConstants.CFG_IDLOUTPUTFILE);
         if ((wsdlOutput == null) && (idlOutput == null)) {        
             LOG.log(Level.WARNING,
                     "Using default wsdl/idl filenames...");

Modified: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java?view=diff&rev=553869&r1=553868&r2=553869
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java
(original)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/processors/wsdl/WSDLToIDLAction.java
Fri Jul  6 06:01:27 2007
@@ -22,6 +22,7 @@
 import java.io.File;
 import java.io.OutputStream;
 import java.io.PrintWriter;
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -99,7 +100,6 @@
     private static String wsdlFileName;
     private static String namespace;
     private static boolean verboseOn;
-    private String[] outputFiles;
     private String outputFile;
     private PrintWriter printWriter;
     private OutputStreamFactory factory = new FileOutputStreamFactory();
@@ -125,7 +125,11 @@
             extReg = def.getExtensionRegistry();
             addExtensions(extReg);
             typeProcessor.setExtensionRegistry(extReg);
-        }       
+        }
+
+        if (printWriter == null) {
+            printWriter = createPrintWriter(outputFile);
+        }
         
         if (!isGenerateAllBindings()) {
             Binding binding = findBinding(def);
@@ -144,19 +148,25 @@
                 org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr,
LOG);
                 throw new Exception(msg.toString());
             } else {
+                List<QName> portTypes = new ArrayList<QName>();
                 Iterator iter = bindingList.values().iterator();
-                int i = 0;
                 while (iter.hasNext()) {
                     Binding binding = (Binding)iter.next();
-                    PrintWriter writer  = createPrintWriter(binding.getQName().getLocalPart(),
-                                                    outputFiles[i]);
-                    i++;
-                    setPrintWriter(writer);
+                    List ext = binding.getExtensibilityElements();
+                    if (!(ext.get(0) instanceof BindingType)) {
+                        continue;
+                    }
+                    if (portTypes.contains(binding.getPortType().getQName())) {
+                        continue;
+                    } else {
+                        portTypes.add(binding.getPortType().getQName());
+                    }
                     generateIDL(def, binding);
                     root = IdlRoot.create();
                 }
             }
         }
+        printWriter.close();
         
     }
 
@@ -186,22 +196,13 @@
         }
     }    
 
-    public void generateIDL(Definition definition, Binding binding) {
+    private void generateIDL(Definition definition, Binding binding) {
         List ext = binding.getExtensibilityElements();
         if (!(ext.get(0) instanceof BindingType)) {
             // throw an error not a corba binding
             throw new RuntimeException(binding.getQName() + " is not a corba binding, "
                                        + "please pass a corba binding/porttype to use");
-        }
-
-        if (printWriter == null) {
-            try {
-                printWriter = createPrintWriter(binding.getQName().getLocalPart(),
-                                                outputFile);
-            } catch (Exception ex) {
-                ex.printStackTrace();
-            }
-        }        
+        }    
 
         String nm[] = unscopeName(binding.getPortType().getQName().getLocalPart());
         int pos = nm[nm.length - 1].lastIndexOf("Binding");
@@ -219,7 +220,6 @@
                 parent = mod;
             }
         }
-        
         intf = IdlInterface.create(parent, nm[nm.length - 1]);
         parent.holdForScope(intf);
         try {
@@ -231,7 +231,6 @@
         }
         parent.promoteHeldToScope();
         root.write(printWriter);
-        printWriter.close();
     }
     
     private void collectIdlDefns(Binding binding) throws Exception {
@@ -825,23 +824,8 @@
         return enum1;
     }
 
-    private PrintWriter createPrintWriter(String bindName, String filename) throws Exception
{        
-        if (filename == null || filename.length() <= 1) {            
-            String nm[] = unscopeName(bindName);
-            int pos = nm[nm.length - 1].lastIndexOf("Binding");
-
-            if (pos != -1) {
-                nm[nm.length - 1] = nm[nm.length - 1].substring(0, pos);
-            }
-
-            filename = new String(nm[nm.length - 1] + ".idl");
-            LOG.log(Level.WARNING,
-                    "No file name specified for " + bindName + ". Using default " 
-                    + filename + " file...");
-        }
-
+    private PrintWriter createPrintWriter(String filename) throws Exception {
         OutputStream out = factory.createOutputStream(filename);
-
         return new PrintWriter(out);
     }            
 
@@ -891,18 +875,8 @@
         return result;
     }
         
-    public void setOutputFile(String file) {                
-        StringTokenizer tok = new StringTokenizer(file, ",");
-        String filenames[] = new String[tok.countTokens()];
-
-        int i = 0;
-        while (tok.hasMoreTokens()) {            
-            filenames[i] = tok.nextToken();
-            i++;
-        }
-        
-        outputFiles = filenames;
-        outputFile = new String(filenames[0]);
+    public void setOutputFile(String file) {
+        outputFile = file;
     }
     
     public void setPrintWriter(PrintWriter pw) {
@@ -939,6 +913,6 @@
     
     public boolean isGenerateAllBindings() {
         return generateAllBindings;
-    }        
+    }
 
 }

Modified: incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToIDLGenerationTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToIDLGenerationTest.java?view=diff&rev=553869&r1=553868&r2=553869
==============================================================================
--- incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToIDLGenerationTest.java
(original)
+++ incubator/yoko/trunk/tools/src/test/java/org/apache/yoko/tools/processors/WSDLToIDLGenerationTest.java
Fri Jul  6 06:01:27 2007
@@ -643,30 +643,17 @@
             String fileName = getClass().getResource("/idlgen/multiplebinding.wsdl").toString();
             idlgen.setWsdlFile(fileName);
                         
-            idlgen.setOutputFile("expected_test1.idl,expected_test2.idl");  
+            idlgen.setOutputFile("multiplebinding.idl");
+            idlgen.setPrintWriter(new PrintWriter(idloutput));  
             idlgen.setGenerateAllBindings(true);            
             idlgen.generateIDL(null);
 
-            File file1 = new File("expected_test1.idl");            
-            File file2 = new File("expected_test2.idl");            
-            
             InputStream origstream = 
-                getClass().getResourceAsStream("/idlgen/expected_test1.idl");
-            byte orig[] = inputStreamToBytes(origstream);            
-            InputStream actualStream = new FileInputStream(file1);                
-            byte actual[] = inputStreamToBytes(actualStream);
-            checkIDLStrings(orig, actual);
-            
-            origstream = 
-                getClass().getResourceAsStream("/idlgen/expected_test2.idl");
-            orig = inputStreamToBytes(origstream);
-            actualStream = new FileInputStream(file2);                
-            actual = inputStreamToBytes(actualStream);
-            checkIDLStrings(orig, actual);
-            
+                getClass().getResourceAsStream("/idlgen/expected_multiplebinding.idl");
+            byte orig[] = inputStreamToBytes(origstream);
+            checkIDLStrings(orig, idloutput.toByteArray());           
         } finally {
-            new File("expected_test1.idl").deleteOnExit();
-            new File("expected_test2.idl").deleteOnExit();
+            new File("multiplebinding.idl").deleteOnExit();
         }
     }
 

Added: incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_multiplebinding.idl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_multiplebinding.idl?view=auto&rev=553869
==============================================================================
--- incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_multiplebinding.idl (added)
+++ incubator/yoko/trunk/tools/src/test/resources/idlgen/expected_multiplebinding.idl Fri
Jul  6 06:01:27 2007
@@ -0,0 +1,36 @@
+module edell {
+    module test2 {
+        struct num2 {
+            long long2;
+        };
+    };
+    interface test1 {
+        struct num1 {
+            string str1;
+        };
+        num1
+        opNum1(
+            in num1 in1,
+            out num1 out1,
+            inout num1 inout1
+        );
+    };
+};
+module edell {
+    module test1 {
+        struct num1 {
+            string str1;
+        };
+    };
+    interface test2 {
+        struct num2 {
+            long long2;
+        };
+        num2
+        opNum2(
+            in num2 in2,
+            out num2 out2,
+            inout num2 inout2
+        );
+    };
+};



Mime
View raw message