Apache Celix  2.3.0
An implementation of the OSGi specification adapted to C and C++
Public Attributes | List of all members
celix_service_registration_options Struct Reference

Service Registration Options when registering services to the Celix framework. More...

#include <celix_bundle_context.h>

Public Attributes

void *svc CELIX_OPTS_INIT
 The service pointer. More...
 
celix_service_factory_t *factory CELIX_OPTS_INIT
 The service factory pointer. More...
 
const char *serviceName CELIX_OPTS_INIT
 The required service name. More...
 
celix_properties_t *properties CELIX_OPTS_INIT
 The optional service properties. More...
 
const char *serviceLanguage CELIX_OPTS_INIT
 The optional service language. More...
 
const char *serviceVersion CELIX_OPTS_INIT
 The optional service version (in the form of <MAJOR>.<MINOR>.<MICRO>.<QUALIFIER>). More...
 
void *asyncData CELIX_OPTS_INIT
 Async data pointer for the async register callback. More...
 
void(* asyncCallback )(void *data, long serviceId) CELIX_OPTS_INIT
 Async callback. More...
 

Detailed Description

Service Registration Options when registering services to the Celix framework.

Member Data Documentation

◆ asyncCallback

void(* celix_service_registration_options::asyncCallback) (void *data, long serviceId) CELIX_OPTS_INIT

Async callback.

Will be called after the a service is registered in the service registry using a async call. Will be called on the Celix event loop.

If a asyns service registration is combined with a sync service unregistration, it can happen that unregistration happens before the registration event is processed. In this case the asyncCallback will not be called.

◆ CELIX_OPTS_INIT [1/7]

void* svc celix_service_registration_options::CELIX_OPTS_INIT

The service pointer.

The actual pointer to the service. For C this is normally a pointer to a struct with function pointers, but theoretically this can be a pointer to anything (e.g. a pointer to a single function, or a pointer to a C++ interface implementation, or just a pointer to a data structure).

The bundle is responsible to keep the service pointer valid as long as it is registered in the Celix framework.

◆ CELIX_OPTS_INIT [2/7]

celix_service_factory_t* factory celix_service_registration_options::CELIX_OPTS_INIT

The service factory pointer.

Note if the factory service is set, the svc field will not be used.

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 when a service tacker is stopped) the ungetService function of the service factory will be called.

The bundle is responsible to keep the service factory pointer valid as long as it is registered in the Celix framework.

◆ CELIX_OPTS_INIT [3/7]

const char* serviceName celix_service_registration_options::CELIX_OPTS_INIT

The required service name.

This is used to identify the service. A fully qualified name with a namespace is advisable to prevent name collision. (e.g. EXAMPLE_PRESSURE_SENSOR).

◆ CELIX_OPTS_INIT [4/7]

celix_properties_t* properties celix_service_registration_options::CELIX_OPTS_INIT

The optional service properties.

These contain meta information about the service in the form of string key/values. (e.g. the location of a pressure sensor: location=left-tire).

When a service is registered the Celix framework will take ownership of the provided properties. If a registration fails, the properties will be destroyed (freed) by the Celix framework.

◆ CELIX_OPTS_INIT [5/7]

const char* serviceLanguage celix_service_registration_options::CELIX_OPTS_INIT

The optional service language.

If this is NULL, CELIX_FRAMEWORK_SERVICE_LANGUAGE_C is used.

◆ CELIX_OPTS_INIT [6/7]

const char* serviceVersion celix_service_registration_options::CELIX_OPTS_INIT

The optional service version (in the form of <MAJOR>.<MINOR>.<MICRO>.<QUALIFIER>).

If present consumer of the service can specific which service version range of a specific service they are interested in. Note that it is the responsibility of the users to ensure that service in those version range are compatible (binary of source). It is advisable to use semantic versioning for this.

◆ CELIX_OPTS_INIT [7/7]

void* asyncData celix_service_registration_options::CELIX_OPTS_INIT

Async data pointer for the async register callback.


The documentation for this struct was generated from the following file: