Apache Celix  2.3.0
An implementation of the OSGi specification adapted to C and C++
Classes | Macros | Typedefs | Functions
celix_bundle_context.h File Reference
#include "celix_types.h"
#include "celix_service_factory.h"
#include "celix_properties.h"
#include "celix_array_list.h"
#include "celix_filter.h"
Include dependency graph for celix_bundle_context.h:
This graph shows which files directly or indirectly include this file:

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...
 

Macro Definition Documentation

◆ CELIX_EMPTY_BUNDLE_TRACKING_OPTIONS

#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.

◆ CELIX_EMPTY_SERVICE_FILTER_OPTIONS

#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.

◆ CELIX_EMPTY_SERVICE_REGISTRATION_OPTIONS

#define CELIX_EMPTY_SERVICE_REGISTRATION_OPTIONS
Value:
{ .svc = NULL, \
.factory = NULL, \
.serviceName = NULL, \
.properties = NULL, \
.serviceLanguage = NULL, \
.serviceVersion = NULL, \
.asyncData = NULL, \
.asyncCallback = NULL }

C Macro to create a empty celix_service_registration_options_t type.

◆ CELIX_EMPTY_SERVICE_TRACKING_OPTIONS

#define CELIX_EMPTY_SERVICE_TRACKING_OPTIONS
Value:
{ .filter.serviceName = NULL, \
.filter.versionRange = NULL, \
.filter.filter = NULL, \
.filter.serviceLanguage = NULL, \
.filter.ignoreServiceLanguage = false, \
.callbackHandle = NULL, \
.set = NULL, \
.add = NULL, \
.remove = NULL, \
.setWithProperties = NULL, \
.addWithProperties = NULL, \
.removeWithProperties = NULL, \
.setWithOwner = NULL, \
.addWithOwner = NULL, \
.removeWithOwner = NULL, \
.trackerCreatedCallbackData = NULL, \
.trackerCreatedCallback = NULL }

C Macro to create a empty celix_service_tracking_options_t type.

◆ CELIX_EMPTY_SERVICE_USE_OPTIONS

#define CELIX_EMPTY_SERVICE_USE_OPTIONS
Value:
{.filter.serviceName = NULL, \
.filter.versionRange = NULL, \
.filter.filter = NULL, \
.filter.serviceLanguage = NULL, \
.waitTimeoutInSeconds = 0.0F, \
.callbackHandle = NULL, \
.use = NULL, \
.useWithProperties = NULL, \
.useWithOwner = NULL, \
.flags=0}

C Macro to create a empty celix_service_use_options_t type.

◆ CELIX_OPTS_INIT

#define CELIX_OPTS_INIT

Init macro so that the opts are correctly initialized for C++ compilers

◆ CELIX_SERVICE_USE_DIRECT

#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.

◆ CELIX_SERVICE_USE_SOD

#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 Documentation

◆ celix_bundle_tracking_options_t

The Service Bundle Tracking options can be used to fine tune the requested bundle tracker options.

◆ celix_service_filter_options_t

Service filter options which can be used to query for certain services.

◆ celix_service_registration_options_t

Service Registration Options when registering services to the Celix framework.

◆ celix_service_tracker_info_t

Service Tracker Info provided to the service tracker tracker callbacks.

◆ 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.

◆ celix_service_use_options_t

Service Use Options used to fine tune which services to use and which callbacks to use.

Function Documentation

◆ celix_bundleContext_findService()

long celix_bundleContext_findService ( celix_bundle_context_t *  ctx,
const char *  serviceName 
)

Finds the highest ranking service and returns the service id.

Parameters
ctxThe bundle context
serviceNameThe required service name
Returns
If found a valid service id (>= 0) if not found -1.

◆ celix_bundleContext_findServices()

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.

Parameters
ctxThe bundle context
serviceNameThe required service name
Returns
A array list with as value a long int.

◆ celix_bundleContext_findServicesWithOptions()

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.

Parameters
ctxThe bundle context
optsThe pointer to the filter options.
Returns
A array list with as value a long int.

◆ celix_bundleContext_findServiceWithOptions()

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.

Parameters
ctxThe bundle context
optsThe pointer to the filter options.
Returns
If found a valid service id (>= 0) if not found -1.

◆ celix_bundleContext_getBundle()

celix_bundle_t* celix_bundleContext_getBundle ( const celix_bundle_context_t *  ctx)

Returns the bundle for this bundle context.

