简体   繁体   English

OSGi / BND:取决于操作系统的不同要求

[英]OSGi/BND: Different requirements depending on OS

I created a command component for OSGi and using Apache Felix Shell. 我为OSGi创建了一个命令组件,并使用了Apache Felix Shell。 One command opens a new Thread which starts a SWT UI. 一个命令打开一个新线程,该线程启动SWT UI。

In the BND Config the SWT Bundle is required for building and to run this component. 在BND Config中,构建和运行此组件需要SWT捆绑包。 The Problem now is, that every developer has to change the config and include the SWT Bundle for their OS. 现在的问题是,每个开发人员都必须更改配置,并为其操作系统包含SWT捆绑包。 Also for every OS a other packed Bundle is needed, where the only difference is a line in the Manifest of the jar, which other Bundles are required to launch. 同样,对于每个OS,都需要另一个打包的Bundle,唯一的区别是jar清单中的一行,需要启动其他Bundle。

Is there any trick in BND or OSGi, where i can set a build or run dependency dependent on the current running system? BND或OSGi中有什么窍门,可以根据当前运行的系统设置构建或运行依赖项吗?

Something like "org.eclipse.swt.{OS}.{WS}.{ARCH}" instead of "org.eclipse.swt.win32.win32.x86_64"? 类似于“ org.eclipse.swt。{OS}。{WS}。{ARCH}”而不是“ org.eclipse.swt.win32.win32.x86_64”? Or at least can I require a specific OS in the config? 或者至少我可以在配置中需要特定的操作系统? So that if a user uses a wrong bundle, it shows a nice error instead of a ClassNotFound Exception? 这样,如果用户使用错误的包,它将显示一个不错的错误而不是ClassNotFound异常?

The solution described in another question (http://stackoverflow.com/questions/2706222/create-cross-platform-java-swt-application/5784073#5784073) doesn't work for me or better I don't know how this could be done with BND/OSGi. 另一个问题中描述的解决方案(http://stackoverflow.com/questions/2706222/create-cross-platform-java-swt-application/5784073#5784073)对我不起作用或更好,我不知道这可以使用BND / OSGi完成。

Any Idea? 任何想法?

bnd can use includes. bnd可以使用include。 So create a standard configuration and include this in platform specific bndrun files. 因此,创建一个标准配置,并将其包含在平台特定的bndrun文件中。

 bnd.bnd:
 # standard set that uses macros for the places where specials need to be insered
 -runbundles: \
        ....
        ${platformdeps}

 windows.bndrun:
 -include bnd.bnd
 platformdeps = org.eclipse.swt.win.x86.jar

Anyway, look at bndtools. 无论如何,请看bndtools。 Neil Bartlett builds bndtools in bndtools without PDE. Neil Bartlett在没有PDE的bndtools中构建bndtools。 So he has bndrun files for all platforms. 因此,他拥有适用于所有平台的bndrun文件。

There is also an ${if ... } macro or a ${replace } macro. 还有一个$ {if ...}宏或$ {replace}宏。 If people would still pay for books instead of downloading pirated versions ... Until that small problem is solved, look at http://www.aqute.biz/Bnd/Bnd 如果人们仍然愿意为书籍付费而不是下载盗版版本...在解决这个小问题之前,请访问http://www.aqute.biz/Bnd/Bnd

Neil Bartlett's book "OSGi in Practice" has a section on Fragment Bundles in which operating system dependent configurations are mentioned. 尼尔·巴特利特(Neil Bartlett)的《 OSGi实践》一书中有关于片段捆绑的部分,其中提到了依赖于操作系统的配置。 (However, as I did not have a need to actually do that, I cannot say, whether this really is what you are looking for.) (但是,由于我实际上并不需要这样做,所以我不能说这是否真的是您想要的。)

The book: http://njbartlett.name/osgibook.html 该书: http : //njbartlett.name/osgibook.html

(This is not really a pretty answer, but maybe enough to get going.) (这并不是一个很好的答案,但也许足以解决这个问题。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM