You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by ab...@apache.org on 2014/09/30 10:18:24 UTC
svn commit: r1628371 - in /celix/trunk:
device_access/device_access/private/src/
device_access/example/consuming_driver/private/src/
device_access/example/refining_driver/private/src/
event_admin/event_admin/private/src/ framework/private/include/ fram...
Author: abroekhuis
Date: Tue Sep 30 08:18:23 2014
New Revision: 1628371
URL: http://svn.apache.org/r1628371
Log:
CELIX-157: Updated the registration and reference API according to the OSGi spec. Refactored code using the private API.
Modified:
celix/trunk/device_access/device_access/private/src/device_manager.c
celix/trunk/device_access/device_access/private/src/driver_attributes.c
celix/trunk/device_access/device_access/private/src/driver_matcher.c
celix/trunk/device_access/example/consuming_driver/private/src/consuming_driver.c
celix/trunk/device_access/example/refining_driver/private/src/refining_driver.c
celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c
celix/trunk/framework/private/include/service_reference_private.h
celix/trunk/framework/private/include/service_registration_private.h
celix/trunk/framework/private/src/framework.c
celix/trunk/framework/private/src/service_reference.c
celix/trunk/framework/private/src/service_registry.c
celix/trunk/framework/public/include/service_reference.h
celix/trunk/framework/public/include/service_registration.h
celix/trunk/remote_services/discovery/private/src/discovery.c
celix/trunk/remote_services/discovery_bonjour/private/src/discovery.c
celix/trunk/remote_services/discovery_shm/private/src/discovery.c
celix/trunk/remote_services/discovery_slp/private/src/discovery.c
celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
celix/trunk/remote_services/topology_manager/private/src/activator.c
celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
celix/trunk/shell/private/src/inspect_command.c
Modified: celix/trunk/device_access/device_access/private/src/device_manager.c
URL: http://svn.apache.org/viewvc/celix/trunk/device_access/device_access/private/src/device_manager.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/device_access/device_access/private/src/device_manager.c (original)
+++ celix/trunk/device_access/device_access/private/src/device_manager.c Tue Sep 30 08:18:23 2014
@@ -158,43 +158,49 @@ static celix_status_t deviceManager_atta
if (status == CELIX_SUCCESS) {
status = arrayList_create(&excluded);
if (status == CELIX_SUCCESS) {
- service_registration_pt registration = NULL;
- status = serviceReference_getServiceRegistration(ref, ®istration);
- if (status == CELIX_SUCCESS) {
- properties_pt properties = NULL;
- status = serviceRegistration_getProperties(registration, &properties);
- if (status == CELIX_SUCCESS) {
- status = driverLoader_findDrivers(loader, attachPool, manager->locators, properties, &driverIds);
- if (status == CELIX_SUCCESS) {
- hash_map_iterator_pt iter = hashMapIterator_create(manager->drivers);
- while (hashMapIterator_hasNext(iter)) {
- driver_attributes_pt driverAttributes = hashMapIterator_nextValue(iter);
- arrayList_add(included, driverAttributes);
-
- // Each driver that already is installed can be removed from the list
- char *id = NULL;
- celix_status_t substatus = driverAttributes_getDriverId(driverAttributes, &id);
- if (substatus == CELIX_SUCCESS) {
- // arrayList_removeElement(driverIds, id);
- array_list_iterator_pt idsIter = arrayListIterator_create(driverIds);
- while (arrayListIterator_hasNext(idsIter)) {
- char *value = arrayListIterator_next(idsIter);
- if (strcmp(value, id) == 0) {
- arrayListIterator_remove(idsIter);
- }
- }
- arrayListIterator_destroy(idsIter);
- } else {
- // Ignore
- }
- }
- hashMapIterator_destroy(iter);
+ properties_pt properties = properties_create();
- status = deviceManager_matchAttachDriver(manager, attachPool, loader, driverIds, included, excluded, service, ref);
- arrayList_destroy(driverIds);
- }
- }
- }
+ unsigned int size = 0;
+ char **keys;
+
+ serviceReference_getPropertyKeys(ref, &keys, &size);
+ for (int i = 0; i < size; i++) {
+ char *key = keys[i];
+ char *value = NULL;
+ serviceReference_getProperty(ref, key, &value);
+ properties_set(properties, key, value);
+ }
+
+ status = driverLoader_findDrivers(loader, attachPool, manager->locators, properties, &driverIds);
+ if (status == CELIX_SUCCESS) {
+ hash_map_iterator_pt iter = hashMapIterator_create(manager->drivers);
+ while (hashMapIterator_hasNext(iter)) {
+ driver_attributes_pt driverAttributes = hashMapIterator_nextValue(iter);
+ arrayList_add(included, driverAttributes);
+
+ // Each driver that already is installed can be removed from the list
+ char *id = NULL;
+ celix_status_t substatus = driverAttributes_getDriverId(driverAttributes, &id);
+ if (substatus == CELIX_SUCCESS) {
+ // arrayList_removeElement(driverIds, id);
+ array_list_iterator_pt idsIter = arrayListIterator_create(driverIds);
+ while (arrayListIterator_hasNext(idsIter)) {
+ char *value = arrayListIterator_next(idsIter);
+ if (strcmp(value, id) == 0) {
+ arrayListIterator_remove(idsIter);
+ }
+ }
+ arrayListIterator_destroy(idsIter);
+ } else {
+ // Ignore
+ }
+ }
+ hashMapIterator_destroy(iter);
+
+ status = deviceManager_matchAttachDriver(manager, attachPool, loader, driverIds, included, excluded, service, ref);
+ arrayList_destroy(driverIds);
+ }
+ properties_destroy(properties);
arrayList_destroy(excluded);
}
arrayList_destroy(included);
@@ -258,33 +264,25 @@ celix_status_t deviceManager_matchAttach
if (match == NULL) {
status = deviceManager_noDriverFound(manager, service, reference);
} else {
- service_registration_pt registration = NULL;
- status = serviceReference_getServiceRegistration(match->reference, ®istration);
- if (status == CELIX_SUCCESS) {
- properties_pt properties = NULL;
- status = serviceRegistration_getProperties(registration, &properties);
- if (status == CELIX_SUCCESS) {
- driver_attributes_pt finalAttributes = hashMap_get(manager->drivers, match->reference);
- if (finalAttributes == NULL) {
- status = deviceManager_noDriverFound(manager, service, reference);
- } else {
- char *newDriverId = NULL;
- status = driverAttributes_attach(finalAttributes, reference, &newDriverId);
- if (status == CELIX_SUCCESS) {
- if (newDriverId != NULL) {
- array_list_pt ids = NULL;
- arrayList_create(&ids);
- arrayList_add(ids, newDriverId);
- arrayList_add(excluded, finalAttributes);
- status = deviceManager_matchAttachDriver(manager, attachPool, loader,
- ids, included, excluded, service, reference);
- } else {
- // Attached, unload unused drivers
- status = driverLoader_unloadDrivers(loader, finalAttributes);
- }
- }
- }
- }
+ driver_attributes_pt finalAttributes = hashMap_get(manager->drivers, match->reference);
+ if (finalAttributes == NULL) {
+ status = deviceManager_noDriverFound(manager, service, reference);
+ } else {
+ char *newDriverId = NULL;
+ status = driverAttributes_attach(finalAttributes, reference, &newDriverId);
+ if (status == CELIX_SUCCESS) {
+ if (newDriverId != NULL) {
+ array_list_pt ids = NULL;
+ arrayList_create(&ids);
+ arrayList_add(ids, newDriverId);
+ arrayList_add(excluded, finalAttributes);
+ status = deviceManager_matchAttachDriver(manager, attachPool, loader,
+ ids, included, excluded, service, reference);
+ } else {
+ // Attached, unload unused drivers
+ status = driverLoader_unloadDrivers(loader, finalAttributes);
+ }
+ }
}
}
}
@@ -300,19 +298,12 @@ celix_status_t deviceManager_matchAttach
celix_status_t deviceManager_noDriverFound(device_manager_pt manager, void *service, service_reference_pt reference) {
celix_status_t status = CELIX_SUCCESS;
- service_registration_pt registration = NULL;
- status = serviceReference_getServiceRegistration(reference, ®istration);
- if (status == CELIX_SUCCESS) {
- properties_pt properties = NULL;
- status = serviceRegistration_getProperties(registration, &properties);
- if (status == CELIX_SUCCESS) {
- char *objectClass = properties_get(properties, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
- if (strcmp(objectClass, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME) == 0) {
- device_service_pt device = service;
- status = device->noDriverFound(device->device);
- }
- }
- }
+ char *objectClass = NULL;
+ serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &objectClass);
+ if (strcmp(objectClass, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME) == 0) {
+ device_service_pt device = service;
+ status = device->noDriverFound(device->device);
+ }
return status;
}
@@ -544,22 +535,13 @@ celix_status_t deviceManager_isDriverBun
if (refs != NULL) {
int i;
for (i = 0; i < arrayList_size(refs); i++) {
- celix_status_t substatus = CELIX_SUCCESS;
service_reference_pt ref = arrayList_get(refs, i);
- service_registration_pt registration = NULL;
- substatus = serviceReference_getServiceRegistration(ref, ®istration);
- if (substatus == CELIX_SUCCESS) {
- properties_pt properties = NULL;
- substatus = serviceRegistration_getProperties(registration, &properties);
- if (substatus == CELIX_SUCCESS) {
- char *object = properties_get(properties, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
- if (strcmp(object, "driver") == 0) {
- *isDriver = true;
- break;
- }
- }
-
- }
+ char *object = NULL;
+ serviceReference_getProperty(ref, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &object);
+ if (strcmp(object, "driver") == 0) {
+ *isDriver = true;
+ break;
+ }
}
arrayList_destroy(refs);
}
Modified: celix/trunk/device_access/device_access/private/src/driver_attributes.c
URL: http://svn.apache.org/viewvc/celix/trunk/device_access/device_access/private/src/driver_attributes.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/device_access/device_access/private/src/driver_attributes.c (original)
+++ celix/trunk/device_access/device_access/private/src/driver_attributes.c Tue Sep 30 08:18:23 2014
@@ -83,24 +83,17 @@ celix_status_t driverAttributes_getRefer
celix_status_t driverAttributes_getDriverId(driver_attributes_pt driverAttributes, char **driverId) {
celix_status_t status = CELIX_SUCCESS;
- service_registration_pt registration = NULL;
- status = serviceReference_getServiceRegistration(driverAttributes->reference, ®istration);
- if (status == CELIX_SUCCESS) {
- properties_pt properties = NULL;
- status = serviceRegistration_getProperties(registration, &properties);
-
- if (status == CELIX_SUCCESS) {
- char *id_prop = properties_get(properties, "DRIVER_ID");
-
- if (!id_prop) {
- status = CELIX_ENOMEM;
- } else {
- *driverId = apr_pstrdup(driverAttributes->pool,id_prop);
+ char *id_prop = NULL;
+ status = serviceReference_getProperty(driverAttributes->reference, "DRIVER_ID", &id_prop);
+ if (status == CELIX_SUCCESS) {
+ if (!id_prop) {
+ status = CELIX_ENOMEM;
+ } else {
+ *driverId = apr_pstrdup(driverAttributes->pool,id_prop);
- if (*driverId == NULL) {
- status = CELIX_ENOMEM;
- }
+ if (*driverId == NULL) {
+ status = CELIX_ENOMEM;
}
}
}
@@ -116,28 +109,6 @@ celix_status_t driverAttributes_match(dr
return status;
}
-celix_status_t static get_property_from_registration(service_reference_pt ref, char *key, char **prop_value) {
- celix_status_t status = CELIX_SUCCESS;
- service_registration_pt registration = NULL;
- status = serviceReference_getServiceRegistration(ref, ®istration);
-
- if (status == CELIX_SUCCESS) {
- properties_pt properties = NULL;
- status = serviceRegistration_getProperties(registration, &properties);
-
- if (status == CELIX_SUCCESS) {
- (*prop_value) = properties_get(properties, key);
-
- if (*prop_value == NULL) {
- status = CELIX_ENOMEM;
- }
- }
- }
-
- return status;
-}
-
-
celix_status_t driverAttributes_isInUse(driver_attributes_pt driverAttributes, bool *inUse) {
celix_status_t status = CELIX_SUCCESS;
@@ -151,11 +122,11 @@ celix_status_t driverAttributes_isInUse(
for (i = 0; i < arrayList_size(references); i++) {
service_reference_pt ref = arrayList_get(references, i);
char *object = NULL;
- status = get_property_from_registration(ref, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &object);
+ status = serviceReference_getProperty(ref, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &object);
if (status == CELIX_SUCCESS) {
char *category = NULL;
- status = get_property_from_registration(ref, "DEVICE_CATEGORY", &category);
+ status = serviceReference_getProperty(ref, "DEVICE_CATEGORY", &category);
if (status == CELIX_SUCCESS) {
if ((object != NULL && strcmp(object, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME) == 0) || (category != NULL)) {
Modified: celix/trunk/device_access/device_access/private/src/driver_matcher.c
URL: http://svn.apache.org/viewvc/celix/trunk/device_access/device_access/private/src/driver_matcher.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/device_access/device_access/private/src/driver_matcher.c (original)
+++ celix/trunk/device_access/device_access/private/src/driver_matcher.c Tue Sep 30 08:18:23 2014
@@ -199,39 +199,34 @@ celix_status_t driverMatcher_getBestMatc
fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DRIVER_MATCHER: Compare ranking");
char *rank1Str, *rank2Str;
int rank1, rank2;
- service_registration_pt registration = NULL;
- substatus = serviceReference_getServiceRegistration(reference, ®istration);
- if (substatus == CELIX_SUCCESS) {
- properties_pt properties = NULL;
- status = serviceRegistration_getProperties(registration, &properties);
- if (status == CELIX_SUCCESS) {
-
- rank1Str = properties_getWithDefault(properties, (char *) OSGI_FRAMEWORK_SERVICE_RANKING, "0");
- rank2Str = properties_getWithDefault(properties, (char *) OSGI_FRAMEWORK_SERVICE_RANKING, "0");
-
- rank1 = atoi(rank1Str);
- rank2 = atoi(rank2Str);
-
- if (rank1 != rank2) {
- if (rank1 > rank2) {
- best = reference;
- }
- } else {
- fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DRIVER_MATCHER: Compare id's");
- char *id1Str, *id2Str;
- long id1, id2;
-
- id1Str = properties_get(properties, (char *) OSGI_FRAMEWORK_SERVICE_ID);
- id2Str = properties_get(properties, (char *) OSGI_FRAMEWORK_SERVICE_ID);
-
- id1 = atol(id1Str);
- id2 = atol(id2Str);
-
- if (id1 < id2) {
- best = reference;
- }
- }
- }
+ rank1Str = "0";
+ rank2Str = "0";
+ serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_RANKING, &rank1Str);
+ serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_RANKING, &rank2Str);
+
+ rank1 = atoi(rank1Str);
+ rank2 = atoi(rank2Str);
+
+ if (rank1 != rank2) {
+ if (rank1 > rank2) {
+ best = reference;
+ }
+ } else {
+ fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DRIVER_MATCHER: Compare id's");
+ char *id1Str, *id2Str;
+ long id1, id2;
+
+ id1Str = NULL;
+ id2Str = NULL;
+ serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_ID, &id1Str);
+ serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_ID, &id2Str);
+
+ id1 = atol(id1Str);
+ id2 = atol(id2Str);
+
+ if (id1 < id2) {
+ best = reference;
+ }
}
} else {
best = reference;
Modified: celix/trunk/device_access/example/consuming_driver/private/src/consuming_driver.c
URL: http://svn.apache.org/viewvc/celix/trunk/device_access/example/consuming_driver/private/src/consuming_driver.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/device_access/example/consuming_driver/private/src/consuming_driver.c (original)
+++ celix/trunk/device_access/example/consuming_driver/private/src/consuming_driver.c Tue Sep 30 08:18:23 2014
@@ -126,18 +126,13 @@ celix_status_t consumingDriver_match(voi
int match=0;
celix_status_t status = CELIX_SUCCESS;
- service_registration_pt registration = NULL;
- properties_pt properties = NULL;
- status = serviceReference_getServiceRegistration(reference, ®istration);
- if (status == CELIX_SUCCESS) {
- status = serviceRegistration_getProperties(registration, &properties);
- if (status == CELIX_SUCCESS) {
- char *category = properties_get(properties, OSGI_DEVICEACCESS_DEVICE_CATEGORY);
- if (strcmp(category, REFINING_DRIVER_DEVICE_CATEGORY) == 0) {
- match = 10;
- }
- }
- }
+ char *category = NULL;
+ status = serviceReference_getProperty(reference, OSGI_DEVICEACCESS_DEVICE_CATEGORY, &category);
+ if (status == CELIX_SUCCESS) {
+ if (strcmp(category, REFINING_DRIVER_DEVICE_CATEGORY) == 0) {
+ match = 10;
+ }
+ }
(*value) = match;
return status;
Modified: celix/trunk/device_access/example/refining_driver/private/src/refining_driver.c
URL: http://svn.apache.org/viewvc/celix/trunk/device_access/example/refining_driver/private/src/refining_driver.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/device_access/example/refining_driver/private/src/refining_driver.c (original)
+++ celix/trunk/device_access/example/refining_driver/private/src/refining_driver.c Tue Sep 30 08:18:23 2014
@@ -230,18 +230,13 @@ celix_status_t refiningDriver_match(void
int match = 0;
celix_status_t status = CELIX_SUCCESS;
- service_registration_pt registration = NULL;
- properties_pt properties = NULL;
- status = serviceReference_getServiceRegistration(reference, ®istration);
- if (status == CELIX_SUCCESS) {
- status = serviceRegistration_getProperties(registration, &properties);
- if (status == CELIX_SUCCESS) {
- char *category = properties_get(properties, OSGI_DEVICEACCESS_DEVICE_CATEGORY);
- if (strcmp(category, BASE_DRIVER_DEVICE_CATEGORY) == 0) {
- match = 10;
- }
- }
- }
+ char *category = NULL;
+ status = serviceReference_getProperty(reference, OSGI_DEVICEACCESS_DEVICE_CATEGORY, &category);
+ if (status == CELIX_SUCCESS) {
+ if (strcmp(category, BASE_DRIVER_DEVICE_CATEGORY) == 0) {
+ match = 10;
+ }
+ }
(*value) = match;
return status;
Modified: celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c (original)
+++ celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c Tue Sep 30 08:18:23 2014
@@ -212,11 +212,8 @@ celix_status_t eventAdmin_addedService(v
event_admin_pt event_admin = handle;
event_handler_service_pt event_handler_service = NULL;
event_handler_service = (event_handler_service_pt) service;
- service_registration_pt registration = NULL;
- serviceReference_getServiceRegistration(ref,®istration);
- properties_pt props = NULL;
- serviceRegistration_getProperties(registration, &props);
- char *topic = properties_get(props, (char*)EVENT_TOPIC);
+ char *topic = NULL;
+ serviceReference_getProperty(ref, (char*)EVENT_TOPIC, &topic);
fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "Original TOPIC: %s", topic);
eventAdmin_createEventChannels(&event_admin,topic,event_handler_service);
return status;
Modified: celix/trunk/framework/private/include/service_reference_private.h
URL: http://svn.apache.org/viewvc/celix/trunk/framework/private/include/service_reference_private.h?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/framework/private/include/service_reference_private.h (original)
+++ celix/trunk/framework/private/include/service_reference_private.h Tue Sep 30 08:18:23 2014
@@ -35,5 +35,12 @@ struct serviceReference {
struct serviceRegistration * registration;
};
+celix_status_t serviceReference_create(bundle_pt bundle, service_registration_pt registration, service_reference_pt *reference);
+celix_status_t serviceReference_destroy(service_reference_pt reference);
+
+celix_status_t serviceReference_invalidate(service_reference_pt reference);
+celix_status_t serviceRefernce_isValid(service_reference_pt reference, bool *result);
+
+celix_status_t serviceReference_getServiceRegistration(service_reference_pt reference, service_registration_pt *registration);
#endif /* SERVICE_REFERENCE_PRIVATE_H_ */
Modified: celix/trunk/framework/private/include/service_registration_private.h
URL: http://svn.apache.org/viewvc/celix/trunk/framework/private/include/service_registration_private.h?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/framework/private/include/service_registration_private.h (original)
+++ celix/trunk/framework/private/include/service_registration_private.h Tue Sep 30 08:18:23 2014
@@ -53,4 +53,17 @@ struct serviceRegistration {
int nrOfServices;
};
+service_registration_pt serviceRegistration_create(service_registry_pt registry, bundle_pt bundle, char * serviceName, long serviceId, void * serviceObject, properties_pt dictionary);
+service_registration_pt serviceRegistration_createServiceFactory(service_registry_pt registry, bundle_pt bundle, char * serviceName, long serviceId, void * serviceObject, properties_pt dictionary);
+celix_status_t serviceRegistration_destroy(service_registration_pt registration);
+
+bool serviceRegistration_isValid(service_registration_pt registration);
+void serviceRegistration_invalidate(service_registration_pt registration);
+
+celix_status_t serviceRegistration_getService(service_registration_pt registration, bundle_pt bundle, void **service);
+celix_status_t serviceRegistration_getProperties(service_registration_pt registration, properties_pt *properties);
+celix_status_t serviceRegistration_getRegistry(service_registration_pt registration, service_registry_pt *registry);
+celix_status_t serviceRegistration_getBundle(service_registration_pt registration, bundle_pt *bundle);
+celix_status_t serviceRegistration_getServiceName(service_registration_pt registration, char **serviceName);
+
#endif /* SERVICE_REGISTRATION_PRIVATE_H_ */
Modified: celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/celix/trunk/framework/private/src/framework.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/framework/private/src/framework.c (original)
+++ celix/trunk/framework/private/src/framework.c Tue Sep 30 08:18:23 2014
@@ -53,9 +53,9 @@
#include "bundle_revision.h"
#include "bundle_context.h"
#include "linked_list_iterator.h"
-#include "service_reference.h"
+#include "service_reference_private.h"
#include "listener_hook_service.h"
-#include "service_registration.h"
+#include "service_registration_private.h"
#include "celix_log.h"
#include "celix_threads.h"
Modified: celix/trunk/framework/private/src/service_reference.c
URL: http://svn.apache.org/viewvc/celix/trunk/framework/private/src/service_reference.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/framework/private/src/service_reference.c (original)
+++ celix/trunk/framework/private/src/service_reference.c Tue Sep 30 08:18:23 2014
@@ -30,7 +30,7 @@
#include "service_registry.h"
#include "service_reference_private.h"
-#include "service_registration.h"
+#include "service_registration_private.h"
#include "module.h"
#include "wire.h"
#include "bundle.h"
@@ -71,6 +71,36 @@ celix_status_t serviceReference_getServi
return CELIX_SUCCESS;
}
+celix_status_t serviceReference_getProperty(service_reference_pt reference, char *key, char **value) {
+ celix_status_t status = CELIX_SUCCESS;
+ properties_pt props = NULL;
+
+ serviceRegistration_getProperties(reference->registration, &props);
+ *value = properties_get(props, key);
+
+ return status;
+}
+
+FRAMEWORK_EXPORT celix_status_t serviceReference_getPropertyKeys(service_reference_pt reference, char **keys[], unsigned int *size) {
+ celix_status_t status = CELIX_SUCCESS;
+ properties_pt props = NULL;
+
+ serviceRegistration_getProperties(reference->registration, &props);
+ hash_map_iterator_pt it;
+ int i = 0;
+ int vsize = hashMap_size(props);
+ *size = vsize;
+ *keys = malloc(vsize * sizeof(*keys));
+ it = hashMapIterator_create(props);
+ while (hashMapIterator_hasNext(it)) {
+ (*keys)[i] = hashMapIterator_nextKey(it);
+ i++;
+ }
+ hashMapIterator_destroy(it);
+
+ return status;
+}
+
celix_status_t serviceReference_invalidate(service_reference_pt reference) {
reference->registration = NULL;
return CELIX_SUCCESS;
Modified: celix/trunk/framework/private/src/service_registry.c
URL: http://svn.apache.org/viewvc/celix/trunk/framework/private/src/service_registry.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/framework/private/src/service_registry.c (original)
+++ celix/trunk/framework/private/src/service_registry.c Tue Sep 30 08:18:23 2014
@@ -28,12 +28,12 @@
#include <string.h>
#include "service_registry_private.h"
-#include "service_registration.h"
+#include "service_registration_private.h"
#include "module.h"
#include "bundle.h"
#include "listener_hook_service.h"
#include "constants.h"
-#include "service_reference.h"
+#include "service_reference_private.h"
#include "framework_private.h"
#include "celix_log.h"
Modified: celix/trunk/framework/public/include/service_reference.h
URL: http://svn.apache.org/viewvc/celix/trunk/framework/public/include/service_reference.h?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/framework/public/include/service_reference.h (original)
+++ celix/trunk/framework/public/include/service_reference.h Tue Sep 30 08:18:23 2014
@@ -35,18 +35,15 @@ typedef struct serviceReference * servic
#include "bundle.h"
#include "framework_exports.h"
-celix_status_t serviceReference_create(bundle_pt bundle, service_registration_pt registration, service_reference_pt *reference);
-celix_status_t serviceReference_destroy(service_reference_pt reference);
-
-FRAMEWORK_EXPORT celix_status_t serviceReference_invalidate(service_reference_pt reference);
-FRAMEWORK_EXPORT celix_status_t serviceRefernce_isValid(service_reference_pt reference, bool *result);
-
-FRAMEWORK_EXPORT celix_status_t serviceReference_getServiceRegistration(service_reference_pt reference, service_registration_pt *registration);
FRAMEWORK_EXPORT celix_status_t serviceReference_getBundle(service_reference_pt reference, bundle_pt *bundle);
FRAMEWORK_EXPORT bool serviceReference_isAssignableTo(service_reference_pt reference, bundle_pt requester, char * serviceName);
FRAMEWORK_EXPORT celix_status_t serviceReference_getUsingBundles(service_reference_pt reference, array_list_pt *bundles);
+
+FRAMEWORK_EXPORT celix_status_t serviceReference_getProperty(service_reference_pt reference, char *key, char **value);
+FRAMEWORK_EXPORT celix_status_t serviceReference_getPropertyKeys(service_reference_pt reference, char **keys[], unsigned int *size);
+
FRAMEWORK_EXPORT celix_status_t serviceReference_equals(service_reference_pt reference, service_reference_pt compareTo, bool *equal);
FRAMEWORK_EXPORT unsigned int serviceReference_hashCode(void *referenceP);
FRAMEWORK_EXPORT int serviceReference_equals2(void *reference1, void *reference2);
Modified: celix/trunk/framework/public/include/service_registration.h
URL: http://svn.apache.org/viewvc/celix/trunk/framework/public/include/service_registration.h?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/framework/public/include/service_registration.h (original)
+++ celix/trunk/framework/public/include/service_registration.h Tue Sep 30 08:18:23 2014
@@ -36,22 +36,10 @@ typedef struct serviceRegistration * ser
#include "bundle.h"
#include "framework_exports.h"
-service_registration_pt serviceRegistration_create(service_registry_pt registry, bundle_pt bundle, char * serviceName, long serviceId, void * serviceObject, properties_pt dictionary);
-service_registration_pt serviceRegistration_createServiceFactory(service_registry_pt registry, bundle_pt bundle, char * serviceName, long serviceId, void * serviceObject, properties_pt dictionary);
-celix_status_t serviceRegistration_destroy(service_registration_pt registration);
-FRAMEWORK_EXPORT bool serviceRegistration_isValid(service_registration_pt registration);
-FRAMEWORK_EXPORT void serviceRegistration_invalidate(service_registration_pt registration);
FRAMEWORK_EXPORT celix_status_t serviceRegistration_unregister(service_registration_pt registration);
-FRAMEWORK_EXPORT celix_status_t serviceRegistration_getService(service_registration_pt registration, bundle_pt bundle, void **service);
-
FRAMEWORK_EXPORT celix_status_t serviceRegistration_setProperties(service_registration_pt registration, properties_pt properties);
-
-FRAMEWORK_EXPORT celix_status_t serviceRegistration_getProperties(service_registration_pt registration, properties_pt *properties);
-FRAMEWORK_EXPORT celix_status_t serviceRegistration_getRegistry(service_registration_pt registration, service_registry_pt *registry);
FRAMEWORK_EXPORT celix_status_t serviceRegistration_getServiceReferences(service_registration_pt registration, array_list_pt *references);
-FRAMEWORK_EXPORT celix_status_t serviceRegistration_getBundle(service_registration_pt registration, bundle_pt *bundle);
-FRAMEWORK_EXPORT celix_status_t serviceRegistration_getServiceName(service_registration_pt registration, char **serviceName);
#endif /* SERVICE_REGISTRATION_H_ */
Modified: celix/trunk/remote_services/discovery/private/src/discovery.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery/private/src/discovery.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery/private/src/discovery.c (original)
+++ celix/trunk/remote_services/discovery/private/src/discovery.c Tue Sep 30 08:18:23 2014
@@ -82,14 +82,11 @@ celix_status_t discovery_endpointListene
celix_status_t status = CELIX_SUCCESS;
discovery_pt discovery = handle;
- service_registration_pt registration = NULL;
- serviceReference_getServiceRegistration(reference, ®istration);
+ char *discoveryListener = NULL;
+ serviceReference_getProperty(reference, "DISCOVERY", &discoveryListener);
+ char *scope = NULL;
+ serviceReference_getProperty(reference, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, &scope);
- properties_pt serviceProperties = NULL;
- serviceRegistration_getProperties(registration, &serviceProperties);
-
- char *discoveryListener = properties_get(serviceProperties, "DISCOVERY");
- char *scope = properties_get(serviceProperties, (char *) OSGI_ENDPOINT_LISTENER_SCOPE);
filter_pt filter = filter_create(scope);
if (discoveryListener != NULL && strcmp(discoveryListener, "true") == 0) {
@@ -167,12 +164,8 @@ celix_status_t discovery_informEndpointL
service_reference_pt reference = hashMapEntry_getKey(entry);
endpoint_listener_pt listener = NULL;
- service_registration_pt registration = NULL;
- serviceReference_getServiceRegistration(reference, ®istration);
-
- properties_pt serviceProperties = NULL;
- serviceRegistration_getProperties(registration, &serviceProperties);
- char *scope = properties_get(serviceProperties, (char *) OSGI_ENDPOINT_LISTENER_SCOPE);
+ char *scope = NULL;
+ serviceReference_getProperty(reference, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, &scope);
filter_pt filter = filter_create(scope);
bool matchResult = false;
Modified: celix/trunk/remote_services/discovery_bonjour/private/src/discovery.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_bonjour/private/src/discovery.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_bonjour/private/src/discovery.c (original)
+++ celix/trunk/remote_services/discovery_bonjour/private/src/discovery.c Tue Sep 30 08:18:23 2014
@@ -307,11 +307,8 @@ celix_status_t discovery_endpointListene
celix_status_t status = CELIX_SUCCESS;
discovery_pt discovery = handle;
- service_registration_pt registration = NULL;
- serviceReference_getServiceRegistration(reference, ®istration);
- properties_pt serviceProperties = NULL;
- serviceRegistration_getProperties(registration, &serviceProperties);
- char *discoveryListener = properties_get(serviceProperties, "DISCOVERY");
+ char *discoveryListener = NULL;
+ serviceReference_getProperty(reference, "DISCOVERY", &discoveryListener);
if (discoveryListener != NULL && strcmp(discoveryListener, "true") == 0) {
fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "DISCOVERY: EndpointListener Ignored - Discovery listener.");
@@ -325,8 +322,8 @@ celix_status_t discovery_endpointListene
endpoint_description_pt endpoint = hashMapIterator_nextKey(iter);
endpoint_listener_pt listener = service;
- char *scope = properties_get(serviceProperties,
- (char *) OSGI_ENDPOINT_LISTENER_SCOPE);
+ char *scope = NULL;
+ serviceReference_getProperty(reference, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, &scope);
filter_pt filter = filter_create(scope); //FIXME memory leak
bool matchResult = false;
filter_match(filter, endpoint->properties, &matchResult);
@@ -505,12 +502,8 @@ static celix_status_t discovery_informEn
service_reference_pt reference = hashMapEntry_getKey(entry);
endpoint_listener_pt listener = NULL;
- service_registration_pt registration = NULL;
- serviceReference_getServiceRegistration(reference, ®istration);
- properties_pt serviceProperties = NULL;
- serviceRegistration_getProperties(registration, &serviceProperties);
- char *scope = properties_get(serviceProperties,
- (char *) OSGI_ENDPOINT_LISTENER_SCOPE);
+ char *scope = NULL;
+ serviceReference_getProperty(reference, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, &scope);
filter_pt filter = filter_create(scope);
bool matchResult = false;
filter_match(filter, endpoint->properties, &matchResult);
Modified: celix/trunk/remote_services/discovery_shm/private/src/discovery.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_shm/private/src/discovery.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_shm/private/src/discovery.c (original)
+++ celix/trunk/remote_services/discovery_shm/private/src/discovery.c Tue Sep 30 08:18:23 2014
@@ -180,11 +180,8 @@ celix_status_t discovery_addService(disc
service_reference_pt reference = hashMapEntry_getKey(entry);
endpoint_listener_pt listener = NULL;
- service_registration_pt registration = NULL;
- serviceReference_getServiceRegistration(reference, ®istration);
- properties_pt serviceProperties = NULL;
- serviceRegistration_getProperties(registration, &serviceProperties);
- char *scope = properties_get(serviceProperties, (char *) OSGI_ENDPOINT_LISTENER_SCOPE);
+ char *scope = NULL;
+ serviceReference_getProperty(reference, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, &scope);
filter_pt filter = filter_create(scope);
bool matchResult = false;
filter_match(filter, endpoint->properties, &matchResult);
@@ -691,11 +688,8 @@ celix_status_t discovery_endpointListene
celix_status_t status = CELIX_SUCCESS;
discovery_pt discovery = handle;
- service_registration_pt registration = NULL;
- serviceReference_getServiceRegistration(reference, ®istration);
- properties_pt serviceProperties = NULL;
- serviceRegistration_getProperties(registration, &serviceProperties);
- char *discoveryListener = properties_get(serviceProperties, "DISCOVERY");
+ char *discoveryListener = NULL;
+ serviceReference_getProperty(reference, "DISCOVERY", &discoveryListener);
if (discoveryListener != NULL && strcmp(discoveryListener, "true") == 0) {
fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DISCOVERY_SHM: EndpointListener Ignored - Discovery listener.");
Modified: celix/trunk/remote_services/discovery_slp/private/src/discovery.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_slp/private/src/discovery.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery_slp/private/src/discovery.c (original)
+++ celix/trunk/remote_services/discovery_slp/private/src/discovery.c Tue Sep 30 08:18:23 2014
@@ -177,11 +177,8 @@ celix_status_t discovery_addService(disc
service_reference_pt reference = hashMapEntry_getKey(entry);
endpoint_listener_pt listener = NULL;
- service_registration_pt registration = NULL;
- serviceReference_getServiceRegistration(reference, ®istration);
- properties_pt serviceProperties = NULL;
- serviceRegistration_getProperties(registration, &serviceProperties);
- char *scope = properties_get(serviceProperties, (char *) OSGI_ENDPOINT_LISTENER_SCOPE);
+ char *scope = NULL;
+ serviceReference_getProperty(reference, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, &scope);
filter_pt filter = filter_create(scope);
bool matchResult = false;
filter_match(filter, endpoint->properties, &matchResult);
@@ -332,11 +329,8 @@ celix_status_t discovery_endpointListene
celix_status_t status = CELIX_SUCCESS;
discovery_pt discovery = handle;
- service_registration_pt registration = NULL;
- serviceReference_getServiceRegistration(reference, ®istration);
- properties_pt serviceProperties = NULL;
- serviceRegistration_getProperties(registration, &serviceProperties);
- char *discoveryListener = properties_get(serviceProperties, "DISCOVERY");
+ char *discoveryListener = NULL;
+ serviceReference_getProperty(reference, "DISCOVERY", &discoveryListener);
if (discoveryListener != NULL && strcmp(discoveryListener, "true") == 0) {
fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "DISCOVERY: EndpointListener Ignored - Discovery listener.");
Modified: celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c (original)
+++ celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c Tue Sep 30 08:18:23 2014
@@ -70,7 +70,7 @@ static const char *DEFAULT_PORT = "8888"
static int remoteServiceAdmin_callback(struct mg_connection *conn);
celix_status_t remoteServiceAdmin_installEndpoint(remote_service_admin_pt admin, export_registration_pt registration, service_reference_pt reference, char *interface);
-celix_status_t remoteServiceAdmin_createEndpointDescription(remote_service_admin_pt admin, properties_pt serviceProperties, properties_pt endpointProperties, char *interface, endpoint_description_pt *description);
+celix_status_t remoteServiceAdmin_createEndpointDescription(remote_service_admin_pt admin, service_reference_pt reference, properties_pt endpointProperties, char *interface, endpoint_description_pt *description);
static celix_status_t constructServiceUrl(remote_service_admin_pt admin, char *service, char **serviceUrl);
static size_t remoteServiceAdmin_readCallback(void *ptr, size_t size, size_t nmemb, void *userp);
@@ -227,7 +227,6 @@ celix_status_t remoteServiceAdmin_export
arrayList_create(registrations);
array_list_pt references = NULL;
service_reference_pt reference = NULL;
- service_registration_pt registration = NULL;
apr_pool_t *tmpPool = NULL;
apr_pool_create(&tmpPool, admin->pool);
@@ -251,12 +250,10 @@ celix_status_t remoteServiceAdmin_export
return CELIX_ILLEGAL_STATE;
}
-
- serviceReference_getServiceRegistration(reference, ®istration);
- properties_pt serviceProperties = NULL;
- serviceRegistration_getProperties(registration, &serviceProperties);
- char *exports = properties_get(serviceProperties, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES);
- char *provided = properties_get(serviceProperties, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
+ char *exports = NULL;
+ char *provided = NULL;
+ serviceReference_getProperty(reference, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &exports);
+ serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &provided);
if (exports == NULL || provided == NULL) {
fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "RSA: No Services to export.");
@@ -323,22 +320,17 @@ celix_status_t remoteServiceAdmin_remove
celix_status_t remoteServiceAdmin_installEndpoint(remote_service_admin_pt admin, export_registration_pt registration, service_reference_pt reference, char *interface) {
celix_status_t status = CELIX_SUCCESS;
properties_pt endpointProperties = properties_create();
- properties_pt serviceProperties = NULL;
- service_registration_pt sRegistration = NULL;
- serviceReference_getServiceRegistration(reference, &sRegistration);
+ unsigned int size = 0;
+ char **keys;
- serviceRegistration_getProperties(sRegistration, &serviceProperties);
-
- hash_map_iterator_pt iter = hashMapIterator_create(serviceProperties);
- while (hashMapIterator_hasNext(iter)) {
- hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
- char *key = (char *) hashMapEntry_getKey(entry);
- char *value = (char *) hashMapEntry_getValue(entry);
+ serviceReference_getPropertyKeys(reference, &keys, &size);
+ for (int i = 0; i < size; i++) {
+ char *key = keys[i];
+ char *value = NULL;
properties_set(endpointProperties, key, value);
}
- hashMapIterator_destroy(iter);
char *serviceId = (char *) hashMap_remove(endpointProperties, (void *) OSGI_FRAMEWORK_SERVICE_ID);
char *uuid = NULL;
@@ -363,7 +355,7 @@ celix_status_t remoteServiceAdmin_instal
properties_set(endpointProperties, (char*) ENDPOINT_URL, url);
endpoint_description_pt endpointDescription = NULL;
- remoteServiceAdmin_createEndpointDescription(admin, serviceProperties, endpointProperties, interface, &endpointDescription);
+ remoteServiceAdmin_createEndpointDescription(admin, reference, endpointProperties, interface, &endpointDescription);
exportRegistration_setEndpointDescription(registration, endpointDescription);
return status;
@@ -400,7 +392,7 @@ static celix_status_t constructServiceUr
return status;
}
-celix_status_t remoteServiceAdmin_createEndpointDescription(remote_service_admin_pt admin, properties_pt serviceProperties,
+celix_status_t remoteServiceAdmin_createEndpointDescription(remote_service_admin_pt admin, service_reference_pt reference,
properties_pt endpointProperties, char *interface, endpoint_description_pt *description) {
celix_status_t status = CELIX_SUCCESS;
@@ -412,7 +404,9 @@ celix_status_t remoteServiceAdmin_create
status = CELIX_ENOMEM;
} else {
(*description)->id = properties_get(endpointProperties, (char*) OSGI_RSA_ENDPOINT_ID);
- (*description)->serviceId = apr_atoi64(properties_get(serviceProperties, (char*) OSGI_FRAMEWORK_SERVICE_ID));
+ char *serviceId = NULL;
+ serviceReference_getProperty(reference, (char*) OSGI_FRAMEWORK_SERVICE_ID, &serviceId);
+ (*description)->serviceId = apr_atoi64(serviceId);
(*description)->frameworkUUID = properties_get(endpointProperties, (char*) OSGI_RSA_ENDPOINT_FRAMEWORK_UUID);
(*description)->service = interface;
(*description)->properties = endpointProperties;
Modified: celix/trunk/remote_services/topology_manager/private/src/activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/topology_manager/private/src/activator.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/remote_services/topology_manager/private/src/activator.c (original)
+++ celix/trunk/remote_services/topology_manager/private/src/activator.c Tue Sep 30 08:18:23 2014
@@ -160,18 +160,11 @@ celix_status_t bundleActivator_start(voi
int i;
for (i = 0; i < arrayList_size(references); i++) {
service_reference_pt reference = arrayList_get(references, i);
-
- service_registration_pt registration = NULL;
- serviceReference_getServiceRegistration(reference, ®istration);
- properties_pt props = NULL;
- serviceRegistration_getProperties(registration, &props);
- char *serviceId = properties_get(props, (char *)OSGI_FRAMEWORK_SERVICE_ID);
-
- status = topologyManager_addExportedService(activator->manager, reference, serviceId);
+ char *serviceId = NULL;
+ status = CELIX_DO_IF(status, serviceReference_getProperty(reference, (char *)OSGI_FRAMEWORK_SERVICE_ID, &serviceId));
+ status = CELIX_DO_IF(status, topologyManager_addExportedService(activator->manager, reference, serviceId));
}
-
-
return status;
}
Modified: celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/remote_services/topology_manager/private/src/topology_manager.c (original)
+++ celix/trunk/remote_services/topology_manager/private/src/topology_manager.c Tue Sep 30 08:18:23 2014
@@ -219,13 +219,10 @@ celix_status_t topologyManager_serviceCh
service_listener_pt listen = listener;
topology_manager_pt manager = listen->handle;
- service_registration_pt registration = NULL;
- serviceReference_getServiceRegistration(event->reference, ®istration);
-
- properties_pt props = NULL;
- serviceRegistration_getProperties(registration, &props);
- char *export = properties_get(props, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES);
- char *serviceId = properties_get(props, (char *)OSGI_FRAMEWORK_SERVICE_ID);
+ char *export = NULL;
+ char *serviceId = NULL;
+ serviceReference_getProperty(event->reference, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &export);
+ serviceReference_getProperty(event->reference, (char *)OSGI_FRAMEWORK_SERVICE_ID, &serviceId);
if (!export) {
// Nothing needs to be done: we're not interested...
Modified: celix/trunk/shell/private/src/inspect_command.c
URL: http://svn.apache.org/viewvc/celix/trunk/shell/private/src/inspect_command.c?rev=1628371&r1=1628370&r2=1628371&view=diff
==============================================================================
--- celix/trunk/shell/private/src/inspect_command.c (original)
+++ celix/trunk/shell/private/src/inspect_command.c Tue Sep 30 08:18:23 2014
@@ -165,20 +165,18 @@ celix_status_t inspectCommand_printExpor
unsigned int j = 0;
for (j = 0; j < arrayList_size(refs); j++) {
service_reference_pt ref = (service_reference_pt) arrayList_get(refs, j);
- service_registration_pt reg = NULL;
- properties_pt props = NULL;
- char line[256];
-
- serviceReference_getServiceRegistration(ref, ®);
-
- serviceRegistration_getProperties(reg, &props);
- hash_map_iterator_pt iter = hashMapIterator_create(props);
- while (hashMapIterator_hasNext(iter)) {
- hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
- sprintf(line, "%s = %s\n", (char*) hashMapEntry_getKey(entry), (char*) hashMapEntry_getValue(entry));
- out(line);
+ unsigned int size = 0;
+ char **keys;
+
+ serviceReference_getPropertyKeys(ref, &keys, &size);
+ for (int i = 0; i < size; i++) {
+ char *key = keys[i];
+ char *value = NULL;
+ serviceReference_getProperty(ref, key, &value);
+
+ sprintf(line, "%s = %s\n", key, value);
+ out(line);
}
- hashMapIterator_destroy(iter);
// objectClass = properties_get(props, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
// sprintf(line, "ObjectClass = %s\n", objectClass);
@@ -253,8 +251,6 @@ celix_status_t inspectCommand_printImpor
unsigned int j = 0;
for (j = 0; j < arrayList_size(refs); j++) {
service_reference_pt ref = (service_reference_pt) arrayList_get(refs, j);
- service_registration_pt reg = NULL;
- properties_pt props = NULL;
char line[256];
bundle_pt usedBundle = NULL;
module_pt usedModule = NULL;
@@ -269,15 +265,18 @@ celix_status_t inspectCommand_printImpor
sprintf(line, "%s [%ld]\n", usedSymbolicName, usedBundleId);
out(line);
- serviceReference_getServiceRegistration(ref, ®);
- serviceRegistration_getProperties(reg, &props);
- hash_map_iterator_pt iter = hashMapIterator_create(props);
- while (hashMapIterator_hasNext(iter)) {
- hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
- sprintf(line, "%s = %s\n", (char*) hashMapEntry_getKey(entry), (char*) hashMapEntry_getValue(entry));
+ unsigned int size = 0;
+ char **keys;
+
+ serviceReference_getPropertyKeys(ref, &keys, &size);
+ for (int i = 0; i < size; i++) {
+ char *key = keys[i];
+ char *value = NULL;
+ serviceReference_getProperty(ref, key, &value);
+
+ sprintf(line, "%s = %s\n", key, value);
out(line);
}
- hashMapIterator_destroy(iter);
// objectClass = properties_get(props, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
// sprintf(line, "ObjectClass = %s\n", objectClass);