◆ celix_bundleContext_getBundleId()

long celix_bundleContext_getBundleId ( const celix_bundle_context_t *  ctx)

Returns the bundle if for the bundle of this bundle context.

◆ celix_bundleContext_getBundleSymbolicName()

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.

Parameters
ctxThe bundle context
bndIdThe bundle id to retrieve the symbolic name for.
Returns
The bundle symbolic name or NULL if the bundle for the provided bundle id does not exist.

◆ celix_bundleContext_getDependencyManager()

celix_dependency_manager_t* celix_bundleContext_getDependencyManager ( celix_bundle_context_t *  ctx)

Gets the dependency manager for this bundle context.

Returns
the dependency manager or NULL if unsuccessful.

◆ celix_bundleContext_getFramework()

celix_framework_t* celix_bundleContext_getFramework ( const celix_bundle_context_t *  ctx)

◆ celix_bundleContext_getProperty()

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.

Parameters
keyThe key of the property to receive.
defaultValThe default value to use if the property is not found (can be NULL).
Returns
The property value for the provided key or the provided defaultValue is the key is not found.

◆ celix_bundleContext_getPropertyAsBool()

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.

Parameters
keyThe key of the property to receive.
defaultValThe default value to use if the property is not found.
Returns
The property value for the provided key or the provided defaultValue is the key is not found.

◆ celix_bundleContext_getPropertyAsDouble()

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.

Parameters
keyThe key of the property to receive.
defaultValThe default value to use if the property is not found.
Returns
The property value for the provided key or the provided defaultValue is the key is not found.

◆ celix_bundleContext_getPropertyAsLong()

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.

Parameters
keyThe key of the property to receive.
defaultValThe default value to use if the property is not found.
Returns
The property value for the provided key or the provided defaultValue is the key is not found.

◆ celix_bundleContext_installBundle()

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.

Parameters
ctxThe bundle context
bundleLocThe bundle location to the bundle zip file.
autoStartIf the bundle should also be started.
Returns
the bundleId (>= 0) or < 0 if the bundle could not be installed and possibly started.

◆ celix_bundleContext_isBundleActive()

bool celix_bundleContext_isBundleActive ( celix_bundle_context_t *  ctx,
long  bndId 
)

Check whether the bundle is active.

Parameters
ctxThe bundle context.
bndIdThe bundle id to check
Returns
true if the bundle is installed and active.

◆ celix_bundleContext_isBundleInstalled()

bool celix_bundleContext_isBundleInstalled ( celix_bundle_context_t *  ctx,
long  bndId 
)

Check whether a bundle is installed.

Parameters
ctxThe bundle context.
bndIdThe bundle id to check
Returns
true if the bundle is installed.

◆ celix_bundleContext_isServiceRegistered()

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_bundleContext_listBundles()

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).

Parameters
ctxThe bundle context.
Returns
A array with bundle ids (long). The caller is responsible for destroying the array.

◆ celix_bundleContext_listInstalledBundles()

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).

Parameters
ctxThe bundle context.
Returns
A array with bundle ids (long). The caller is responsible for destroying the array.

◆ celix_bundleContext_log()

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.

Parameters
ctxThe bundle context
levelThe log level to use
formatprintf style format string
...printf style format arguments

◆ celix_bundleContext_registerService()

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.

Parameters
ctxThe bundle context
svcthe service object. Normally a pointer to a service struct (i.e. a struct with function pointers)
serviceNamethe service name, cannot be NULL
propertiesThe meta properties associated with the service. The service registration will take ownership of the properties (i.e. no destroy needed)
Returns
The serviceId (>=0) or -1 if the registration was unsuccessful.

◆ celix_bundleContext_registerServiceAsync()

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.

Parameters
ctxThe bundle context
svcthe service object. Normally a pointer to a service struct (i.e. a struct with function pointers)
serviceNamethe service name, cannot be NULL
propertiesThe meta properties associated with the service. The service registration will take ownership of the properties (i.e. no destroy needed)
Returns
The serviceId (>=0) or -1 if the registration was unsuccessful.

◆ celix_bundleContext_registerServiceFactory()

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.

Parameters
ctxThe bundle context
factoryThe pointer to the factory service.
serviceNameThe required service name of the services this factory will produce.
propertiesThe optional service factory properties. For a service consumer this will be seen as the service properties.
Returns
The serviceId (>= 0) or < 0 if the registration was unsuccessful.

