BundleContext

本文详细介绍了org.osgi.framework.BundleContext的概念及其在OSGi环境中的作用。BundleContext为bundle提供了执行上下文,允许bundle订阅框架事件、注册服务、获取服务引用等关键功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[b]org.osgi.framework.BundleContext[/b]

A bundle's execution context within the Framework. The context is used to grant access to other methods so that this bundle can interact with the Framework.

BundleContext methods allow a bundle to:

[list]Subscribe to events published by the Framework.
Register service objects with the Framework service registry.
Retrieve ServiceReferences from the Framework service registry.
Get and release service objects for a referenced service.
Install new bundles in the Framework.
Get the list of bundles installed in the Framework.
Get the Bundle object for a bundle.
Create File objects for files in a persistent storage area provided for the bundle by the Framework. [/list]
A BundleContext object will be created and provided to the bundle associated with this context when it is started using the BundleActivator.start method. The same BundleContext object will be passed to the bundle associated with this context when it is stopped using the BundleActivator.stop method. A BundleContext object is generally for the private use of its associated bundle and is not meant to be shared with other bundles in the OSGi environment.

The Bundle object associated with a BundleContext object is called the context bundle.

The BundleContext object is only valid during the execution of its context bundle; that is, during the period from when the context bundle is in the STARTING, STOPPING, and ACTIVE bundle states. If the BundleContext object is used subsequently, an IllegalStateException must be thrown. The BundleContext object must never be reused after its context bundle is stopped.

The Framework is the only entity that can create BundleContext objects and they are only valid within the Framework that created them.

@[b]version[/b] $Revision: 1.17 $
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值