Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into feature/685-refactor-manifest-f…
Browse files Browse the repository at this point in the history
…ormat
  • Loading branch information
pnoltes committed Jul 26, 2024
2 parents 7b4b0cc + bba867a commit 89bafcb
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extern "C" {
/**
* @brief The Event Admin service name
*/
#define CELIX_EVENT_ADMIN_SERVICE_NAME "celix.service.event.EventAdmin"
#define CELIX_EVENT_ADMIN_SERVICE_NAME "celix_event_admin_service"

/**
* @brief The Event Admin service version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern "C" {
/**
* @brief Name of the event handler service
*/
#define CELIX_EVENT_HANDLER_SERVICE_NAME "celix.service.event.EventHandler"
#define CELIX_EVENT_HANDLER_SERVICE_NAME "celix_event_handler_service"

/**
* @brief Version of the event handler service
Expand Down
9 changes: 9 additions & 0 deletions libs/framework/gtest/src/CelixFrameworkTestSuite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,15 @@ TEST_F(FrameworkFactoryTestSuite, FactoryCreateTest) {
celix_frameworkFactory_destroyFramework(fw);
}

TEST_F(FrameworkFactoryTestSuite, ConfigureFrameworkUUIDTest) {
celix_properties_t* config = celix_properties_create();
celix_properties_set(config, CELIX_FRAMEWORK_UUID, "test-framework");
framework_t* fw = celix_frameworkFactory_createFramework(config);
ASSERT_TRUE(fw != nullptr);
EXPECT_STREQ("test-framework", celix_framework_getUUID(fw));
celix_frameworkFactory_destroyFramework(fw);
}

TEST_F(FrameworkFactoryTestSuite, FactoryCreateAndToManyStartAndStopsTest) {
framework_t* fw = celix_frameworkFactory_createFramework(nullptr);
ASSERT_TRUE(fw != nullptr);
Expand Down
2 changes: 1 addition & 1 deletion libs/framework/include/celix/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ namespace celix {
constexpr const char * const FRAMEWORK_CACHE_DIR = CELIX_FRAMEWORK_CACHE_DIR;

/**
* @brief Celix framework environment property (named "org.osgi.framework.uuid") specifying the UUID for the
* @brief Celix framework environment property (named "CELIX_FRAMEWORK_UUID") specifying the UUID for the
* framework UUID.
*
* The framework UUID is used to uniquely identify a single framework. If no framework uuid is provided
Expand Down
4 changes: 2 additions & 2 deletions libs/framework/include/celix_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ extern "C" {
#define CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE "CELIX_FRAMEWORK_CLEAN_CACHE_DIR_ON_CREATE"

/**
* @brief Celix framework environment property (named "org.osgi.framework.uuid") specifying the UUID for the
* @brief Celix framework environment property (named "CELIX_FRAMEWORK_UUID") specifying the UUID for the
* framework UUID.
*
* The framework UUID is used to uniquely identify a single framework. If no framework uuid is provided
* random uuid will be generated during startup.
*
* @note The Celix framework expects framework UUIDs to be unique per process.
*/
#define CELIX_FRAMEWORK_UUID "org.osgi.framework.uuid"
#define CELIX_FRAMEWORK_UUID "CELIX_FRAMEWORK_UUID"

/**
* @brief Celix framework environment property (named "CELIX_BUNDLES_PATH") which specified a `:` separated
Expand Down
16 changes: 10 additions & 6 deletions libs/framework/src/framework.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,15 @@ struct fw_frameworkListener {

typedef struct fw_frameworkListener * fw_framework_listener_pt;

static void celix_framework_createAndStoreFrameworkUUID(celix_framework_t* fw) {
if (celix_properties_get(fw->configurationMap, CELIX_FRAMEWORK_UUID, NULL) == NULL) {
char uuid[37];
uuid_t uid;
uuid_generate(uid);
uuid_unparse(uid, uuid);
celix_properties_set(fw->configurationMap, CELIX_FRAMEWORK_UUID, uuid);
}
}

celix_status_t framework_create(framework_pt *out, celix_properties_t* config) {
celix_framework_t* framework = calloc(1, sizeof(*framework));
Expand Down Expand Up @@ -244,12 +253,7 @@ celix_status_t framework_create(framework_pt *out, celix_properties_t* config) {
framework->dispatcher.dynamicEventQueue = celix_arrayList_create();
framework->dispatcher.scheduledEvents = celix_longHashMap_create();

//create and store framework uuid
char uuid[37];
uuid_t uid;
uuid_generate(uid);
uuid_unparse(uid, uuid);
celix_properties_set(framework->configurationMap, CELIX_FRAMEWORK_UUID, uuid);
celix_framework_createAndStoreFrameworkUUID(framework);

//setup framework logger
const char* logStr = celix_framework_getConfigProperty(framework, CELIX_LOGGING_DEFAULT_ACTIVE_LOG_LEVEL_CONFIG_NAME, CELIX_LOGGING_DEFAULT_ACTIVE_LOG_LEVEL_DEFAULT_VALUE, NULL);
Expand Down

0 comments on commit 89bafcb

Please sign in to comment.