◆ celix_bundleContext_registerServiceFactoryAsync()

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.

Parameters
ctxThe bundle context
factoryThe pointer to the factory service.
serviceNameThe required service name of the services this factory will produce.
propertiesThe optional service factory properties. For a service consumer this will be seen as the service properties.
Returns
The serviceId (>= 0) or < 0 if the registration was unsuccessful.

◆ celix_bundleContext_registerServiceWithOptions()

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.

Parameters
ctxThe bundle context
optsThe pointer to the registration options. The options are only in the during registration call.
Returns
The serviceId (>= 0) or -1 if the registration was unsuccessful and -2 if the registration was cancelled (
See also
celix_bundleContext_reserveSvcId).

◆ celix_bundleContext_registerServiceWithOptionsAsync()

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.

Parameters
ctxThe bundle context
optsThe pointer to the registration options. The options are only in the during registration call.
Returns
The serviceId (>= 0) or -1 if the registration was unsuccessful and -2 if the registration was cancelled (
See also
celix_bundleContext_reserveSvcId).

◆ celix_bundleContext_startBundle()

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.

Parameters
ctxThe bundle context
bndIdThe bundle id to start.
Returns
true if the bundle is found & correctly started. False if not.

◆ celix_bundleContext_stopBundle()

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.

Parameters
ctxThe bundle context
bndIdThe bundle id to stop.
Returns
true if the bundle is found & correctly stop. False if not.

◆ celix_bundleContext_stopTracker()

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.

◆ celix_bundleContext_stopTrackerAsync()

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.

◆ celix_bundleContext_trackBundles()

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.

Parameters
ctxThe bundle context.
callbackHandleThe data pointer, which will be used in the callbacks
addThe callback which will be called for started bundles.
removeThe callback which will be called when bundles are stopped.
Returns
The bundle tracker id or < 0 if unsuccessful.

◆ celix_bundleContext_trackBundlesAsync()

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.

Parameters
ctxThe bundle context.
callbackHandleThe data pointer, which will be used in the callbacks
addThe callback which will be called for started bundles.
removeThe callback which will be called when bundles are stopped.
Returns
The bundle tracker id or < 0 if unsuccessful.

◆ celix_bundleContext_trackBundlesWithOptions()

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;

Parameters
ctxThe bundle context.
optsThe pointer to the bundle tracker options.
Returns
The bundle tracker id (>=0) or < 0 if unsuccessful.

◆ celix_bundleContext_trackBundlesWithOptionsAsync()

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.

Parameters
ctxThe bundle context.
optsThe pointer to the bundle tracker options.
Returns
The bundle tracker id (>=0) or < 0 if unsuccessful.

◆ celix_bundleContext_trackService()

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.

Parameters
ctxThe bundle context.
serviceNameThe required service name to track. If NULL is all service are tracked.
callbackHandleThe data pointer, which will be used in the callbacks
setis a required callback, which will be called when a new highest ranking service is set.
Returns
the tracker id (>=0) or < 0 if unsuccessful.

◆ celix_bundleContext_trackServiceAsync()

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.

Parameters
ctxThe bundle context.
serviceNameThe required service name to track. If NULL is all service are tracked.
callbackHandleThe data pointer, which will be used in the callbacks
setis a required callback, which will be called when a new highest ranking service is set.
Returns
the tracker id (>=0) or < 0 if unsuccessful.

◆ celix_bundleContext_trackServices()

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.

Parameters
ctxThe bundle context.
serviceNameThe required service name to track If NULL is all service are tracked.
callbackHandleThe data pointer, which will be used in the callbacks
addis a required callback, which will be called when a service is added and initially for the existing service.
removeis a required callback, which will be called when a service is removed
Returns
the tracker id (>=0) or < 0 if unsuccessful.

◆ celix_bundleContext_trackServicesAsync()

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.

Parameters
ctxThe bundle context.
serviceNameThe required service name to track If NULL is all service are tracked.
callbackHandleThe data pointer, which will be used in the callbacks
addis a required callback, which will be called when a service is added and initially for the existing service.
removeis a required callback, which will be called when a service is removed
Returns
the tracker id (>=0) or < 0 if unsuccessful.

◆ celix_bundleContext_trackServicesWithOptions()

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.

Parameters
ctxThe bundle context.
optsThe pointer to the tracker options.
Returns
the tracker id (>=0) or < 0 if unsuccessful.

