Poco::OSP

class Bundle

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

Description

This class represents a Bundle in OSP.

For every bundle directory or file found in the OSP bundle repository, a Bundle object is created. The bundle class stores the state of the Bundle and gives access to the bundle's manifest, configuration properties and resources.

The Bundle class also manages localized resources.

Inheritance

Direct Base Classes: Poco::RefCountedObject

All Base Classes: Poco::RefCountedObject

Member Summary

Member Functions: activator, activatorClass, activatorLibrary, addProperties, copyright, events, getLocalizedResource, getResource, isActive, isResolved, isStarted, language, lazyStart, loadManifest, loadProperties, manifest, name, path, properties, requiredBundles, resolve, runLevel, setActivator, start, state, stateString, stop, storage, symbolicName, uninstall, vendor, version

Inherited Functions: duplicate, referenceCount, release

Types

ConstPtr

typedef const Ptr ConstPtr;

Ptr

typedef Poco::AutoPtr < Bundle > Ptr;

Enumerations

State

BUNDLE_INSTALLED

BUNDLE_UNINSTALLED

BUNDLE_RESOLVED

BUNDLE_STARTING

BUNDLE_ACTIVE

BUNDLE_STOPPING

Constructors

Bundle protected

Bundle(
    BundleLoader & loader,
    BundleStorage::Ptr pStorage,
    const LanguageTag & language
);

Creates the Bundle and reads the manifest using the given BundleStorage object.

The bundle takes ownership of the BundleStorage object.

Destructor

~Bundle protected virtual

~Bundle();

Destroys the Bundle.

Member Functions

activator inline

BundleActivator * activator() const;

If the bundle is active and has an activator, returns a pointer to the bundle's activator. Otherwise, returns NULL.

activatorClass inline

const std::string & activatorClass() const;

Returns the class name of the bundle's activator, or an empty string if the manifest does not specify an activator.

activatorLibrary inline

const std::string & activatorLibrary() const;

Returns the name of the library containing the bundle's activator class, or an empty string if the manifest does not specify an activator library.

copyright inline

const std::string & copyright() const;

Returns the bundle's copyright information, or an empty string if no copyright information has been specified in the pManifest->

If the copyright string contains a reference to a property, (${<property>}) the reference is expanded first.

getLocalizedResource

std::istream * getLocalizedResource(
    const std::string & name
) const;

Creates and returns an input stream for reading the bundle's localized resource with the given name.

Resources are ordinary files stored within the bundle's directory or archive file.

Returns NULL if the resource does not exist.

The caller gets ownership of the input stream and must delete it when it's no longer needed.

getLocalizedResource

std::istream * getLocalizedResource(
    const std::string & name,
    const LanguageTag & language
) const;

Creates and returns an input stream for reading the bundle's localized (for the given language) resource with the given name.

Resources are ordinary files stored within the bundle's directory or archive file.

Returns NULL if the resource does not exist.

The caller gets ownership of the input stream and must delete it when it's no longer needed.

getResource

std::istream * getResource(
    const std::string & name
) const;

Creates and returns an input stream for reading the bundle's (non-localized) resource with the given name.

Resources are ordinary files stored within the bundle's directory or archive file.

Returns NULL if the resource does not exist.

The caller gets ownership of the input stream and must delete it when it's no longer needed.

isActive inline

bool isActive() const;

Returns true iff the bundle's state is BUNDLE_ACTIVE.

isResolved inline

bool isResolved() const;

Returns true iff the bundle has been successfully resolved.

In other words, the bundle's state must be one of BUNDLE_RESOLVED, BUNDLE_STARTING, BUNDLE_ACTIVE, BUNDLE_STOPPED.

isStarted inline

bool isStarted() const;

Returns true iff the bundle's state is BUNDLE_STARTING, BUNDLE_ACTIVE or BUNDLE_STOPPING.

language inline

const LanguageTag & language() const;

Returns the language used for localization.

lazyStart inline

bool lazyStart() const;

Returns true whether lazy start has been specified for the bundle.

manifest inline

const BundleManifest & manifest() const;

Returns a reference to the BundleManifest object.

name inline

const std::string & name() const;

Returns the bundle's name.

If the name contains a reference to a property, (${<property>}) the reference is expanded first.

path inline

std::string path() const;

Returns the path to the bundle's directory or archive file.

properties inline

const Poco::Util::AbstractConfiguration & properties() const;

Returns the bundle's properties, which are obtained from the bundle's "bundle.properties" file (and its optional localizations).

requiredBundles inline

const BundleManifest::Dependencies & requiredBundles() const;

Returns a vector containing information about all bundles required by this bundle.

resolve

void resolve();

Resolves the bundle by verifying the availability of all required bundles. The bundle must be in BUNDLE_INSTALLED state. A sucessful resolve() puts the bundle in BUNDLE_RESOLVED state.

Throws an exception if the bundle cannot be resolved.

runLevel inline

const std::string & runLevel() const;

Returns the bundle's run level.

If the bundle does not specify a run level, returns the default "999-user".

start

void start();

Starts the bundle. The bundle's state must be BUNDLE_RESOLVED.

Puts the bundle in BUNDLE_STARTING state, loads the bundle's activator and invokes it, and finally puts the bundle in BUNDLE_RUNNING state.

state inline

State state() const;

Returns the current state of the bundle.

stateString

const std::string & stateString() const;

Returns the current state of the bundle as a string.

stop

void stop();

Stops the bundle. The bundle's state must be BUNDLE_ACTIVE. Puts the bundle into BUNDLE_STOPPING state, stops the bundle activator and finally puts the bundle into BUNDLE_RESOLVED state.

symbolicName inline

const std::string & symbolicName() const;

Returns the symbolic name of the bundle.

uninstall

void uninstall();

Uninstalls the bundle. The bundle must be in BUNDLE_INSTALLED or BUNDLE_RESOLVED state. The bundle is also removed from the bundle repository.

vendor inline

const std::string & vendor() const;

Returns the bundle's vendor name, or an empty string if no vendor name has been specified in the pManifest->

If the vendor string contains a reference to a property, (${<property>}) the reference is expanded first.

version inline

const Version & version() const;

Returns the bundle's version.

addProperties protected

void addProperties(
    const std::string & path
);

Adds the properties from the property file specified by path to the bundle's properties.

events protected

BundleEvents & events();

Returns a reference to the BundleEvents object.

loadManifest protected

void loadManifest();

Loads the bundle's manifest file.

loadProperties protected

void loadProperties();

Loads the bundle's properties.

setActivator protected

void setActivator(
    BundleActivator * pActivator
);

Sets the BundleActivator.

storage protected inline

BundleStorage & storage();

Returns a reference to the BundleStorage object.

Variables

BUNDLE_ACTIVE_STRING static

static const std::string BUNDLE_ACTIVE_STRING;

BUNDLE_INSTALLED_STRING static

static const std::string BUNDLE_INSTALLED_STRING;

BUNDLE_INVALID_STRING static

static const std::string BUNDLE_INVALID_STRING;

BUNDLE_RESOLVED_STRING static

static const std::string BUNDLE_RESOLVED_STRING;

BUNDLE_STARTING_STRING static

static const std::string BUNDLE_STARTING_STRING;

BUNDLE_STOPPING_STRING static

static const std::string BUNDLE_STOPPING_STRING;

BUNDLE_UNINSTALLED_STRING static

static const std::string BUNDLE_UNINSTALLED_STRING;

MANIFEST_FILE static

static const std::string MANIFEST_FILE;

PROPERTIES_FILE static

static const std::string PROPERTIES_FILE;