Author: abroekhuis
Date: Tue Dec  6 09:32:06 2011
New Revision: 1210833

URL: http://svn.apache.org/viewvc?rev=1210833&view=rev
Log:
Update bundle api, added getServicesInUser

Modified:
    incubator/celix/trunk/framework/private/include/bundle.h
    incubator/celix/trunk/framework/private/include/service_reference.h
    incubator/celix/trunk/framework/private/include/service_registry.h
    incubator/celix/trunk/framework/private/src/bundle.c
    incubator/celix/trunk/framework/private/src/framework.c
    incubator/celix/trunk/framework/private/src/service_reference.c
    incubator/celix/trunk/framework/private/src/service_registry.c

Modified: incubator/celix/trunk/framework/private/include/bundle.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/bundle.h?rev=1210833&r1=1210832&r2=1210833&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/bundle.h (original)
+++ incubator/celix/trunk/framework/private/include/bundle.h Tue Dec  6 
09:32:06 2011
@@ -83,5 +83,6 @@ celix_status_t bundle_refresh(BUNDLE bun
 celix_status_t bundle_getBundleId(BUNDLE bundle, long *id);
 
 celix_status_t bundle_getRegisteredServices(BUNDLE bundle, ARRAY_LIST *list);
+celix_status_t bundle_getServicesInUse(BUNDLE bundle, ARRAY_LIST *list);
 
 #endif /* BUNDLE_H_ */

Modified: incubator/celix/trunk/framework/private/include/service_reference.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/service_reference.h?rev=1210833&r1=1210832&r2=1210833&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/service_reference.h 
(original)
+++ incubator/celix/trunk/framework/private/include/service_reference.h Tue Dec 
 6 09:32:06 2011
@@ -31,4 +31,6 @@
 
 bool serviceReference_isAssignableTo(SERVICE_REFERENCE reference, BUNDLE 
requester, char * serviceName);
 
+celix_status_t serviceReference_getUsingBundles(SERVICE_REFERENCE reference, 
apr_pool_t *pool, ARRAY_LIST *bundles);
+
 #endif /* SERVICE_REFERENCE_H_ */

Modified: incubator/celix/trunk/framework/private/include/service_registry.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/service_registry.h?rev=1210833&r1=1210832&r2=1210833&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/service_registry.h 
(original)
+++ incubator/celix/trunk/framework/private/include/service_registry.h Tue Dec  
6 09:32:06 2011
@@ -36,6 +36,7 @@
 SERVICE_REGISTRY serviceRegistry_create(FRAMEWORK framework, void 
(*serviceChanged)(FRAMEWORK, SERVICE_EVENT, PROPERTIES));
 celix_status_t serviceRegistry_destroy(SERVICE_REGISTRY registry);
 ARRAY_LIST serviceRegistry_getRegisteredServices(SERVICE_REGISTRY registry, 
BUNDLE bundle);
+ARRAY_LIST serviceRegistry_getServicesInUse(SERVICE_REGISTRY registry, BUNDLE 
bundle);
 SERVICE_REGISTRATION serviceRegistry_registerService(SERVICE_REGISTRY 
registry, BUNDLE bundle, char * serviceName, void * serviceObject, PROPERTIES 
dictionary);
 SERVICE_REGISTRATION serviceRegistry_registerServiceFactory(SERVICE_REGISTRY 
registry, BUNDLE bundle, char * serviceName, service_factory_t factory, 
PROPERTIES dictionary);
 void serviceRegistry_unregisterService(SERVICE_REGISTRY registry, BUNDLE 
bundle, SERVICE_REGISTRATION registration);
@@ -44,7 +45,7 @@ ARRAY_LIST serviceRegistry_getServiceRef
 void * serviceRegistry_getService(SERVICE_REGISTRY registry, BUNDLE bundle, 
SERVICE_REFERENCE reference);
 bool serviceRegistry_ungetService(SERVICE_REGISTRY registry, BUNDLE bundle, 
SERVICE_REFERENCE reference);
 void serviceRegistry_ungetServices(SERVICE_REGISTRY registry, BUNDLE bundle);
-ARRAY_LIST serviceRegistry_getUsingBundles(SERVICE_REGISTRY registry, 
SERVICE_REFERENCE reference);
+ARRAY_LIST serviceRegistry_getUsingBundles(SERVICE_REGISTRY registry, 
apr_pool_t *pool, SERVICE_REFERENCE reference);
 SERVICE_REGISTRATION serviceRegistry_findRegistration(SERVICE_REGISTRY 
registry, SERVICE_REFERENCE reference);
 
 celix_status_t serviceRegistry_getListenerHooks(SERVICE_REGISTRY registry, 
ARRAY_LIST *hooks);

Modified: incubator/celix/trunk/framework/private/src/bundle.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle.c?rev=1210833&r1=1210832&r2=1210833&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle.c Tue Dec  6 09:32:06 
2011
@@ -525,3 +525,11 @@ celix_status_t bundle_getRegisteredServi
 
        return status;
 }
