Apache Celix
2.3.0
An implementation of the OSGi specification adapted to C and C++
|
#include "celix_types.h"
#include "celix_service_factory.h"
#include "celix_properties.h"
#include "celix_array_list.h"
#include "celix_filter.h"
Go to the source code of this file.
Classes | |
struct | celix_service_registration_options |
Service Registration Options when registering services to the Celix framework. More... | |
struct | celix_service_filter_options |
Service filter options which can be used to query for certain services. More... | |
struct | celix_service_tracking_options |
Service Tracker Options used to fine tune which services to track and the callback to be used for the tracked services. More... | |
struct | celix_service_use_options |
Service Use Options used to fine tune which services to use and which callbacks to use. More... | |
struct | celix_bundle_tracker_options |
The Service Bundle Tracking options can be used to fine tune the requested bundle tracker options. More... | |
struct | celix_service_tracker_info |
Service Tracker Info provided to the service tracker tracker callbacks. More... | |
Macros | |
#define | CELIX_OPTS_INIT |
#define | CELIX_EMPTY_SERVICE_REGISTRATION_OPTIONS |
C Macro to create a empty celix_service_registration_options_t type. More... | |
#define | CELIX_EMPTY_SERVICE_FILTER_OPTIONS {.serviceName = NULL, .versionRange = NULL, .filter = NULL, .serviceLanguage = NULL, .ignoreServiceLanguage = false} |
C Macro to create a empty celix_service_filter_options_t type. More... | |
#define | CELIX_EMPTY_SERVICE_TRACKING_OPTIONS |
C Macro to create a empty celix_service_tracking_options_t type. More... | |
#define | CELIX_SERVICE_USE_DIRECT (1) |
Call the provided callbacks from the caller thread directly if set, otherwise the callbacks will be called from the Celix event loop (most likely indirectly). Note that using blocking service in the Celix event loop is generally a bad idea, which should be avoided if possible. More... | |
#define | CELIX_SERVICE_USE_SOD (2) |
Whether "service on demand" pattern is supported when CELIX_SERVICE_USE_DIRECT is set. Note that it has no effect in indirect mode, in which case "service on demand" is supported. More... | |
#define | CELIX_EMPTY_SERVICE_USE_OPTIONS |
C Macro to create a empty celix_service_use_options_t type. More... | |
#define | CELIX_EMPTY_BUNDLE_TRACKING_OPTIONS {.callbackHandle = NULL, .onInstalled = NULL, .onStarted = NULL, .onStopped = NULL, .onBundleEvent = NULL, .includeFrameworkBundle = false, .trackerCreatedCallbackData = NULL, .trackerCreatedCallback = NULL} |
C Macro to create a empty celix_service_filter_options_t type. More... | |
Typedefs | |
typedef struct celix_service_registration_options | celix_service_registration_options_t |
Service Registration Options when registering services to the Celix framework. More... | |
typedef struct celix_service_filter_options | celix_service_filter_options_t |
Service filter options which can be used to query for certain services. More... | |
typedef struct celix_service_tracking_options | celix_service_tracking_options_t |
Service Tracker Options used to fine tune which services to track and the callback to be used for the tracked services. More... | |
typedef struct celix_service_use_options | celix_service_use_options_t |
Service Use Options used to fine tune which services to use and which callbacks to use. More... | |
typedef struct celix_bundle_tracker_options | celix_bundle_tracking_options_t |
The Service Bundle Tracking options can be used to fine tune the requested bundle tracker options. More... | |
typedef struct celix_service_tracker_info | celix_service_tracker_info_t |
Service Tracker Info provided to the service tracker tracker callbacks. More... | |
Functions | |
long | celix_bundleContext_registerServiceAsync (celix_bundle_context_t *ctx, void *svc, const char *serviceName, celix_properties_t *properties) |
Register a service to the Celix framework. More... | |
long | celix_bundleContext_registerService (celix_bundle_context_t *ctx, void *svc, const char *serviceName, celix_properties_t *properties) |
Register a service to the Celix framework. More... | |
long | celix_bundleContext_registerServiceFactoryAsync (celix_bundle_context_t *ctx, celix_service_factory_t *factory, const char *serviceName, celix_properties_t *props) |
Register a service factory in the framework. More... | |
long | celix_bundleContext_registerServiceFactory (celix_bundle_context_t *ctx, celix_service_factory_t *factory, const char *serviceName, celix_properties_t *props) |
Register a service factory in the framework. More... | |
long | celix_bundleContext_registerServiceWithOptionsAsync (celix_bundle_context_t *ctx, const celix_service_registration_options_t *opts) |
Register a service to the Celix framework using the provided service registration options. More... | |
long | celix_bundleContext_registerServiceWithOptions (celix_bundle_context_t *ctx, const celix_service_registration_options_t *opts) |
Register a service to the Celix framework using the provided service registration options. More... | |
void | celix_bundleContext_waitForAsyncRegistration (celix_bundle_context_t *ctx, long serviceId) |
Waits til the async service registration for the provided serviceId is done. More... | |
bool | celix_bundleContext_isServiceRegistered (celix_bundle_context_t *ctx, long serviceId) |
Checks whether a service for the provided service id is registered in the service registry. More... | |
void | celix_bundleContext_unregisterService (celix_bundle_context_t *ctx, long serviceId) |
Unregister the service or service factory with service id. More... | |
void | celix_bundleContext_unregisterServiceAsync (celix_bundle_context_t *ctx, long serviceId, void *doneData, void(*doneCallback)(void *doneData)) |
Unregister the service or service factory with service id. More... | |
void | celix_bundleContext_waitForAsyncUnregistration (celix_bundle_context_t *ctx, long serviceId) |
Waits til the async service unregistration for the provided serviceId is done. More... | |
long | celix_bundleContext_findService (celix_bundle_context_t *ctx, const char *serviceName) |
Finds the highest ranking service and returns the service id. More... | |
celix_array_list_t * | celix_bundleContext_findServices (celix_bundle_context_t *ctx, const char *serviceName) |
Finds the services with the provided service name and returns a list of the found service ids. More... | |
long | celix_bundleContext_findServiceWithOptions (celix_bundle_context_t *ctx, const celix_service_filter_options_t *opts) |
Finds the highest ranking service and returns the service id. More... | |
celix_array_list_t * | celix_bundleContext_findServicesWithOptions (celix_bundle_context_t *ctx, const celix_service_filter_options_t *opts) |
Finds the services conform the provider filter options and returns a list of the found service ids. More... | |
long | celix_bundleContext_trackServiceAsync (celix_bundle_context_t *ctx, const char *serviceName, void *callbackHandle, void(*set)(void *handle, void *svc)) |
Track the highest ranking service with the provided serviceName. More... | |
long | celix_bundleContext_trackService (celix_bundle_context_t *ctx, const char *serviceName, void *callbackHandle, void(*set)(void *handle, void *svc)) |
Track the highest ranking service with the provided serviceName. More... | |
long | celix_bundleContext_trackServicesAsync (celix_bundle_context_t *ctx, const char *serviceName, void *callbackHandle, void(*add)(void *handle, void *svc), void(*remove)(void *handle, void *svc)) |
Track services with the provided serviceName. More... | |
long | celix_bundleContext_trackServices (celix_bundle_context_t *ctx, const char *serviceName, void *callbackHandle, void(*add)(void *handle, void *svc), void(*remove)(void *handle, void *svc)) |
Track services with the provided serviceName. More... | |
long | celix_bundleContext_trackServicesWithOptionsAsync (celix_bundle_context_t *ctx, const celix_service_tracking_options_t *opts) |
Tracks services using the provided tracker options. More... | |
long | celix_bundleContext_trackServicesWithOptions (celix_bundle_context_t *ctx, const celix_service_tracking_options_t *opts) |
Tracks services using the provided tracker options. More... | |
void | celix_bundleContext_stopTrackerAsync (celix_bundle_context_t *ctx, long trackerId, void *doneCallbackData, void(*doneCallback)(void *doneCallbackData)) |
Stop the tracker with the provided track id. More... | |
void | celix_bundleContext_waitForAsyncTracker (celix_bundle_context_t *ctx, long trackerId) |
Wait for (async) creation of tracker. More... | |
void | celix_bundleContext_waitForAsyncStopTracker (celix_bundle_context_t *ctx, long trackerId) |
Wait for (async) stopping of tracking. More... | |
void | celix_bundleContext_stopTracker (celix_bundle_context_t *ctx, long trackerId) |
Stop the tracker with the provided track id. More... | |
bool | celix_bundleContext_useServiceWithId (celix_bundle_context_t *ctx, long serviceId, const char *serviceName, void *callbackHandle, void(*use)(void *handle, void *svc)) |
Use the service with the provided service id using the provided callback. The Celix framework will ensure that the targeted service cannot be removed during the callback. More... | |
bool | celix_bundleContext_useService (celix_bundle_context_t *ctx, const char *serviceName, void *callbackHandle, void(*use)(void *handle, void *svc)) |
Use the highest ranking service with the provided service name using the provided callback. More... | |
size_t | celix_bundleContext_useServices (celix_bundle_context_t *ctx, const char *serviceName, void *callbackHandle, void(*use)(void *handle, void *svc)) |
Use the services with the provided service name using the provided callback. More... | |
bool | celix_bundleContext_useServiceWithOptions (celix_bundle_context_t *ctx, const celix_service_use_options_t *opts) |
Use the highest ranking service satisfying the provided service filter options using the provided callback. More... | |
size_t | celix_bundleContext_useServicesWithOptions (celix_bundle_context_t *ctx, const celix_service_use_options_t *opts) |
Use the services with the provided service filter options using the provided callback. More... | |
celix_array_list_t * | celix_bundleContext_listBundles (celix_bundle_context_t *ctx) |
List the installed and started bundle ids. The bundle ids does not include the framework bundle (bundle id CELIX_FRAMEWORK_BUNDLE_ID). More... | |
celix_array_list_t * | celix_bundleContext_listInstalledBundles (celix_bundle_context_t *ctx) |
List the installed bundle ids. The bundle ids does not include the framework bundle (bundle id CELIX_FRAMEWORK_BUNDLE_ID). More... | |
bool | celix_bundleContext_isBundleInstalled (celix_bundle_context_t *ctx, long bndId) |
Check whether a bundle is installed. More... | |
bool | celix_bundleContext_isBundleActive (celix_bundle_context_t *ctx, long bndId) |
Check whether the bundle is active. More... | |
long | celix_bundleContext_installBundle (celix_bundle_context_t *ctx, const char *bundleLoc, bool autoStart) |
Install and optional start a bundle. Will silently ignore bundle ids < 0. More... | |
bool | celix_bundleContext_uninstallBundle (celix_bundle_context_t *ctx, long bndId) |
Uninstall the bundle with the provided bundle id. If needed the bundle will be stopped first. Will silently ignore bundle ids < 0. More... | |
bool | celix_bundleContext_stopBundle (celix_bundle_context_t *ctx, long bndId) |
Stop the bundle with the provided bundle id. Will silently ignore bundle ids < 0. More... | |
bool | celix_bundleContext_startBundle (celix_bundle_context_t *ctx, long bndId) |
Start the bundle with the provided bundle id. Will silently ignore bundle ids < 0. More... | |
char * | celix_bundleContext_getBundleSymbolicName (celix_bundle_context_t *ctx, long bndId) |
Returns the bundle symbolic name for the provided bundle id. The caller is owner of the return string. More... | |
long | celix_bundleContext_trackBundlesAsync (celix_bundle_context_t *ctx, void *callbackHandle, void(*onStarted)(void *handle, const celix_bundle_t *bundle), void(*onStopped)(void *handle, const celix_bundle_t *bundle)) |
Track bundles. More... | |
long | celix_bundleContext_trackBundles (celix_bundle_context_t *ctx, void *callbackHandle, void(*onStarted)(void *handle, const celix_bundle_t *bundle), void(*onStopped)(void *handle, const celix_bundle_t *bundle)) |
Track bundles. More... | |
long | celix_bundleContext_trackBundlesWithOptionsAsync (celix_bundle_context_t *ctx, const celix_bundle_tracking_options_t *opts) |
Tracks bundles using the provided bundle tracker options. More... | |
long | celix_bundleContext_trackBundlesWithOptions (celix_bundle_context_t *ctx, const celix_bundle_tracking_options_t *opts) |
Tracks bundles using the provided bundle tracker options. More... | |
bool | celix_bundleContext_useBundle (celix_bundle_context_t *ctx, long bundleId, void *callbackHandle, void(*use)(void *handle, const celix_bundle_t *bundle)) |
Use the bundle with the provided bundle id if it is in the active (started) state. More... | |
void | celix_bundleContext_useBundles (celix_bundle_context_t *ctx, void *callbackHandle, void(*use)(void *handle, const celix_bundle_t *bundle)) |
Use the currently active (started) bundles. More... | |
long | celix_bundleContext_trackServiceTrackersAsync (celix_bundle_context_t *ctx, const char *serviceName, void *callbackHandle, void(*trackerAdd)(void *handle, const celix_service_tracker_info_t *info), void(*trackerRemove)(void *handle, const celix_service_tracker_info_t *info), void *doneCallbackData, void(*doneCallback)(void *doneCallbackData)) |
Track the service tracker targeting the provided service name. More... | |
long | celix_bundleContext_trackServiceTrackers (celix_bundle_context_t *ctx, const char *serviceName, void *callbackHandle, void(*trackerAdd)(void *handle, const celix_service_tracker_info_t *info), void(*trackerRemove)(void *handle, const celix_service_tracker_info_t *info)) |
Track the service tracker targeting the provided service name. More... | |
celix_dependency_manager_t * | celix_bundleContext_getDependencyManager (celix_bundle_context_t *ctx) |
Gets the dependency manager for this bundle context. More... | |
void | celix_bundleContext_waitForEvents (celix_bundle_context_t *ctx) |
Wait until all Celix event for this bundle are completed. More... | |
celix_bundle_t * | celix_bundleContext_getBundle (const celix_bundle_context_t *ctx) |
Returns the bundle for this bundle context. More... | |
long | celix_bundleContext_getBundleId (const celix_bundle_context_t *ctx) |
Returns the bundle if for the bundle of this bundle context. More... | |
celix_framework_t * | celix_bundleContext_getFramework (const celix_bundle_context_t *ctx) |
void | celix_bundleContext_log (const celix_bundle_context_t *ctx, celix_log_level_e level, const char *format,...) |
Logs a message to Celix framework logger with the provided log level. More... | |
void | celix_bundleContext_vlog (const celix_bundle_context_t *ctx, celix_log_level_e level, const char *format, va_list formatArgs) |
Logs a message to Celix framework logger with the provided log level. More... | |
const char * | celix_bundleContext_getProperty (celix_bundle_context_t *ctx, const char *key, const char *defaultVal) |
Gets the config property - or environment variable if the config property does not exist - for the provided name. More... | |
long | celix_bundleContext_getPropertyAsLong (celix_bundle_context_t *ctx, const char *key, long defaultValue) |
Gets the config property as converts it to long. If the property is not a valid long, the defaultValue will be returned. The rest of the behaviour is the same as celix_bundleContext_getProperty. More... | |
double | celix_bundleContext_getPropertyAsDouble (celix_bundle_context_t *ctx, const char *key, double defaultValue) |
Gets the config property as converts it to double. If the property is not a valid double, the defaultValue will be returned. The rest of the behaviour is the same as celix_bundleContext_getProperty. More... | |
bool | celix_bundleContext_getPropertyAsBool (celix_bundle_context_t *ctx, const char *key, bool defaultValue) |
Gets the config property as converts it to bool. If the property is not a valid bool, the defaultValue will be returned. The rest of the behaviour is the same as celix_bundleContext_getProperty. More... | |
#define CELIX_EMPTY_BUNDLE_TRACKING_OPTIONS {.callbackHandle = NULL, .onInstalled = NULL, .onStarted = NULL, .onStopped = NULL, .onBundleEvent = NULL, .includeFrameworkBundle = false, .trackerCreatedCallbackData = NULL, .trackerCreatedCallback = NULL} |
C Macro to create a empty celix_service_filter_options_t type.
#define CELIX_EMPTY_SERVICE_FILTER_OPTIONS {.serviceName = NULL, .versionRange = NULL, .filter = NULL, .serviceLanguage = NULL, .ignoreServiceLanguage = false} |
C Macro to create a empty celix_service_filter_options_t type.
#define CELIX_EMPTY_SERVICE_REGISTRATION_OPTIONS |
C Macro to create a empty celix_service_registration_options_t type.
#define CELIX_EMPTY_SERVICE_TRACKING_OPTIONS |
C Macro to create a empty celix_service_tracking_options_t type.
#define CELIX_EMPTY_SERVICE_USE_OPTIONS |
C Macro to create a empty celix_service_use_options_t type.
#define CELIX_OPTS_INIT |
Init macro so that the opts are correctly initialized for C++ compilers
#define CELIX_SERVICE_USE_DIRECT (1) |
Call the provided callbacks from the caller thread directly if set, otherwise the callbacks will be called from the Celix event loop (most likely indirectly). Note that using blocking service in the Celix event loop is generally a bad idea, which should be avoided if possible.
#define CELIX_SERVICE_USE_SOD (2) |
Whether "service on demand" pattern is supported when CELIX_SERVICE_USE_DIRECT is set. Note that it has no effect in indirect mode, in which case "service on demand" is supported.
typedef struct celix_bundle_tracker_options celix_bundle_tracking_options_t |
The Service Bundle Tracking options can be used to fine tune the requested bundle tracker options.
typedef struct celix_service_filter_options celix_service_filter_options_t |
Service filter options which can be used to query for certain services.
Service Registration Options when registering services to the Celix framework.
typedef struct celix_service_tracker_info celix_service_tracker_info_t |
Service Tracker Info provided to the service tracker tracker callbacks.
typedef struct celix_service_tracking_options celix_service_tracking_options_t |
Service Tracker Options used to fine tune which services to track and the callback to be used for the tracked services.
typedef struct celix_service_use_options celix_service_use_options_t |
Service Use Options used to fine tune which services to use and which callbacks to use.
long celix_bundleContext_findService | ( | celix_bundle_context_t * | ctx, |
const char * | serviceName | ||
) |
Finds the highest ranking service and returns the service id.
ctx | The bundle context |
serviceName | The required service name |
celix_array_list_t* celix_bundleContext_findServices | ( | celix_bundle_context_t * | ctx, |
const char * | serviceName | ||
) |
Finds the services with the provided service name and returns a list of the found service ids.
ctx | The bundle context |
serviceName | The required service name |
celix_array_list_t* celix_bundleContext_findServicesWithOptions | ( | celix_bundle_context_t * | ctx, |
const celix_service_filter_options_t * | opts | ||
) |
Finds the services conform the provider filter options and returns a list of the found service ids.
ctx | The bundle context |
opts | The pointer to the filter options. |
long celix_bundleContext_findServiceWithOptions | ( | celix_bundle_context_t * | ctx, |
const celix_service_filter_options_t * | opts | ||
) |
Finds the highest ranking service and returns the service id.
ctx | The bundle context |
opts | The pointer to the filter options. |
celix_bundle_t* celix_bundleContext_getBundle | ( | const celix_bundle_context_t * | ctx | ) |
Returns the bundle for this bundle context.
long celix_bundleContext_getBundleId | ( | const celix_bundle_context_t * | ctx | ) |
Returns the bundle if for the bundle of this bundle context.
char* celix_bundleContext_getBundleSymbolicName | ( | celix_bundle_context_t * | ctx, |
long | bndId | ||
) |
Returns the bundle symbolic name for the provided bundle id. The caller is owner of the return string.
ctx | The bundle context |
bndId | The bundle id to retrieve the symbolic name for. |
celix_dependency_manager_t* celix_bundleContext_getDependencyManager | ( | celix_bundle_context_t * | ctx | ) |
Gets the dependency manager for this bundle context.
celix_framework_t* celix_bundleContext_getFramework | ( | const celix_bundle_context_t * | ctx | ) |
const char* celix_bundleContext_getProperty | ( | celix_bundle_context_t * | ctx, |
const char * | key, | ||
const char * | defaultVal | ||
) |
Gets the config property - or environment variable if the config property does not exist - for the provided name.
key | The key of the property to receive. |
defaultVal | The default value to use if the property is not found (can be NULL). |
bool celix_bundleContext_getPropertyAsBool | ( | celix_bundle_context_t * | ctx, |
const char * | key, | ||
bool | defaultValue | ||
) |
Gets the config property as converts it to bool. If the property is not a valid bool, the defaultValue will be returned. The rest of the behaviour is the same as celix_bundleContext_getProperty.
key | The key of the property to receive. |
defaultVal | The default value to use if the property is not found. |
double celix_bundleContext_getPropertyAsDouble | ( | celix_bundle_context_t * | ctx, |
const char * | key, | ||
double | defaultValue | ||
) |
Gets the config property as converts it to double. If the property is not a valid double, the defaultValue will be returned. The rest of the behaviour is the same as celix_bundleContext_getProperty.
key | The key of the property to receive. |
defaultVal | The default value to use if the property is not found. |
long celix_bundleContext_getPropertyAsLong | ( | celix_bundle_context_t * | ctx, |
const char * | key, | ||
long | defaultValue | ||
) |
Gets the config property as converts it to long. If the property is not a valid long, the defaultValue will be returned. The rest of the behaviour is the same as celix_bundleContext_getProperty.
key | The key of the property to receive. |
defaultVal | The default value to use if the property is not found. |
long celix_bundleContext_installBundle | ( | celix_bundle_context_t * | ctx, |
const char * | bundleLoc, | ||
bool | autoStart | ||
) |
Install and optional start a bundle. Will silently ignore bundle ids < 0.
If this function is called on the Celix event thread and autoStart is true, the actual starting of the bundle will be done async and on a separate thread. If this function is called from a different thread than the Celix event thread and the autoStart is true, then the function will return after the bundle is started.
ctx | The bundle context |
bundleLoc | The bundle location to the bundle zip file. |
autoStart | If the bundle should also be started. |
bool celix_bundleContext_isBundleActive | ( | celix_bundle_context_t * | ctx, |
long | bndId | ||
) |
Check whether the bundle is active.
ctx | The bundle context. |
bndId | The bundle id to check |
bool celix_bundleContext_isBundleInstalled | ( | celix_bundle_context_t * | ctx, |
long | bndId | ||
) |
Check whether a bundle is installed.
ctx | The bundle context. |
bndId | The bundle id to check |
bool celix_bundleContext_isServiceRegistered | ( | celix_bundle_context_t * | ctx, |
long | serviceId | ||
) |
Checks whether a service for the provided service id is registered in the service registry.
Note return false if the service for the provided service id is still pending in the event loop. Silently ignore service ids < 0 (returns false).
Returns true if the service is registered in the service registry.
celix_array_list_t* celix_bundleContext_listBundles | ( | celix_bundle_context_t * | ctx | ) |
List the installed and started bundle ids. The bundle ids does not include the framework bundle (bundle id CELIX_FRAMEWORK_BUNDLE_ID).
ctx | The bundle context. |
celix_array_list_t* celix_bundleContext_listInstalledBundles | ( | celix_bundle_context_t * | ctx | ) |
List the installed bundle ids. The bundle ids does not include the framework bundle (bundle id CELIX_FRAMEWORK_BUNDLE_ID).
ctx | The bundle context. |
void celix_bundleContext_log | ( | const celix_bundle_context_t * | ctx, |
celix_log_level_e | level, | ||
const char * | format, | ||
... | |||
) |
Logs a message to Celix framework logger with the provided log level.
ctx | The bundle context |
level | The log level to use |
format | printf style format string |
... | printf style format arguments |
long celix_bundleContext_registerService | ( | celix_bundle_context_t * | ctx, |
void * | svc, | ||
const char * | serviceName, | ||
celix_properties_t * | properties | ||
) |
Register a service to the Celix framework.
Note: Please use the celix_bundleContext_registerServiceAsync instead.
ctx | The bundle context |
svc | the service object. Normally a pointer to a service struct (i.e. a struct with function pointers) |
serviceName | the service name, cannot be NULL |
properties | The meta properties associated with the service. The service registration will take ownership of the properties (i.e. no destroy needed) |
long celix_bundleContext_registerServiceAsync | ( | celix_bundle_context_t * | ctx, |
void * | svc, | ||
const char * | serviceName, | ||
celix_properties_t * | properties | ||
) |
Register a service to the Celix framework.
The service will be registered async on the Celix event loop thread. This means that service registration is (probably) not yet concluded when this function returns, but is added to the event loop. Use celix_bundleContext_waitForAsyncRegistration to synchronise with the actual service registration in the framework's service registry.
ctx | The bundle context |
svc | the service object. Normally a pointer to a service struct (i.e. a struct with function pointers) |
serviceName | the service name, cannot be NULL |
properties | The meta properties associated with the service. The service registration will take ownership of the properties (i.e. no destroy needed) |
long celix_bundleContext_registerServiceFactory | ( | celix_bundle_context_t * | ctx, |
celix_service_factory_t * | factory, | ||
const char * | serviceName, | ||
celix_properties_t * | props | ||
) |
Register a service factory in the framework.
The service factory will be called for every bundle requesting/de-requesting a service. This gives the provider the option to create bundle specific service instances. Note: Please use the celix_bundleContext_registerServiceFactoryAsync instead.
When a service is requested for a bundle the getService of the factory service will be called. This function must return a valid pointer to a service conform the registered service name or NULL. When a service in no longer needed for a bundle (e.g. ending the useService(s) calls or when a service tracker is stopped) the ungetService function of the service factory will be called.
ctx | The bundle context |
factory | The pointer to the factory service. |
serviceName | The required service name of the services this factory will produce. |
properties | The optional service factory properties. For a service consumer this will be seen as the service properties. |
long celix_bundleContext_registerServiceFactoryAsync | ( | celix_bundle_context_t * | ctx, |
celix_service_factory_t * | factory, | ||
const char * | serviceName, | ||
celix_properties_t * | props | ||
) |
Register a service factory in the framework.
The service factory will be called for every bundle requesting/de-requesting a service. This gives the provider the option to create bundle specific service instances.
When a service is requested for a bundle the getService of the factory service will be called. This function must return a valid pointer to a service conform the registered service name or NULL. When a service in no longer needed for a bundle (e.g. ending the useService(s) calls or when a service tracker is stopped) the ungetService function of the service factory will be called.
The service will be registered async on the Celix event loop thread. This means that service registration is (probably) not yet concluded when this function returns, but is added to the event loop. Use celix_bundleContext_waitForAsyncRegistration to synchronise with the actual service registration in the framework's service registry.
ctx | The bundle context |
factory | The pointer to the factory service. |
serviceName | The required service name of the services this factory will produce. |
properties | The optional service factory properties. For a service consumer this will be seen as the service properties. |
long celix_bundleContext_registerServiceWithOptions | ( | celix_bundle_context_t * | ctx, |
const celix_service_registration_options_t * | opts | ||
) |
Register a service to the Celix framework using the provided service registration options.
Note: Please use the celix_bundleContext_registerServiceAsyncWithOptions instead.
ctx | The bundle context |
opts | The pointer to the registration options. The options are only in the during registration call. |
long celix_bundleContext_registerServiceWithOptionsAsync | ( | celix_bundle_context_t * | ctx, |
const celix_service_registration_options_t * | opts | ||
) |
Register a service to the Celix framework using the provided service registration options.
The service will be registered async on the Celix event loop thread. This means that service registration is (probably) not yet concluded when this function returns, but is added to the event loop.. Use celix_bundleContext_waitForAsyncRegistration to synchronise with the actual service registration in the framework's service registry.
ctx | The bundle context |
opts | The pointer to the registration options. The options are only in the during registration call. |
bool celix_bundleContext_startBundle | ( | celix_bundle_context_t * | ctx, |
long | bndId | ||
) |
Start the bundle with the provided bundle id. Will silently ignore bundle ids < 0.
If this function is called on the Celix event thread, the actual starting of the bundle will be done async and on a separate thread. If this function is called from a different thread than the Celix event thread, then the function will return after the bundle is started.
ctx | The bundle context |
bndId | The bundle id to start. |
bool celix_bundleContext_stopBundle | ( | celix_bundle_context_t * | ctx, |
long | bndId | ||
) |
Stop the bundle with the provided bundle id. Will silently ignore bundle ids < 0.
If this function is called on the Celix event thread, the actual stopping of the bundle will be done async and on a separate thread. If this function is called from a different thread than the Celix event thread, then the function will return after the bundle is stopped.
ctx | The bundle context |
bndId | The bundle id to stop. |
void celix_bundleContext_stopTracker | ( | celix_bundle_context_t * | ctx, |
long | trackerId | ||
) |
Stop the tracker with the provided track id.
Could be a service tracker, bundle tracker or service tracker tracker. Only works for the trackers owned by the bundle of the bundle context. Note: Please use the celix_bundleContext_registerServiceFactoryAsync instead.
Will log a error if the provided tracker id is unknown. Will silently ignore trackerId < 0.
void celix_bundleContext_stopTrackerAsync | ( | celix_bundle_context_t * | ctx, |
long | trackerId, | ||
void * | doneCallbackData, | ||
void(*)(void *doneCallbackData) | doneCallback | ||
) |
Stop the tracker with the provided track id.
Could be a service tracker, bundle tracker or service tracker tracker. Only works for the trackers owned by the bundle of the bundle context.
The service tracker will be destroyed async on the Celix event loop thread. This means that the function can return before the tracker is destroyed.
if the doneCallback is not NULL, this will be called when the destruction of the service tracker is done. (will be called on the event loop thread).
Will log a error if the provided tracker id is unknown. Will silently ignore trackerId < 0.
long celix_bundleContext_trackBundles | ( | celix_bundle_context_t * | ctx, |
void * | callbackHandle, | ||
void(*)(void *handle, const celix_bundle_t *bundle) | onStarted, | ||
void(*)(void *handle, const celix_bundle_t *bundle) | onStopped | ||
) |
Track bundles.
The add bundle callback will also be called for already installed bundles.
Note: please use celix_bundleContext_trackBundlesAsync instead.
ctx | The bundle context. |
callbackHandle | The data pointer, which will be used in the callbacks |
add | The callback which will be called for started bundles. |
remove | The callback which will be called when bundles are stopped. |
long celix_bundleContext_trackBundlesAsync | ( | celix_bundle_context_t * | ctx, |
void * | callbackHandle, | ||
void(*)(void *handle, const celix_bundle_t *bundle) | onStarted, | ||
void(*)(void *handle, const celix_bundle_t *bundle) | onStopped | ||
) |
Track bundles.
The add bundle callback will also be called for already installed bundles.
The bundle tracker will be created async on the Celix event loop thread. This means that the function can return before the tracker is created.
ctx | The bundle context. |
callbackHandle | The data pointer, which will be used in the callbacks |
add | The callback which will be called for started bundles. |
remove | The callback which will be called when bundles are stopped. |
long celix_bundleContext_trackBundlesWithOptions | ( | celix_bundle_context_t * | ctx, |
const celix_bundle_tracking_options_t * | opts | ||
) |
Tracks bundles using the provided bundle tracker options.
The tracker options are only using during this call and can safely be freed/reused after this call returns. (i.e. can be on the stack)
Note: please use celix_bundleContext_trackBundlesWithOptionsAsync instead;
ctx | The bundle context. |
opts | The pointer to the bundle tracker options. |
long celix_bundleContext_trackBundlesWithOptionsAsync | ( | celix_bundle_context_t * | ctx, |
const celix_bundle_tracking_options_t * | opts | ||
) |
Tracks bundles using the provided bundle tracker options.
The tracker options are only using during this call and can safely be freed/reused after this call returns. (i.e. can be on the stack)
The bundle tracker will be created async on the Celix event loop thread. This means that the function can return before the tracker is created.
ctx | The bundle context. |
opts | The pointer to the bundle tracker options. |
long celix_bundleContext_trackService | ( | celix_bundle_context_t * | ctx, |
const char * | serviceName, | ||
void * | callbackHandle, | ||
void(*)(void *handle, void *svc) | set | ||
) |
Track the highest ranking service with the provided serviceName.
The highest ranking services will used for the callback. If a new and higher ranking services the callback with be called again with the new service. If a service is removed a the callback with be called with next highest ranking service or NULL as service. Note: Please use the celix_bundleContext_trackServiceAsync instead.
ctx | The bundle context. |
serviceName | The required service name to track. If NULL is all service are tracked. |
callbackHandle | The data pointer, which will be used in the callbacks |
set | is a required callback, which will be called when a new highest ranking service is set. |
long celix_bundleContext_trackServiceAsync | ( | celix_bundle_context_t * | ctx, |
const char * | serviceName, | ||
void * | callbackHandle, | ||
void(*)(void *handle, void *svc) | set | ||
) |
Track the highest ranking service with the provided serviceName.
The highest ranking services will used for the callback. If a new and higher ranking services the callback with be called again with the new service. If a service is removed a the callback with be called with next highest ranking service or NULL as service.
The service tracker will be created async on the Celix event loop thread. This means that the function can return before the tracker is created.
ctx | The bundle context. |
serviceName | The required service name to track. If NULL is all service are tracked. |
callbackHandle | The data pointer, which will be used in the callbacks |
set | is a required callback, which will be called when a new highest ranking service is set. |
long celix_bundleContext_trackServices | ( | celix_bundle_context_t * | ctx, |
const char * | serviceName, | ||
void * | callbackHandle, | ||
void(*)(void *handle, void *svc) | add, | ||
void(*)(void *handle, void *svc) | remove | ||
) |
Track services with the provided serviceName.
Note: Please use the celix_bundleContext_trackServicesAsync instead.
ctx | The bundle context. |
serviceName | The required service name to track If NULL is all service are tracked. |
callbackHandle | The data pointer, which will be used in the callbacks |
add | is a required callback, which will be called when a service is added and initially for the existing service. |
remove | is a required callback, which will be called when a service is removed |
long celix_bundleContext_trackServicesAsync | ( | celix_bundle_context_t * | ctx, |
const char * | serviceName, | ||
void * | callbackHandle, | ||
void(*)(void *handle, void *svc) | add, | ||
void(*)(void *handle, void *svc) | remove | ||
) |
Track services with the provided serviceName.
The service tracker will be created async on the Celix event loop thread. This means that the function can return before the tracker is created.
ctx | The bundle context. |
serviceName | The required service name to track If NULL is all service are tracked. |
callbackHandle | The data pointer, which will be used in the callbacks |
add | is a required callback, which will be called when a service is added and initially for the existing service. |
remove | is a required callback, which will be called when a service is removed |
long celix_bundleContext_trackServicesWithOptions | ( | celix_bundle_context_t * | ctx, |
const celix_service_tracking_options_t * | opts | ||
) |
Tracks services using the provided tracker options.
The tracker options are only using during this call and can safely be freed/reused after this call returns. Note: Please use the celix_bundleContext_registerServiceFactoryAsync instead.
ctx | The bundle context. |
opts | The pointer to the tracker options. |
long celix_bundleContext_trackServicesWithOptionsAsync | ( | celix_bundle_context_t * | ctx, |
const celix_service_tracking_options_t * | opts | ||
) |
Tracks services using the provided tracker options.
The tracker options are only using during this call and can safely be freed/reused after this call returns.
The service tracker will be created async on the Celix event loop thread. This means that the function can return before the tracker is created.
ctx | The bundle context. |
opts | The pointer to the tracker options. |
long celix_bundleContext_trackServiceTrackers | ( | celix_bundle_context_t * | ctx, |
const char * | serviceName, | ||
void * | callbackHandle, | ||
void(*)(void *handle, const celix_service_tracker_info_t *info) | trackerAdd, | ||
void(*)(void *handle, const celix_service_tracker_info_t *info) | trackerRemove | ||
) |
Track the service tracker targeting the provided service name.
This can be used to track if there is an interest in a certain service and ad-hoc act on that interest.
Note that the celix_service_tracker_info_t pointer in the trackerAdd/trackerRemove callbacks are only valid during the callback.
Note: Please use celix_bundleContext_trackServiceTrackersAsync instead.
This tracker can be stopped with the celix_bundleContext_stopTracker function.
ctx | The bundle context |
serviceName | The target service name for the service tracker to track. If NULL is provided, add/remove callbacks will be called for all service trackers in the framework. |
callbackHandle | The callback handle which will be provided as handle in the trackerAdd and trackerRemove callback. |
trackerAdd | Called when a service tracker is added, which tracks the provided service name. Will also be called for all existing service tracker when this tracker is started. |
trackerRemove | Called when a service tracker is removed, which tracks the provided service name |
long celix_bundleContext_trackServiceTrackersAsync | ( | celix_bundle_context_t * | ctx, |
const char * | serviceName, | ||
void * | callbackHandle, | ||
void(*)(void *handle, const celix_service_tracker_info_t *info) | trackerAdd, | ||
void(*)(void *handle, const celix_service_tracker_info_t *info) | trackerRemove, | ||
void * | doneCallbackData, | ||
void(*)(void *doneCallbackData) | doneCallback | ||
) |
Track the service tracker targeting the provided service name.
This can be used to track if there is an interest in a certain service and ad-hoc act on that interest.
Note that the celix_service_tracker_info_t pointer in the trackerAdd/trackerRemove callbacks are only valid during the callback.
This tracker can be stopped with the celix_bundleContext_stopTracker function.
The service tracker tracker will be created async on the Celix event loop thread. This means that the function can return before the tracker is created.
ctx | The bundle context |
serviceName | The target service name for the service tracker to track. If NULL is provided, add/remove callbacks will be called for all service trackers in the framework. |
callbackHandle | The callback handle which will be provided as handle in the trackerAdd and trackerRemove callback. |
trackerAdd | Called when a service tracker is added, which tracks the provided service name. Will also be called for all existing service tracker when this tracker is started. |
trackerRemove | Called when a service tracker is removed, which tracks the provided service name |
doneCallbackData | call back data argument provided to the done callback function. |
doneCallback | If not NULL will be called when the service tracker tracker is created. If a asyns track service is combined with a sync stop tracker, it can happen that "stop tracker" happens before the "create tracker" event is processed. In this case the doneCallback will not be called. |
bool celix_bundleContext_uninstallBundle | ( | celix_bundle_context_t * | ctx, |
long | bndId | ||
) |
Uninstall the bundle with the provided bundle id. If needed the bundle will be stopped first. Will silently ignore bundle ids < 0.
If this function is called on the Celix event thread, the actual stopping of the bundle will be done async and on a separate thread. If this function is called from a different thread than the Celix event thread, then the function will return after the bundle is stopped.
ctx | The bundle context |
bndId | The bundle id to uninstall. |
void celix_bundleContext_unregisterService | ( | celix_bundle_context_t * | ctx, |
long | serviceId | ||
) |
Unregister the service or service factory with service id.
The service will only be unregistered if the bundle of the bundle context is the owner of the service.
Will log an error if service id is unknown. Will silently ignore services ids < 0.
ctx | The bundle context |
serviceId | The service id |
void celix_bundleContext_unregisterServiceAsync | ( | celix_bundle_context_t * | ctx, |
long | serviceId, | ||
void * | doneData, | ||
void(*)(void *doneData) | doneCallback | ||
) |
Unregister the service or service factory with service id.
The service will only be unregistered if the bundle of the bundle context is the owner of the service.
The service will be umregistered async on the Celix event loop thread. This means that service unregistration is (probably) not yet concluded when this function returns. Use celix_bundleContext_waitForAsyncUnregistration to synchronise with the actual service unregistration in the framework's service registry.
ctx | The bundle context |
serviceId | The service id |
doneData | The data used on the doneCallback (if present) |
doneCallback | If not NULL, this callback will be called when the unregisration is done. (will be called on the event loop thread) |
bool celix_bundleContext_useBundle | ( | celix_bundle_context_t * | ctx, |
long | bundleId, | ||
void * | callbackHandle, | ||
void(*)(void *handle, const celix_bundle_t *bundle) | use | ||
) |
Use the bundle with the provided bundle id if it is in the active (started) state.
The provided callback will be called if the bundle is found and in the active (started) state.
ctx | The bundle context. |
bundleId | The bundle id. |
callbackHandle | The data pointer, which will be used in the callbacks |
use | The callback which will be called for the currently started bundles. The bundle pointers are only guaranteed to be valid during the callback. |
void celix_bundleContext_useBundles | ( | celix_bundle_context_t * | ctx, |
void * | callbackHandle, | ||
void(*)(void *handle, const celix_bundle_t *bundle) | use | ||
) |
Use the currently active (started) bundles.
The provided callback will be called for all the currently started bundles (excluding the framework bundle).
ctx | The bundle context. |
callbackHandle | The data pointer, which will be used in the callbacks |
use | The callback which will be called for the currently started bundles. The bundle pointers are only guaranteed to be valid during the callback. |
bool celix_bundleContext_useService | ( | celix_bundle_context_t * | ctx, |
const char * | serviceName, | ||
void * | callbackHandle, | ||
void(*)(void *handle, void *svc) | use | ||
) |
Use the highest ranking service with the provided service name using the provided callback.
The Celix framework will ensure that the targeted service cannot be removed during the callback.
The svc is should only be considered valid during the callback. If no service is found, the callback will not be invoked and this function will return false immediately.
This function will block until the callback is finished. As result it is possible to provide callback data from the stack.
ctx | The bundle context |
serviceName | the required service name. |
callbackHandle | The data pointer, which will be used in the callbacks |
use | The callback, which will be called when service is retrieved. |
size_t celix_bundleContext_useServices | ( | celix_bundle_context_t * | ctx, |
const char * | serviceName, | ||
void * | callbackHandle, | ||
void(*)(void *handle, void *svc) | use | ||
) |
Use the services with the provided service name using the provided callback.
The Celix framework will ensure that the targeted service cannot be removed during the callback.
The svc is should only be considered valid during the callback. If no service is found, the callback will not be invoked and this function will return 0 immediately.
This function will block until the callback is finished. As result it is possible to provide callback data from the stack.
ctx | The bundle context |
serviceName | the required service name. |
callbackHandle | The data pointer, which will be used in the callbacks |
use | The callback, which will be called for every service found. |
size_t celix_bundleContext_useServicesWithOptions | ( | celix_bundle_context_t * | ctx, |
const celix_service_use_options_t * | opts | ||
) |
Use the services with the provided service filter options using the provided callback.
The Celix framework will ensure that the targeted service cannot be removed during the callback.
The svc is should only be considered valid during the callback. If no service is found, the callback will not be invoked and this function will return 0 immediately. Note that waitTimeoutInSeconds in opts has no effect.
This function will block until the callback is finished. As result it is possible to provide callback data from the stack.
ctx | The bundle context. |
opts | The required options. Note that the serviceName is required. |
bool celix_bundleContext_useServiceWithId | ( | celix_bundle_context_t * | ctx, |
long | serviceId, | ||
const char * | serviceName, | ||
void * | callbackHandle, | ||
void(*)(void *handle, void *svc) | use | ||
) |
Use the service with the provided service id using the provided callback. The Celix framework will ensure that the targeted service cannot be removed during the callback.
The svc is should only be considered valid during the callback. If no service is found, the callback will not be invoked and this function will return false immediately.
This function will block until the callback is finished. As result it is possible to provide callback data from the stack.
ctx | The bundle context |
serviceId | the service id. |
serviceName | the service name of the service. Should match with the registered service name of the provided service id (sanity check) |
callbackHandle | The data pointer, which will be used in the callbacks |
use | The callback, which will be called when service is retrieved. |
bool | returns true if a service was found. |
bool celix_bundleContext_useServiceWithOptions | ( | celix_bundle_context_t * | ctx, |
const celix_service_use_options_t * | opts | ||
) |
Use the highest ranking service satisfying the provided service filter options using the provided callback.
The Celix framework will ensure that the targeted service cannot be removed during the callback.
The svc is should only be considered valid during the callback. If no service is found the callback will not be invoked. In such cases, if a non-zero waitTimeoutInSeconds is specified in opts, this function will block until the timeout is expired or when at least one service is found, otherwise it will return false immediately.
This function will block until the callback is finished. As result it is possible to provide callback data from the stack.
ctx | The bundle context. |
opts | The required options. Note that the serviceName is required. |
void celix_bundleContext_vlog | ( | const celix_bundle_context_t * | ctx, |
celix_log_level_e | level, | ||
const char * | format, | ||
va_list | formatArgs | ||
) |
Logs a message to Celix framework logger with the provided log level.
void celix_bundleContext_waitForAsyncRegistration | ( | celix_bundle_context_t * | ctx, |
long | serviceId | ||
) |
Waits til the async service registration for the provided serviceId is done.
Silently ignore service ids < 0. Will directly return if there is no pending service registration for the provided service id.
void celix_bundleContext_waitForAsyncStopTracker | ( | celix_bundle_context_t * | ctx, |
long | trackerId | ||
) |
Wait for (async) stopping of tracking.
void celix_bundleContext_waitForAsyncTracker | ( | celix_bundle_context_t * | ctx, |
long | trackerId | ||
) |
Wait for (async) creation of tracker.
void celix_bundleContext_waitForAsyncUnregistration | ( | celix_bundle_context_t * | ctx, |
long | serviceId | ||
) |
Waits til the async service unregistration for the provided serviceId is done.
Silently ignore service < 0.
void celix_bundleContext_waitForEvents | ( | celix_bundle_context_t * | ctx | ) |
Wait until all Celix event for this bundle are completed.