我的項目目錄結構(在Eclipse):我如何去使用一個OSGi包一個** ** CSS資源文件從另一個OSGi包
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
我想在CSS文件中使用的style.css在類StyleImpl.java
包含在OSGi包MyProjectContainingCSS
在其他OSGi包MyProjectContainingCSS
,
是這樣的:
public class StyleImpl {
public static void main(String[] args) {
css = this.getClass().getResource("/com/me/myapp/style.css").toExternalForm();
scene.getStylesheets().add(css);
}
}
我如何才能在另一個OSGi包的一個OSGi包中使用CSS資源文件?
謝謝大家提前。
UPDATE
的bnd.bnd文件
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: *
潤描述
-runfw: org.apache.felix.framework;version='[4,5)'
-runee: JavaSE-1.8
-runsystemcapabilities: ${native_capability}
-resolve.effective: active;skip:="osgi.service"
-runbundles: \
org.apache.felix.dependencymanager,\
org.apache.felix.dependencymanager.runtime,\
org.apache.felix.dependencymanager.shell,\
org.apache.felix.metatype,\
org.apache.felix.eventadmin,\
org.apache.felix.configadmin,\
org.apache.felix.log,\
org.apache.felix.gogo.command,\
org.apache.felix.gogo.runtime,\
org.apache.felix.gogo.shell,\
launcher;version=latest,\
ui;version=latest,\
mainscreen;version=latest
-runsystempackages: javafx.application,javafx.scene,javafx.stage,javafx.scene.layout,javafx.event,javafx.collections,javafx.scene.control,javafx.scene.paint,javafx.scene.shape
在CSS包中創建一個類,將InputStream公開爲CSS文件並將該類導入到另一個包中。 – 11thdimension
一個包如何知道在另一個包中可以找到具有特定名稱的特定資源?這種假設意味着你違反了模塊化封裝。嘗試找到一個不會對其他模塊做出假設的解決方案。爲什麼不描述你正試圖解決的*真實*問題? –