论坛首页 Java企业应用论坛

OSGI如何读取插件中的资源文件

浏览 9646 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2011-11-16  
lhgyy00 写道
troyconder 写道
LZ是个妞

瞎说。。。

那是人妖?
0 请登录后投票
   发表时间:2011-11-16  
devworks 写道
Thread.currentThread().getContextClassLoader().getResource()

这个应该可以,在解决weblogic的jar包和自己的bundle冲突的时候,通过这种方式来设置classLoader来的,还蛮好用
0 请登录后投票
   发表时间:2011-11-16  
devworks 写道
lhgyy00 写道
troyconder 写道
LZ是个妞

瞎说。。。

那是人妖?

好吧,女程序员
0 请登录后投票
   发表时间:2011-11-16  
用上下文怎么cl加载不到的吧?你说的weblogic的问题场景相同?
0 请登录后投票
   发表时间:2011-11-16   最后修改:2011-11-16
/**
 *@param symbolicName the symbolic name of the bundle
 *@param path the file path
 */
public static InputStream getResourceByBundle(String path, String symbolicName) throws IOException {
    InputStream in=null;
    Bundle bundle=Platform.getBundle(symbolicName);
    if(bundle==null){
        return null;
    }
    IPath path=new Path(path);
    URL resource=FileLocator.find(bundle, path, null);
    if(resource!=null){
        in = resource.openStream();
    }
    return in;
}
0 请登录后投票
   发表时间:2011-11-17  
坛子里好像女程序媛多起来了,不错啊。
0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics