001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.util.ant;
016    
017    import java.io.File;
018    
019    import org.apache.axis.tools.ant.wsdl.NamespaceMapping;
020    import org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class Wsdl2JavaTask {
026    
027            public static void generateJava(String url, String output) {
028                    generateJava(url, output, null);
029            }
030    
031            public static void generateJava(String url, String output, String mapping) {
032                    Wsdl2javaAntTask wsdl2Java = new Wsdl2javaAntTask();
033    
034                    wsdl2Java.setProject(AntUtil.getProject());
035                    wsdl2Java.setURL(url);
036                    wsdl2Java.setOutput(new File(output));
037                    wsdl2Java.setServerSide(true);
038                    wsdl2Java.setTestCase(false);
039                    wsdl2Java.setVerbose(false);
040    
041                    if (mapping != null) {
042                            NamespaceMapping namespaceMapping = new NamespaceMapping();
043    
044                            namespaceMapping.setFile(new File(mapping));
045    
046                            wsdl2Java.addMapping(namespaceMapping);
047                    }
048    
049                    wsdl2Java.execute();
050            }
051    
052    }