You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by mm...@apache.org on 2007/12/07 04:17:32 UTC

svn commit: r601970 - in /incubator/cxf/trunk: distribution/src/main/release/bin/ tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/

Author: mmao
Date: Thu Dec  6 19:17:27 2007
New Revision: 601970

URL: http://svn.apache.org/viewvc?rev=601970&view=rev
Log:
* Independence of Java2JS


Added:
    incubator/cxf/trunk/distribution/src/main/release/bin/java2js
    incubator/cxf/trunk/distribution/src/main/release/bin/java2js.bat
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/JavaToJS.java
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/java2js.xml
Modified:
    incubator/cxf/trunk/distribution/src/main/release/bin/java2ws
    incubator/cxf/trunk/distribution/src/main/release/bin/java2ws.bat

Added: incubator/cxf/trunk/distribution/src/main/release/bin/java2js
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/bin/java2js?rev=601970&view=auto
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/bin/java2js (added)
+++ incubator/cxf/trunk/distribution/src/main/release/bin/java2js Thu Dec  6 19:17:27 2007
@@ -0,0 +1,96 @@
+#
+#
+#    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.
+#
+#
+#!/bin/sh
+# run the CXF java2ws tool 
+#
+
+# Check for irritating 'operating systems'.
+cygwin=false;
+darwin=false;
+case "`uname`" in
+  CYGWIN*) cygwin=true ;;
+  Darwin*) darwin=true
+           if [ -z "$JAVA_HOME" ] ; then
+             JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
+           fi
+           ;;
+esac
+
+
+me=`basename $0`
+cxf_home=$CXF_HOME
+if [ ! -f  $cxf_home/lib/cxf-manifest-incubator.jar ]; then
+    cxf_home=`dirname $0`/..
+fi
+                                                                                                                                                             
+cxf_jar=$cxf_home/lib/cxf-manifest-incubator.jar
+
+
+if [ ! -f $cxf_jar ]; then 
+    if [ ! -f ${cxf_home}/../../target/srcbuild_env ]; then
+        echo "ERROR: Unable to find cxf-manifest-incubator.jar in $cxf_home/lib"
+        exit 1
+    else
+        . ${cxf_home}/../../target/srcbuild_env
+        cxf_jar=${CXF_CLASSPATH}
+    fi
+fi 
+
+#
+# add the jdk's tools.jar to the classpath
+#
+
+sun_tool_path=""
+if [ $darwin == false ]; then
+    sun_tool_path=${JAVA_HOME}/lib/tools.jar
+    if [ ! -f $sun_tool_path ]; then
+	echo "ERROR: Set JAVA_HOME to the path where the J2SE 5.0 (JDK5.0) is installed"
+	exit 1
+    fi
+fi 
+
+log_config=$cxf_home/etc/logging.properties 
+
+
+# For Cygwin, switch paths to appropriate format before running java
+# For PATHs convert to unix format first, then to windows format to ensure
+# both formats are supported. Probably this will fail on directories with ;
+# in the name in the path. Let's assume that paths containing ; are more
+# rare than windows style paths on cygwin.
+if $cygwin; then
+  if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
+    format=mixed
+  else
+    format=windows
+  fi
+  cxf_classpath=`cygpath --$format "${cxf_jar}"`
+  if [ ! -z "${CLASSPATH}" ]; then
+    cxf_classpath=${cxf_classpath}\;`cygpath --$format --path "${CLASSPATH}"`
+  fi
+  if [ ! -z "${sun_tool_path}" ] ; then
+    cxf_classpath=${cxf_classpath}\;`cygpath --$format "${sun_tool_path}"`
+  fi
+  log_config=`cygpath --$format "$log_config"`
+else
+  cxf_classpath=${cxf_jar}:${CLASSPATH}:${sun_tool_path}
+fi
+
+$JAVA_HOME/bin/java -cp ${cxf_classpath} -Djava.util.logging.config.file=$log_config org.apache.cxf.tools.java2js.JavaToJS "$@"

