public JavaDocProvider(Bus bus, String... paths) throws Exception { if (paths != null) { URL[] javaDocUrls = new URL[paths.length]; for (int i = 0; i < paths.length; i++) { javaDocUrls[i] = ResourceUtils.getResourceURL(paths[i], bus); } javaDocLoader = new URLClassLoader(javaDocUrls); } }
public static InputStream getResourceStream(String loc, Bus bus) throws Exception { URL url = getResourceURL(loc, bus); return url == null ? null : url.openStream(); }
public static InputStream getResourceStream(String loc, Bus bus) throws Exception { URL url = getResourceURL(loc, bus); return url == null ? null : url.openStream(); }
protected Templates createTemplates(String loc) { try { return createTemplates(ResourceUtils.getResourceURL(loc, this.getBus())); } catch (Exception ex) { LOG.warning("No template can be created : " + ex.getMessage()); } return null; }
protected Templates createTemplates(String loc) { try { URL urlStream = ResourceUtils.getResourceURL(loc, this.getBus()); if (urlStream == null) { return null; } Reader r = new BufferedReader( new InputStreamReader(urlStream.openStream(), "UTF-8")); Source source = new StreamSource(r); source.setSystemId(urlStream.toExternalForm()); if (factory == null) { factory = (SAXTransformerFactory)TransformerFactory.newInstance(); if (uriResolver != null) { factory.setURIResolver(uriResolver); } } return factory.newTemplates(source); } catch (Exception ex) { LOG.warning("No template can be created : " + ex.getMessage()); } return null; }
List<Source> sources = new ArrayList<Source>(); for (String loc : locations) { URL url = ResourceUtils.getResourceURL(loc, bus); if (url == null) { throw new IllegalArgumentException("Cannot find XML schema location: " + loc); catalogLocation = catalogLocation == null ? SchemaHandler.DEFAULT_CATALOG_LOCATION : catalogLocation; URL catalogURL = ResourceUtils.getResourceURL(catalogLocation, bus); if (catalogURL != null) { try {
private Application readWadl(String wadl, String docPath) { Element wadlElement = readXmlDocument(new StringReader(wadl)); try { if (validateWadl) { SchemaFactory factory = SchemaFactory.newInstance(Constants.URI_2001_SCHEMA_XSD); URL schemaURL = ResourceUtils.getResourceURL("classpath:/schemas/wadl/wadl.xsd", bus); Reader r = new BufferedReader(new InputStreamReader(schemaURL.openStream(), StandardCharsets.UTF_8)); StreamSource source = new StreamSource(r); source.setSystemId(schemaURL.toString()); Schema s = factory.newSchema(new Source[]{source}); DOMSource wadlDoc = new DOMSource(wadlElement); Validator v = s.newValidator(); WadlValidationErrorHandler errorHandler = new WadlValidationErrorHandler(); v.setErrorHandler(errorHandler); v.validate(wadlDoc); if (errorHandler.isValidationFailed()) { throw new ValidationException("WADL document is not valid."); } } } catch (ValidationException ex) { throw ex; } catch (Exception ex) { throw new ValidationException("WADL document can not be validated", ex); } return new Application(wadlElement, docPath); }
schemaURLs = ClasspathScanner.findResources(loc, "xsd"); } else { URL url = ResourceUtils.getResourceURL(loc, bus); if (url != null) { schemaURLs.add(url); catalogLocation = catalogLocation == null ? SchemaHandler.DEFAULT_CATALOG_LOCATION : catalogLocation; URL catalogURL = ResourceUtils.getResourceURL(catalogLocation, bus); if (catalogURL != null) { try {