cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r601017 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/tools/common/ rt/javascript/src/main/java/org/apache/cxf/javascript/ rt/javascript/src/main/java/org/apache/cxf/javascript/types/ tools/javato/ws/ tools/javato/ws/src/main/...
Date Tue, 04 Dec 2007 17:49:42 GMT
Author: bimargulies
Date: Tue Dec  4 09:49:40 2007
New Revision: 601017

URL: http://svn.apache.org/viewvc?rev=601017&view=rev
Log:
Connect up JavaScript client generation to java2ws.

Added:
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2js/
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/BasicNameManager.java
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
    incubator/cxf/trunk/tools/javato/ws/pom.xml
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java?rev=601017&r1=601016&r2=601017&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java Tue
Dec  4 09:49:40 2007
@@ -62,6 +62,8 @@
     public static final String CFG_XJC_ARGS = "xjc";
     public static final String CFG_CATALOG = "catalog";
     public static final String CFG_DEFAULT_VALUES = "defaultValues";
+    public static final String CFG_JAVASCRIPT_OUTPUT = "javascriptOutput";
+    public static final String CFG_JAVASCRIPT_UTILS =  "javascriptUtils";
 
 
     public static final String CFG_VALIDATE_WSDL = "validate";

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/BasicNameManager.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/BasicNameManager.java?rev=601017&r1=601016&r2=601017&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/BasicNameManager.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/BasicNameManager.java
Tue Dec  4 09:49:40 2007
@@ -47,10 +47,11 @@
     
     public BasicNameManager(ServiceInfo service, Endpoint endpoint) {
         nsPrefixMap = new HashMap<String, String>();
-        JavascriptOptionsFeature options = getOptions(endpoint);
-        
-        if (options.getNamespacePrefixMap() != null) {
-            nsPrefixMap.putAll(options.getNamespacePrefixMap());
+        if (endpoint != null) {
+            JavascriptOptionsFeature options = getOptions(endpoint);
+            if (options.getNamespacePrefixMap() != null) {
+                nsPrefixMap.putAll(options.getNamespacePrefixMap());
+            }
         }
         
         Set<String> poorPrefixURIs = new HashSet<String>();

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java?rev=601017&r1=601016&r2=601017&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptQueryHandler.java
Tue Dec  4 09:49:40 2007
@@ -83,8 +83,8 @@
         return false;
     }
     
-    private void writeUtilsToResponseStream(OutputStream outputStream) {
-        InputStream utils = getClass().getResourceAsStream(JS_UTILS_PATH);
+    public static void writeUtilsToResponseStream(Class<?> referenceClass, OutputStream
outputStream) {
+        InputStream utils = referenceClass.getResourceAsStream(JS_UTILS_PATH);
         if (utils == null) {
             throw new RuntimeException("Unable to get stream for " + JS_UTILS_PATH);
         }
@@ -121,7 +121,7 @@
         Map<String, String> map = UrlUtilities.parseQueryString(query);
         OutputStreamWriter writer = new OutputStreamWriter(os, UTF8);
         if (map.containsKey(UTILS_QUERY_KEY)) {
-            writeUtilsToResponseStream(os);
+            writeUtilsToResponseStream(JavascriptQueryHandler.class, os);
         } else if (map.containsKey(CODE_QUERY_KEY)) {
             ServiceInfo serviceInfo = endpoint.getService();
             Collection<SchemaInfo> schemata = serviceInfo.getSchemas();

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java?rev=601017&r1=601016&r2=601017&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
Tue Dec  4 09:49:40 2007
@@ -69,7 +69,10 @@
     public String generateCodeForSchema(SchemaInfo schema) {
         StringBuffer code = new StringBuffer();
         code.append("//\n");
-        code.append("// Definitions for schema: " + schema.toString() + "\n");
+        code.append("// Definitions for schema: " + schema.getNamespaceURI());
+        if (schema.getSystemId() != null) {
+            code.append("//  " + schema.getSystemId());
+        }
         code.append("//\n");
 
         XmlSchemaObjectTable schemaTypes = schema.getSchema().getSchemaTypes();

Modified: incubator/cxf/trunk/tools/javato/ws/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/pom.xml?rev=601017&r1=601016&r2=601017&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/pom.xml (original)
+++ incubator/cxf/trunk/tools/javato/ws/pom.xml Tue Dec  4 09:49:40 2007
@@ -39,7 +39,6 @@
             <version>${project.version}</version>
         </dependency>
 
-
         <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-api</artifactId>
@@ -52,16 +51,12 @@
             <version>${project.version}</version>
         </dependency>
 
-
-
         <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-tools-wsdlto-core</artifactId>
             <version>${project.version}</version>
         </dependency>
 
-
-
         <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-tools-wsdlto-databinding-jaxb</artifactId>
@@ -77,6 +72,12 @@
         <dependency>
 	     <groupId>org.apache.cxf</groupId>
 	     <artifactId>cxf-rt-core</artifactId>
+	     <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+	     <groupId>org.apache.cxf</groupId>
+	     <artifactId>cxf-rt-javascript</artifactId>
 	     <version>${project.version}</version>
         </dependency>
 

Added: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java?rev=601017&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java
Tue Dec  4 09:49:40 2007
@@ -0,0 +1,308 @@
+/**
+ * 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.processor;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.ws.BindingType;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.BusApplicationContext;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.javascript.BasicNameManager;
+import org.apache.cxf.javascript.JavascriptQueryHandler;
+import org.apache.cxf.javascript.NamespacePrefixAccumulator;
+import org.apache.cxf.javascript.service.ServiceJavascriptBuilder;
+import org.apache.cxf.javascript.types.SchemaJavascriptBuilder;
+import org.apache.cxf.service.ServiceBuilder;
+import org.apache.cxf.service.model.SchemaInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+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.java2wsdl.processor.internal.ServiceBuilderFactory;
+import org.apache.cxf.tools.util.AnnotationUtil;
+import org.apache.cxf.wsdl.WSDLConstants;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.FileSystemResource;
+
+public class JavaToJSProcessor implements Processor {
+    private static final Logger LOG = LogUtils.getL7dLogger(JavaToJSProcessor.class);
+    private static final String JAVA_CLASS_PATH = "java.class.path";
+    private static final Charset UTF8 = Charset.forName("utf-8");
+    private ToolContext context;
+    private ApplicationContext applicationContext;
+
+    /**
+     * This is factored out to permit use in a unit test.
+     * 
+     * @param bus
+     * @return
+     */
+    public static ApplicationContext getApplicationContext(Bus bus, List<String> additionalFilePathnames)
{
+        BusApplicationContext busApplicationContext = bus.getExtension(BusApplicationContext.class);
+        GenericApplicationContext appContext = new GenericApplicationContext(busApplicationContext);
+        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
+        reader.loadBeanDefinitions(new ClassPathResource("META-INF/cxf/java2wsbeans.xml"));
+        for (String pathname : additionalFilePathnames) {
+            try {
+                reader.loadBeanDefinitions(new FileSystemResource(pathname));
+            } catch (BeanDefinitionStoreException bdse) {
+                throw new ToolException("Unable to open bean definition file " + pathname,
bdse.getCause());
+            }
+        }
+
+        return appContext;
+    }
+
+    public void process() throws ToolException {
+        String oldClassPath = System.getProperty(JAVA_CLASS_PATH);
+        LOG.log(Level.INFO, "OLD_CP", oldClassPath);
+        if (context.get(ToolConstants.CFG_CLASSPATH) != null) {
+            String newCp = (String)context.get(ToolConstants.CFG_CLASSPATH);
+            System.setProperty(JAVA_CLASS_PATH, newCp + File.pathSeparator + oldClassPath);
+            LOG.log(Level.INFO, "NEW_CP", newCp);
+        }
+
+        // check for command line specification of data binding.
+
+        ServiceBuilder builder = getServiceBuilder();
+        ServiceInfo serviceInfo = builder.createService();
+
+        File jsFile = getOutputFile(builder.getOutputFile(), serviceInfo.getName().getLocalPart()
+ ".js");
+
+        BasicNameManager nameManager = new BasicNameManager(serviceInfo, null);
+        NamespacePrefixAccumulator prefixManager = new NamespacePrefixAccumulator(serviceInfo
+            .getXmlSchemaCollection());
+        Collection<SchemaInfo> schemata = serviceInfo.getSchemas();
+        try {
+            FileOutputStream fileOutputStream = new FileOutputStream(jsFile);
+            if (null != context.get(ToolConstants.CFG_JAVASCRIPT_UTILS)) {
+                JavascriptQueryHandler.writeUtilsToResponseStream(JavaToJSProcessor.class,
fileOutputStream);
+            }
+            
+            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream,
UTF8);
+            BufferedWriter writer = new BufferedWriter(outputStreamWriter);
+                
+            for (SchemaInfo schema : schemata) {
+                SchemaJavascriptBuilder jsBuilder = new SchemaJavascriptBuilder(serviceInfo
+                    .getXmlSchemaCollection(), prefixManager, nameManager, schema);
+                String allThatJavascript = jsBuilder.generateCodeForSchema(schema);
+                writer.append(allThatJavascript);
+            }
+
+            ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo,
prefixManager,
+                                                                                   nameManager);
+            serviceBuilder.walk();
+            String serviceJavascript = serviceBuilder.getCode();
+            writer.append(serviceJavascript);
+            writer.close();
+        } catch (FileNotFoundException e) {
+            throw new ToolException(e);
+        } catch (IOException e) {
+            throw new ToolException(e);
+        }
+
+        System.setProperty(JAVA_CLASS_PATH, oldClassPath);
+        LOG.log(Level.INFO, "RESUME_CP", oldClassPath);
+    }
+
+    @SuppressWarnings("unchecked")
+    public ServiceBuilder getServiceBuilder() throws ToolException {
+        Object beanFilesParameter = context.get(ToolConstants.CFG_BEAN_CONFIG);
+        List<String> beanDefinitions = new ArrayList<String>();
+        if (beanFilesParameter != null) {
+            if (beanFilesParameter instanceof String) {
+                beanDefinitions.add((String)beanFilesParameter);
+            } else if (beanFilesParameter instanceof List) {
+                // is there a better way to avoid the warning?
+                beanDefinitions.addAll((List<String>)beanFilesParameter);
+            }
+        }
+        applicationContext = getApplicationContext(getBus(), beanDefinitions);
+        ServiceBuilderFactory builderFactory = ServiceBuilderFactory.getInstance();
+        Class<?> clz = getServiceClass();
+        context.put(Class.class, clz);
+        if (clz.isInterface()) {
+            context.put(ToolConstants.GEN_FROM_SEI, Boolean.TRUE);
+            context.put(ToolConstants.SEI_CLASS, clz.getName());
+        } else {
+            context.put(ToolConstants.IMPL_CLASS, clz.getName());
+            if (clz.getInterfaces().length == 1) {
+                context.put(ToolConstants.SEI_CLASS, clz.getInterfaces()[0].getName());
+            }
+            // TODO: if it is simple frontend, and the impl class implements
+            // multiple interfaces
+            context.put(ToolConstants.GEN_FROM_SEI, Boolean.FALSE);
+        }
+        builderFactory.setServiceClass(clz);
+        builderFactory.setDatabindingName(getDataBindingName());
+        // The service class determines the frontend, so no need to pass it in
+        // twice.
+        ServiceBuilder builder = builderFactory.newBuilder(applicationContext);
+
+        builder.validate();
+
+        builder.setTransportId(getTransportId());
+        builder.setBus(getBus());
+        builder.setBindingId(getBindingId());
+
+        return builder;
+    }
+
+    protected String getTransportId() {
+        if (isSOAP12()) {
+            return WSDLConstants.NS_SOAP12;
+        }
+        return WSDLConstants.NS_SOAP11;
+    }
+
+    protected String getBindingId() {
+        if (isSOAP12()) {
+            return WSDLConstants.NS_SOAP12;
+        } else {
+            return WSDLConstants.NS_SOAP11;
+        }
+    }
+
+    protected boolean isSOAP12() {
+        if (!this.context.optionSet(ToolConstants.CFG_SOAP12)) {
+            BindingType bType = getServiceClass().getAnnotation(BindingType.class);
+            if (bType != null) {
+                return SOAPBinding.SOAP12HTTP_BINDING.equals(bType.value());
+            }
+            return false;
+        }
+        return true;
+    }
+
+    protected File getOutputDir(File wsdlLocation) {
+        String dir = (String)context.get(ToolConstants.CFG_OUTPUTDIR);
+        if (dir == null) {
+            if (wsdlLocation == null) {
+                dir = "./";
+            } else {
+                dir = wsdlLocation.getParent();
+            }
+        }
+        return new File(dir);
+    }
+
+    protected File getOutputFile(File nameFromClz, String defaultOutputFile) {
+        String output = (String)context.get(ToolConstants.CFG_OUTPUTFILE);
+        String dir = (String)context.get(ToolConstants.CFG_OUTPUTDIR);
+        if (dir == null) {
+            dir = "./";
+        }
+
+        File result;
+        if (output != null) {
+            result = new File(output);
+            if (!result.isAbsolute()) {
+                result = new File(new File(dir), output);
+            }
+        } else {
+            result = new File(new File(dir), defaultOutputFile);
+        }
+        if (nameFromClz != null) {
+            result = nameFromClz;
+        }
+
+        // rename the exising wsdl file
+        if (result.exists() && !result.renameTo(new File(result.getParent(), result.getName())))
{
+            throw new ToolException(new Message("OUTFILE_EXISTS", LOG));
+        }
+        return result;
+    }
+
+    public Class<?> getServiceClass() {
+        return AnnotationUtil.loadClass((String)context.get(ToolConstants.CFG_CLASSNAME),
Thread
+            .currentThread().getContextClassLoader());
+    }
+
+    public WSDLConstants.WSDLVersion getWSDLVersion() {
+        String version = (String)context.get(ToolConstants.CFG_WSDL_VERSION);
+        WSDLConstants.WSDLVersion wsVersion = WSDLConstants.getVersion(version);
+        if (wsVersion == WSDLConstants.WSDLVersion.UNKNOWN) {
+            wsVersion = WSDLConstants.WSDLVersion.WSDL11;
+        }
+        return wsVersion;
+    }
+
+    public String getServiceName() {
+        return (String)this.context.get(ToolConstants.CFG_SERVICENAME);
+    }
+
+    File getSourceDir() {
+        String dir = (String)this.context.get(ToolConstants.CFG_SOURCEDIR);
+        if (StringUtils.isEmpty(dir)) {
+            return null;
+        }
+        return new File(dir);
+    }
+
+    File getClassesDir() {
+        String dir = (String)this.context.get(ToolConstants.CFG_CLASSDIR);
+        if (StringUtils.isEmpty(dir)) {
+            return null;
+        }
+        return new File(dir);
+    }
+
+    public Bus getBus() {
+        return BusFactory.getDefaultBus();
+    }
+
+    public void setEnvironment(ToolContext env) {
+        this.context = env;
+    }
+
+    public ToolContext getEnvironment() {
+        return this.context;
+    }
+
+    public String getDataBindingName() {
+        String databindingName = (String)context.get(ToolConstants.CFG_DATABINDING);
+        if (databindingName == null) {
+            databindingName = ToolConstants.DEFAULT_DATA_BINDING_NAME;
+        }
+        return databindingName;
+    }
+}

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java?rev=601017&r1=601016&r2=601017&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/JavaToWSContainer.java
Tue Dec  4 09:49:40 2007
@@ -32,6 +32,7 @@
 import org.apache.cxf.tools.common.toolspec.parser.BadUsageException;
 import org.apache.cxf.tools.common.toolspec.parser.CommandDocument;
 import org.apache.cxf.tools.common.toolspec.parser.ErrorVisitor;
+import org.apache.cxf.tools.java2js.processor.JavaToJSProcessor;
 import org.apache.cxf.tools.java2wsdl.processor.JavaToWSDLProcessor;
 import org.apache.cxf.tools.java2wsdl.processor.internal.jaxws.JAXWSFrontEndProcessor;
 import org.apache.cxf.tools.java2wsdl.processor.internal.simple.SimpleFrontEndProcessor;
@@ -46,7 +47,6 @@
     }
 
     public void execute(boolean exitOnFinish) throws ToolException {
-        Processor processor = null;
         ErrorVisitor errors = new ErrorVisitor();
         try {
             super.execute(exitOnFinish);
@@ -73,22 +73,11 @@
                     //use aegis databinding for simple front end by default
                     env.put(ToolConstants.CFG_DATABINDING, ToolConstants.AEGIS_DATABINDING);
                 }
-                env.put(ToolConstants.CFG_FRONTEND, ft); 
-                processor = new JavaToWSDLProcessor();
-                processor.setEnvironment(env);
-                processor.process();
-                
-                
-                if (ft.equals(ToolConstants.JAXWS_FRONTEND)) {
-                    if (env.optionSet(ToolConstants.CFG_SERVER) || env.optionSet(ToolConstants.CFG_CLIENT))
{
-                        processor = new JAXWSFrontEndProcessor();
-                        processor.setEnvironment(env);
-                        processor.process();
-                    }
-                } else {               
-                    processor = new SimpleFrontEndProcessor();
-                    processor.setEnvironment(env);
-                    processor.process();
+                env.put(ToolConstants.CFG_FRONTEND, ft);
+                if (null != env.get(ToolConstants.CFG_JAVASCRIPT_OUTPUT)) {
+                    processJavascript(env);
+                } else {
+                    processWSDL(env, ft);
                 }
             }
         } catch (ToolException ex) {
@@ -109,6 +98,31 @@
             throw new ToolException(ex.getMessage(), ex.getCause());
         } finally {
             tearDown();
+        }
+    }
+
+    private void processJavascript(ToolContext env) {
+        Processor processor = new JavaToJSProcessor();
+        processor.setEnvironment(env);
+        processor.process();
+    }
+
+    private void processWSDL(ToolContext env, String ft) {
+        Processor processor = new JavaToWSDLProcessor();
+        processor.setEnvironment(env);
+        processor.process();
+        
+        
+        if (ft.equals(ToolConstants.JAXWS_FRONTEND)) {
+            if (env.optionSet(ToolConstants.CFG_SERVER) || env.optionSet(ToolConstants.CFG_CLIENT))
{
+                processor = new JAXWSFrontEndProcessor();
+                processor.setEnvironment(env);
+                processor.process();
+            }
+        } else {               
+            processor = new SimpleFrontEndProcessor();
+            processor.setEnvironment(env);
+            processor.process();
         }
     }
 

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml?rev=601017&r1=601016&r2=601017&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2ws/java2ws.xml
Tue Dec  4 09:49:40 2007
@@ -32,6 +32,7 @@
    java2ws -o hello.wsdl -wsdl org.apache.hello_world_soap_http.Greeter 
    java2ws -client -server org.apache.hello_world_soap_http.Greeter
    java2ws -wrapperbean org.apache.hello_world_soap_http.Greeter
+   java2ws -javascript org.apache.hello_world_soap_http.Greeter -o bloop.js
 	</annotation>
 	<usage>
 		<optionGroup id="options">
@@ -54,6 +55,20 @@
 				<associatedArgument placement="afterSpace">
 					<annotation>jaxws or simple</annotation>
 				</associatedArgument>
+			</option>
+			
+			<option id="javascriptOutput" maxOccurs="1">
+				<annotation>
+					Request output of a JavaScript client.
+				</annotation>
+				<switch>js</switch>
+			</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="wsdl" maxOccurs="1">



Mime
View raw message