1 28 29 package com.caucho.ant.jaxws; 30 31 import java.io.*; 32 import java.util.*; 33 34 import com.caucho.soap.reflect.WebServiceIntrospector; 35 import com.caucho.server.util.CauchoSystem; 36 37 41 public class WSDLGenerator extends org.apache.tools.ant.Task { 42 private String _sei; 43 private String _destDir; 44 private String _classpath; 45 private String _resourceDestDir; 46 private String _sourceDestDir; 47 private boolean _keep; 48 private boolean _verbose; 49 private boolean _genWsdl; 50 private boolean _extension; 51 private boolean _debug; private boolean _fork; private String _protocol; 54 private String _serviceName; 55 private String _portName; 56 57 private static void error(String msg) 58 { 59 System.err.print(msg); 60 System.exit(1); 61 } 62 63 private static void error(String msg, Exception e) 64 { 65 System.err.print(msg + ":" ); 66 e.printStackTrace(); 67 System.exit(1); 68 } 69 70 public void setSei(String sei) 71 { 72 _sei = sei; 73 } 74 75 public void setDestdir(String destDir) 76 { 77 _destDir = destDir; 78 } 79 80 public void setClasspath(String classpath) 81 { 82 _classpath = classpath; 83 } 84 85 public void setCp(String classpath) 86 { 87 setClasspath(classpath); 88 } 89 90 public void addClasspath(ClassPath classPath) 91 { 92 _classpath = classPath.getPath(); 93 } 94 95 public void setResourcedestdir(String resourceDestDir) 96 { 97 _resourceDestDir = resourceDestDir; 98 } 99 100 public void setSourcedestdir(String sourceDestDir) 101 { 102 _sourceDestDir = sourceDestDir; 103 } 104 105 public void setKeep(boolean keep) 106 { 107 _keep = keep; 108 } 109 110 public void setVerbose(boolean verbose) 111 { 112 _verbose = verbose; 113 } 114 115 public void setGenwsdl(boolean genWsdl) 116 { 117 _genWsdl = genWsdl; 118 } 119 120 public void setDebug(boolean debug) 121 { 122 _debug = debug; 123 } 124 125 public void setFork(boolean fork) 126 { 127 _fork = fork; 128 } 129 130 public void setProtocol(String protocol) 131 { 132 _protocol = protocol; 133 } 134 135 public void setServicename(String serviceName) 136 { 137 _serviceName = serviceName; 138 } 139 140 public void setPortname(String portName) 141 { 142 _portName = portName; 143 } 144 145 public void setExtension(boolean extension) 146 { 147 _extension = extension; 148 } 149 150 153 public void execute() 154 throws org.apache.tools.ant.BuildException 155 { 156 Class seiClass = null; 157 158 try { 159 seiClass = CauchoSystem.loadClass(_sei); 160 } 161 catch (ClassNotFoundException e) { 162 throw new org.apache.tools.ant.BuildException(e); 163 } 164 165 WebServiceIntrospector introspector = new WebServiceIntrospector(); 166 167 try { 168 if (_resourceDestDir != null && ! "".equals(_resourceDestDir)) 169 introspector.introspect(seiClass, "").dumpWSDL(_resourceDestDir); 170 else 171 introspector.introspect(seiClass, "").dumpWSDL(System.out); 172 } 173 catch (Exception e) { 174 throw new org.apache.tools.ant.BuildException(e); 175 } 176 } 177 178 public static void main(String [] args) 179 { 180 if (args.length < 1) 181 error("usage: wsdl-gen <SEI>"); 182 183 WSDLGenerator generator = new WSDLGenerator(); 184 185 generator.setSei(args[0]); 186 187 try { 188 generator.execute(); 189 } 190 catch (org.apache.tools.ant.BuildException e) { 191 error("Unable to load SEI (" + args[0] + ")", e); 192 } 193 } 194 195 public static class ClassPath { 196 private List<PathElement> _pathElements = new ArrayList<PathElement>(); 197 private String _path; 198 199 public String getPath() 200 { 201 return _path; 202 } 203 204 public void setPath(String path) 205 { 206 _path = path; 207 } 208 209 public List<PathElement> getPathElements() 210 { 211 return _pathElements; 212 } 213 214 public void addPathelement(PathElement pathElement) 215 { 216 _pathElements.add(pathElement); 217 } 218 219 public static class PathElement { 220 private String _path; 221 222 public String getPath() 223 { 224 return _path; 225 } 226 227 public void setPath(String path) 228 { 229 _path = path; 230 } 231 } 232 } 233 } 234 235 236 | Popular Tags |