Poco::OSP

class BundleContext

Library: OSP
Package: Bundle
Header: Poco/OSP/BundleContext.h

Description

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.

Inheritance

Direct Base Classes: Poco::RefCountedObject

All Base Classes: Poco::RefCountedObject

Member Summary

Member Functions: contextForBundle, events, findBundle, initPersistency, listBundles, logger, loggerName, pathForLibrary, persistentDirectory, registry, systemEvents, temporaryDirectory, thisBundle

Inherited Functions: duplicate, referenceCount, release

Types

ConstPtr

typedef const Ptr ConstPtr;

Ptr

typedef Poco::AutoPtr < BundleContext > Ptr;

Constructors

BundleContext protected

BundleContext(
    BundleLoader & loader,
    Bundle::ConstPtr pBundle,
    BundleEvents & events,
    SystemEvents & systemEvents,
    ServiceRegistry & registry,
    const Path & persistencyDir
);

Creates the BundleContext.

Destructor

~BundleContext protected virtual

~BundleContext();

Destroys the BundleContext.

Member Functions

contextForBundle

BundleContext::Ptr contextForBundle(
    Bundle::ConstPtr pBundle
) const;

Returns the BundleContext for the given bundle.

events inline

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.

findBundle

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.

findBundle

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.

listBundles

void listBundles(
    std::vector < Bundle::Ptr > & bundles
) const;

Fills the given vector with all bundles known to the OSP framework.

listBundles

void listBundles(
    std::vector < Bundle::Ptr > & bundles,
    BundleFilter::Ptr pFilter
) const;

Fills the given vector with all bundles known to the OSP framework, filtered by the given BundleFilter.

logger inline

Poco::Logger & logger() const;

Returns a reference to a Poco::Logger that the bundle can use to emit log messages.

pathForLibrary

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.

persistentDirectory

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.

registry inline

ServiceRegistry & registry() const;

Returns a reference to the ServiceRegistry object, which can be used to find or register services.

systemEvents inline

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.

temporaryDirectory

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.

thisBundle inline

Bundle::ConstPtr thisBundle() const;

Returns a pointer to the bundle's Bundle object.

initPersistency protected

void initPersistency(
    const Poco::Path & persistencyPath
);

Sets up the temporary and persistent data paths.

loggerName protected static

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.