OSGI之Require-Bundle与Imported-Package

 

OSGI中的bundle在依赖其他的bundle的时候,有两种方式:Require-Bundle与Imported-Package。这里简单的讲讲他们之间的区别。

先看看基础的定义:

  • Required-Bundle: Specify the list of plug-ins required for the operation of this plug-in.
  • Imported-Package:Specify packages on which this plug-in depends without explicitly identifying their originating plug-in.

 

OSGI ClassLoader机制

Many bundles can share a single virtual machine (VM). Within this VM, bundles can hide packages and classes from other bundles, as well as share packages with other bundles.

Bundle共享Java虚拟机,这样的不同的bundle之间才能相互引用package。

The key mechanism to hide and share packages is the Java class loader that loads classes from a sub-set of the bundle-space using well-defined rules. Each bundle has a single class loader.

理解OSGI的Package import-export机制的关键在于明白每个bundle都有自己的Class Loader。

对于OSGI环境来说,它们是没有区别的。无论是Require-Bundle还是Imported-Package,前提都是需要把相关的packages先Export出。先看看OSGI下的ClassImport-Export关系:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值