/** * Unmarshall a WADL file, process any schemas referenced in the WADL file, add any items with an * ID to a global ID map, and follow any references to additional WADL files. * * @param desc the URI of the description file * @return the unmarshalled WADL application element * @throws javax.xml.bind.JAXBException if the WADL file is invalid or if the code generator * encounters a problem. * @throws java.io.IOException if the specified WADL file cannot be read. */ public Application processDescription(URI desc) throws JAXBException, IOException { // check for files that have already been processed to prevent loops if (processedDocs.contains(desc.toString())) return null; processedDocs.add(desc.toString()); // read in WADL file System.out.println(Wadl2JavaMessages.PROCESSING(desc.toString())); Application a = (Application) u.unmarshal(desc.toURL()); // process embedded schemas Grammars g = a.getGrammars(); if (g != null) { for (Include i : g.getInclude()) { URI incl = desc.resolve(i.getHref()); if (processedDocs.contains(incl.toString())) continue; processedDocs.add(incl.toString()); System.out.println(Wadl2JavaMessages.PROCESSING(incl.toString())); InputSource input = new InputSource(incl.toURL().openStream()); input.setSystemId(incl.toString()); s2j.parseSchema(input); } int embeddedSchemaNo = 0; // used to generate unique system ID for (Object any : g.getAny()) { if (any instanceof Element) { Element element = (Element) any; s2j.parseSchema( desc.toString() + "#schema" + Integer.toString(embeddedSchemaNo), element); embeddedSchemaNo++; } } } for (File customization : customizations) { URI incl = desc.resolve(customization.toURI()); System.out.println(Wadl2JavaMessages.PROCESSING(incl.toString())); InputSource input = new InputSource(incl.toURL().openStream()); input.setSystemId(incl.toString()); s2j.parseSchema(input); } buildIDMap(a, desc); return a; }