Library: OSP
Package: Bundle
Header: Poco/OSP/BundleContext.h
A BundleContext gives a BundleActivator access to the bundle's runtime environment. Via the BundleContext, the BundleActivator can obtain a pointer to the Bundle object, to system-wide configuration properties and to the ServiceRegistry. The BundleContext can also be used to find other bundles in the system.
Direct Base Classes: Poco::RefCountedObject
All Base Classes: Poco::RefCountedObject
Member Functions: contextForBundle, events, findBundle, initPersistency, listBundles, logger, loggerName, pathForLibrary, persistentDirectory, registry, systemEvents, temporaryDirectory, thisBundle
Inherited Functions: duplicate, referenceCount, release
typedef Poco::AutoPtr < BundleContext > Ptr;
BundleContext(
BundleLoader & loader,
Bundle::ConstPtr pBundle,
BundleEvents & events,
SystemEvents & systemEvents,
ServiceRegistry & registry,
const Path & persistencyDir
);
Creates the BundleContext.
~BundleContext();
Destroys the BundleContext.
BundleContext::Ptr contextForBundle(
Bundle::ConstPtr pBundle
) const;
Returns the BundleContext for the given bundle.
BundleEvents & events() const;
Returns a reference to the global BundleEvents object which can be used to subscribe to events reporting state changes in installed bundles.
Bundle::ConstPtr findBundle(
const std::string & name
) const;
Returns a pointer to the Bundle object for the bundle with the given name, if such a bundle exists. Otherwise, returns NULL.
Bundle::ConstPtr findBundle(
int id
) const;
Returns a pointer to the Bundle object for the bundle with the given ID, if such a bundle exists. Otherwise, returns NULL.
void listBundles(
std::vector < Bundle::Ptr > & bundles
) const;
Fills the given vector with all bundles known to the OSP framework.
Poco::Logger & logger() const;
Returns a reference to a Poco::Logger that the bundle can use to emit log messages.
std::string pathForLibrary(
const std::string & libraryName
);
Returns the full path for the library with the given libraryName. If libraryName is the empty string, return the path to the code cache directory.
const Poco::Path & persistentDirectory() const;
Returns the path to the bundle's persistent data directory.
A bundle can use this directory to create files that must be preserved between different runs of the application.
If the directory does not exist, it is created. The persistent data directory is never cleared.
ServiceRegistry & registry() const;
Returns a reference to the ServiceRegistry object, which can be used to find or register services.
SystemEvents & systemEvents() const;
Returns a reference to the global SystemEvents object which can be used to subscribe to events reporting state changes in the OSP system.
const Poco::Path & temporaryDirectory() const;
Returns the path to the bundle's temporary (transient) data directory.
A bundle can use this directory to create temporary files that need not be preserved between different runs of the application.
If the directory does not exist, it is created. The directory is cleared whenever the bundle is unloaded.
Bundle::ConstPtr thisBundle() const;
Returns a pointer to the bundle's Bundle object.
void initPersistency(
const Poco::Path & persistencyPath
);
Sets up the temporary and persistent data paths.
static std::string loggerName(
const Bundle * pBundle
);
Returns a logger name for the bundle.
The logger's name is "osp.bundle.<symbolic-name>", where <symbolic-name> is the bundle's symbolic name.