1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.util.ant;
16  
17  import java.io.File;
18  
19  import org.apache.axis.tools.ant.wsdl.NamespaceMapping;
20  import org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask;
21  
22  /**
23   * <a href="Wsdl2JavaTask.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Brian Wing Shun Chan
26   */
27  public class Wsdl2JavaTask {
28  
29      public static void generateJava(String url, String output) {
30          generateJava(url, output, null);
31      }
32  
33      public static void generateJava(String url, String output, String mapping) {
34          Wsdl2javaAntTask wsdl2Java = new Wsdl2javaAntTask();
35  
36          wsdl2Java.setProject(AntUtil.getProject());
37          wsdl2Java.setURL(url);
38          wsdl2Java.setOutput(new File(output));
39          wsdl2Java.setServerSide(true);
40          wsdl2Java.setTestCase(false);
41          wsdl2Java.setVerbose(false);
42  
43          if (mapping != null) {
44              NamespaceMapping namespaceMapping = new NamespaceMapping();
45  
46              namespaceMapping.setFile(new File(mapping));
47  
48              wsdl2Java.addMapping(namespaceMapping);
49          }
50  
51          wsdl2Java.execute();
52      }
53  
54  }