如何OSGIfy库 [英] How to OSGIfy a library

查看:261
本文介绍了如何OSGIfy库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个项目,它的集成项目中,我们使用Apache骆驼和Apache Karaf。
在项目中,我需要使用吉拉REST Java客户端库。

I'm working on a project, it's integration project, we are using Apache Camel and Apache Karaf. In the project, I need to use the Jira REST Java client library.

所以,我读过不少各种文章和关于如何包装非OSGI库OSGi包的线程,但我真的不知道,如果我是正确的。

So I've read quite a lot of various articles and threads about how to wrap non-OSGI library to OSGI bundle, but I'm really not sure if I got it right.

所以,我创建了一个依赖项所需的库中的POM文件。制成的包装,并试图将其部署到Karaf,当然,Karaf抱怨丢失的包。

So, I've created a POM file with a dependency to the needed library. Made a package and tried to deploy it to Karaf, of course, Karaf complained for missing packages.

所以,我发现相应的Maven的依赖,增加它,包进入<进口包装及GT; 和依赖到<嵌入-Dependency方式>

So, I've found corresponding maven dependency, added it, package goes into <Import-Package> and dependency into <Embed-Dependency>.

又一轮,部署,找的依赖性,添加...又一次,又一次,直到Karaf是好的同捆。

Another round, deploy, find dependency, add, ... and again, and again, until Karaf is fine with the bundle.

这真的正确吗?在我看来,像相当疯狂,所以我想我没有得到它为usualy:)

Is that really correct? It seems to me like quite crazy, so I guess I don't got it as usualy :)

最后,包到达那是我的工作电脑上的稳定,我赶紧检查了它,回家去了,有我继续,但是,奇怪,同样的POM /包,我的个人电脑上编不工作,再抱怨缺失的软件包,但是这一次,这个包是肯定的POM文件并确保它在包包埋,我可以在那里看到了。

Finally, the package get to stable that was on my work computer, I checked it quickly and went home, there I continued but, strange, the same POM / package, compiled on my personal computer is not working, again complaining about missing package, but this time, this package is for sure in the POM file and for sure it is embeded in the package, I can see it there.

这缺少的包是这个时候org.apache.commons。codeC。

This missing package is this time org.apache.commons.codec.

org.osgi.framework.BundleException: Unresolved constraint in bundle jiraclient.bundle [134]: Unable to     resolve 134.0: missing requirement [134.0] osgi.wiring.package; (osgi.wiring.package=org.apache.commons.codec)
    at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3826)[org.apache.felix.framework-4.0.3.jar:]
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1868)[org.apache.felix.framework-4.0.3.jar:]
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)[org.apache.felix.framework-4.0.3.jar:]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1247)[6:org.apache.felix.fileinstall:3.2.6]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1219)[6:org.apache.felix.fileinstall:3.2.6]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1208)[6:org.apache.felix.fileinstall:3.2.6]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:503)[6:org.apache.felix.fileinstall:3.2.6]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:291)[6:org.apache.felix.fileinstall:3.2.6]

所以,现在我完全糊涂了,什么是错的:(

So, now I'm totally confused, what is wrong :(

pretty请,伙计们,帮帮我吧。谢谢!

Pretty please, guys, help me. Thanks!

的POM文件是漫长的,所以我想链接更好: http://pastebin.com/j5cmWveG

The POM file is long, so I guess link is better: http://pastebin.com/j5cmWveG

推荐答案

是OSGi是恕我直言易远用在其部署模型而言,需要在MANIFEST.MF文件中的OSGi元数据100%的包。而你需要的数学博士,了解BND工具。不幸的是很多的JAR都没有OSGi包。

Yes OSGi is IMHO "far from easy to use" in terms of its deployment model, requiring 100% bundles with osgi metadata in MANIFEST.MF files. And you need a PhD in mathematics to understand the BND tool. And unfortunately many JARs are not OSGi bundles.

综观所有进口的pom.xml文件|出口,而且不容易理解的语法,将只取5秒,平均任何工程师明白,这东西是在丹麦的状态wrotten 如OSGi的!=,我们生活的世界,这必须和应该更容易恕我直言。

Looking at your pom.xml file with all the imports|exports, and that "not easy to understand" syntax, would just take 5-sec for any average engineer to understand that this "something is wrotten in the state of Denmark" ; eg OSGi != the world we live in. This must and should be easier IMHO.

您可以使用包装 URL处理器安装在Karaf一个普通的JAR:
http://karaf.apache.org/manual/latest/developers -guide /创建-bundles.html

You can install a plain JAR in Karaf using the wrap url handler: http://karaf.apache.org/manual/latest/developers-guide/creating-bundles.html

另一个技巧是创建一个尤伯杯JAR ,例如把它在一个单一的JAR文件,然后可以部署。

Another trick is to create an uber JAR, eg to put it all in a single JAR file and then you can deploy that.

还有 FAB (保险丝包),这使得OSGi的部署更简单,因为它处理很多这种疯狂的为你在部署时,而不是你不必处理OSGi的MANIFEST.MF疯狂: http://www.davsclaus.com/ 2012/08 / OSGi的部署,定制易于使用,fab.html

There is also FAB (Fuse Bundles) which makes OSGi deployment easier, as it handles much of this craziness for you at deploy time, instead of you having to deal with the OSGi MANIFEST.MF madness: http://www.davsclaus.com/2012/08/osgi-deployment-made-easy-with-fab.html

这篇关于如何OSGIfy库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