Fluent builder API to build a new service registration for a service.
More...
#include <ServiceRegistrationBuilder.h>
template<typename I>
class celix::ServiceRegistrationBuilder< I >
Fluent builder API to build a new service registration for a service.
- See also
- celix::BundleContext::registerService for more info.
- Template Parameters
-
I | The service type (Note should be the abstract interface, not the interface implementer) |
- Note
- Not thread safe.
◆ ServiceRegistrationBuilder() [1/2]
◆ ServiceRegistrationBuilder() [2/2]
◆ addOnRegistered()
Adds an on registered callback for the service registration.
This callback will be called on the Celix event thread when the service is registered (REGISTERED state)
◆ addOnUnregistered()
Adds an on unregistered callback for the service registration.
This callback will be called on the Celix event thread when the service is unregistered (UNREGISTERED state)
◆ addProperties()
Add the properties to the service properties.
Note this call will add these properties to the already set properties. If a key is already present the value will be overridden.
◆ addProperty()
template<typename I >
template<typename T >
Add a property to the service properties.
If a key is already present the value will be overridden.
◆ build()
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ setProperties()
Set the service properties.
Note this call will clear already set properties.
◆ setRegisterAsync()
Configure if the service registration will be done synchronized or asynchronized.
When a service registration is done synchronized the underlining service will be registered in the Celix framework (and all service trackers will have been informed) when the build() returns. For asynchronized the build() will not wait until this is done.
The benefit of synchronized is the user is ensured a service registration is completely done, but extra care has te be taking into account to prevent deadlocks: lock object -> register service -> trigger service tracker -> trying to update a locked object.
The benefit of asynchronized is that service registration can safely be done inside a lock.
Default behavior is asynchronized.
◆ setUnregisterAsync()
Configure if the service un-registration will be done synchronized or asynchronized.
When a service un-registration is done synchronized the underlining service will be unregistered in the Celix framework (and all service trackers will have been informed) when the ServiceRegistration::unregister is called of when the ServiceRegistration goes out of scope (with a still REGISTERED service). For asynchronized this will be done asynchronously and the actual ServiceRegistration object will only be deleted if the un-registration is completed async.
The benefit of synchronized is the user is ensured a service un-registration is completely done when calling unregister() / letting ServiceRegistration out of scope, but extra care has te be taking into account to prevent deadlocks: lock object -> unregister service -> trigger service tracker -> trying to update a locked object.
The benefit of asynchronized is that service un-registration can safely be called inside a lock.
Default behavior is asynchronized.
◆ setVersion()
Set the service version.
This will lead to a 'service.version' service property.
◆ BundleContext
The documentation for this class was generated from the following file: