No access to Bundle Resource/File (OSGi)

后端 未结 2 1755
独厮守ぢ
独厮守ぢ 2020-12-05 12:22

at the moment i\'m developing an OSGi based WebApp with Jetty and Equinox (see: http://wiki.eclipse.org/Jetty/Tutorial/EclipseRT-Jetty-Starter-Kit). Everything ist fine so f

2条回答
  •  抹茶落季
    2020-12-05 12:29

    Solved!!! Thanks to Danail Nachev (see comment) who brought me to the right way! After some searching after "bundleentry://xyz" and "bundleresource://" i found this mailinglist post: http://www.mail-archive.com/felix-dev@incubator.apache.org/msg02410.html

    So the answer is the following (Usging (Equinox) FileLocator):

    URL configURL = context.getBundleContext().getBundle().getResource("config.csv");
    File configFile = new File(FileLocator.toFileURL(configURL).getPath());
    

    But (also asked in that mailinglist) it would be interesting if there exists other solutionss wich are not only applicable for Equinox?

提交回复
热议问题