public InputStream getResourceAsStream(final String name) { return ClassLoaderUtils.getResourceAsStream(name, getClass()); }
InputStream getLegacyPropertiesStream() { return ClassLoaderUtils.getResourceAsStream(LEGACY_PROPERTIES_FILE, this.getClass()); }
public InputStream getResourceAsStream(final String name) { return ClassLoaderUtils.getResourceAsStream(name, getClass()); } }
/** * {@link ClassLoaderUtils} throws {@link IllegalArgumentException} in the case of malformed resource URIs, so let's * use the plugins2 class defensively (FISH-352) * @param resource resource to load * @param clazz reference class * @return an InputStream from the resource, or null if the resource could not be found or there was a problem * reading from the resource */ public static InputStream getResourceAsStream(String resource, Class clazz) { try { return ClassLoaderUtils.getResourceAsStream(resource, clazz); } catch (Exception e) { log.debug("Failed to retrieve resource '" + resource + "'", e); return null; } }
static Document readPlatformVersionDocument() throws RuntimeException { InputStream in = ClassLoaderUtils.getResourceAsStream(PLATFORM_VERSION_PATH, PlatformVersionSpecReader.class); try { SAXReader reader = new SAXReader(); return reader.read(in); } catch (DocumentException e) { throw new RuntimeException("Cannot read the platform version definition", e); } finally { IOUtils.closeQuietly(in); } }
private static String getPluginFrameworkVersionInternal() { Properties props = new Properties(); InputStream in = null; try { in = ClassLoaderUtils.getResourceAsStream(BUILD_PROPERTY_PATH, PluginFrameworkUtils.class); if (in != null) { // this should automatically get rid of comment lines. props.load(in); return props.getProperty("version"); } else { // probably ran via IDEA where pom.properties won't exist return "2.7.0"; } } catch (IOException e) { LOG.error("cannot determine the plugin framework version", e); throw new IllegalStateException("cannot determine the plugin framework version", e); } finally { IOUtils.closeQuietly(in); } } }
protected InputStream getSource() { if (resource != null) { return ClassLoaderUtils.getResourceAsStream(resource, this.getClass()); } if (url != null) { try { return url.openConnection().getInputStream(); } catch (IOException e) { throw new PluginParseException(e); } } throw new IllegalStateException("No defined method for getting an input stream."); } }
/** * Reads export file and return a map of package->version. * Returned versions are in OSGi format which can be 0.0.0 if not specified in the file. * * @param exportFilePath the file path, never null. * @return map of package->version, never null. */ static Map<String, String> parseExportFile(String exportFilePath) { Properties props = new Properties(); InputStream in = null; try { in = ClassLoaderUtils.getResourceAsStream(exportFilePath, ExportBuilderUtils.class); if (in == null) { LOG.warn("Unable to find properties for package export: " + exportFilePath); return ImmutableMap.of(); } // this should automatically get rid of comment lines. props.load(in); } catch (IOException e) { LOG.warn("Problem occurred while processing package export: " + exportFilePath, e); return ImmutableMap.of(); } finally { IOUtils.closeQuietly(in); } // convert version strings to osgi format and return the resultant map. // this Maps.transformValues returns a view backed by immutable map in this case so itself is already immutable. return Maps.transformValues(Maps.fromProperties(props), CONVERT_VERSION); }
log.debug("Crawling " + className); InputStream in = ClassLoaderUtils.getResourceAsStream(className, OsgiHeaderUtil.class); if (in == null) { log.error("Cannot find class: [" + className + "]");