/** * Process the root WADL file and generate code. * * @param rootDesc the URI of the WADL file to process * @throws javax.xml.bind.JAXBException if the WADL file is invalid, a referenced WADL file is * invalid, or if the code generator encounters a problem. * @throws java.io.IOException if the specified WADL file cannot be read. * @throws com.sun.codemodel.JClassAlreadyExistsException if, during code generation, the WADL * processor attempts to create a duplicate class. This indicates a structural problem with * the WADL file, e.g. duplicate peer resource entries. */ public void process(URI rootDesc) throws JAXBException, IOException, JClassAlreadyExistsException { // read in root WADL file JAXBContext jbc = JAXBContext.newInstance("org.jvnet.ws.wadl", this.getClass().getClassLoader()); u = jbc.createUnmarshaller(); s2j = new SchemaCompilerImpl(); errorListener = new SchemaCompilerErrorListener(); if (!autoPackage) s2j.setDefaultPackageName(pkg); s2j.setErrorListener(errorListener); idMap = new HashMap<String, Object>(); ifaceMap = new HashMap<String, ResourceTypeNode>(); Application a = processDescription(rootDesc); ResourceNode r = buildAst(a, rootDesc); // generate code s2jModel = s2j.bind(); if (s2jModel != null) { codeModel = s2jModel.generateCode(null, errorListener); Iterator<JPackage> packages = codeModel.packages(); StringBuilder buf = new StringBuilder(); while (packages.hasNext()) { JPackage genPkg = packages.next(); if (!genPkg.isDefined("ObjectFactory")) continue; if (buf.length() > 0) buf.append(':'); buf.append(genPkg.name()); } generatedPackages = buf.toString(); jPkg = codeModel._package(pkg); generateResourceTypeInterfaces(); generateEndpointClass(r); codeModel.build(outputDir); } }