+
+celix_status_t bundle_getServicesInUse(BUNDLE bundle, ARRAY_LIST *list) {
+       celix_status_t status = CELIX_SUCCESS;
+
+       status = fw_getBundleServicesInUse(bundle->framework, bundle, list);
+
+       return status;
+}

Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1210833&r1=1210832&r2=1210833&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Tue Dec  6 09:32:06 
2011
@@ -1081,6 +1081,12 @@ celix_status_t fw_getBundleRegisteredSer
        return status;
 }
 
+celix_status_t fw_getBundleServicesInUse(FRAMEWORK framework, BUNDLE bundle, 
ARRAY_LIST *services) {
+       celix_status_t status = CELIX_SUCCESS;
+       *services = serviceRegistry_getServicesInUse(framework->registry, 
bundle);
+       return status;
+}
+
 bool framework_ungetService(FRAMEWORK framework, BUNDLE bundle 
ATTRIBUTE_UNUSED, SERVICE_REFERENCE reference) {
        return serviceRegistry_ungetService(framework->registry, bundle, 
reference);
 }

Modified: incubator/celix/trunk/framework/private/src/service_reference.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_reference.c?rev=1210833&r1=1210832&r2=1210833&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_reference.c (original)
+++ incubator/celix/trunk/framework/private/src/service_reference.c Tue Dec  6 
09:32:06 2011
@@ -23,6 +23,8 @@
  *      Author: alexanderb
  */
 #include <stdio.h>
+#include <stdlib.h>
+
 #include "service_reference.h"
 #include "module.h"
 #include "wire.h"
@@ -51,3 +53,13 @@ bool serviceReference_isAssignableTo(SER
        return allow;
 }
 
+celix_status_t serviceReference_getUsingBundles(SERVICE_REFERENCE reference, 
apr_pool_t *pool, ARRAY_LIST *bundles) {
+       celix_status_t status = CELIX_SUCCESS;
+
+       ARRAY_LIST bnds = 
serviceRegistry_getUsingBundles(reference->registration->registry, pool, 
reference);
+
+       *bundles = bnds;
+
+       return status;
+}
+

Modified: incubator/celix/trunk/framework/private/src/service_registry.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_registry.c?rev=1210833&r1=1210832&r2=1210833&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registry.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registry.c Tue Dec  6 
09:32:06 2011
@@ -221,7 +221,7 @@ void serviceRegistry_unregisterService(S
        pthread_mutex_lock(&registry->mutex);
        // unget service
 
-       ARRAY_LIST clients = serviceRegistry_getUsingBundles(registry, 
registration->reference);
+       ARRAY_LIST clients = serviceRegistry_getUsingBundles(registry, 
registry->framework->mp, registration->reference);
        int i;
        for (i = 0; (clients != NULL) && (i < arrayList_size(clients)); i++) {
                BUNDLE client = arrayList_get(clients, i);
@@ -332,7 +332,7 @@ void * serviceRegistry_getService(SERVIC
                serviceRegistration_getService(registration, bundle, &service);
        }
        pthread_mutex_lock(&registry->mutex);
-       if ((serviceRegistration_isValid(registration)) || (service == NULL)) {
+       if ((!serviceRegistration_isValid(registration)) || (service == NULL)) {
                serviceRegistry_flushUsageCount(registry, bundle, reference);
        } else {
                usage->service = service;
@@ -391,9 +391,11 @@ void serviceRegistry_ungetServices(SERVI
        arrayList_destroy(fusages);
 }
 
-ARRAY_LIST serviceRegistry_getUsingBundles(SERVICE_REGISTRY registry, 
SERVICE_REFERENCE reference) {
+ARRAY_LIST serviceRegistry_getUsingBundles(SERVICE_REGISTRY registry, 
apr_pool_t *pool, SERVICE_REFERENCE reference) {
        ARRAY_LIST bundles = NULL;
-       arrayList_create(registry->framework->mp, &bundles);
+       apr_pool_t *npool;
+       apr_pool_create(&npool, pool);
+       arrayList_create(npool, &bundles);
        HASH_MAP_ITERATOR iter = hashMapIterator_create(registry->inUseMap);
        while (hashMapIterator_hasNext(iter)) {
                HASH_MAP_ENTRY entry = hashMapIterator_nextEntry(iter);


Reply via email to