Apache Celix  2.3.0
An implementation of the OSGi specification adapted to C and C++
celix_bundle_context.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #include "celix_types.h"
21 #include "celix_service_factory.h"
22 #include "celix_properties.h"
23 #include "celix_array_list.h"
24 #include "celix_filter.h"
25 
26 #ifndef CELIX_BUNDLE_CONTEXT_H_
27 #define CELIX_BUNDLE_CONTEXT_H_
28 
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
37 #ifdef __cplusplus
38 #define CELIX_OPTS_INIT {}
39 #else
40 #define CELIX_OPTS_INIT
41 #endif
42 
57 long celix_bundleContext_registerServiceAsync(celix_bundle_context_t *ctx, void *svc, const char *serviceName, celix_properties_t *properties);
58 
70 long celix_bundleContext_registerService(celix_bundle_context_t *ctx, void *svc, const char *serviceName, celix_properties_t *properties);
71 
94 long celix_bundleContext_registerServiceFactoryAsync(celix_bundle_context_t *ctx, celix_service_factory_t *factory, const char *serviceName, celix_properties_t *props);
95 
114 long celix_bundleContext_registerServiceFactory(celix_bundle_context_t *ctx, celix_service_factory_t *factory, const char *serviceName, celix_properties_t *props);
115 
129  void *svc CELIX_OPTS_INIT;
130 
146  celix_service_factory_t *factory CELIX_OPTS_INIT;
147 
154  const char *serviceName CELIX_OPTS_INIT;
155 
165  celix_properties_t *properties CELIX_OPTS_INIT;
166 
172  const char *serviceLanguage CELIX_OPTS_INIT;
173 
182  const char *serviceVersion CELIX_OPTS_INIT;
183 
187  void *asyncData CELIX_OPTS_INIT;
188 
199  void (*asyncCallback)(void *data, long serviceId) CELIX_OPTS_INIT;
201 
205 #ifndef __cplusplus
206 #define CELIX_EMPTY_SERVICE_REGISTRATION_OPTIONS { .svc = NULL, \
207  .factory = NULL, \
208  .serviceName = NULL, \
209  .properties = NULL, \
210  .serviceLanguage = NULL, \
211  .serviceVersion = NULL, \
212  .asyncData = NULL, \
213  .asyncCallback = NULL }
214 #endif
215 
229 
239 long celix_bundleContext_registerServiceWithOptions(celix_bundle_context_t *ctx, const celix_service_registration_options_t *opts);
240 
247 void celix_bundleContext_waitForAsyncRegistration(celix_bundle_context_t* ctx, long serviceId);
248 
257 bool celix_bundleContext_isServiceRegistered(celix_bundle_context_t* ctx, long serviceId);
258 
259 
270 void celix_bundleContext_unregisterService(celix_bundle_context_t *ctx, long serviceId);
271 
272 
287 void celix_bundleContext_unregisterServiceAsync(celix_bundle_context_t *ctx, long serviceId, void* doneData, void (*doneCallback)(void* doneData));
288 
289 
295 void celix_bundleContext_waitForAsyncUnregistration(celix_bundle_context_t* ctx, long serviceId);
296 
297 
298 
299 
307 long celix_bundleContext_findService(celix_bundle_context_t *ctx, const char *serviceName);
308 
316 celix_array_list_t* celix_bundleContext_findServices(celix_bundle_context_t *ctx, const char *serviceName);
317 
327  const char* serviceName CELIX_OPTS_INIT;
328 
336  const char* versionRange CELIX_OPTS_INIT;
337 
343  const char* filter CELIX_OPTS_INIT;
344 
349  const char* serviceLanguage CELIX_OPTS_INIT;
350 
351 
356  bool ignoreServiceLanguage CELIX_OPTS_INIT;
358 
362 #ifndef __cplusplus
363 #define CELIX_EMPTY_SERVICE_FILTER_OPTIONS {.serviceName = NULL, .versionRange = NULL, .filter = NULL, .serviceLanguage = NULL, .ignoreServiceLanguage = false}
364 #endif
365 
366 
374 long celix_bundleContext_findServiceWithOptions(celix_bundle_context_t *ctx, const celix_service_filter_options_t *opts);
375 
383 celix_array_list_t* celix_bundleContext_findServicesWithOptions(celix_bundle_context_t *ctx, const celix_service_filter_options_t *opts);
384 
403  celix_bundle_context_t* ctx,
404  const char* serviceName,
405  void* callbackHandle,
406  void (*set)(void* handle, void* svc)
407 );
408 
425  celix_bundle_context_t* ctx,
426  const char* serviceName,
427  void* callbackHandle,
428  void (*set)(void* handle, void* svc)
429 ); //__attribute__((deprecated("Use celix_bundleContext_trackServiceSync instead!")));
430 
446  celix_bundle_context_t* ctx,
447  const char* serviceName,
448  void* callbackHandle,
449  void (*add)(void* handle, void* svc),
450  void (*remove)(void* handle, void* svc)
451 );
452 
467  celix_bundle_context_t* ctx,
468  const char* serviceName,
469  void* callbackHandle,
470  void (*add)(void* handle, void* svc),
471  void (*remove)(void* handle, void* svc)
472 );
473 
482 
486  void* callbackHandle CELIX_OPTS_INIT;
487 
494  void (*set)(void *handle, void *svc) CELIX_OPTS_INIT;
495 
500  void (*setWithProperties)(void *handle, void *svc, const celix_properties_t *props) CELIX_OPTS_INIT; //highest ranking
501 
506  void (*setWithOwner)(void *handle, void *svc, const celix_properties_t *props, const celix_bundle_t *svcOwner) CELIX_OPTS_INIT; //highest ranking
507 
514  void (*add)(void *handle, void *svc) CELIX_OPTS_INIT;
515 
520  void (*addWithProperties)(void *handle, void *svc, const celix_properties_t *props) CELIX_OPTS_INIT;
521 
526  void (*addWithOwner)(void *handle, void *svc, const celix_properties_t *props, const celix_bundle_t *svcOwner) CELIX_OPTS_INIT;
527 
537  void (*remove)(void *handle, void *svc) CELIX_OPTS_INIT;
538 
543  void (*removeWithProperties)(void *handle, void *svc, const celix_properties_t *props) CELIX_OPTS_INIT;
544 
549  void (*removeWithOwner)(void *handle, void *svc, const celix_properties_t *props, const celix_bundle_t *svcOwner) CELIX_OPTS_INIT;
550 
551 
555  void *trackerCreatedCallbackData CELIX_OPTS_INIT;
556 
564  void (*trackerCreatedCallback)(void *trackerCreatedCallbackData) CELIX_OPTS_INIT;
566 
570 #ifndef __cplusplus
571 #define CELIX_EMPTY_SERVICE_TRACKING_OPTIONS { .filter.serviceName = NULL, \
572  .filter.versionRange = NULL, \
573  .filter.filter = NULL, \
574  .filter.serviceLanguage = NULL, \
575  .filter.ignoreServiceLanguage = false, \
576  .callbackHandle = NULL, \
577  .set = NULL, \
578  .add = NULL, \
579  .remove = NULL, \
580  .setWithProperties = NULL, \
581  .addWithProperties = NULL, \
582  .removeWithProperties = NULL, \
583  .setWithOwner = NULL, \
584  .addWithOwner = NULL, \
585  .removeWithOwner = NULL, \
586  .trackerCreatedCallbackData = NULL, \
587  .trackerCreatedCallback = NULL }
588 #endif
589 
602 long celix_bundleContext_trackServicesWithOptionsAsync(celix_bundle_context_t *ctx, const celix_service_tracking_options_t *opts);
603 
615 long celix_bundleContext_trackServicesWithOptions(celix_bundle_context_t *ctx, const celix_service_tracking_options_t *opts); //__attribute__((deprecated("Use celix_bundleContext_trackServicesWithOptionsAsync instead!")));
616 
632  celix_bundle_context_t *ctx,
633  long trackerId,
634  void *doneCallbackData,
635  void (*doneCallback)(void* doneCallbackData));
636 
640 void celix_bundleContext_waitForAsyncTracker(celix_bundle_context_t* ctx, long trackerId);
641 
645 void celix_bundleContext_waitForAsyncStopTracker(celix_bundle_context_t* ctx, long trackerId);
646 
656 void celix_bundleContext_stopTracker(celix_bundle_context_t *ctx, long trackerId);
657 
658 
659 
678  celix_bundle_context_t *ctx,
679  long serviceId,
680  const char *serviceName /*sanity check*/,
681  void *callbackHandle,
682  void (*use)(void *handle, void* svc)
683 );
684 
703  celix_bundle_context_t *ctx,
704  const char* serviceName,
705  void *callbackHandle,
706  void (*use)(void *handle, void *svc)
707 );
708 
727  celix_bundle_context_t *ctx,
728  const char* serviceName,
729  void *callbackHandle,
730  void (*use)(void *handle, void *svc)
731 );
732 
741 
747  double waitTimeoutInSeconds CELIX_OPTS_INIT;
748 
752  void *callbackHandle CELIX_OPTS_INIT;
753 
761  void (*use)(void *handle, void *svc) CELIX_OPTS_INIT;
762 
767  void (*useWithProperties)(void *handle, void *svc, const celix_properties_t *props) CELIX_OPTS_INIT;
768 
773  void (*useWithOwner)(void *handle, void *svc, const celix_properties_t *props, const celix_bundle_t *svcOwner) CELIX_OPTS_INIT;
778 #define CELIX_SERVICE_USE_DIRECT (1)
779 
783 #define CELIX_SERVICE_USE_SOD (2)
784  int flags CELIX_OPTS_INIT;
786 
790 #ifndef __cplusplus
791 #define CELIX_EMPTY_SERVICE_USE_OPTIONS {.filter.serviceName = NULL, \
792  .filter.versionRange = NULL, \
793  .filter.filter = NULL, \
794  .filter.serviceLanguage = NULL, \
795  .waitTimeoutInSeconds = 0.0F, \
796  .callbackHandle = NULL, \
797  .use = NULL, \
798  .useWithProperties = NULL, \
799  .useWithOwner = NULL, \
800  .flags=0}
801 #endif
802 
820  celix_bundle_context_t *ctx,
821  const celix_service_use_options_t *opts);
822 
823 
841  celix_bundle_context_t *ctx,
842  const celix_service_use_options_t *opts);
843 
844 
852 celix_array_list_t* celix_bundleContext_listBundles(celix_bundle_context_t *ctx);
853 
861 celix_array_list_t* celix_bundleContext_listInstalledBundles(celix_bundle_context_t *ctx);
862 
863 
870 bool celix_bundleContext_isBundleInstalled(celix_bundle_context_t *ctx, long bndId);
871 
878 bool celix_bundleContext_isBundleActive(celix_bundle_context_t *ctx, long bndId);
879 
880 
895 long celix_bundleContext_installBundle(celix_bundle_context_t *ctx, const char *bundleLoc, bool autoStart);
896 
910 bool celix_bundleContext_uninstallBundle(celix_bundle_context_t *ctx, long bndId);
911 
925 bool celix_bundleContext_stopBundle(celix_bundle_context_t *ctx, long bndId);
926 
940 bool celix_bundleContext_startBundle(celix_bundle_context_t *ctx, long bndId);
941 
950 char* celix_bundleContext_getBundleSymbolicName(celix_bundle_context_t *ctx, long bndId);
951 
952 
968  celix_bundle_context_t* ctx,
969  void* callbackHandle,
970  void (*onStarted)(void* handle, const celix_bundle_t *bundle),
971  void (*onStopped)(void *handle, const celix_bundle_t *bundle)
972 );
973 
988  celix_bundle_context_t* ctx,
989  void* callbackHandle,
990  void (*onStarted)(void* handle, const celix_bundle_t *bundle),
991  void (*onStopped)(void *handle, const celix_bundle_t *bundle)
992 ); //__attribute__((deprecated("Use celix_bundleContext_trackBundlesAsync instead!")));
993 
994 
1002  void* callbackHandle CELIX_OPTS_INIT;
1003 
1010  void (*onInstalled)(void *handle, const celix_bundle_t *bundle) CELIX_OPTS_INIT;
1011 
1018  void (*onStarted)(void *handle, const celix_bundle_t *bundle) CELIX_OPTS_INIT;
1019 
1026  void (*onStopped)(void *handle, const celix_bundle_t *bundle) CELIX_OPTS_INIT;
1027 
1033  void (*onBundleEvent)(void *handle, const celix_bundle_event_t *event) CELIX_OPTS_INIT;
1034 
1039  bool includeFrameworkBundle CELIX_OPTS_INIT;
1040 
1044  void *trackerCreatedCallbackData CELIX_OPTS_INIT;
1045 
1054  void (*trackerCreatedCallback)(void *trackerCreatedCallbackData) CELIX_OPTS_INIT;
1056 
1060 #ifndef __cplusplus
1061 #define CELIX_EMPTY_BUNDLE_TRACKING_OPTIONS {.callbackHandle = NULL, .onInstalled = NULL, .onStarted = NULL, .onStopped = NULL, .onBundleEvent = NULL, .includeFrameworkBundle = false, .trackerCreatedCallbackData = NULL, .trackerCreatedCallback = NULL}
1062 #endif
1063 
1078  celix_bundle_context_t* ctx,
1080 );
1081 
1095  celix_bundle_context_t* ctx,
1097 );
1098 
1112  celix_bundle_context_t *ctx,
1113  long bundleId,
1114  void *callbackHandle,
1115  void (*use)(void *handle, const celix_bundle_t *bundle)
1116 );
1117 
1129  celix_bundle_context_t *ctx,
1130  void *callbackHandle,
1131  void (*use)(void *handle, const celix_bundle_t *bundle)
1132 );
1133 
1141  celix_filter_t *filter;
1142 
1146  const char *serviceName;
1147 
1152  const char *serviceLanguage;
1153 
1157  long bundleId;
1159 
1188  celix_bundle_context_t *ctx,
1189  const char *serviceName,
1190  void *callbackHandle,
1191  void (*trackerAdd)(void *handle, const celix_service_tracker_info_t *info),
1192  void (*trackerRemove)(void *handle, const celix_service_tracker_info_t *info),
1193  void *doneCallbackData,
1194  void (*doneCallback)(void* doneCallbackData));
1195 
1218  celix_bundle_context_t *ctx,
1219  const char *serviceName,
1220  void *callbackHandle,
1221  void (*trackerAdd)(void *handle, const celix_service_tracker_info_t *info),
1222  void (*trackerRemove)(void *handle, const celix_service_tracker_info_t *info)); //__attribute__((deprecated("Use celix_bundleContext_trackServiceTrackersAsync instead!")));
1223 
1229 celix_dependency_manager_t* celix_bundleContext_getDependencyManager(celix_bundle_context_t *ctx);
1230 
1231 
1235 void celix_bundleContext_waitForEvents(celix_bundle_context_t* ctx);
1236 
1237 
1241 celix_bundle_t* celix_bundleContext_getBundle(const celix_bundle_context_t *ctx);
1242 
1243 
1247 long celix_bundleContext_getBundleId(const celix_bundle_context_t *ctx);
1248 
1249 celix_framework_t* celix_bundleContext_getFramework(const celix_bundle_context_t* ctx);
1250 
1258 void celix_bundleContext_log(const celix_bundle_context_t* ctx, celix_log_level_e level, const char* format, ...);
1259 
1263 void celix_bundleContext_vlog(const celix_bundle_context_t* ctx, celix_log_level_e level, const char* format, va_list formatArgs);
1264 
1265 
1272 const char* celix_bundleContext_getProperty(celix_bundle_context_t *ctx, const char *key, const char *defaultVal);
1273 
1282 long celix_bundleContext_getPropertyAsLong(celix_bundle_context_t *ctx, const char *key, long defaultValue);
1283 
1292 double celix_bundleContext_getPropertyAsDouble(celix_bundle_context_t *ctx, const char *key, double defaultValue);
1293 
1302 bool celix_bundleContext_getPropertyAsBool(celix_bundle_context_t *ctx, const char *key, bool defaultValue);
1303 
1304 #undef CELIX_OPTS_INIT
1305 
1306 #ifdef __cplusplus
1307 }
1308 #endif
1309 
1310 #endif //CELIX_BUNDLE_CONTEXT_H_
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....
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.
celix_bundleContext_stopTrackerAsync
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.
celix_service_tracking_options::addWithOwner
void(* addWithOwner)(void *handle, void *svc, const celix_properties_t *props, const celix_bundle_t *svcOwner) CELIX_OPTS_INIT
The optional addWithOwner callback is handled as the add callback, but with the addition that the ser...
Definition: celix_bundle_context.h:526
celix_bundle_tracker_options::CELIX_OPTS_INIT
bool includeFrameworkBundle CELIX_OPTS_INIT
Default the framework bundle (bundle id 0) will not trigger the callbacks. This is done,...
Definition: celix_bundle_context.h:1039
celix_bundleContext_trackServiceTrackers
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.
celix_bundle_tracker_options::CELIX_OPTS_INIT
void *trackerCreatedCallbackData CELIX_OPTS_INIT
Data for the trackerCreatedCallback.
Definition: celix_bundle_context.h:1044
celix_service_use_options::CELIX_OPTS_INIT
double waitTimeoutInSeconds CELIX_OPTS_INIT
An optional timeout (in seconds), if > 0 the use service call will block until the timeout is expired...
Definition: celix_bundle_context.h:747
celix_service_tracking_options::CELIX_OPTS_INIT
void *callbackHandle CELIX_OPTS_INIT
The optional callback pointer used in all the provided callback function (set, add,...
Definition: celix_bundle_context.h:486
celix_bundleContext_trackServiceAsync
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.
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.
celix_bundle_tracker_options::onBundleEvent
void(* onBundleEvent)(void *handle, const celix_bundle_event_t *event) CELIX_OPTS_INIT
Definition: celix_bundle_context.h:1033
celix_bundleContext_trackService
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.
celix_service_registration_options::CELIX_OPTS_INIT
void *asyncData CELIX_OPTS_INIT
Async data pointer for the async register callback.
Definition: celix_bundle_context.h:187
celix_service_registration_options
Service Registration Options when registering services to the Celix framework.
Definition: celix_bundle_context.h:119
celix_bundleContext_trackBundles
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.
celix_bundleContext_useService
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.
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 pr...
celix_bundleContext_trackServices
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.
celix_service_filter_options::CELIX_OPTS_INIT
const char *serviceName CELIX_OPTS_INIT
The service name.
Definition: celix_bundle_context.h:327
celix_service_registration_options::CELIX_OPTS_INIT
const char *serviceVersion CELIX_OPTS_INIT
The optional service version (in the form of <MAJOR>.<MINOR>.<MICRO>.<QUALIFIER>).
Definition: celix_bundle_context.h:182
celix_bundle_tracker_options::trackerCreatedCallback
void(* trackerCreatedCallback)(void *trackerCreatedCallbackData) CELIX_OPTS_INIT
The callback called when the tracker has ben created (and is active) when using the track bundles asc...
Definition: celix_bundle_context.h:1054
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.
celix_bundle_tracker_options
The Service Bundle Tracking options can be used to fine tune the requested bundle tracker options.
Definition: celix_bundle_context.h:998
celix_service_tracking_options::setWithProperties
void(* setWithProperties)(void *handle, void *svc, const celix_properties_t *props) CELIX_OPTS_INIT
The optional setWithProperties callback is handled as the set callback, but with the addition that th...
Definition: celix_bundle_context.h:500
celix_service_registration_options_t
struct celix_service_registration_options celix_service_registration_options_t
Service Registration Options when registering services to the Celix framework.
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.
celix_bundleContext_waitForEvents
void celix_bundleContext_waitForEvents(celix_bundle_context_t *ctx)
Wait until all Celix event for this bundle are completed.
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.
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.
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.
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.
celix_bundleContext_unregisterServiceAsync
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.
celix_service_registration_options::CELIX_OPTS_INIT
celix_properties_t *properties CELIX_OPTS_INIT
The optional service properties.
Definition: celix_bundle_context.h:165
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.
celix_service_use_options_t
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.
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_service_use_options::useWithOwner
void(* useWithOwner)(void *handle, void *svc, const celix_properties_t *props, const celix_bundle_t *svcOwner) CELIX_OPTS_INIT
The optional useWithOwner callback is handled as the yse callback, but with the addition that the ser...
Definition: celix_bundle_context.h:773
celix_bundleContext_trackBundlesAsync
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.
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.
celix_service_filter_options::CELIX_OPTS_INIT
const char *versionRange CELIX_OPTS_INIT
The optional version range.
Definition: celix_bundle_context.h:336
celix_service_tracking_options_t
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...
celix_service_tracking_options::remove
void(* remove)(void *handle, void *svc) CELIX_OPTS_INIT
The optional remove callback will be called for every service conform the provided service filter opt...
Definition: celix_bundle_context.h:537
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.
celix_service_tracking_options::addWithProperties
void(* addWithProperties)(void *handle, void *svc, const celix_properties_t *props) CELIX_OPTS_INIT
The optional addWithProperties callback is handled as the add callback, but with the addition that th...
Definition: celix_bundle_context.h:520
celix_service_filter_options::CELIX_OPTS_INIT
const char *serviceLanguage CELIX_OPTS_INIT
Definition: celix_bundle_context.h:349
celix_bundleContext_useServiceWithId
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 en...
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...
celix_service_tracker_info::bundleId
long bundleId
Bundle id of the owner of the service tracker.
Definition: celix_bundle_context.h:1157
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,...
celix_service_use_options::useWithProperties
void(* useWithProperties)(void *handle, void *svc, const celix_properties_t *props) CELIX_OPTS_INIT
The optional useWithProperties callback is handled as the use callback, but with the addition that th...
Definition: celix_bundle_context.h:767
celix_service_filter_options::CELIX_OPTS_INIT
const char *filter CELIX_OPTS_INIT
LDAP filter to use for fine tuning the filtering, e.g. (|(location=middle)(location=front))
Definition: celix_bundle_context.h:343
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,...
celix_service_registration_options::CELIX_OPTS_INIT
const char *serviceLanguage CELIX_OPTS_INIT
The optional service language.
Definition: celix_bundle_context.h:172
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.
celix_service_registration_options::asyncCallback
void(* asyncCallback)(void *data, long serviceId) CELIX_OPTS_INIT
Async callback.
Definition: celix_bundle_context.h:199
celix_service_tracking_options::CELIX_OPTS_INIT
celix_service_filter_options_t filter CELIX_OPTS_INIT
The service filter options, used to setup the filter for the service to track.
Definition: celix_bundle_context.h:481
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 cal...
celix_service_tracking_options::trackerCreatedCallback
void(* trackerCreatedCallback)(void *trackerCreatedCallbackData) CELIX_OPTS_INIT
The callback called when the tracker has ben created (and is active) when using a async call.
Definition: celix_bundle_context.h:564
celix_service_tracking_options::removeWithOwner
void(* removeWithOwner)(void *handle, void *svc, const celix_properties_t *props, const celix_bundle_t *svcOwner) CELIX_OPTS_INIT
The optional removeWithOwner callback is handled as the remove callback, but with the addition that t...
Definition: celix_bundle_context.h:549
celix_service_use_options
Service Use Options used to fine tune which services to use and which callbacks to use.
Definition: celix_bundle_context.h:736
celix_service_use_options::use
void(* use)(void *handle, void *svc) CELIX_OPTS_INIT
The optional use callback will be called when for every services found conform the service filter opt...
Definition: celix_bundle_context.h:761
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.
celix_bundleContext_getFramework
celix_framework_t * celix_bundleContext_getFramework(const celix_bundle_context_t *ctx)
celix_service_tracker_info::filter
celix_filter_t * filter
The parsed service filter, e.g. parsed "(&(objectClass=example_calc)(service.language=C)(meta....
Definition: celix_bundle_context.h:1141
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_...
celix_service_tracking_options::CELIX_OPTS_INIT
void *trackerCreatedCallbackData CELIX_OPTS_INIT
Data for the trackerCreatedCallback.
Definition: celix_bundle_context.h:555
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.
celix_service_tracking_options
Service Tracker Options used to fine tune which services to track and the callback to be used for the...
Definition: celix_bundle_context.h:477
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.
celix_bundleContext_useBundles
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.
celix_service_use_options::CELIX_OPTS_INIT
int flags CELIX_OPTS_INIT
Definition: celix_bundle_context.h:784
celix_bundleContext_stopTracker
void celix_bundleContext_stopTracker(celix_bundle_context_t *ctx, long trackerId)
Stop the tracker with the provided track id.
celix_service_filter_options
Service filter options which can be used to query for certain services.
Definition: celix_bundle_context.h:321
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_bundle_tracker_options::onStarted
void(* onStarted)(void *handle, const celix_bundle_t *bundle) CELIX_OPTS_INIT
Tracker callback when a bundle is started.
Definition: celix_bundle_context.h:1018
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,...
celix_bundle_tracker_options::onInstalled
void(* onInstalled)(void *handle, const celix_bundle_t *bundle) CELIX_OPTS_INIT
Tracker callback when a bundle is installed.
Definition: celix_bundle_context.h:1010
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.
celix_service_filter_options_t
struct celix_service_filter_options celix_service_filter_options_t
Service filter options which can be used to query for certain services.
celix_service_tracking_options::removeWithProperties
void(* removeWithProperties)(void *handle, void *svc, const celix_properties_t *props) CELIX_OPTS_INIT
The optional removeWithProperties callback is handled as the remove callback, but with the addition t...
Definition: celix_bundle_context.h:543
celix_service_tracking_options::set
void(* set)(void *handle, void *svc) CELIX_OPTS_INIT
The optional set callback will be called when a new highest ranking service is available conform the ...
Definition: celix_bundle_context.h:494
celix_service_filter_options::CELIX_OPTS_INIT
bool ignoreServiceLanguage CELIX_OPTS_INIT
Definition: celix_bundle_context.h:356
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.
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.
celix_bundleContext_waitForAsyncTracker
void celix_bundleContext_waitForAsyncTracker(celix_bundle_context_t *ctx, long trackerId)
Wait for (async) creation of tracker.
celix_bundleContext_isBundleActive
bool celix_bundleContext_isBundleActive(celix_bundle_context_t *ctx, long bndId)
Check whether the bundle is active.
celix_service_tracker_info_t
struct celix_service_tracker_info celix_service_tracker_info_t
Service Tracker Info provided to the service tracker tracker callbacks.
celix_service_registration_options::CELIX_OPTS_INIT
const char *serviceName CELIX_OPTS_INIT
The required service name.
Definition: celix_bundle_context.h:154
celix_service_use_options::CELIX_OPTS_INIT
celix_service_filter_options_t filter CELIX_OPTS_INIT
The service filter options, used to setup the filter for the service to track.
Definition: celix_bundle_context.h:740
celix_service_tracker_info
Service Tracker Info provided to the service tracker tracker callbacks.
Definition: celix_bundle_context.h:1137
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.
celix_bundle_tracking_options_t
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.
celix_bundleContext_useServices
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.
celix_service_tracking_options::setWithOwner
void(* setWithOwner)(void *handle, void *svc, const celix_properties_t *props, const celix_bundle_t *svcOwner) CELIX_OPTS_INIT
The optional setWithOwner callback is handled as the set callback, but with the addition that the ser...
Definition: celix_bundle_context.h:506
celix_bundle_tracker_options::onStopped
void(* onStopped)(void *handle, const celix_bundle_t *bundle) CELIX_OPTS_INIT
Tracker callback when a bundle is stopped.
Definition: celix_bundle_context.h:1026
celix_service_use_options::CELIX_OPTS_INIT
void *callbackHandle CELIX_OPTS_INIT
The optional callback pointer used in all the provided callback function (set, add,...
Definition: celix_bundle_context.h:752
celix_bundleContext_useBundle
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.
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.
celix_bundleContext_trackServiceTrackersAsync
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.
celix_bundleContext_trackServicesAsync
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.
celix_service_registration_options::CELIX_OPTS_INIT
celix_service_factory_t *factory CELIX_OPTS_INIT
The service factory pointer.
Definition: celix_bundle_context.h:146
celix_bundleContext_getDependencyManager
celix_dependency_manager_t * celix_bundleContext_getDependencyManager(celix_bundle_context_t *ctx)
Gets the dependency manager for this bundle context.
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.
celix_bundleContext_waitForAsyncStopTracker
void celix_bundleContext_waitForAsyncStopTracker(celix_bundle_context_t *ctx, long trackerId)
Wait for (async) stopping of tracking.
celix_service_tracking_options::add
void(* add)(void *handle, void *svc) CELIX_OPTS_INIT
The optional add callback will be called for every current and future service found conform the provi...
Definition: celix_bundle_context.h:514
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.
celix_bundleContext_isBundleInstalled
bool celix_bundleContext_isBundleInstalled(celix_bundle_context_t *ctx, long bndId)
Check whether a bundle is installed.
celix_bundle_tracker_options::CELIX_OPTS_INIT
void *callbackHandle CELIX_OPTS_INIT
The optional callback pointer used in all the provided callback function (set, add,...
Definition: celix_bundle_context.h:1002
celix_service_tracker_info::serviceLanguage
const char * serviceLanguage
Definition: celix_bundle_context.h:1152
celix_bundleContext_getBundle
celix_bundle_t * celix_bundleContext_getBundle(const celix_bundle_context_t *ctx)
Returns the bundle for this bundle context.
celix_bundleContext_unregisterService
void celix_bundleContext_unregisterService(celix_bundle_context_t *ctx, long serviceId)
Unregister the service or service factory with service id.
celix_service_registration_options::CELIX_OPTS_INIT
void *svc CELIX_OPTS_INIT
The service pointer.
Definition: celix_bundle_context.h:129
celix_service_tracker_info::serviceName
const char * serviceName
The service name filter attribute parsed from the service filter (i.e. the value of the objectClass a...
Definition: celix_bundle_context.h:1146
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 (bund...