My html hyperlinks do not work in my OSGI bundle

与世无争的帅哥 提交于 2019-12-13 07:46:13

问题


I am using Java and HelpGUI in my OSGI bundle and the links that use do not work. When I use HelpGUI in a non-OSGI Java project, they work just fine on the same html files. Is there some security setting or something special with paths that I need to consider? Let me know, I am horribly stuck.


回答1:


You should have a look at the source code of HelpGui, I can see why it doesn't quite work in OSGi (it relies on a specific URL format resources in jar files usually have).

If you look at the net.sourceforge.helpgui.gui.HelpView page, around line 222:

else //It's perhaps a page on the help toppic
{
//Serach the page from  
int ind = url.lastIndexOf('!');
url = url.substring(ind+1,url.length());
url = url.replaceFirst(MainFrame.helpPath+"/","");
updatePage(getLinkedPage(pageRoot.children(), url), true);
}

That is not going to work in OSGi, as the URL format of entries is really different. For example in Equinox a bundle URL looks like:

bundleresource://2.fwk1657006569:1general/features.html

(Other implementations might be different, point is, you can't rely on it)

In 'normal java' the URL looks like:

jar:file:/home/demo-helpgui/nonosgi/lib/helpgui-1.1-demo.jar!/docs/help/general/features.html   

It is fixable, it shouldn't be too hard, but you'll have to either contact the HelpGui author or get your hands dirty yourself.

regards, Frank



来源:https://stackoverflow.com/questions/11761383/my-html-hyperlinks-do-not-work-in-my-osgi-bundle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!