Framework¶
-
class
cppmicroservices::
Framework
¶ A Framework instance.
A Framework is itself a bundle and is known as the “System Bundle”. The System Bundle differs from other bundles in the following ways:
- The system bundle is always assigned a bundle identifier of zero (0).
- The system bundle
GetLocation
method returns the string: “System Bundle”. - The system bundle’s life cycle cannot be managed like normal bundles. Its life cycle methods behave as follows:
- Start - Initialize the framework and start installed bundles.
- Stop - Stops all installed bundles.
- Uninstall - The Framework throws a std::runtime_error exception indicating that the system bundle cannot be uninstalled.
Framework instances are created using a FrameworkFactory. The methods of this class can be used to manage and control the created framework instance.
- Remark
- This class is thread-safe.
- See
- FrameworkFactory::NewFramework(const std::map<std::string, Any>& configuration)
Inherits from cppmicroservices::Bundle
Public Functions
-
Framework
(Bundle b)¶ Convert a
Bundle
representing the system bundle to aFramework
instance.- Parameters
b
: The system bundle
- Exceptions
std::logic_error
: If the bundle is not the system bundle.
-
void
Init
()¶ Initialize this Framework.
After calling this method, this Framework has:
- Generated a new framework UUID.
- Moved to the STATE_STARTING state.
- A valid Bundle Context.
- Event handling enabled.
- Reified Bundle objects for all installed bundles.
- Registered any framework services.
This Framework will not actually be started until Start is called.
This method does nothing if called when this Framework is in the STATE_STARTING, STATE_ACTIVE or STATE_STOPPING states.
- Exceptions
std::runtime_error
: If this Framework could not be initialized.
-
FrameworkEvent
WaitForStop
(const std::chrono::milliseconds &timeout)¶ Wait until this Framework has completely stopped.
The
Stop
method on a Framework performs an asynchronous stop of the Framework if it was built with threading support.This method can be used to wait until the asynchronous stop of this Framework has completed. This method will only wait if called when this Framework is in the STATE_STARTING, STATE_ACTIVE, or STATE_STOPPING states. Otherwise it will return immediately.
A Framework Event is returned to indicate why this Framework has stopped.
- Return
- A Framework Event indicating the reason this method returned. The following
FrameworkEvent
types may be returned by this method.FRAMEWORK_STOPPED - This Framework has been stopped.
FRAMEWORK_ERROR - The Framework encountered an error while shutting down or an error has occurred which forced the framework to shutdown.
FRAMEWORK_WAIT_TIMEDOUT - This method has timed out and returned before this Framework has stopped.
- Parameters
timeout
: Maximum time duration to wait until this Framework has completely stopped. A value of zero will wait indefinitely.