简体   繁体   English

使用Maven进行构建时如何在OSGI捆绑包中导入javax.smartcardio?

[英]How to import javax.smartcardio in a osgi bundle when building with maven?

I'm trying to add a module to an existing osgi framework (www.ogema.org). 我正在尝试将模块添加到现有的osgi框架(www.ogema.org)。 I have to use a library that depends on javax.smartcardio. 我必须使用依赖于javax.smartcardio的库。 I added the library to a local repository and that seems to work. 我将库添加到本地存储库中,这似乎可以正常工作。 But when I want to start the bundle that uses the library i get the error: 但是,当我想启动使用该库的捆绑软件时,出现错误:

The bundle "org.ogema.examples.securitymodule-app_1.1.1 [12]" could not be resolved. Reason: Missing Constraint: Import-Package: javax.smartcardio; version="0.0.0"

How can I add javax.smartcardio as a dependency? 如何添加javax.smartcardio作为依赖项?

It already is added as a dependency, so that's fine. 它已经被添加为依赖项,所以很好。 The problem is that you don't have a bundle in the OSGi Framework that exports the javax.smartcardio package. 问题在于,OSGi Framework中没有捆绑包来导出 javax.smartcardio包。 For each imported package in a bundle there has to be a corresponding export of that package from another bundle. 对于捆绑中的每个导入包,必须从另一个捆绑中相应导出该包。

I'm not familiar with the Smartcard API so I can't offer advice on how to find a bundle that exports it. 我对Smartcard API并不熟悉,因此无法提供有关如何找到将其导出的捆绑包的建议。 If it is available as a plain JAR file then you may need to "wrap" it as an OSGi bundle. 如果可以将其作为普通JAR文件使用,则可能需要将其“包装”为OSGi捆绑包。

javax.smartcardio is part of the JRE (at least in 6, not sure if it was already in 5, the spec JSR 268 is from 2006 so it could have been in J5). javax.smartcardio是JRE的一部分(至少在6中,不确定它是否已在5中,规范JSR 268是2006年以来的,因此它可能已包含在J5中)。

It is very likely that you framework does not export this package. 您的框架很可能不会导出此程序包。 You can export this package from the framework by setting the org.osgi.framework.system.packages.extra framework property to javax.smartcardio;version=1.0.0;jsr=268 (the JSR or version are optional but it is nice documentation). 您可以通过将org.osgi.framework.system.packages.extra框架属性设置为javax.smartcardio;version=1.0.0;jsr=268 (JSR或版本是可选的,但这是不错的文档),从框架中导出此程序包)。

In bndtools you could do: 在bndtools中,您可以执行以下操作:

  -runsystempackages: \
    javax.smartcardio;version=1.0.0;jsr=268

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

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