cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r531359 - in /incubator/cxf/trunk/tools/javato/src: main/java/org/apache/cxf/tools/java2wsdl/JavaToWSDL.java test/java/org/apache/cxf/tools/java2wsdl/JavaToWSDLTest.java
Date Mon, 23 Apr 2007 07:18:52 GMT
Author: ema
Date: Mon Apr 23 00:18:51 2007
New Revision: 531359

URL: http://svn.apache.org/viewvc?view=rev&rev=531359
Log:
Fixed issue CXF-587

Modified:
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/JavaToWSDL.java
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/JavaToWSDLTest.java

Modified: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/JavaToWSDL.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/JavaToWSDL.java?view=diff&rev=531359&r1=531358&r2=531359
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/JavaToWSDL.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/JavaToWSDL.java
Mon Apr 23 00:18:51 2007
@@ -16,92 +16,75 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.apache.cxf.tools.java2wsdl;
 
-import java.util.HashSet;
+import java.util.Arrays;
+import java.util.List;
 
-import org.apache.cxf.common.i18n.Message;
-import org.apache.cxf.tools.common.AbstractCXFToolContainer;
-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.common.util.StringUtils;
 import org.apache.cxf.tools.common.toolspec.ToolRunner;
-import org.apache.cxf.tools.common.toolspec.ToolSpec;
-import org.apache.cxf.tools.common.toolspec.parser.BadUsageException;
-import org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor;
-import org.apache.cxf.tools.java2wsdl.processor.JavaToProcessor;
-import org.apache.cxf.tools.util.AnnotationUtil;
-
-public class JavaToWSDL extends AbstractCXFToolContainer {
-   
-    private static final String TOOL_NAME = "java2wsdl";
 
-    public JavaToWSDL(ToolSpec toolspec) throws Exception {
-        super(TOOL_NAME, toolspec);
-    }
+public class JavaToWSDL {
 
-    public void execute(boolean exitOnFinish) throws ToolException {
-        Processor processor = null;
+    private String[] args;
 
-        try {
-            super.execute(exitOnFinish);
-            if (!hasInfoOption()) {
-                ToolContext env = new ToolContext();
-                env.setParameters(getParametersMap(new HashSet()));
-                if (isVerboseOn()) {
-                    env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
-                }
+    public JavaToWSDL() {
+        args = new String[0];
+    }
 
-                processor = new JavaToProcessor();
+    public JavaToWSDL(String pargs[]) {
+        args = pargs;
+    }
 
-                processor.setEnvironment(env);
-                processor.process();
-            }
-        } catch (ToolException ex) {            
-            if (ex.getCause() instanceof BadUsageException) {
-                printUsageException(TOOL_NAME, (BadUsageException)ex.getCause());
-                if (isVerboseOn()) {
-                    ex.printStackTrace();
-                }
-            }
-            throw ex;
+    public static void main(String[] args) {
+        JavaToWSDL j2w = new JavaToWSDL(args);
+        try {
+            j2w.run();
         } catch (Exception ex) {
             System.err.println("Error : " + ex.getMessage());
             System.err.println();
-            if (isVerboseOn()) {
+            if (j2w.isVerbose()) {
                 ex.printStackTrace();
             }
-            
-            throw new ToolException(ex.getMessage(), ex.getCause());
+            if (j2w.isExitOnFinish()) {
+                System.exit(1);
+            }
         }
     }
-
-    public Class getServiceClass(ToolContext context) {
-        return AnnotationUtil.loadClass((String)context.get(ToolConstants.CFG_CLASSNAME),
-                                        getClass().getClassLoader());
+    
+    private boolean isVerbose() {
+        return isSet(new String[]{"-V", "-verbose"});
     }
-
-    public static void main(String[] pargs) { 
-        try {
-            runTool(pargs);
-        } catch (Exception ex) {
-            System.err.println("Error : " + ex.getMessage());
-            System.err.println();
-            ex.printStackTrace();
+    
+    private boolean isSet(String[] keys) {
+        if (args == null) {
+            return false;
         }
+        List<String> pargs = Arrays.asList(args);
+        
+        for (String key : keys) {
+            if (pargs.contains(key)) {
+                return true;
+            }
+        }
+        return false;
     }
     
-    public static void runTool(String[] pargs) throws Exception {
-        ToolRunner.runTool(JavaToWSDL.class, JavaToWSDL.class
-                .getResourceAsStream("java2wsdl.xml"), false, pargs);
+    private void run() throws Exception {
+        ToolRunner.runTool(JavaToWSDLContainer.class, JavaToWSDLContainer.class
+                           .getResourceAsStream("java2wsdl.xml"), false, args);
     }
-
-    public void checkParams(ErrorVisitor errors) throws ToolException {
-        if (errors.getErrors().size() > 0) {
-            Message msg = new Message("PARAMETER_MISSSING", LOG);
-            throw new ToolException(msg, new BadUsageException(getUsage(), errors));
+    
+    
+    private boolean isExitOnFinish() {
+        String exit = System.getProperty("exitOnFinish");
+        if (StringUtils.isEmpty(exit)) {
+            return false;
         }
+        return "YES".equalsIgnoreCase(exit) || "TRUE".equalsIgnoreCase(exit);
     }
+
+
 }
+    
+

Modified: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/JavaToWSDLTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/JavaToWSDLTest.java?view=diff&rev=531359&r1=531358&r2=531359
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/JavaToWSDLTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/JavaToWSDLTest.java
Mon Apr 23 00:18:51 2007
@@ -69,5 +69,11 @@
         JavaToWSDL.main(args);
         assertNotNull(getStdOut());
     }
+    
+    public void testNoArg() {
+        String[] args = new String[] {};
+        JavaToWSDL.main(args);
+        assertEquals(-1, getStdOut().indexOf("Caused by:"));
+    }
 
 }



Mime
View raw message