本文整理汇总了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;
}