/** {@inheritDoc} */ @Override protected URL findResource(String name) { URL resource = bundle.getResource(name); if (resource == null && clsLdr != null) resource = clsLdr.getResource(name); return resource; }
@Override public URL loadResource(String uri) { return context.getBundle().getResource(uri); }
@Override public String getResourceURL(long bundleID, String resource) { Bundle b = bundleContext.getBundle(bundleID); if (b == null) throw new IllegalArgumentException("Not a valid bundle ID: " + bundleID); URL res = b.getResource(resource); if (res == null) return null; else return res.toString(); } }
private InputStream openInputStream() { try { return persistenceBundle.getResource( resource ).openStream(); } catch ( IOException e ) { throw new PersistenceException( "Unable to open an InputStream on the OSGi Bundle resource!", e ); } }
for ( Bundle bundle : bundles ) { try { final URL resource = bundle.getResource( name ); if ( resource != null ) { resourceCache.put( name, resource );
@Override public URL getResource( final String name ) { final String normalizedname = Path.normalizeResourcePath( name ); return getBundle().getResource( normalizedname ); }
URL resource = wrapper.bundle.getResource(path); if( resource == null ) { continue;
/** * Called when this bundle is started so the Framework can perform the * bundle-specific activities necessary to start this bundle. This method * can be used to register services or to allocate any resources that this * bundle needs. * * <p> * This method must complete and return to its caller in a timely manner. * * <p> * This method attempts to register a SAX and DOM parser with the * Framework's service registry. * * @param context The execution context of the bundle being started. * @throws java.lang.Exception If this method throws an exception, this * bundle is marked as stopped and the Framework will remove this * bundle's listeners, unregister all services registered by this * bundle, and release all services used by this bundle. */ public void start(BundleContext context) throws Exception { this.context = context; Bundle parserBundle = context.getBundle(); // check for sax parsers registerSAXParsers(getParserFactoryClassNames(parserBundle.getResource(SAXCLASSFILE))); // check for dom parsers registerDOMParsers(getParserFactoryClassNames(parserBundle.getResource(DOMCLASSFILE))); }
LOG.debug("Trying to locate [{}] via Bundle [{}]", xsdPath, bundle.getClass().getSimpleName()); url = bundle.getResource(xsdPath);
result.add(bundle.getResource(jarEntryName));
result.add(bundle.getResource(jarEntryName));
List<String> componentDescriptions = Arrays.asList(value.split("\\s*,\\s*")); for (String desc : componentDescriptions) { final URL url = bundle.getResource(desc); process(url);
/** * Called when this bundle is started so the Framework can perform the * bundle-specific activities necessary to start this bundle. This method * can be used to register services or to allocate any resources that this * bundle needs. * * <p> * This method must complete and return to its caller in a timely manner. * * <p> * This method attempts to register a SAX and DOM parser with the * Framework's service registry. * * @param context The execution context of the bundle being started. * @throws java.lang.Exception If this method throws an exception, this * bundle is marked as stopped and the Framework will remove this * bundle's listeners, unregister all services registered by this * bundle, and release all services used by this bundle. */ public void start(BundleContext context) throws Exception { this.context = context; Bundle parserBundle = context.getBundle(); // check for sax parsers registerSAXParsers(getParserFactoryClassNames(parserBundle .getResource(SAXCLASSFILE))); // check for dom parsers registerDOMParsers(getParserFactoryClassNames(parserBundle .getResource(DOMCLASSFILE))); }
.getName(); Bundle bundle = Platform.getBundle(contributorPluginId); InputStream input = (InputStream) bundle.getResource( xml).getContent(); ((GenericMapper) mapper).parseMappings(input);
private void readStockThemes(Map<String, ColorTheme> themes) { IConfigurationElement[] config = Platform.getExtensionRegistry() .getConfigurationElementsFor( Activator.EXTENSION_POINT_ID_THEME); try { for (IConfigurationElement e : config) { String xml = e.getAttribute("file"); String contributorPluginId = e.getContributor().getName(); Bundle bundle = Platform.getBundle(contributorPluginId); InputStream input = (InputStream) bundle.getResource(xml) .getContent(); ParsedTheme theme = parseTheme(input, false); amendThemeEntries(theme.getTheme().getEntries()); themes.put(theme.getTheme().getName(), theme.getTheme()); } } catch (Exception e) { e.printStackTrace(); } }
private URL loadFromResources(String resourcePath) { for (Bundle resourceBundle : resourceBundles) { URL resourceUrl = resourceBundle.getResource(resourcePath); if (null != resourceUrl) return resourceUrl; } return null; }
@Override public boolean exists() { return this.bundle.getResource( path ) != null; }
@Override public URL getResource(String name) { if (name.startsWith("/")) { name = name.substring(1); } return this.bundle.getResource(name); }
@Deprecated private String createUri(Bundle cl, String ref) { URL url = cl.getResource(ref); if ( url == null && ref.startsWith( "/" ) ) { url = cl.getResource( ref.substring( 1 ) ); } if ( url == null ) { throw new RuntimeException( "reference " + ref + " not found on classloader " + cl ); } return "uri:" + url.toString().replaceFirst( ref + "$", "" ); } /**
@Override public CharSource getCharSource() { final URL resource = this.bundle.getResource( this.path ); return Resources.asCharSource( resource, StandardCharsets.UTF_8 ); }