Poco::OSP

class BundleLoader

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

Description

The BundleLoader is used internally by the framework to manage Bundle and BundleContext objects, and to load shared libraries containing BundleActivator classes.

The BundleLoader uses the logger osp.core.BundleLoader to write diagnostic messages.

Member Summary

Member Functions: contextForBundle, createBundle, events, findBundle, installLibraries, isResolving, libraryNameFor, libraryPathFor, listBundles, listLibraries, loadActivator, loadBundle, makeValidFileName, osArchitecture, osName, pathForLibrary, resolveAllBundles, resolveBundle, resolveDependency, sortBundles, startAllBundles, startBundle, startDependencies, stopAllBundles, stopBundle, uninstallBundle, uninstallLibraries, unloadActivator, unloadAllBundles, unloadBundle

Nested Classes

struct BundleInfo

 more...

Types

ActivatorClassLoader

typedef Poco::ClassLoader < BundleActivator > ActivatorClassLoader;

ActivatorClassLoaderPtr

typedef Poco::SharedPtr < ActivatorClassLoader > ActivatorClassLoaderPtr;

BundleMap

typedef std::map < std::string, BundleInfo > BundleMap;

BundleSet

typedef std::set < Bundle * > BundleSet;

Constructors

BundleLoader

BundleLoader(
    CodeCache & codeCache,
    BundleFactory::Ptr pBundleFactory,
    BundleContextFactory::Ptr pBundleContextFactory
);

Creates the BundleLoader.

Destructor

~BundleLoader

~BundleLoader();

Destroys the BundleLoader.

Member Functions

contextForBundle

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

Returns the BundleContext for the given bundle.

createBundle

Bundle::Ptr createBundle(
    const std::string & path
);

Loads a bundle from the given path.

A new Bundle object is created for the bundle, and the Bundle's state is BUNDLE_INSTALLED. The bundle is not added to the bundle map.

events inline

BundleEvents & events();

Returns a reference to the BundleEvents object.

findBundle

Bundle::ConstPtr findBundle(
    const std::string & symbolicName
) const;

Returns the Bundle object for the bundle with the given symbolic name, or NULL if the bundle does not exist.

listBundles

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

Fills the given vector with all bundles known to the loader.

loadBundle

Bundle::Ptr loadBundle(
    const std::string & path
);

Loads a bundle from the given path. A new Bundle object is created for the bundle, and the Bundle's state is BUNDLE_INSTALLED.

The bundle is then added to the bundle map. If another version of the same bundle is already loaded, a BundleVersionConflictException is thrown.

Returns the new Bundle object.

loadBundle

void loadBundle(
    Bundle::Ptr pBundle
);

Loads the given Bundle, which must have been created with createBundle().

The bundle is then added to the bundle map. If another version of the same bundle is already loaded, a BundleVersionConflictException is thrown.

osArchitecture inline

const std::string & osArchitecture() const;

Returns the name of the hardware architecture.

osName inline

const std::string & osName() const;

Returns the name of the operating system.

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.

resolveAllBundles

void resolveAllBundles();

Resolves all bundles.

If a bundle cannot be resolved, an error is logged and the loader will continue to resolve other bundles.

startAllBundles

void startAllBundles();

Starts all bundles, ordered by their run level. If a bundle has the lazyStart property set, that bundle won't be started unless another bundle requires it.

Bundles with lower run levels will be started before bundles with higher run levels.

If a bundle cannot be started, an error will be logged, and the loader will continue to load other bundles.

stopAllBundles

void stopAllBundles();

Stops all bundles.

Bundles are stopped in order of their depedencies.

unloadAllBundles

void unloadAllBundles();

Stops and unloads all bundles.

unloadBundle

void unloadBundle(
    Bundle::Ptr pBundle
);

Unloads the given bundle.

The bundle is removed from the bundle map and its activator library, if loaded, is unloaded.

installLibraries protected

void installLibraries(
    Bundle * pBundle
);

Copies all shared libraries in the bundle (for the current platform) to the code cache.

isResolving protected

bool isResolving(
    Bundle * pBundle
) const;

Returns true iff the given bundle is currently being resolved.

libraryNameFor protected

const std::string & libraryNameFor(
    Bundle * pBundle
);

Returns the library name for the library containing the activator for the given bundle.

libraryPathFor protected

std::string libraryPathFor(
    Bundle * pBundle
);

Returns the library path for the library containing the activator for the given bundle.

listLibraries protected

void listLibraries(
    Bundle * pBundle,
    std::vector < std::string > & list
);

Lists all shared libraries contained in the bundle for the current platform.

loadActivator protected

BundleActivator * loadActivator(
    BundleInfo & bundleInfo
);

Loads the activator for the given bundle, unless it has already been loaded.

makeValidFileName protected static

static void makeValidFileName(
    std::string & name
);

Replaces all non alphanumeric characters in name with an underscore.

resolveBundle protected

void resolveBundle(
    Bundle * pBundle
);

Resolves the given bundle.

resolveDependency protected

void resolveDependency(
    Bundle * pBundle,
    const BundleManifest::Dependency & dependency
);

Resolves a single dependency of a bundle.

sortBundles protected

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

Sorts all bundles topologically, based on their dependencies.

The bundles are sorted in such a way so that bundles can be safely stopped in the resulting order.

startBundle protected

void startBundle(
    Bundle * pBundle
);

Starts the given bundle.

startDependencies protected

void startDependencies(
    Bundle * pBundle
);

Starts all bundles that the given bundle requires to run.

stopBundle protected

void stopBundle(
    Bundle * pBundle
);

Stops the given bundle.

uninstallBundle protected

void uninstallBundle(
    Bundle * pBundle
);

Uninstalls the given bundle.

uninstallLibraries protected

void uninstallLibraries(
    Bundle * pBundle
);

Removes all shared libraries belonging to the given bundle from the code cache.

unloadActivator protected

void unloadActivator(
    BundleInfo & bundleInfo
);

Unloads the activator for the given bundle.