celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject svn commit: r1645706 - in /celix/trunk/remote_services/topology_manager: CMakeLists.txt private/src/activator.c private/src/topology_manager.c
Date Mon, 15 Dec 2014 17:40:30 GMT
Author: bpetri
Date: Mon Dec 15 17:40:29 2014
New Revision: 1645706

URL: http://svn.apache.org/r1645706
Log:
CELIX-182: replace topology_manager fw_log calls w/ loghelper

Modified:
    celix/trunk/remote_services/topology_manager/CMakeLists.txt
    celix/trunk/remote_services/topology_manager/private/src/activator.c
    celix/trunk/remote_services/topology_manager/private/src/topology_manager.c

Modified: celix/trunk/remote_services/topology_manager/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/topology_manager/CMakeLists.txt?rev=1645706&r1=1645705&r2=1645706&view=diff
==============================================================================
--- celix/trunk/remote_services/topology_manager/CMakeLists.txt (original)
+++ celix/trunk/remote_services/topology_manager/CMakeLists.txt Mon Dec 15 17:40:29 2014
@@ -20,6 +20,7 @@ include_directories("${PROJECT_SOURCE_DI
 include_directories("${PROJECT_SOURCE_DIR}/remote_services/topology_manager/private/include")
 include_directories("${PROJECT_SOURCE_DIR}/remote_services/endpoint_listener/public/include")
 include_directories("${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/public/include")
+include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
 
 SET_HEADER(BUNDLE_SYMBOLICNAME "apache_celix_rs_topology_manager")
 SET(BUNDLE_VERSION "0.0.1")
@@ -29,6 +30,8 @@ bundle(topology_manager SOURCES
     private/src/topology_manager
     private/src/activator
     
+    ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
+    
     private/include/topology_manager.h
 )
 

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=1645706&r1=1645705&r2=1645706&view=diff
==============================================================================
--- celix/trunk/remote_services/topology_manager/private/src/activator.c (original)
+++ celix/trunk/remote_services/topology_manager/private/src/activator.c Mon Dec 15 17:40:29
2014
@@ -36,6 +36,8 @@
 #include "endpoint_listener.h"
 #include "remote_constants.h"
 #include "listener_hook_service.h"
+#include "log_service.h"
+#include "log_helper.h"
 
 struct activator {
 	bundle_context_pt context;
@@ -50,6 +52,8 @@ struct activator {
 
 	listener_hook_service_pt hookService;
 	service_registration_pt hook;
+
+	log_helper_pt loghelper;
 };
 
 static celix_status_t bundleActivator_createRSATracker(struct activator *activator, service_tracker_pt
*tracker);
@@ -72,6 +76,8 @@ celix_status_t bundleActivator_create(bu
 	activator->remoteServiceAdminTracker = NULL;
 	activator->serviceListener = NULL;
 
+	logHelper_create(context, &activator->loghelper);
+
 	status = topologyManager_create(context, &activator->manager);
 	if (status == CELIX_SUCCESS) {
 		status = bundleActivator_createRSATracker(activator, &activator->remoteServiceAdminTracker);
@@ -119,6 +125,8 @@ celix_status_t bundleActivator_start(voi
 	celix_status_t status = CELIX_SUCCESS;
 	struct activator *activator = userData;
 
+	logHelper_start(activator->loghelper);
+
 	endpoint_listener_pt endpointListener = malloc(sizeof(*endpointListener));
 	endpointListener->handle = activator->manager;
 	endpointListener->endpointAdded = topologyManager_addImportedService;
@@ -128,7 +136,7 @@ celix_status_t bundleActivator_start(voi
 	char *uuid = NULL;
 	status = bundleContext_getProperty(activator->context, (char *)OSGI_FRAMEWORK_FRAMEWORK_UUID,
&uuid);
 	if (!uuid) {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "TOPOLOGY_MANAGER: no framework UUID defined?!");
+		logHelper_log(activator->loghelper, OSGI_LOGSERVICE_ERROR, "TOPOLOGY_MANAGER: no framework
UUID defined?!");
 		return CELIX_ILLEGAL_STATE;
 	}
 
@@ -140,7 +148,7 @@ celix_status_t bundleActivator_start(voi
 
 	snprintf(scope, len, "(&(%s=*)(!(%s=%s)))", OSGI_FRAMEWORK_OBJECTCLASS, OSGI_RSA_ENDPOINT_FRAMEWORK_UUID,
uuid);
 
-	fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "TOPOLOGY_MANAGER: endpoint listener scope is %s",
scope);
+	logHelper_log(activator->loghelper, OSGI_LOGSERVICE_INFO, "TOPOLOGY_MANAGER: endpoint
listener scope is %s", scope);
 
 	properties_pt props = properties_create();
 	properties_set(props, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, scope);
@@ -192,6 +200,8 @@ celix_status_t bundleActivator_stop(void
 	serviceRegistration_unregister(activator->endpointListenerService);
 	free(activator->endpointListener);
 
+	logHelper_stop(activator->loghelper);
+
 	return status;
 }
 
@@ -203,6 +213,8 @@ celix_status_t bundleActivator_destroy(v
 		status = CELIX_BUNDLE_EXCEPTION;
 	}
 	else {
+		logHelper_destroy(&activator->loghelper);
+
 		status = topologyManager_destroy(activator->manager);
 		free(activator);
 	}

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=1645706&r1=1645705&r2=1645706&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 Mon Dec 15
17:40:29 2014
@@ -38,6 +38,9 @@
 #include "utils.h"
 #include "service_reference.h"
 #include "service_registration.h"
+#include "log_service.h"
+#include "log_helper.h"
+
 
 struct topology_manager {
 	bundle_context_pt context;
@@ -53,6 +56,8 @@ struct topology_manager {
 
 	celix_thread_mutex_t importInterestsLock;
 	hash_map_pt importInterests;
+
+	log_helper_pt loghelper;
 };
 
 struct import_interest {
@@ -84,6 +89,10 @@ celix_status_t topologyManager_create(bu
 	(*manager)->importedServices = hashMap_create(NULL, NULL, NULL, NULL);
 	(*manager)->importInterests = hashMap_create(utils_stringHash, NULL, utils_stringEquals,
NULL);
 
+	if (logHelper_create(context, &(*manager)->loghelper) == CELIX_SUCCESS) {
+		logHelper_start((*manager)->loghelper);
+	}
+
 	return status;
 }
 
@@ -118,6 +127,10 @@ celix_status_t topologyManager_destroy(t
 	status = celixThreadMutex_unlock(&manager->importInterestsLock);
 	status = celixThreadMutex_destroy(&manager->importInterestsLock);
 
+	if (logHelper_stop(manager->loghelper) == CELIX_SUCCESS) {
+		logHelper_destroy(&manager->loghelper);
+	}
+
 	free(manager);
 
 	return status;
@@ -137,7 +150,7 @@ celix_status_t topologyManager_rsaAdded(
 	celix_status_t status = CELIX_SUCCESS;
 	topology_manager_pt manager = handle;
 	remote_service_admin_service_pt rsa = (remote_service_admin_service_pt) service;
-	fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "TOPOLOGY_MANAGER: Added RSA");
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "TOPOLOGY_MANAGER: Added RSA");
 
 	status = celixThreadMutex_lock(&manager->rsaListLock);
 	arrayList_add(manager->rsaList, rsa);
@@ -204,7 +217,7 @@ celix_status_t topologyManager_rsaRemove
     celix_status_t status = CELIX_SUCCESS;
     topology_manager_pt manager = handle;
 
-    fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "TOPOLOGY_MANAGER: Removed RSA");
+    logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "TOPOLOGY_MANAGER: Removed
RSA");
 
     remote_service_admin_service_pt rsa = (remote_service_admin_service_pt) service;
 
@@ -236,7 +249,7 @@ celix_status_t topologyManager_rsaRemove
 
     status = celixThreadMutex_unlock(&manager->exportedServicesLock);
 
-    fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "TOPOLOGY_MANAGER: Removed RSA");
+    logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "TOPOLOGY_MANAGER: Removed
RSA");
 
     status = celixThreadMutex_lock(&manager->rsaListLock);
     arrayList_removeElement(manager->rsaList, rsa);
@@ -297,7 +310,7 @@ celix_status_t topologyManager_addImport
 	celix_status_t status = CELIX_SUCCESS;
 	topology_manager_pt manager = handle;
 
-	fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "TOPOLOGY_MANAGER: Add imported service (%s; %s).",
endpoint->service, endpoint->id);
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "TOPOLOGY_MANAGER: Add imported
service (%s; %s).", endpoint->service, endpoint->id);
 
 	// Create a local copy of the current list of RSAs, to ensure we do not run into threading
issues...
 	array_list_pt localRSAs = NULL;
@@ -328,7 +341,7 @@ celix_status_t topologyManager_removeImp
 	celix_status_t status = CELIX_SUCCESS;
 	topology_manager_pt manager = handle;
 
-	fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "TOPOLOGY_MANAGER: Remove imported service (%s;
%s).", endpoint->service, endpoint->id);
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "TOPOLOGY_MANAGER: Remove imported
service (%s; %s).", endpoint->service, endpoint->id);
 
 	status = celixThreadMutex_lock(&manager->importedServicesLock);
 
@@ -366,7 +379,7 @@ celix_status_t topologyManager_removeImp
 celix_status_t topologyManager_addExportedService(topology_manager_pt manager, service_reference_pt
reference, char *serviceId) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "TOPOLOGY_MANAGER: Add exported service (%s).",
serviceId);
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "TOPOLOGY_MANAGER: Add exported
service (%s).", serviceId);
 
 	// Create a local copy of the current list of RSAs, to ensure we do not run into threading
issues...
 	array_list_pt localRSAs = NULL;
@@ -379,7 +392,7 @@ celix_status_t topologyManager_addExport
 
 	int size = arrayList_size(localRSAs);
 	if (size == 0) {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_WARNING, "TOPOLOGY_MANAGER: No RSA available yet.");
+		logHelper_log(manager->loghelper, OSGI_LOGSERVICE_WARNING, "TOPOLOGY_MANAGER: No RSA
available yet.");
 	}
 
 	for (int iter = 0; iter < size; iter++) {
@@ -404,7 +417,7 @@ celix_status_t topologyManager_addExport
 celix_status_t topologyManager_removeExportedService(topology_manager_pt manager, service_reference_pt
reference, char *serviceId) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "TOPOLOGY_MANAGER: Remove exported service (%s).",
serviceId);
+	logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "TOPOLOGY_MANAGER: Remove exported
service (%s).", serviceId);
 
 	status = celixThreadMutex_lock(&manager->exportedServicesLock);
 
@@ -542,13 +555,14 @@ celix_status_t topologyManager_notifyLis
 	return status;
 }
 
-celix_status_t topologyManager_extendFilter(bundle_context_pt context, char *filter, char
**updatedFilter) {
+celix_status_t topologyManager_extendFilter(topology_manager_pt manager, char *filter, char
**updatedFilter) {
 	celix_status_t status = CELIX_SUCCESS;
-
+	bundle_context_pt context = manager->context;
 	char* uuid = NULL;
+
 	status = bundleContext_getProperty(context, (char *)OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid);
 	if (!uuid) {
-		fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "TOPOLOGY_MANAGER: no framework UUID defined?!");
+		logHelper_log(manager->loghelper, OSGI_LOGSERVICE_ERROR, "TOPOLOGY_MANAGER: no framework
UUID defined?!");
 		return CELIX_BUNDLE_EXCEPTION;
 	}
 
@@ -574,14 +588,14 @@ celix_status_t topologyManager_listenerA
 		bundleContext_getBundle(info->context, &bundle);
 		bundleContext_getBundle(manager->context, &self);
 		if (bundle == self) {
-			fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "TOPOLOGY_MANAGER: Ignore myself.");
+			logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "TOPOLOGY_MANAGER: Ignore
myself.");
 			continue;
 		}
 
-		fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "TOPOLOGY_MANAGER: listener with filter \"%s\"
added", info->filter);
+		logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "TOPOLOGY_MANAGER: listener
with filter \"%s\" added", info->filter);
 
 		char *filter = NULL;
-		topologyManager_extendFilter(manager->context, info->filter, &filter);
+		topologyManager_extendFilter(manager, info->filter, &filter);
 
 		status = celixThreadMutex_lock(&manager->importInterestsLock);
 
@@ -613,14 +627,14 @@ celix_status_t topologyManager_listenerR
 		bundleContext_getBundle(info->context, &bundle);
 		bundleContext_getBundle(manager->context, &self);
 		if (bundle == self) {
-			fw_log(logger, OSGI_FRAMEWORK_LOG_DEBUG, "TOPOLOGY_MANAGER: Ignore myself.");
+			logHelper_log(manager->loghelper, OSGI_LOGSERVICE_DEBUG, "TOPOLOGY_MANAGER: Ignore
myself.");
 			continue;
 		}
 
-		fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "TOPOLOGY_MANAGER: listener with filter \"%s\"
removed.", info->filter);
+		logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "TOPOLOGY_MANAGER: listener
with filter \"%s\" removed.", info->filter);
 
 		char *filter = NULL;
-		topologyManager_extendFilter(manager->context, info->filter, &filter);
+		topologyManager_extendFilter(manager, info->filter, &filter);
 
 		status = celixThreadMutex_lock(&manager->importInterestsLock);
 



Mime
View raw message