简体   繁体   English

如何一次安装和启动osgi捆绑包,其中一个依赖于其他

[英]How to Install and Start to osgi bundles at a time with one of them depending on other

I have two bundle say A and B. A depends on B (specified as Required-Bundle:B at A's MANIFEST). 我有两个束,分别是A和B。A取决于B(在A的清单中指定为Required-Bundle:B)。

Now I installed both A, B bundles one by one (by calling BundleContext.installBundle). 现在,我一个接一个地安装了A,B捆绑包(通过调用BundleContext.installBundle)。 Then when I try to start bundle A, I'm getting following error 然后,当我尝试启动包A时,出现以下错误

org.osgi.framework.BundleException: Could not resolve module: A [140]
  Unresolved requirement: Require-Bundle: B; bundle-version="1.0.0"

I understand from the exception that bundle B is not yet started(resolved). 我从例外中了解到捆绑包B尚未启动(已解决)。 Now how to solve this problem? 现在该如何解决这个问题?

Only way to solve this problem is sorting bundles by it's dependencies? 解决此问题的唯一方法是按依赖项对分发包进行排序? Or Are there any options like specifying a folder to OSGi runtime so that any bundle files copied to it will be activated? 还是是否有任何其他选项,例如为OSGi运行时指定文件夹,以便激活任何复制到该文件夹​​的捆绑文件?

By the way, I'm using equinox. 顺便说一句,我正在使用春分。

Make sure you install ALL of the bundles before you start ANY of them. 启动任何捆绑软件之前,请确保已安装所有捆绑软件。 Ie you need to do this: 即您需要这样做:

  1. Install A, Install B 安装A,安装B
  2. Start A, Start B. 启动A,启动B。

and NOT this: 不是这个:

  1. Install A, Start A 安装A,开始A
  2. Install B, Start B 安装B,开始B

In the second (wrong) scenario, you will get a resolution error because A depends on B and B doesn't exist yet as far as OSGi is concerned. 在第二种(错误的)场景中,您将得到一个解析错误,因为就OSGi而言,A依赖于B且B尚不存在。

In the first (correct) scenario, when you start A, OSGi will work out that it needs to resolve both A and B in order to satisfy the dependencies. 在第一种(正确的)场景中,当您启动A时,OSGi会计算出它需要同时解析A和B才能满足依赖性。

[By the way, in your question you seem to be confusing starting with resolving: you said "B is not yet started(resolved)". [顺便说一句,在您的问题中,您似乎从解决开始就感到困惑:您说“ B尚未开始(解决)”。 These are different things entirely. 这些完全是不同的东西。 B only needs to be installed before you start A, and OSGi will resolve it automatically when it needs to.] 仅在启动A之前需要安装B,OSGi会在需要时自动解决它。

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

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