我的项目目录结构(在Eclipse中):
df['swim'] = np.where(df['EnteroCount']>=110, 'unacceptable', 'acceptable')
我想在类MyProjectContainingCSS/
src/ --> "source directory" on Eclipse's classpath/buildpath
com.me.myapp
style.css
MyProjectInheritingCSS/
src/ --> "source directory" on Eclipse's classpath/buildpath
com.me.myapp
StyleImpl.java
中其他OSGi包MyProjectContainingCSS
中的OSGi包MyProjectContainingCSS
中包含的CSS文件 style.css 中使用,
类似的东西:
StyleImpl.java
如何在另一个OSGi包中的一个OSGi包中使用 CSS 资源文件?
提前谢谢大家。
更新
bnd.bnd文件
public class StyleImpl {
public static void main(String[] args) {
css = this.getClass().getResource("/com/me/myapp/style.css").toExternalForm();
scene.getStylesheets().add(css);
}
}
运行描述符
Bundle-Version: 0.0.0.${tstamp}
-buildpath: \
../cnf/plugins/org.apache.felix.dependencymanager.annotation-3.2.0.jar;version=file,\
org.apache.felix.dependencymanager,\
osgi.core,\
launcher;version=latest,\
libs/commons-io-2.4.jar;version=file
Private-Package: ui.impl
Export-Package: ui
Import-Package: *
答案 0 :(得分:0)
要从您自己的捆绑包中获取文件,您可以执行以下操作:
Bundle bundle = FrameworkUtil.getBundle(this.getClass());
Enumeration<URL> resources = bundle.getResources("/com/me/myapp/style.css");
if (resources != null) {
URL myCSS = resources.nextElement();
}
如果您可以找到其他OSGi包对象,您也可以这样做。我会尝试这样的事情:
Bundle bundle = FrameworkUtil.getBundle(this.getClass());
Bundle[] bArray = bundle.getBundleContext().getBundles();
Bundle cssBundle = null;
for (Bundle b : bArray){
if(b.getSymbolicName().equals("com.me.myapp")) {
cssBundle = b;
break;
}
}
Enumeration<URL> resources = cssBundle.getResources("/com/me/myapp/style.css");
if (resources != null) {
URL myCSS = resources.nextElement();
}