KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > wsm > axis > ant > AxisTypeGeneratorTask


1 /*
2  * AxisTypeGeneratorTask.java
3  *
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *
20  * Original author: Jonathan Colwell
21  */

22 package org.apache.beehive.wsm.axis.ant;
23
24 import java.io.File JavaDoc;
25
26 import org.apache.tools.ant.AntClassLoader;
27 import org.apache.tools.ant.BuildException;
28 import org.apache.tools.ant.Task;
29 import org.apache.tools.ant.types.FileSet;
30 import org.apache.tools.ant.types.Path;
31 import org.apache.tools.ant.types.Reference;
32
33 /*******************************************************************************
34  *
35  *
36  * @author Jonathan Colwell
37  */

38 public class AxisTypeGeneratorTask extends Task {
39
40     File JavaDoc mWSDL, mOutDir;
41     boolean generateJWS=false;
42      
43     /**
44      * @return Returns the generateJWS.
45      */

46     public boolean isGenerateJWS() {
47         return generateJWS;
48     }
49     /**
50      * @param generateJWS The generateJWS to set.
51      */

52     public void setGenerateJWS(boolean generateJWS) {
53         this.generateJWS = generateJWS;
54     }
55     public void setWSDLDir(File JavaDoc wsdl) {
56         mWSDL = wsdl;
57     }
58
59     public void setOutputDir(File JavaDoc outputDir) {
60         mOutDir = outputDir;
61     }
62
63     public void execute() throws BuildException {
64         try {
65             AntClassLoader acl = (AntClassLoader)getClass().getClassLoader();
66             //System.out.println(acl.getClasspath());
67
if (mOutDir != null && mWSDL != null && mWSDL.isDirectory()) {
68                 AxisTypeGenerator atg = new AxisTypeGenerator();
69                 for (File JavaDoc f : mWSDL.listFiles(new WSDLFilter())) {
70                     atg.generateTypes(f.getPath(),
71                                       mOutDir.getPath());
72                 }
73             }
74             else {
75                 throw new BuildException("Both a valid wsdl directory and an output directory must be provided.");
76             }
77         }
78         catch (Throwable JavaDoc e) {
79             e.printStackTrace();
80             if (e instanceof BuildException) {
81                 throw (BuildException)e;
82             }
83             else {
84                 throw new BuildException(e.toString(), e);
85             }
86         }
87     }
88 }
89
Popular Tags