◆ celix_bundleContext_trackServicesWithOptionsAsync()

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.

Parameters
ctxThe bundle context.
optsThe pointer to the tracker options.
Returns
the tracker id (>=0) or < 0 if unsuccessful.

◆ celix_bundleContext_trackServiceTrackers()

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.

Parameters
ctxThe bundle context
serviceNameThe 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.
callbackHandleThe callback handle which will be provided as handle in the trackerAdd and trackerRemove callback.
trackerAddCalled 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.
trackerRemoveCalled when a service tracker is removed, which tracks the provided service name
Returns
The tracker id or <0 if something went wrong (will log an error).

◆ celix_bundleContext_trackServiceTrackersAsync()

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.

Parameters
ctxThe bundle context
serviceNameThe 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.
callbackHandleThe callback handle which will be provided as handle in the trackerAdd and trackerRemove callback.
trackerAddCalled 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.
trackerRemoveCalled when a service tracker is removed, which tracks the provided service name
doneCallbackDatacall back data argument provided to the done callback function.
doneCallbackIf 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.
Returns
The tracker id or <0 if something went wrong (will log an error).

◆ celix_bundleContext_uninstallBundle()

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.

Parameters
ctxThe bundle context
bndIdThe bundle id to uninstall.
Returns
true if the bundle is correctly uninstalled. False if not.

◆ celix_bundleContext_unregisterService()

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.

Parameters
ctxThe bundle context
serviceIdThe service id

◆ celix_bundleContext_unregisterServiceAsync()

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.

Parameters
ctxThe bundle context
serviceIdThe service id
doneDataThe data used on the doneCallback (if present)
doneCallbackIf not NULL, this callback will be called when the unregisration is done. (will be called on the event loop thread)

◆ celix_bundleContext_useBundle()

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.

Parameters
ctxThe bundle context.
bundleIdThe bundle id.
callbackHandleThe data pointer, which will be used in the callbacks
useThe callback which will be called for the currently started bundles. The bundle pointers are only guaranteed to be valid during the callback.
Returns
Returns true if the bundle is found and the callback is called.

◆ celix_bundleContext_useBundles()

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).

Parameters
ctxThe bundle context.
callbackHandleThe data pointer, which will be used in the callbacks
useThe callback which will be called for the currently started bundles. The bundle pointers are only guaranteed to be valid during the callback.

◆ celix_bundleContext_useService()

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.

Parameters
ctxThe bundle context
serviceNamethe required service name.
callbackHandleThe data pointer, which will be used in the callbacks
useThe callback, which will be called when service is retrieved.
Returns
True if a service was found.

◆ celix_bundleContext_useServices()

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.

Parameters
ctxThe bundle context
serviceNamethe required service name.
callbackHandleThe data pointer, which will be used in the callbacks
useThe callback, which will be called for every service found.
Returns
The number of services found and called

◆ celix_bundleContext_useServicesWithOptions()

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.

Parameters
ctxThe bundle context.
optsThe required options. Note that the serviceName is required.
Returns
The number of services found and called

◆ celix_bundleContext_useServiceWithId()

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.

Parameters
ctxThe bundle context
serviceIdthe service id.
serviceNamethe service name of the service. Should match with the registered service name of the provided service id (sanity check)
callbackHandleThe data pointer, which will be used in the callbacks
useThe callback, which will be called when service is retrieved.
boolreturns true if a service was found.

◆ celix_bundleContext_useServiceWithOptions()

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.

Parameters
ctxThe bundle context.
optsThe required options. Note that the serviceName is required.
Returns
True if a service was found.

◆ celix_bundleContext_vlog()

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.

◆ celix_bundleContext_waitForAsyncRegistration()

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.

◆ celix_bundleContext_waitForAsyncStopTracker()

void celix_bundleContext_waitForAsyncStopTracker ( celix_bundle_context_t *  ctx,
long  trackerId 
)

Wait for (async) stopping of tracking.

◆ celix_bundleContext_waitForAsyncTracker()

void celix_bundleContext_waitForAsyncTracker ( celix_bundle_context_t *  ctx,
long  trackerId 
)

Wait for (async) creation of tracker.

◆ celix_bundleContext_waitForAsyncUnregistration()

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.

◆ celix_bundleContext_waitForEvents()

void celix_bundleContext_waitForEvents ( celix_bundle_context_t *  ctx)

Wait until all Celix event for this bundle are completed.