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

被折叠的 条评论
为什么被折叠?