Added: incubator/cxf/trunk/distribution/src/main/release/bin/java2js.bat
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/bin/java2js.bat?rev=601970&view=auto
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/bin/java2js.bat (added)
+++ incubator/cxf/trunk/distribution/src/main/release/bin/java2js.bat Thu Dec  6 19:17:27 2007
@@ -0,0 +1,57 @@
+@echo off
+rem
+rem
+rem    Licensed to the Apache Software Foundation (ASF) under one
+rem    or more contributor license agreements. See the NOTICE file
+rem    distributed with this work for additional information
+rem    regarding copyright ownership. The ASF licenses this file
+rem    to you under the Apache License, Version 2.0 (the
+rem    "License"); you may not use this file except in compliance
+rem    with the License. You may obtain a copy of the License at
+rem
+rem    http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem    Unless required by applicable law or agreed to in writing,
+rem    software distributed under the License is distributed on an
+rem    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+rem    KIND, either express or implied. See the License for the
+rem    specific language governing permissions and limitations
+rem    under the License.
+rem
+rem
+
+rem 
+rem  invoke the CXF java2js tool
+rem 
+@setlocal
+
+if not defined CXF_HOME goto set_cxf_home
+                                                                                                                                                             
+:cont
+if not defined JAVA_HOME goto no_java_home
+
+set SUN_TOOL_PATH=%JAVA_HOME%\lib\tools.jar;
+
+if not exist "%CXF_HOME%\lib\cxf-manifest-incubator.jar" goto no_cxf_jar
+
+set CXF_JAR=%CXF_HOME%\lib\cxf-manifest-incubator.jar
+
+"%JAVA_HOME%\bin\java" -cp "%CXF_JAR%;%SUN_TOOL_PATH%;%CLASSPATH%" -Djava.util.logging.config.file="%CXF_HOME%\etc\logging.properties" org.apache.cxf.tools.java2js.JavaToJS %*
+
+@endlocal
+
+goto end
+
+:no_cxf_jar
+echo ERROR: Unable to find cxf-manifest-incubator.jar in %cxf_home/lib
+goto end
+
+:no_java_home
+echo ERROR: Set JAVA_HOME to the path where the J2SE 5.0 (JDK5.0) is installed
+goto end 
+
+:set_cxf_home
+set CXF_HOME=%~dp0..
+goto cont
+
+:end
\ No newline at end of file

Modified: incubator/cxf/trunk/distribution/src/main/release/bin/java2ws
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/bin/java2ws?rev=601970&r1=601969&r2=601970&view=diff
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/bin/java2ws (original)
+++ incubator/cxf/trunk/distribution/src/main/release/bin/java2ws Thu Dec  6 19:17:27 2007
@@ -19,7 +19,7 @@
 #
 #
 #!/bin/sh
-# run the CXF java2wsdl tool 
+# run the CXF java2js tool 
 #
 
 # Check for irritating 'operating systems'.

Modified: incubator/cxf/trunk/distribution/src/main/release/bin/java2ws.bat
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/bin/java2ws.bat?rev=601970&r1=601969&r2=601970&view=diff
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/bin/java2ws.bat (original)
+++ incubator/cxf/trunk/distribution/src/main/release/bin/java2ws.bat Thu Dec  6 19:17:27 2007
@@ -21,7 +21,7 @@
 rem
 
 rem 
