incubator-celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1235725 - in /incubator/celix/trunk: ./ dependency_manager/ examples/echo_service/client/ examples/osgi-in-action/chapter04-paint-example/paint/private/src/ examples/whiteboard/tracker/ framework/ framework/private/src/ framework/public/in...
Date Wed, 25 Jan 2012 12:27:32 GMT
Author: abroekhuis
Date: Wed Jan 25 12:27:31 2012
New Revision: 1235725

URL: http://svn.apache.org/viewvc?rev=1235725&view=rev
Log:
Refactor service tracker

Refactored service tracker to use memory pools

Modified:
    incubator/celix/trunk/WB Dependency Manager.launch
    incubator/celix/trunk/dependency_manager/service_dependency.c
    incubator/celix/trunk/examples/echo_service/client/echo_client_activator.c
    incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/activator.c
    incubator/celix/trunk/examples/whiteboard/tracker/activator.c
    incubator/celix/trunk/framework/CMakeLists.txt
    incubator/celix/trunk/framework/private/src/bundle_context.c
    incubator/celix/trunk/framework/private/src/filter.c
    incubator/celix/trunk/framework/private/src/service_tracker.c
    incubator/celix/trunk/framework/public/include/service_tracker.h
    incubator/celix/trunk/remote_services/discovery/private/src/discovery_activator.c
    incubator/celix/trunk/remote_services/remote_service_admin/private/src/export_registration_impl.c
    incubator/celix/trunk/remote_services/remote_service_admin/private/src/import_registration_impl.c
    incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c
    incubator/celix/trunk/target.cmake

Modified: incubator/celix/trunk/WB Dependency Manager.launch
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/WB%20Dependency%20Manager.launch?rev=1235725&r1=1235724&r2=1235725&view=diff
==============================================================================
--- incubator/celix/trunk/WB Dependency Manager.launch (original)
+++ incubator/celix/trunk/WB Dependency Manager.launch Wed Jan 25 12:27:31 2012
@@ -20,7 +20,7 @@
 <listAttribute key="org.eclipse.cdt.dsf.gdb.SOLIB_PATH"/>
 <booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
 <booleanAttribute key="org.eclipse.cdt.dsf.gdb.internal.ui.launching.LocalApplicationCDebuggerTab.DEFAULTS_SET"
value="true"/>
-<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
+<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="0"/>
 <stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="org.eclipse.cdt.debug.mi.core.CDebuggerNew"/>
 <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>

