Apache Celix
2.3.0
An implementation of the OSGi specification adapted to C and C++
|
#include "celix_types.h"
#include "celix_properties.h"
#include "celix_log_level.h"
#include "celix_array_list.h"
Go to the source code of this file.
Functions | |
const char * | celix_framework_getUUID (const celix_framework_t *fw) |
Returns the framework UUID. This is unique for every created framework and will not be the same if the process is restarted. More... | |
celix_bundle_context_t * | celix_framework_getFrameworkContext (const celix_framework_t *fw) |
Returns the framework bundle context. This is the same as a 'normal' bundle context and can be used to register, use and track services. The only difference is that the framework is the bundle. More... | |
celix_bundle_t * | celix_framework_getFrameworkBundle (const celix_framework_t *fw) |
Returns the framework bundle. This is the same as a 'normal' bundle, expect that this bundle cannot be uninstalled and the celix_bundle_getEntry return a entries relative from the working directory. More... | |
void | celix_framework_useBundles (celix_framework_t *fw, bool includeFrameworkBundle, void *callbackHandle, void(*use)(void *handle, const celix_bundle_t *bnd)) |
Use the currently active (started) bundles. The provided callback will be called for all the currently started bundles. More... | |
bool | celix_framework_useBundle (celix_framework_t *fw, bool onlyActive, long bndId, void *callbackHandle, void(*use)(void *handle, const celix_bundle_t *bnd)) |
Use the bundle with the provided bundle id The provided callback will be called if the bundle is found. More... | |
bool | celix_framework_isBundleInstalled (celix_framework_t *fw, long bndId) |
Check whether a bundle is installed. More... | |
bool | celix_framework_isBundleActive (celix_framework_t *fw, long bndId) |
Check whether the bundle is active. More... | |
long | celix_framework_installBundle (celix_framework_t *fw, const char *bundleLoc, bool autoStart) |
Install and optional start a bundle. Will silently ignore bundle ids < 0. More... | |
bool | celix_framework_uninstallBundle (celix_framework_t *fw, 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_framework_stopBundle (celix_framework_t *fw, long bndId) |
Stop the bundle with the provided bundle id. Will silently ignore bundle ids < 0. More... | |
bool | celix_framework_startBundle (celix_framework_t *fw, long bndId) |
Start the bundle with the provided bundle id. Will silently ignore bundle ids < 0. More... | |
long | celix_framework_installBundleAsync (celix_framework_t *fw, const char *bundleLoc, bool autoStart) |
Install and optional start a bundle async. Will silently ignore bundle ids < 0. More... | |
void | celix_framework_uninstallBundleAsync (celix_framework_t *fw, long bndId) |
Uninstall the bundle with the provided bundle id async. If needed the bundle will be stopped first. Will silently ignore bundle ids < 0. More... | |
void | celix_framework_stopBundleAsync (celix_framework_t *fw, long bndId) |
Stop the bundle with the provided bundle id async. Will silently ignore bundle ids < 0. More... | |
void | celix_framework_startBundleAsync (celix_framework_t *fw, long bndId) |
Start the bundle with the provided bundle id async. Will silently ignore bundle ids < 0. More... | |
celix_array_list_t * | celix_framework_listBundles (celix_framework_t *framework) |
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_framework_listInstalledBundles (celix_framework_t *framework) |
List the installed bundle ids. The bundle ids does not include the framework bundle (bundle id CELIX_FRAMEWORK_BUNDLE_ID). More... | |
void | celix_framework_waitForEmptyEventQueue (celix_framework_t *fw) |
Wait until the framework event queue is empty. More... | |
void | celix_framework_setLogCallback (celix_framework_t *fw, void *logHandle, void(*logFunction)(void *handle, celix_log_level_e level, const char *file, const char *function, int line, const char *format, va_list formatArgs)) |
Sets the log function for this framework. Default the celix framework will log to stdout/stderr. More... | |
void | celix_framework_waitUntilNoEventsForBnd (celix_framework_t *fw, long bndId) |
wait until all events for the bundle identified by the bndId are processed. More... | |
void | celix_framework_waitUntilNoPendingRegistration (celix_framework_t *fw) |
wait until all pending service registration are processed. More... | |
bool | celix_framework_isCurrentThreadTheEventLoop (celix_framework_t *fw) |
Returns whether the current thread is the Celix framework event loop thread. More... | |
long | celix_framework_fireGenericEvent (celix_framework_t *fw, long eventId, long bndId, const char *eventName, void *processData, void(*processCallback)(void *data), void *doneData, void(*doneCallback)(void *doneData)) |
Fire a generic event. The event will be added to the event loop and handled on the event loop thread. More... | |
long | celix_framework_nextEventId (celix_framework_t *fw) |
Get the next event id. More... | |
void | celix_framework_waitForGenericEvent (celix_framework_t *fw, long eventId) |
Wait until a event with the provided event id is completely handled. This function will directly return if the provided event id is not in the event loop (already done or never issued). More... | |
void | celix_framework_waitForStop (celix_framework_t *framework) |
Wait until the framework is stopped. More... | |
long celix_framework_fireGenericEvent | ( | celix_framework_t * | fw, |
long | eventId, | ||
long | bndId, | ||
const char * | eventName, | ||
void * | processData, | ||
void(*)(void *data) | processCallback, | ||
void * | doneData, | ||
void(*)(void *doneData) | doneCallback | ||
) |
Fire a generic event. The event will be added to the event loop and handled on the event loop thread.
if bndId >=0 the bundle usage count will be increased while the event is not yet processed or finished processing. The eventName is expected to be const char* valid during til the event is finished processing.
if eventId >=0 this will be used, otherwise a new event id will be generated return eventId
celix_bundle_t* celix_framework_getFrameworkBundle | ( | const celix_framework_t * | fw | ) |
Returns the framework bundle. This is the same as a 'normal' bundle, expect that this bundle cannot be uninstalled and the celix_bundle_getEntry
return a entries relative from the working directory.
fw | The framework |
celix_bundle_context_t* celix_framework_getFrameworkContext | ( | const celix_framework_t * | fw | ) |
Returns the framework bundle context. This is the same as a 'normal' bundle context and can be used to register, use and track services. The only difference is that the framework is the bundle.
fw | The framework |
const char* celix_framework_getUUID | ( | const celix_framework_t * | fw | ) |
Returns the framework UUID. This is unique for every created framework and will not be the same if the process is restarted.
long celix_framework_installBundle | ( | celix_framework_t * | fw, |
const char * | bundleLoc, | ||
bool | autoStart | ||
) |
Install and optional start a bundle. Will silently ignore bundle ids < 0.
fw | The Celix framework |
bundleLoc | The bundle location to the bundle zip file. |
autoStart | If the bundle should also be started. |
long celix_framework_installBundleAsync | ( | celix_framework_t * | fw, |
const char * | bundleLoc, | ||
bool | autoStart | ||
) |
Install and optional start a bundle async. Will silently ignore bundle ids < 0.
If the bundle needs to be started this will be done a separate spawned thread.
fw | The Celix framework |
bundleLoc | The bundle location to the bundle zip file. |
autoStart | If the bundle should also be started. |
bool celix_framework_isBundleActive | ( | celix_framework_t * | fw, |
long | bndId | ||
) |
Check whether the bundle is active.
fw | The Celix framework |
bndId | The bundle id to check |
bool celix_framework_isBundleInstalled | ( | celix_framework_t * | fw, |
long | bndId | ||
) |
Check whether a bundle is installed.
fw | The Celix framework |
bndId | The bundle id to check |
bool celix_framework_isCurrentThreadTheEventLoop | ( | celix_framework_t * | fw | ) |
Returns whether the current thread is the Celix framework event loop thread.
celix_array_list_t* celix_framework_listBundles | ( | celix_framework_t * | framework | ) |
List the installed and started bundle ids. The bundle ids does not include the framework bundle (bundle id CELIX_FRAMEWORK_BUNDLE_ID).
framework | The Celix framework. |
celix_array_list_t* celix_framework_listInstalledBundles | ( | celix_framework_t * | framework | ) |
List the installed bundle ids. The bundle ids does not include the framework bundle (bundle id CELIX_FRAMEWORK_BUNDLE_ID).
framework | The Celix framework. |
long celix_framework_nextEventId | ( | celix_framework_t * | fw | ) |
Get the next event id.
This can be used to ensure celix_framework_waitForGenericEvent can be used to wait for an event. The returned event id will not be used by the framework itself unless followed up with a celix_framework_fireGenericEvent call using the returned event id.
void celix_framework_setLogCallback | ( | celix_framework_t * | fw, |
void * | logHandle, | ||
void(*)(void *handle, celix_log_level_e level, const char *file, const char *function, int line, const char *format, va_list formatArgs) | logFunction | ||
) |
Sets the log function for this framework. Default the celix framework will log to stdout/stderr.
A log function can be injected to change how the Celix framework logs. Can be reset by setting the log function to NULL.
bool celix_framework_startBundle | ( | celix_framework_t * | fw, |
long | bndId | ||
) |
Start the bundle with the provided bundle id. Will silently ignore bundle ids < 0.
fw | The Celix framework |
bndId | The bundle id to start. |
void celix_framework_startBundleAsync | ( | celix_framework_t * | fw, |
long | bndId | ||
) |
Start the bundle with the provided bundle id async. Will silently ignore bundle ids < 0.
The bundle will be started on a separate spawned thread.
fw | The Celix framework |
bndId | The bundle id to start. |
bool celix_framework_stopBundle | ( | celix_framework_t * | fw, |
long | bndId | ||
) |
Stop the bundle with the provided bundle id. Will silently ignore bundle ids < 0.
fw | The Celix framework |
bndId | The bundle id to stop. |
void celix_framework_stopBundleAsync | ( | celix_framework_t * | fw, |
long | bndId | ||
) |
Stop the bundle with the provided bundle id async. Will silently ignore bundle ids < 0.
The bundle will be stopped on a separate spawned thread.
fw | The Celix framework |
bndId | The bundle id to stop. |
bool celix_framework_uninstallBundle | ( | celix_framework_t * | fw, |
long | bndId | ||
) |
Uninstall the bundle with the provided bundle id. If needed the bundle will be stopped first. Will silently ignore bundle ids < 0.
fw | The Celix framework |
bndId | The bundle id to uninstall. |
void celix_framework_uninstallBundleAsync | ( | celix_framework_t * | fw, |
long | bndId | ||
) |
Uninstall the bundle with the provided bundle id async. If needed the bundle will be stopped first. Will silently ignore bundle ids < 0.
The bundle will be uninstalled on a separate spawned thread.
fw | The Celix framework |
bndId | The bundle id to uninstall. |
bool celix_framework_useBundle | ( | celix_framework_t * | fw, |
bool | onlyActive, | ||
long | bndId, | ||
void * | callbackHandle, | ||
void(*)(void *handle, const celix_bundle_t *bnd) | use | ||
) |
Use the bundle with the provided bundle id The provided callback will be called if the bundle is found.
fw | The framework. |
onlyActive | If true only starting and active bundles will trigger the callback. |
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_framework_useBundles | ( | celix_framework_t * | fw, |
bool | includeFrameworkBundle, | ||
void * | callbackHandle, | ||
void(*)(void *handle, const celix_bundle_t *bnd) | use | ||
) |
Use the currently active (started) bundles. The provided callback will be called for all the currently started bundles.
ctx | The bundle context. |
includeFrameworkBundle | If true the callback will also be triggered for the framework bundle. |
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_framework_waitForEmptyEventQueue | ( | celix_framework_t * | fw | ) |
Wait until the framework event queue is empty.
The Celix framework has an event queue which (among others) handles bundle events. This function can be used to ensure that all queue event are handled, mainly useful for testing.
fw | The Celix Framework |
void celix_framework_waitForGenericEvent | ( | celix_framework_t * | fw, |
long | eventId | ||
) |
Wait until a event with the provided event id is completely handled. This function will directly return if the provided event id is not in the event loop (already done or never issued).
void celix_framework_waitForStop | ( | celix_framework_t * | framework | ) |
Wait until the framework is stopped.
void celix_framework_waitUntilNoEventsForBnd | ( | celix_framework_t * | fw, |
long | bndId | ||
) |
wait until all events for the bundle identified by the bndId are processed.
void celix_framework_waitUntilNoPendingRegistration | ( | celix_framework_t * | fw | ) |
wait until all pending service registration are processed.