Library: OSP
Package: Bundle
Header: Poco/OSP/BundleLoader.h
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 Functions: contextForBundle, createBundle, events, findBundle, installLibraries, isResolving, libraryNameFor, libraryPathFor, listBundles, listLibraries, loadActivator, loadBundle, makeValidFileName, nextBundleId, osArchitecture, osName, pathForLibrary, resolveAllBundles, resolveBundle, resolveDependency, sortBundles, startAllBundles, startBundle, startDependencies, stopAllBundles, stopBundle, uninstallBundle, uninstallLibraries, unloadActivator, unloadAllBundles, unloadBundle
typedef Poco::ClassLoader < BundleActivator > ActivatorClassLoader;
typedef Poco::SharedPtr < ActivatorClassLoader > ActivatorClassLoaderPtr;
typedef std::map < std::string, BundleInfo > BundleMap;
typedef std::set < Bundle * > BundleSet;
BundleLoader(
CodeCache & codeCache,
BundleFactory::Ptr pBundleFactory,
BundleContextFactory::Ptr pBundleContextFactory
);
Creates the BundleLoader.
~BundleLoader();
Destroys the BundleLoader.
BundleContext::Ptr contextForBundle(
Bundle::ConstPtr pBundle
) const;
Returns the BundleContext for the given bundle.
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.
BundleEvents & events();
Returns a reference to the BundleEvents object.
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.
Bundle::ConstPtr findBundle(
int id
) const;
Returns the Bundle object for the bundle with the given ID, or NULL if the bundle does not exist.
void listBundles(
std::vector < Bundle::Ptr > & bundles
) const;
Fills the given vector with all bundles known to the loader.
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.
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.
int nextBundleId();
Returns a new unique bundle ID.
const std::string & osArchitecture() const;
Returns the name of the hardware architecture.
const std::string & osName() const;
Returns the name of the operating system.
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.
void resolveAllBundles();
Resolves all bundles.
If a bundle cannot be resolved, an error is logged and the loader will continue to resolve other bundles.
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.
void stopAllBundles();
Stops all bundles.
Bundles are stopped in order of their depedencies.
void unloadAllBundles();
Stops and unloads all bundles.
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.
void installLibraries(
Bundle * pBundle
);
Copies all shared libraries in the bundle (for the current platform) to the code cache.
bool isResolving(
Bundle * pBundle
) const;
Returns true if and only if the given bundle is currently being resolved.
const std::string & libraryNameFor(
Bundle * pBundle
);
Returns the library name for the library containing the activator for the given bundle.
std::string libraryPathFor(
Bundle * pBundle
);
Returns the library path for the library containing the activator for the given bundle.
void listLibraries(
Bundle * pBundle,
std::vector < std::string > & list
);
Lists all shared libraries contained in the bundle for the current platform.
BundleActivator * loadActivator(
BundleInfo & bundleInfo
);
Loads the activator for the given bundle, unless it has already been loaded.
static void makeValidFileName(
std::string & name
);
Replaces all non alphanumeric characters in name with an underscore.
void resolveBundle(
Bundle * pBundle
);
Resolves the given bundle.
void resolveDependency(
Bundle * pBundle,
const BundleManifest::Dependency & dependency
);
Resolves a single dependency of a bundle.
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.
void startBundle(
Bundle * pBundle
);
Starts the given bundle.
void startDependencies(
Bundle * pBundle
);
Starts all bundles that the given bundle requires to run.
void stopBundle(
Bundle * pBundle
);
Stops the given bundle.
void uninstallBundle(
Bundle * pBundle
);
Uninstalls the given bundle.
void uninstallLibraries(
Bundle * pBundle
);
Removes all shared libraries belonging to the given bundle from the code cache.
void unloadActivator(
BundleInfo & bundleInfo
);
Unloads the activator for the given bundle.