File Information
Library: OSP
Package: ExtensionPointService
Header: Poco/OSP/ExtensionPointService.h
Description
The ExtensionPointService allows a bundle to define extension points (or "hooks") where other bundles can "hook in" functionality, thus extending the bundle.
The service listens for EV_BUNDLE_STARTED events. For every started bundle, the service tries to retrieve the bundle's "extensions.xml" file. If the file exists, the file is parsed using a DOM parser.
The ExtensionPointService then iterates over all "extension" elements in that document. Every "extension" element must specify an attribute named "point" that specifies the ExtensionPoint object to invoke for this element. The service then invokes the ExtensionPoint::handleExtension() member function with the bundle and the "extension" element as arguments.
The "extensions.xml" file basically looks as follows:
<extensions> <extension point="<id>"> <!-- extension point specific content --> </extension> <!-- more extension elements --> </extensions>
The service name of the ExtensionPointService is "osp.core.xp".
Inheritance
Direct Base Classes: Service
All Base Classes: Service, Poco::RefCountedObject
Member Summary
Member Functions: findExtensionPoint, handleExtension, handleExtensions, isA, onBundleStarted, onBundleStopped, registerExtensionPoint, removeExtension, type, unregisterExtensionPoint
Inherited Functions: duplicate, isA, referenceCount, release, type
Types
void
typedef void (ExtensionPointService::* GenericHandler)(Bundle::ConstPtr pBundle, const std::string & id, Poco::XML::Element * pExtensionElement);
Types Aliases
ConstPtr
Ptr
using Ptr = Poco::AutoPtr < ExtensionPointService >;
Enumerations
Direction
The direction in which to traverse the extension points
Constructors
ExtensionPointService
ExtensionPointService(
BundleEvents & events
);
Creates the ExtensionPointService.
Destructor
~ExtensionPointService
Destroys the ExtensionPointService.
Member Functions
isA
bool isA(
const std::type_info & otherType
) const;
See also: Poco::OSP::Service::isA()
registerExtensionPoint
void registerExtensionPoint(
Bundle::ConstPtr pBundle,
const std::string & id,
ExtensionPoint::Ptr pExtensionPoint
);
Registers the given extension point under the given ID. If the bundle registering the extension point is stopped, the extension point will be automatically unregistered.
Throws a Poco::ExistsException if an extension point with the given ID has already been registered.
type
const std::type_info & type() const;
See also: Poco::OSP::Service::type()
unregisterExtensionPoint
void unregisterExtensionPoint(
const std::string & id
);
Unregisters the extension point with the given ID.
Throws a Poco::NotFoundException if the extension point with the given ID does not exist.
findExtensionPoint
ExtensionPoint::Ptr findExtensionPoint(
const std::string & id
);
Returns the extension point with the given ID.
handleExtension
void handleExtension(
Bundle::ConstPtr pBundle,
const std::string & id,
Poco::XML::Element * pExtensionElement
);
Handles a single "extension" element.
handleExtensions
void handleExtensions(
Bundle::ConstPtr pBundle,
GenericHandler handler,
Direction dir = DIR_FORWARD
);
Handles the "extensions.xml" file, if it exists.
handleExtensions
void handleExtensions(
Bundle::ConstPtr pBundle,
std::istream & istr,
GenericHandler handler,
Direction dir = DIR_FORWARD
);
Handles the "extensions.xml" file.
onBundleStarted
void onBundleStarted(
const void * pSender,
BundleEvent & event
);
Handles an EV_BUNDLE_STARTED event.
onBundleStopped
void onBundleStopped(
const void * pSender,
BundleEvent & event
);
Handles an EV_BUNDLE_STOPPED event.
removeExtension
void removeExtension(
Bundle::ConstPtr pBundle,
const std::string & id,
Poco::XML::Element * pExtensionElement
);
Handles a single "extension" element for extension removal.
Variables
EXTENSIONS_ELEM
static const std::string EXTENSIONS_ELEM;
EXTENSIONS_XML
static const std::string EXTENSIONS_XML;
EXTENSION_ELEM
static const std::string EXTENSION_ELEM;
POINT_ATTR
static const std::string POINT_ATTR;
SERVICE_NAME
static const std::string SERVICE_NAME;