Blueprint的环境管理器

Blueprint Container 规范还定义了许多特殊的环境管理器,它们设置 ID 并提供对环境组件的访问。它们不具有 XML 定义,并且也不能被重写,因为它们的 ID 被保护起来,不能被其他管理器使用。环境管理器提供的对象只能被注入到使用引用的其他管理器中。Blueprint Container 规范定义了 4 种环境管理器:


blueprintBundle
提供包的  Bundle(org.osgi.framework.Bundle) 对象。
blueprintBundleContext
提供包的  BundleContext(org.osgi.framework.BundleContext) 对象。
blueprintContainer
为包提供  BlueprintContainer(org.osgi.service.blueprint.container.BlueprintContainer) 对象。
blueprintConverter
为包提供  Converter(org.osgi.service.blueprint.container.Converter) 对象,提供了对 Blueprint Container 类型转换工具的访问

使用的时候,可以直接在blueprint.xml中配置和使用

如:

<bean id="pbankList" class="com.lala.blueprint.client.BankListProcessor">
	<property name="bundle" ref="blueprintBundle"></property>
	<property name="bundleContext" ref="blueprintBundleContext"></property>
	<property name="blueprintContainer" ref="blueprintContainer"></property>
	<property name="converter" ref="blueprintConverter"></property>
</bean>

BankListProcessor中,加上变量即可

private Bundle bundle;
private BundleContext bundleContext;
private BlueprintContainer blueprintContainer;
private Converter converter;


最后,需要在pom.xml里面加上依赖

<dependency>
	<groupId>org.osgi</groupId>
	<artifactId>org.osgi.service.blueprint</artifactId>
	<version>1.0.2</version>
	<scope>provided</scope>
</dependency>

或者

<dependency>
	<groupId>org.osgi</groupId>
	<artifactId>org.osgi.compendium</artifactId>
	<version>4.3.1</version>
</dependency>




  • 9
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值