-rem  invoke the CXF java2wsdl tool
+rem  invoke the CXF java2js tool
 rem 
 @setlocal
 

Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/JavaToJS.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/JavaToJS.java?rev=601970&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/JavaToJS.java (added)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/JavaToJS.java Thu Dec  6 19:17:27 2007
@@ -0,0 +1,126 @@
+/**
+ * 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.cxf.tools.java2js;
+
+import java.io.File;
+import java.util.HashSet;
+
+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.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.java2js.processor.JavaToJSProcessor;
+
+public class JavaToJS extends AbstractCXFToolContainer {
+
+    public static final String TOOL_NAME = "java2js";
+    
+    public JavaToJS(ToolSpec toolspec) throws Exception {
+        super(TOOL_NAME, toolspec);
+    }
+    
+    public void execute(boolean exitOnFinish) {
+        super.execute(exitOnFinish);
+        Processor processor = new JavaToJSProcessor();
+        try {
+            super.execute(exitOnFinish);
+            if (!hasInfoOption()) {
+                ToolContext env = new ToolContext();
+                env.setParameters(getParametersMap(new HashSet<String>()));
+                if (env.get(ToolConstants.CFG_OUTPUTDIR) == null) {
+                    env.put(ToolConstants.CFG_OUTPUTDIR, ".");
+                }
+
+                if (isVerboseOn()) {
+                    env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
+                }
+                env.put(ToolConstants.CFG_CMD_ARG, getArgument());
+
+                validate(env);
+                
+                processor.setEnvironment(env);
+                processor.process();
+            }
+        } catch (ToolException ex) {
+            if (ex.getCause() instanceof BadUsageException) {
+                printUsageException(TOOL_NAME, (BadUsageException)ex.getCause());
+            }
+            System.err.println();
+            System.err.println("JavaToJS Error : " + ex.getMessage());
+            if (isVerboseOn()) {
+                ex.printStackTrace();
+            }
+        } catch (Exception ex) {
+            System.err.println();
+            System.err.println("JavaToJS Error : " + ex.getMessage());
+            if (isVerboseOn()) {
+                ex.printStackTrace();
+            }
+        } finally {
+            tearDown();
+        }
+    }
+
+    private void validate(ToolContext env) throws ToolException {
+        String outdir = (String)env.get(ToolConstants.CFG_OUTPUTDIR);
+        if (outdir != null) {
+            File dir = new File(outdir);
+            if (!dir.exists()) {
+                Message msg = new Message("DIRECTORY_NOT_EXIST", LOG, outdir);
+                throw new ToolException(msg);
+            }
+            if (!dir.isDirectory()) {
+                Message msg = new Message("NOT_A_DIRECTORY", LOG, outdir);
+                throw new ToolException(msg);
+            }
+        }
+    }
+
+    public static void main(String[] pargs) {
+        try {
+            ToolRunner.runTool(JavaToJS.class,
+                               JavaToJS.class.getResourceAsStream("java2js.xml"),
+                               false,
+                               pargs);
+        } catch (ToolException ex) {
+            System.err.println("Java2JS Error : " + ex.getMessage());
+            System.err.println();
+            ex.printStackTrace();
+        } catch (Exception ex) {
+            System.err.println("Java2JS Error : " + ex.getMessage());
+            System.err.println();
+            ex.printStackTrace();
+        }
+    }
+
+    public void checkParams(ErrorVisitor errors) throws ToolException {
+        super.checkParams(errors);
+        if (errors.getErrors().size() > 0) {
+            Message msg = new Message("PARAMETER_MISSING", LOG);
+            throw new ToolException(msg, new BadUsageException(getUsage(), errors));
+        }
+    }
+}
\ No newline at end of file

Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/java2js.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/java2js.xml?rev=601970&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/java2js.xml (added)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/java2js.xml Thu Dec  6 19:17:27 2007
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<!-- The xhtml namespace is for usage documentation -->
+<toolspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	  xmlns:xhtml="http://www.w3.org/TR/xhtml1/strict"
+	  xsi:schemaLocation="http://cxf.apache.org/Xutil/ToolSpecification http://cxf.apache.org/schema/xutil/tool-specification.xsd"
+	  xmlns="http://cxf.apache.org/Xutil/ToolSpecification"
+	  xmlns:ts="http://cxf.apache.org/Xutil/ToolSpecification">
+
+    <annotation>
+	Examples :
+	java2ws -javascript org.apache.hello_world_soap_http.Greeter -o bloop.js
+    </annotation>
+    <usage>
+	<optionGroup id="options">
+	    
+	    <option id="databinding" maxOccurs="1">
+		<annotation>
+		    Specify the data binding (aegis or jaxb). Default is jaxb for jaxws 
+		    frontend, and aegis for simple frontend.
+		</annotation>
+		<switch>databinding</switch>
+		<associatedArgument placement="afterSpace">
+		    <annotation>jaxb or aegis</annotation>
+		</associatedArgument>
+	    </option>
+	    
+	    <option id="javascriptUtils" maxOccurs="1">
+		<annotation>
+		    Write the JavaScript common utilities at the beginning of the output.
+		</annotation>
+		<switch>jsutils</switch>
+	    </option>
+
+	    <option id="outputfile" maxOccurs="1">
+		<annotation>
+		    Specify the output wsdl file name
+		</annotation>
+		<switch>o</switch>
+		<associatedArgument placement="afterSpace">
+		    <annotation>output-file</annotation>
+		</associatedArgument>
+	    </option>
+	    
+	    <option id="outputdir" maxOccurs="1">
+		<annotation>
+		    The directory in which the output wsdl and other 
+		    resource files are placed
+		</annotation>
+		<switch>d</switch>
+		<associatedArgument placement="afterSpace">
+		    <annotation>resource-directory</annotation>
+		</associatedArgument>
+	    </option>
+
+	    <option id="beans" maxOccurs="unbounded">
+		<annotation>Specify the pathname of a file defining additional Spring beans to customize databinding
+		configuration.</annotation>
+		<switch>beans</switch>
+		<associatedArgument placement="afterSpace">
+		    <annotation>pathname of the bean definition file.</annotation>
+		</associatedArgument>
+	    </option>
+	    
+	    <option id="classpath" maxOccurs="1">
+		<annotation>
+		    Specify the SEI and types class search path of
+		    directories and zip/jar files
+		</annotation>
+		<switch>cp</switch>
+		<associatedArgument placement="afterSpace">
+		    <annotation>class-path</annotation>
+		</associatedArgument>
+	    </option>
+
+	    <option id="soap12" maxOccurs="1">
+		<annotation>
+		    Specify to generate SOAP 1.2 binding
+		</annotation>
+		<switch>soap12</switch>
+	    </option>
+
+	</optionGroup>
+
+	<optionGroup id="common_options">
+	    <option id="help" maxOccurs="1">
+		<annotation>
+		    Display detailed information for options.
+		</annotation>
+		<switch>h</switch>
+		<switch>?</switch>
+		<switch>help</switch>
+	    </option>
+
+	    <option id="version">
+		<annotation>
+		    Display the version of the tool.
+		</annotation>
+		<switch>v</switch>
+	    </option>
+
+	    <option id="verbose">
+		<annotation>
+		    Verbose mode
+		</annotation>
+		<switch>verbose</switch>
+		<switch>V</switch>
+	    </option>
+
+	    <option id="quiet">
+		<annotation>
+		    Quiet mode
+		</annotation>
+		<switch>quiet</switch>
+		<switch>q</switch>
+	    </option>
+	</optionGroup>
+
+	<argument id="classname" minOccurs="1" maxOccurs="1">
+	    <annotation>
+		SEI class name
+	    </annotation>
+	</argument>
+    </usage>
+</toolspec>