celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pepijn Noltes <pepijnnol...@gmail.com>
Subject Re: framework uuid
Date Sun, 17 Feb 2013 20:11:41 GMT
Hi Bjorn,


On Fri, Feb 15, 2013 at 6:12 PM, Björn Petri <bjoern.petri@sundevil.de>wrote:

>
>
> Hi!
>
> I tried to get the celix framework uuid by using the following:
>
>    /* get framework uuid */
>    status = bundleContext_getProperty(bi->**context,
> "endpoint.framework.uuid", &uuidStr)
>
> Unfortunately it does not work ;(. Does anyone have an idea how
> to get the framework uuid?
>

The property endpoint.framework.uuid is used in the remote service admin, I
think the property you are looking for is FRAMEWORK_UUID
(org.osgi.framework.uuid). Apache Celix does not support this yet. I will
try to add this in the coming days.

In the meantime if you just need a unique id, you could also generate one
with apr_utils. The endpoint.framework.uuid is generated in same way:

celix_status_t remoteServicesUtils_getUUID(apr_pool_t *pool, BUNDLE_CONTEXT
context, char **uuidStr) {
        celix_status_t status = CELIX_SUCCESS;

        status = bundleContext_getProperty(context,
ENDPOINT_FRAMEWORK_UUID, uuidStr);
        if (status == CELIX_SUCCESS) {
                if (*uuidStr == NULL) {
                        *uuidStr = apr_palloc(pool,
APR_UUID_FORMATTED_LENGTH + 1);
                        if (!*uuidStr) {
                                status = CELIX_ENOMEM;
                        } else {
                                apr_uuid_t uuid;
                                apr_uuid_get(&uuid);
                                apr_uuid_format(*uuidStr, &uuid);
                                setenv(ENDPOINT_FRAMEWORK_UUID, *uuidStr,
1);
                        }
                }
        }

        return status;
}


I hope this helps.

Greetings,
Pepijn

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message