Modified: incubator/celix/trunk/dependency_manager/service_dependency.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/dependency_manager/service_dependency.c?rev=1235725&r1=1235724&r2=1235725&view=diff
==============================================================================
--- incubator/celix/trunk/dependency_manager/service_dependency.c (original)
+++ incubator/celix/trunk/dependency_manager/service_dependency.c Wed Jan 25 12:27:31 2012
@@ -79,10 +79,13 @@ void serviceDependency_start(SERVICE_DEP
 
 	dependency->tracker = NULL;
 
+	apr_pool_t *pool;
+	bundleContext_getMemoryPool(dependency->context, &pool);
+
 	if (dependency->trackedServiceFilter != NULL) {
-		tracker_createWithFilter(dependency->context, dependency->trackedServiceFilter, cust,
&dependency->tracker);
+		serviceTracker_createWithFilter(pool, dependency->context, dependency->trackedServiceFilter,
cust, &dependency->tracker);
 	} else if (dependency->trackedServiceName != NULL) {
-		serviceTracker_create(dependency->context, dependency->trackedServiceName, cust,
&dependency->tracker);
+		serviceTracker_create(pool, dependency->context, dependency->trackedServiceName,
cust, &dependency->tracker);
 	} else {
 
 	}
@@ -93,7 +96,6 @@ void serviceDependency_start(SERVICE_DEP
 void serviceDependency_stop(SERVICE_DEPENDENCY dependency, SERVICE service) {
 	dependency->started = true;
 	serviceTracker_close(dependency->tracker);
-	tracker_destroy(dependency->tracker);
 }
 
 celix_status_t serviceDependency_addingService(void * handle, SERVICE_REFERENCE reference,
void **service) {

Modified: incubator/celix/trunk/examples/echo_service/client/echo_client_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/echo_service/client/echo_client_activator.c?rev=1235725&r1=1235724&r2=1235725&view=diff
==============================================================================
--- incubator/celix/trunk/examples/echo_service/client/echo_client_activator.c (original)
+++ incubator/celix/trunk/examples/echo_service/client/echo_client_activator.c Wed Jan 25
12:27:31 2012
@@ -49,8 +49,11 @@ celix_status_t bundleActivator_create(BU
 celix_status_t bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
 	struct echoActivator * act = (struct echoActivator *) userData;
 
+	apr_pool_t *pool = NULL;
 	SERVICE_TRACKER tracker = NULL;
-	serviceTracker_create(context, ECHO_SERVICE_NAME, NULL, &tracker);
+
+	bundleContext_getMemoryPool(context, &pool);
+	serviceTracker_create(pool, context, ECHO_SERVICE_NAME, NULL, &tracker);
 	act->tracker = tracker;
 
 	ECHO_CLIENT client = echoClient_create(tracker);
@@ -73,7 +76,6 @@ celix_status_t bundleActivator_stop(void
 celix_status_t bundleActivator_destroy(void * userData, BUNDLE_CONTEXT context) {
 	struct echoActivator * act = (struct echoActivator *) userData;
 	echoClient_destroy(act->client);
-	tracker_destroy(act->tracker);
 
 	return CELIX_SUCCESS;
 }

Modified: incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/activator.c?rev=1235725&r1=1235724&r2=1235725&view=diff
==============================================================================
--- incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/activator.c
(original)
+++ incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/activator.c
Wed Jan 25 12:27:31 2012
@@ -66,7 +66,7 @@ celix_status_t bundleActivator_create(BU
         cust->addingService = addingServ;
         cust->modifiedService = modifiedServ;
         cust->removedService = removedServ;
-        serviceTracker_create(context, SIMPLE_SHAPE_SERVICE_NAME, cust, &activator->tracker);
+        serviceTracker_create(pool, context, SIMPLE_SHAPE_SERVICE_NAME, cust, &activator->tracker);
 		serviceTracker_open(activator->tracker);
 
 	}

Modified: incubator/celix/trunk/examples/whiteboard/tracker/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/whiteboard/tracker/activator.c?rev=1235725&r1=1235724&r2=1235725&view=diff
==============================================================================
--- incubator/celix/trunk/examples/whiteboard/tracker/activator.c (original)
+++ incubator/celix/trunk/examples/whiteboard/tracker/activator.c Wed Jan 25 12:27:31 2012
@@ -111,7 +111,7 @@ celix_status_t bundleActivator_start(voi
         cust->modifiedService = modifiedServ;
         cust->removedService = removedServ;
         SERVICE_TRACKER tracker = NULL;
-        serviceTracker_create(context, (char *) PUBLISHER_NAME, cust, &tracker);
+        serviceTracker_create(pool, context, (char *) PUBLISHER_NAME, cust, &tracker);
         data->tracker = tracker;
 
         serviceTracker_open(tracker);
@@ -138,5 +138,9 @@ celix_status_t bundleActivator_stop(void
 
 celix_status_t bundleActivator_destroy(void * userData, BUNDLE_CONTEXT context) {
     celix_status_t status = CELIX_SUCCESS;
+    struct data * data = (struct data *) userData;
+
+    arrayList_destroy(data->publishers);
+
     return status;
 }

Modified: incubator/celix/trunk/framework/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/CMakeLists.txt?rev=1235725&r1=1235724&r2=1235725&view=diff
==============================================================================
--- incubator/celix/trunk/framework/CMakeLists.txt (original)
+++ incubator/celix/trunk/framework/CMakeLists.txt Wed Jan 25 12:27:31 2012
@@ -43,5 +43,5 @@ add_library(framework SHARED ${SRC})
 target_link_libraries(framework utils ${ZLIB_LIBRARY} ${APR_LIBRARY})
 
 install(TARGETS framework DESTINATION lib COMPONENT framework)
-FILE(GLOB files "private/include/*.h")
+FILE(GLOB files "public/include/*.h")
 INSTALL(FILES ${files} DESTINATION include COMPONENT framework)

Modified: incubator/celix/trunk/framework/private/src/bundle_context.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_context.c?rev=1235725&r1=1235724&r2=1235725&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_context.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_context.c Wed Jan 25 12:27:31 2012
@@ -72,12 +72,12 @@ celix_status_t bundleContext_destroy(BUN
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (context != NULL) {
-		context->bundle = NULL;
-		context->framework = NULL;
 		if (context->pool) {
 			apr_pool_destroy(context->pool);
 		    context->pool = NULL;
 		}
+		context->bundle = NULL;
+		context->framework = NULL;
 		free(context);
 		context = NULL;
 	} else {

Modified: incubator/celix/trunk/framework/private/src/filter.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/filter.c?rev=1235725&r1=1235724&r2=1235725&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/filter.c (original)
+++ incubator/celix/trunk/framework/private/src/filter.c Wed Jan 25 12:27:31 2012
@@ -90,8 +90,17 @@ void filter_destroy(FILTER filter) {
 			arrayList_clear(filter->value);
 			arrayList_destroy(filter->value);
 			filter->value = NULL;
+		} else if (filter->operand == OR) {
+			int size = arrayList_size(filter->value);
+			int i = 0;
+			for (i = 0; i < size; i++) {
+				FILTER f = arrayList_get(filter->value, i);
+				filter_destroy(f);
+			}
+			arrayList_destroy(filter->value);
+			filter->value = NULL;
 		} else {
-			 free(filter->value);
+			free(filter->value);
 			filter->value = NULL;
 		}
 		free(filter->attribute);

Modified: incubator/celix/trunk/framework/private/src/service_tracker.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_tracker.c?rev=1235725&r1=1235724&r2=1235725&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_tracker.c (original)
+++ incubator/celix/trunk/framework/private/src/service_tracker.c Wed Jan 25 12:27:31 2012
@@ -34,28 +34,34 @@ struct serviceTracker {
 	BUNDLE_CONTEXT context;
 	char * filter;
 
-	FW_SERVICE_TRACKER fwTracker;
+	apr_pool_t *pool;
+	SERVICE_TRACKER tracker;
+	SERVICE_TRACKER_CUSTOMIZER customizer;
+	SERVICE_LISTENER listener;
+	ARRAY_LIST tracked;
 };
 
-// #todo: Remove this, make SERVICE_TRACKER an ADT to keep "hidden" information
-//ARRAY_LIST m_trackers;
+struct tracked {
+	SERVICE_REFERENCE reference;
+	void * service;
+};
 
-void * addingService(FW_SERVICE_TRACKER, SERVICE_REFERENCE);
-celix_status_t serviceTracker_track(FW_SERVICE_TRACKER, SERVICE_REFERENCE, SERVICE_EVENT);
-celix_status_t serviceTracker_untrack(FW_SERVICE_TRACKER fwTracker, SERVICE_REFERENCE reference,
SERVICE_EVENT event);
+typedef struct tracked * TRACKED;
 
-celix_status_t serviceTracker_create(BUNDLE_CONTEXT context, char * service, SERVICE_TRACKER_CUSTOMIZER
customizer, SERVICE_TRACKER *tracker) {
+static apr_status_t serviceTracker_destroy(void *trackerP);
+static void * addingService(SERVICE_TRACKER tracker, SERVICE_REFERENCE reference);
+static celix_status_t serviceTracker_track(SERVICE_TRACKER tracker, SERVICE_REFERENCE reference,
SERVICE_EVENT event);
+static celix_status_t serviceTracker_untrack(SERVICE_TRACKER tracker, SERVICE_REFERENCE reference,
SERVICE_EVENT event);
+
+celix_status_t serviceTracker_create(apr_pool_t *pool, BUNDLE_CONTEXT context, char * service,
SERVICE_TRACKER_CUSTOMIZER customizer, SERVICE_TRACKER *tracker) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	if (service == NULL) {
+	if (service == NULL || *tracker != NULL) {
 		status = CELIX_ILLEGAL_ARGUMENT;
 	} else {
-		apr_pool_t *pool = NULL;
-		//status = bundleContext_getMemoryPool(context, &pool);
 		if (status == CELIX_SUCCESS) {
 			int len = strlen(service) + strlen(OBJECTCLASS) + 4;
-			//char *filter = apr_palloc(pool, sizeof(char) * len);
-			char *filter = malloc(sizeof(char) * len);
+			char *filter = apr_palloc(pool, sizeof(char) * len);
 			if (filter == NULL) {
 				status = CELIX_ENOMEM;
 			} else {
@@ -64,7 +70,7 @@ celix_status_t serviceTracker_create(BUN
 				strcat(filter, "=");
 				strcat(filter, service);
 				strcat(filter, ")\0");
-				tracker_createWithFilter(context, filter, customizer, tracker);
+				serviceTracker_createWithFilter(pool, context, filter, customizer, tracker);
 			}
 		}
 	}
@@ -73,37 +79,42 @@ celix_status_t serviceTracker_create(BUN
 	return status;
 }
 
-celix_status_t tracker_createWithFilter(BUNDLE_CONTEXT context, char * filter, SERVICE_TRACKER_CUSTOMIZER
customizer, SERVICE_TRACKER *tracker) {
-	FW_SERVICE_TRACKER fw_tracker;
-	apr_pool_t *pool;
-	*tracker = (SERVICE_TRACKER) malloc(sizeof(**tracker));
-	fw_tracker = (FW_SERVICE_TRACKER) malloc(sizeof(*fw_tracker));
-	bundleContext_getMemoryPool(context, &pool);
-
-//	if (m_trackers == NULL) {
-//		arrayList_create(pool, &m_trackers);
-//	}
-	(*tracker)->context = context;
-	(*tracker)->filter = filter;
-
-	fw_tracker->pool = pool;
-	fw_tracker->tracker = *tracker;
-	fw_tracker->tracked = NULL;
-	arrayList_create(pool, &fw_tracker->tracked);
-	fw_tracker->customizer = customizer;
+celix_status_t serviceTracker_createWithFilter(apr_pool_t *pool, BUNDLE_CONTEXT context,
char * filter, SERVICE_TRACKER_CUSTOMIZER customizer, SERVICE_TRACKER *tracker) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	*tracker = (SERVICE_TRACKER) apr_palloc(pool, sizeof(**tracker));
+	if (!*tracker) {
+		status = CELIX_ENOMEM;
+	} else {
+		apr_pool_pre_cleanup_register(pool, *tracker, serviceTracker_destroy);
+
+		(*tracker)->context = context;
+		(*tracker)->filter = filter;
 
-	(*tracker)->fwTracker = fw_tracker;
+		(*tracker)->pool = pool;
+		(*tracker)->tracker = *tracker;
+		(*tracker)->tracked = NULL;
+		arrayList_create(pool, &(*tracker)->tracked);
+		(*tracker)->customizer = customizer;
+		(*tracker)->listener = NULL;
+	}
 
-//	arrayList_add(m_trackers, fw_tracker);
+	return status;
+}
 
-	return CELIX_SUCCESS;
+apr_status_t serviceTracker_destroy(void *trackerP) {
+	SERVICE_TRACKER tracker = trackerP;
+	bundleContext_removeServiceListener(tracker->context, tracker->listener);
+	arrayList_destroy(tracker->tracked);
+
+	return APR_SUCCESS;
 }
 
 celix_status_t serviceTracker_open(SERVICE_TRACKER tracker) {
 	SERVICE_LISTENER listener;
 	ARRAY_LIST initial = NULL;
 	celix_status_t status = CELIX_SUCCESS;
-	listener = (SERVICE_LISTENER) malloc(sizeof(*listener));
+	listener = (SERVICE_LISTENER) apr_palloc(tracker->pool, sizeof(*listener));
 //	FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
 	
 	status = bundleContext_getServiceReferences(tracker->context, NULL, tracker->filter,
&initial);
@@ -111,16 +122,16 @@ celix_status_t serviceTracker_open(SERVI
 		SERVICE_REFERENCE initial_reference;
 		unsigned int i;
 
-		listener->pool = tracker->fwTracker->pool;
+		listener->pool = tracker->pool;
 		listener->handle = tracker;
 		listener->serviceChanged = (void *) tracker_serviceChanged;
 		status = bundleContext_addServiceListener(tracker->context, listener, tracker->filter);
 		if (status == CELIX_SUCCESS) {
-			tracker->fwTracker->listener = listener;
+			tracker->listener = listener;
 
 			for (i = 0; i < arrayList_size(initial); i++) {
 				initial_reference = (SERVICE_REFERENCE) arrayList_get(initial, i);
-				serviceTracker_track(tracker->fwTracker, initial_reference, NULL);
+				serviceTracker_track(tracker, initial_reference, NULL);
 			}
 			arrayList_clear(initial);
 			arrayList_destroy(initial);
@@ -135,15 +146,14 @@ celix_status_t serviceTracker_open(SERVI
 celix_status_t serviceTracker_close(SERVICE_TRACKER tracker) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	FW_SERVICE_TRACKER fwTracker = tracker->fwTracker;
-	status = bundleContext_removeServiceListener(tracker->context, fwTracker->listener);
+	status = bundleContext_removeServiceListener(tracker->context, tracker->listener);
 	if (status == CELIX_SUCCESS) {
 		ARRAY_LIST refs = tracker_getServiceReferences(tracker);
 		if (refs != NULL) {
 			int i;
 			for (i = 0; i < arrayList_size(refs); i++) {
 				SERVICE_REFERENCE ref = arrayList_get(refs, i);
-				status = serviceTracker_untrack(fwTracker, ref, NULL);
+				status = serviceTracker_untrack(tracker, ref, NULL);
 			}
 		}
 		arrayList_destroy(refs);
@@ -152,23 +162,11 @@ celix_status_t serviceTracker_close(SERV
 	return status;
 }
 
-void tracker_destroy(SERVICE_TRACKER tracker) {
-	FW_SERVICE_TRACKER fwTracker = tracker->fwTracker;
-	bundleContext_removeServiceListener(tracker->context, fwTracker->listener);
-//	arrayList_destroy(m_trackers);
-	arrayList_destroy(fwTracker->tracked);
-	free(fwTracker->listener);
-	free(fwTracker);
-	tracker = NULL;
-	free(tracker);
-}
-
 SERVICE_REFERENCE tracker_getServiceReference(SERVICE_TRACKER tracker) {
-	FW_SERVICE_TRACKER fwTracker = tracker->fwTracker;
 	TRACKED tracked;
 	unsigned int i;
-	for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
-		tracked = (TRACKED) arrayList_get(fwTracker->tracked, i);
+	for (i = 0; i < arrayList_size(tracker->tracked); i++) {
+		tracked = (TRACKED) arrayList_get(tracker->tracked, i);
 		return tracked->reference;
 	}
 	return NULL;
@@ -177,27 +175,23 @@ SERVICE_REFERENCE tracker_getServiceRefe
 ARRAY_LIST tracker_getServiceReferences(SERVICE_TRACKER tracker) {
 	TRACKED tracked;
 	unsigned int i;
-	FW_SERVICE_TRACKER fwTracker = tracker->fwTracker;
-	int size = arrayList_size(fwTracker->tracked);
+	int size = arrayList_size(tracker->tracked);
 	ARRAY_LIST references = NULL;
-	arrayList_create(fwTracker->pool, &references);
+	arrayList_create(tracker->pool, &references);
 	
-	for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
-		tracked = (TRACKED) arrayList_get(fwTracker->tracked, i);
+	for (i = 0; i < arrayList_size(tracker->tracked); i++) {
+		tracked = (TRACKED) arrayList_get(tracker->tracked, i);
 		arrayList_add(references, tracked->reference);
 	}
 	return references;
 }
 
 void * tracker_getService(SERVICE_TRACKER tracker) {
-	FW_SERVICE_TRACKER fwTracker = tracker->fwTracker;
 	TRACKED tracked;
 	unsigned int i;
-	if (fwTracker != NULL) {
-		for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
-			tracked = (TRACKED) arrayList_get(fwTracker->tracked, i);
-			return tracked->service;
-		}
+	for (i = 0; i < arrayList_size(tracker->tracked); i++) {
+		tracked = (TRACKED) arrayList_get(tracker->tracked, i);
+		return tracked->service;
 	}
 	return NULL;
 }
@@ -205,25 +199,23 @@ void * tracker_getService(SERVICE_TRACKE
 ARRAY_LIST tracker_getServices(SERVICE_TRACKER tracker) {
 	TRACKED tracked;
 	unsigned int i;
-	FW_SERVICE_TRACKER fwTracker = tracker->fwTracker;
-	int size = arrayList_size(fwTracker->tracked);
+	int size = arrayList_size(tracker->tracked);
 	ARRAY_LIST references = NULL;
-	arrayList_create(fwTracker->pool, &references);
+	arrayList_create(tracker->pool, &references);
 	
-	for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
-		tracked = (TRACKED) arrayList_get(fwTracker->tracked, i);
+	for (i = 0; i < arrayList_size(tracker->tracked); i++) {
+		tracked = (TRACKED) arrayList_get(tracker->tracked, i);
 		arrayList_add(references, tracked->service);
 	}
 	return references;
 }
 
 void * tracker_getServiceByReference(SERVICE_TRACKER tracker, SERVICE_REFERENCE reference)
{
-	FW_SERVICE_TRACKER fwTracker = tracker->fwTracker;
 	TRACKED tracked;
 	unsigned int i;
-	for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
+	for (i = 0; i < arrayList_size(tracker->tracked); i++) {
 		bool equals;
-		tracked = (TRACKED) arrayList_get(fwTracker->tracked, i);
+		tracked = (TRACKED) arrayList_get(tracker->tracked, i);
 		serviceReference_equals(reference, tracked->reference, &equals);
 		if (equals) {
 			return tracked->service;
@@ -237,25 +229,25 @@ void tracker_serviceChanged(SERVICE_LIST
 	switch (event->type) {
 		case REGISTERED:
 		case MODIFIED:
-			serviceTracker_track(tracker->fwTracker, event->reference, event);
+			serviceTracker_track(tracker, event->reference, event);
 			break;
 		case UNREGISTERING:
-			serviceTracker_untrack(tracker->fwTracker, event->reference, event);
+			serviceTracker_untrack(tracker, event->reference, event);
 			break;
 		case MODIFIED_ENDMATCH:
 			break;
 	}
 }
 
-celix_status_t serviceTracker_track(FW_SERVICE_TRACKER fwTracker, SERVICE_REFERENCE reference,
SERVICE_EVENT event) {
+celix_status_t serviceTracker_track(SERVICE_TRACKER tracker, SERVICE_REFERENCE reference,
SERVICE_EVENT event) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	TRACKED tracked = NULL;
 	int found = -1;
 	unsigned int i;
-	for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
+	for (i = 0; i < arrayList_size(tracker->tracked); i++) {
 		bool equals;
-		tracked = (TRACKED) arrayList_get(fwTracker->tracked, i);
+		tracked = (TRACKED) arrayList_get(tracker->tracked, i);
 		serviceReference_equals(reference, tracked->reference, &equals);
 		if (equals) {
 			found = 0;
@@ -264,58 +256,58 @@ celix_status_t serviceTracker_track(FW_S
 	}
 
 	if (found) {
-		void * service = addingService(fwTracker, reference);
+		void * service = addingService(tracker, reference);
 		if (service != NULL) {
 			tracked = (TRACKED) malloc(sizeof(*tracked));
 			tracked->reference = reference;
 			tracked->service = service;
-			arrayList_add(fwTracker->tracked, tracked);
-			if (fwTracker->customizer != NULL) {
-				fwTracker->customizer->addedService(fwTracker->customizer->handle, reference,
service);
+			arrayList_add(tracker->tracked, tracked);
+			if (tracker->customizer != NULL) {
+				tracker->customizer->addedService(tracker->customizer->handle, reference,
service);
 			}
 		}
 
 	} else {
-		if (fwTracker->customizer != NULL) {
-			fwTracker->customizer->modifiedService(fwTracker->customizer->handle, reference,
tracked->service);
+		if (tracker->customizer != NULL) {
+			tracker->customizer->modifiedService(tracker->customizer->handle, reference,
tracked->service);
 		}
 	}
 
 	return status;
 }
 
-void * addingService(FW_SERVICE_TRACKER fwTracker, SERVICE_REFERENCE reference) {
+void * addingService(SERVICE_TRACKER tracker, SERVICE_REFERENCE reference) {
     void *svc = NULL;
 
-    if (fwTracker->customizer != NULL) {
-		fwTracker->customizer->addingService(fwTracker->customizer->handle, reference,
&svc);
+    if (tracker->customizer != NULL) {
+    	tracker->customizer->addingService(tracker->customizer->handle, reference,
&svc);
 	} else {
-		bundleContext_getService(fwTracker->tracker->context, reference, &svc);
+		bundleContext_getService(tracker->context, reference, &svc);
 	}
 
     return svc;
 }
 
-celix_status_t serviceTracker_untrack(FW_SERVICE_TRACKER fwTracker, SERVICE_REFERENCE reference,
SERVICE_EVENT event) {
+celix_status_t serviceTracker_untrack(SERVICE_TRACKER tracker, SERVICE_REFERENCE reference,
SERVICE_EVENT event) {
 	celix_status_t status = CELIX_SUCCESS;
 	TRACKED tracked = NULL;
 	unsigned int i;
 	bool result = NULL;
 
-	for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
+	for (i = 0; i < arrayList_size(tracker->tracked); i++) {
 		bool equals;
-		tracked = (TRACKED) arrayList_get(fwTracker->tracked, i);
+		tracked = (TRACKED) arrayList_get(tracker->tracked, i);
 		serviceReference_equals(reference, tracked->reference, &equals);
 		if (equals) {
 			if (tracked != NULL) {
-				arrayList_remove(fwTracker->tracked, i);
-				status = bundleContext_ungetService(fwTracker->tracker->context, reference, &result);
+				arrayList_remove(tracker->tracked, i);
+				status = bundleContext_ungetService(tracker->context, reference, &result);
 			}
 			if (status == CELIX_SUCCESS) {
-				if (fwTracker->customizer != NULL) {
-					fwTracker->customizer->removedService(fwTracker->customizer->handle, reference,
tracked->service);
+				if (tracker->customizer != NULL) {
+					tracker->customizer->removedService(tracker->customizer->handle, reference,
tracked->service);
 				} else {
-					status = bundleContext_ungetService(fwTracker->tracker->context, reference, &result);
+					status = bundleContext_ungetService(tracker->tracker->context, reference, &result);
 				}
 				free(tracked);
 				break;
@@ -325,17 +317,3 @@ celix_status_t serviceTracker_untrack(FW
 
 	return status;
 }
-
-//FW_SERVICE_TRACKER findFwServiceTracker(SERVICE_TRACKER tracker) {
-//	FW_SERVICE_TRACKER fwTracker;
-//	unsigned int i;
-//	if (m_trackers != NULL) {
-//		for (i = 0; i < arrayList_size(m_trackers); i++) {
-//			fwTracker = (FW_SERVICE_TRACKER) arrayList_get(m_trackers, i);
-//			if (fwTracker->tracker == tracker) {
-//				return fwTracker;
-//			}
-//		}
-//	}
-//	return NULL;
-//}

Modified: incubator/celix/trunk/framework/public/include/service_tracker.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/service_tracker.h?rev=1235725&r1=1235724&r2=1235725&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/service_tracker.h (original)
+++ incubator/celix/trunk/framework/public/include/service_tracker.h Wed Jan 25 12:27:31 2012
@@ -42,29 +42,11 @@ typedef struct serviceTrackerCustomizer 
 
 typedef struct serviceTracker * SERVICE_TRACKER;
 
-struct fwServiceTracker {
-	apr_pool_t *pool;
-	SERVICE_TRACKER tracker;
-	SERVICE_TRACKER_CUSTOMIZER customizer;
-	SERVICE_LISTENER listener;
-	ARRAY_LIST tracked;
-};
-
-typedef struct fwServiceTracker * FW_SERVICE_TRACKER;
-
-struct tracked {
-	SERVICE_REFERENCE reference;
-	void * service;
-};
-
-typedef struct tracked * TRACKED;
-
-celix_status_t serviceTracker_create(BUNDLE_CONTEXT context, char * service, SERVICE_TRACKER_CUSTOMIZER
customizer, SERVICE_TRACKER *tracker);
-celix_status_t tracker_createWithFilter(BUNDLE_CONTEXT context, char * filter, SERVICE_TRACKER_CUSTOMIZER
customizer, SERVICE_TRACKER *tracker);
+celix_status_t serviceTracker_create(apr_pool_t *pool, BUNDLE_CONTEXT context, char * service,
SERVICE_TRACKER_CUSTOMIZER customizer, SERVICE_TRACKER *tracker);
+celix_status_t serviceTracker_createWithFilter(apr_pool_t *pool, BUNDLE_CONTEXT context,
char * filter, SERVICE_TRACKER_CUSTOMIZER customizer, SERVICE_TRACKER *tracker);
 
 celix_status_t serviceTracker_open(SERVICE_TRACKER tracker);
 celix_status_t serviceTracker_close(SERVICE_TRACKER tracker);
-void tracker_destroy(SERVICE_TRACKER tracker);
 
 SERVICE_REFERENCE tracker_getServiceReference(SERVICE_TRACKER tracker);
 ARRAY_LIST tracker_getServiceReferences(SERVICE_TRACKER tracker);

Modified: incubator/celix/trunk/remote_services/discovery/private/src/discovery_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/discovery/private/src/discovery_activator.c?rev=1235725&r1=1235724&r2=1235725&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/discovery/private/src/discovery_activator.c (original)
+++ incubator/celix/trunk/remote_services/discovery/private/src/discovery_activator.c Wed
Jan 25 12:27:31 2012
@@ -71,7 +71,7 @@ celix_status_t discoveryActivator_create
 		custumizer->modifiedService = discovery_endpointListenerModified;
 		custumizer->removedService = discovery_endpointListenerRemoved;
 
-		status = serviceTracker_create(activator->context, "endpoint_listener", custumizer,
tracker);
+		status = serviceTracker_create(activator->pool, activator->context, "endpoint_listener",
custumizer, tracker);
 
 		serviceTracker_open(activator->endpointListenerTracker);
 	}

Modified: incubator/celix/trunk/remote_services/remote_service_admin/private/src/export_registration_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/remote_service_admin/private/src/export_registration_impl.c?rev=1235725&r1=1235724&r2=1235725&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/remote_service_admin/private/src/export_registration_impl.c
(original)
+++ incubator/celix/trunk/remote_services/remote_service_admin/private/src/export_registration_impl.c
Wed Jan 25 12:27:31 2012
@@ -95,7 +95,7 @@ celix_status_t exportRegistration_create
 		custumizer->modifiedService = exportRegistration_endpointModified;
 		custumizer->removedService = exportRegistration_endpointRemoved;
 
-		status = serviceTracker_create(registration->context, REMOTE_ENDPOINT, custumizer, tracker);
+		status = serviceTracker_create(registration->pool, registration->context, REMOTE_ENDPOINT,
custumizer, tracker);
 	}
 
 	return status;

Modified: incubator/celix/trunk/remote_services/remote_service_admin/private/src/import_registration_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/remote_service_admin/private/src/import_registration_impl.c?rev=1235725&r1=1235724&r2=1235725&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/remote_service_admin/private/src/import_registration_impl.c
(original)
+++ incubator/celix/trunk/remote_services/remote_service_admin/private/src/import_registration_impl.c
Wed Jan 25 12:27:31 2012
@@ -83,7 +83,7 @@ celix_status_t importRegistration_create
 		custumizer->modifiedService = importRegistration_proxyModified;
 		custumizer->removedService = importRegistration_proxyRemoved;
 
-		status = serviceTracker_create(registration->context, REMOTE_PROXY, custumizer, tracker);
+		status = serviceTracker_create(registration->pool, registration->context, REMOTE_PROXY,
custumizer, tracker);
 	}
 
 	return status;

Modified: incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c?rev=1235725&r1=1235724&r2=1235725&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c (original)
+++ incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c Wed Jan
25 12:27:31 2012
@@ -82,7 +82,7 @@ celix_status_t bundleActivator_createRSA
 		custumizer->modifiedService = topologyManager_rsaModified;
 		custumizer->removedService = topologyManager_rsaRemoved;
 
-		status = serviceTracker_create(activator->context, "remote_service_admin", custumizer,
tracker);
+		status = serviceTracker_create(activator->pool, activator->context, "remote_service_admin",
custumizer, tracker);
 	}
 
 	return status;

Modified: incubator/celix/trunk/target.cmake
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/target.cmake?rev=1235725&r1=1235724&r2=1235725&view=diff
==============================================================================
--- incubator/celix/trunk/target.cmake (original)
+++ incubator/celix/trunk/target.cmake Wed Jan 25 12:27:31 2012
@@ -19,6 +19,6 @@
 #deploy("shell test" BUNDLES shell)
 deploy("hello_world" BUNDLES shell shell_tui hello_world log_service)
 #deploy("deployer" BUNDLES shell shell_tui deployer)
-#deploy("wb" BUNDLES tracker publisherA publisherB shell shell_tui log_service log_writer)
-deploy("wb_dp" BUNDLES tracker_depman publisherA publisherB shell shell_tui log_service log_writer)
+deploy("wb" BUNDLES tracker publisherA publisherB shell shell_tui log_service)
+deploy("wb_dp" BUNDLES tracker_depman publisherA publisherB shell shell_tui log_service)
 #deploy("echo" BUNDLES echo_server echo_client shell shell_tui)



Mime
View raw message