本文整理匯總了Java中org.osgi.framework.Bundle.getResource方法的典型用法代碼示例。如果您正苦於以下問題:Java Bundle.getResource方法的具體用法?Java Bundle.getResource怎麽用?Java Bundle.getResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.osgi.framework.Bundle
的用法示例。
在下文中一共展示了Bundle.getResource方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testCallGetResourceOnADifferentBundle
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
public void testCallGetResourceOnADifferentBundle() throws Exception {
// find bundles
Bundle[] bundles = bundleContext.getBundles();
for (int i = 1; i < bundles.length; i++) {
Bundle bundle = bundles[i];
logger.debug("calling #getResource on bundle " + OsgiStringUtils.nullSafeNameAndSymName(bundle));
URL url = bundle.getResource(LOCATION);
if (!OsgiBundleUtils.isFragment(bundle))
assertNotNull("bundle " + OsgiStringUtils.nullSafeNameAndSymName(bundle) + " contains no META-INF/",
url);
}
}
示例2: findResource
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
@Override
public URL findResource(String name) {
//Netigso.start();
Bundle b = bundle;
if (b == null) {
LOG.log(Level.WARNING, "Trying to load resource before initialization finished {0}", name);
return null;
}
return b.getResource(name);
}
示例3: layersFor
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
private static URL[] layersFor(List<Bundle> bundles) {
List<URL> layers = new ArrayList<URL>(2);
for (Bundle b : bundles) {
if (b.getSymbolicName().equals("org.netbeans.modules.autoupdate.ui")) { // NOI18N
// Won't work anyway, so don't even try.
continue;
}
String explicit = (String) b.getHeaders().get("OpenIDE-Module-Layer");
if (explicit != null) {
String base, ext;
int idx = explicit.lastIndexOf('.'); // NOI18N
if (idx == -1) {
base = explicit;
ext = ""; // NOI18N
} else {
base = explicit.substring(0, idx);
ext = explicit.substring(idx);
}
for (String suffix : NbCollections.iterable(NbBundle.getLocalizingSuffixes())) {
URL layer = b.getResource(base + suffix + ext);
if (layer != null) {
layers.add(layer);
} else if (suffix.isEmpty()) {
LOG.log(Level.WARNING, "no such layer {0} in {1} of state {2}", new Object[] {explicit, b.getSymbolicName(), b.getState()});
}
}
}
URL generated = b.getResource("META-INF/generated-layer.xml");
if (generated != null) {
layers.add(generated);
}
}
return layers.toArray(new URL[layers.size()]);
}
示例4: findResource
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
protected @Override URL findResource(String name) {
for (Bundle b : bundles()) {
URL resource = b.getResource(name);
if (resource != null) {
return resource;
}
}
return super.findResource(name);
}
示例5: testNamespaceFilesOnTheClassPath
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
public void testNamespaceFilesOnTheClassPath() throws Exception {
Bundle bundle = OsgiBundleUtils.findBundleBySymbolicName(bundleContext, BND_SYM_NAME);
assertNotNull("cannot find handler bundle", bundle);
URL handlers = bundle.getResource("META-INF/spring.handlers");
URL schemas = bundle.getResource("META-INF/spring.schemas");
assertNotNull("cannot find a handler inside the custom bundle", handlers);
assertNotNull("cannot find a schema inside the custom bundle", schemas);
}
示例6: testNamespaceFilesOnTheClassPath
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
public void testNamespaceFilesOnTheClassPath() throws Exception {
// simple code to trigger an import for this package
assertNotNull(NamespaceHandlerResolver.class);
Bundle bundle = bundleContext.getBundle();
URL handlers = bundle.getResource("META-INF/spring.handlers");
URL schemas = bundle.getResource("META-INF/spring.schemas");
assertNotNull(handlers);
assertNotNull(schemas);
}
示例7: pathExists
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
/**
* Check if a path exists
*
* @param bundle The Bundle to fetch resource
* @param path The path to check
* @return true or false
*/
private static boolean pathExists(Bundle bundle, String path){
boolean response = false;
if (bundle != null && path != null){
URL url = bundle.getResource(path);
if ( url != null ){
response = true;
}
}
return response;
}
示例8: getInputStream
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
/**
* Get input stream by view
*
* @param bundle The bundle used to obtain resource
* @param path The path to get resource
* @return inputStream
*/
public static InputStream getInputStream(Bundle bundle, String path){
InputStream inputStream = null;
if (bundle != null && path != null){
URL url = bundle.getResource(path);
if ( url != null ){
try {
inputStream = url.openStream();
}catch (IOException ioException){
LOG.error(LOG_PRE+ " Error getting InputStream For URL: {}: ",url.getPath(), ioException);
}
}
}
return inputStream;
}