celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [01/51] celix git commit: CELIX-77: Update config_admin implementation
Date Mon, 25 Jan 2016 18:01:17 GMT
Repository: celix
Updated Branches:
  refs/heads/feature/CELIX-335_deploy_refactoring cd1f7491f -> a43d78b30


http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/examples/example_test2/bundle_managed_service/private/src/example_managed_service_impl.c
----------------------------------------------------------------------
diff --git a/config_admin/examples/example_test2/bundle_managed_service/private/src/example_managed_service_impl.c b/config_admin/examples/example_test2/bundle_managed_service/private/src/example_managed_service_impl.c
deleted file mode 100644
index 2812637..0000000
--- a/config_admin/examples/example_test2/bundle_managed_service/private/src/example_managed_service_impl.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * example_managed_service_impl.c
- *
- *  \date       Aug 12, 2013
- *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
- *  \copyright	Apache License, Version 2.0
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "example_managed_service_impl.h"
-
-/* ------------------------ Constructor -------------------------------------*/
-
-celix_status_t managedServiceImpl_create(bundle_context_pt context, managed_service_pt *instance){
-
-	celix_status_t status = CELIX_SUCCESS;
-
-
-	managed_service_pt managedService = calloc(1, sizeof(*managedService));
-	if(!managedService){
-		printf("[ ERROR ]: ManagedServiceImpl - Not initialized (ENOMEM) \n");
-		return CELIX_ENOMEM;
-	}
-
-    managedService->context = context;
-	managedService->registration = NULL;
-	managedService->properties = NULL;
-
-	printf("[ ManagedServiceImpl ]: ManagedServiceImpl - Initialized \n");
-	*instance = managedService;
-	return status;
-}
-
-
-/* -------------------- Implementation --------------------------------------*/
-
-celix_status_t managedServiceImpl_updated(managed_service_pt managedService, properties_pt properties){
-
-	if (properties == NULL){
-		printf("[ managedServiceImpl ]: updated - Received NULL properties \n");
-		managedService->properties = NULL;
-	}else{
-		printf("[ managedServiceImpl ]: updated - Received New Properties \n");
-		managedService->properties = properties_create();
-		managedService->properties = properties;
-	}
-
-	return CELIX_SUCCESS;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/readme.md
----------------------------------------------------------------------
diff --git a/config_admin/readme.md b/config_admin/readme.md
new file mode 100644
index 0000000..900d8a7
--- /dev/null
+++ b/config_admin/readme.md
@@ -0,0 +1,29 @@
+# Configuration Admin
+
+---
+
+## Introduction
+The configuration Admin service allows defining and deploying configuration data to bundles.
+When compared to config.properties it adds the option to update configuration data by providing a persisten storage. It also allows changing configuration data at run-time.
+
+---
+
+## Design
+
+The config_admin bundle implements the configuration_admin service, the interface to configuration objects and the interface of a managed service. At the moment, the implementation uses a config_admin_factory to generate config_admin services for each bundle that wants to use this service. This is an inheritance of the original design and not needed.
+
+---
+
+## TODO
+
+1. Test the configuration of a service_factory
+2. Think about the option to allow remote update of the managed_services
+
+---
+
+## Usage
+
+1. Bundle that needs configuration data
+   This bundle has to register next to its normal service a managed service that has an update method.  Use config_admin_tst/example_test as an example (it is better than example_test2)
+2. Bundle/application that wants to update the configuration data of the system
+   This bundle needs to retrieve the running config_admin service. With this service it can retrieve all configuration objects for all known Persistent Identifiers (PIDs). For each PID, get all properites that need to be updated. See config_admin_test for an example.

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/service/private/include/configuration_admin_factory.h
----------------------------------------------------------------------
diff --git a/config_admin/service/private/include/configuration_admin_factory.h b/config_admin/service/private/include/configuration_admin_factory.h
index 0afed60..d86ea78 100644
--- a/config_admin/service/private/include/configuration_admin_factory.h
+++ b/config_admin/service/private/include/configuration_admin_factory.h
@@ -47,7 +47,7 @@ typedef struct configuration_admin_factory *configuration_admin_factory_pt;
 /* METHODS */
 
 celix_status_t configurationAdminFactory_create(bundle_context_pt context, service_factory_pt *factory, configuration_admin_factory_pt *instance);
-
+celix_status_t configurationAdminFactory_destroy( bundle_context_pt context, configuration_admin_factory_pt instance);
 celix_status_t configurationAdminFactory_start(configuration_admin_factory_pt factory);
 celix_status_t configurationAdminFactory_stop(configuration_admin_factory_pt factory);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/service/private/include/configuration_impl.h
----------------------------------------------------------------------
diff --git a/config_admin/service/private/include/configuration_impl.h b/config_admin/service/private/include/configuration_impl.h
index 05b9c91..71a488c 100644
--- a/config_admin/service/private/include/configuration_impl.h
+++ b/config_admin/service/private/include/configuration_impl.h
@@ -37,30 +37,36 @@
 #include "configuration_admin_factory.h"
 #include "configuration_store.h"
 
+typedef struct configuration_impl *configuration_impl_pt;
+//typedef struct configuration_impl *configuration_pt;
+
+#if 0
+
 
-celix_status_t configuration_create( configuration_admin_factory_pt factory, configuration_store_pt store,
-									 char *factoryPid, char *pid, char *bundleLocation,
-									 configuration_pt *configuration);
 
-celix_status_t configuration_create2(configuration_admin_factory_pt factory, configuration_store_pt store,
-									 properties_pt dictionary,
-									 configuration_pt *configuration);
 
-celix_status_t configuration_lock(configuration_pt configuration);
-celix_status_t configuration_unlock(configuration_pt configuration);
-celix_status_t configuration_checkLocked(configuration_pt configuration);
 
-celix_status_t configuration_bind(configuration_pt configuration, bundle_pt bundle, bool *isBind);
-celix_status_t configuration_unbind(configuration_pt configuration, bundle_pt bundle);
 
-celix_status_t configuration_checkDeleted(configuration_pt configuration);
 
-celix_status_t configuration_getBundleLocation2(configuration_pt configuration, bool checkPermission, char **location);
 celix_status_t configuration_getFactoryPid2(configuration_pt configuration, bool checkDeleted, char **factoryPid);
 celix_status_t configuration_getPid2(configuration_pt configuration, bool checkDeleted, char **pid);
-celix_status_t configuration_getAllProperties(configuration_pt configuration, properties_pt *properties);
 
 celix_status_t configuration_isDeleted(configuration_pt configuration, bool *isDeleted);
+#endif
+celix_status_t configuration_lock(configuration_impl_pt configuration);
+celix_status_t configuration_unlock(configuration_impl_pt configuration);
+celix_status_t configuration_create( configuration_admin_factory_pt factory, configuration_store_pt store,
+									 char *factoryPid, char *pid, char *bundleLocation,
+									 configuration_pt *configuration);
+celix_status_t configuration_create2(configuration_admin_factory_pt factory, configuration_store_pt store,
+									 properties_pt dictionary,
+									 configuration_pt *configuration);
+celix_status_t configuration_getBundleLocation2(configuration_impl_pt configuration, bool checkPermission, char **location);
+celix_status_t configuration_bind(configuration_impl_pt configuration, bundle_pt bundle, bool *isBind);
+celix_status_t configuration_unbind(configuration_impl_pt configuration, bundle_pt bundle);
+celix_status_t configuration_checkLocked(configuration_impl_pt configuration);
+celix_status_t configuration_getAllProperties(configuration_impl_pt configuration, properties_pt *properties);
 
-
+celix_status_t configuration_getPid(void *handle, char **pid);
+celix_status_t configuration_getProperties(void *handle, properties_pt *properties);
 #endif /* CONFIGURATION_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/service/private/include/configuration_store.h
----------------------------------------------------------------------
diff --git a/config_admin/service/private/include/configuration_store.h b/config_admin/service/private/include/configuration_store.h
index afdb985..e5f9a8c 100644
--- a/config_admin/service/private/include/configuration_store.h
+++ b/config_admin/service/private/include/configuration_store.h
@@ -43,6 +43,7 @@ typedef struct configuration_store *configuration_store_pt;
 
 /* METHODS */
 celix_status_t configurationStore_create(bundle_context_pt context, configuration_admin_factory_pt factory, configuration_store_pt *store);
+celix_status_t configurationStore_destroy(configuration_store_pt store);
 
 celix_status_t configurationStore_lock(configuration_store_pt store);
 celix_status_t configurationStore_unlock(configuration_store_pt store);

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/service/private/include/managed_service_tracker.h
----------------------------------------------------------------------
diff --git a/config_admin/service/private/include/managed_service_tracker.h b/config_admin/service/private/include/managed_service_tracker.h
index 774f4a2..c29ea6a 100644
--- a/config_admin/service/private/include/managed_service_tracker.h
+++ b/config_admin/service/private/include/managed_service_tracker.h
@@ -40,15 +40,16 @@
 #include "configuration_store.h"
 
 
-typedef struct managed_service_tracker *managed_service_tracker_t;
+typedef struct managed_service_tracker *managed_service_tracker_pt;
 
 
 celix_status_t managedServiceTracker_create(bundle_context_pt context,
 											configuration_admin_factory_pt factory, configuration_store_pt store,
-											managed_service_tracker_t *trackerHandle, service_tracker_pt *tracker);
+											managed_service_tracker_pt *trackerHandle, service_tracker_pt *tracker);
+celix_status_t managedServiceTracker_destroy(bundle_context_pt context, managed_service_tracker_pt handle, service_tracker_pt tracker);
 
-celix_status_t managedServiceTracker_notifyDeleted(managed_service_tracker_t tracker, configuration_pt configuration);
-celix_status_t managedServiceTracker_notifyUpdated(managed_service_tracker_t tracker, configuration_pt configuration);
+celix_status_t managedServiceTracker_notifyDeleted(managed_service_tracker_pt tracker, configuration_pt configuration);
+celix_status_t managedServiceTracker_notifyUpdated(managed_service_tracker_pt tracker, configuration_pt configuration);
 
 celix_status_t managedServiceTracker_addingService(void * handle, service_reference_pt reference, void **service);
 celix_status_t managedServiceTracker_addedService(void * handle, service_reference_pt reference, void * service);

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/service/private/include/updated_thread_pool.h
----------------------------------------------------------------------
diff --git a/config_admin/service/private/include/updated_thread_pool.h b/config_admin/service/private/include/updated_thread_pool.h
index 3b51db3..3dac3a2 100644
--- a/config_admin/service/private/include/updated_thread_pool.h
+++ b/config_admin/service/private/include/updated_thread_pool.h
@@ -33,7 +33,7 @@
 #define MAX_THREADS 10
 
 
-typedef struct updated_thread_pool *updated_thread_pool_t;
+typedef struct updated_thread_pool *updated_thread_pool_pt;
 
 /* celix.framework.public */
 #include "bundle_context.h"
@@ -44,9 +44,9 @@ typedef struct updated_thread_pool *updated_thread_pool_t;
 
 
 
-celix_status_t updatedThreadPool_create( bundle_context_pt context, int maxTreads, updated_thread_pool_t *updatedThreadPool);
-
-celix_status_t updatedThreadPool_push(updated_thread_pool_t updatedThreadPool, managed_service_service_pt service, properties_pt properties);
+celix_status_t updatedThreadPool_create( bundle_context_pt context, int maxTreads, updated_thread_pool_pt *updatedThreadPool);
+celix_status_t updatedThreadPool_destroy(updated_thread_pool_pt pool);
+celix_status_t updatedThreadPool_push(updated_thread_pool_pt updatedThreadPool, managed_service_service_pt service, properties_pt properties);
 
 
 #endif /* UPDATED_THREAD_POOL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/service/private/src/activator.c
----------------------------------------------------------------------
diff --git a/config_admin/service/private/src/activator.c b/config_admin/service/private/src/activator.c
index 8818051..0cc432c 100644
--- a/config_admin/service/private/src/activator.c
+++ b/config_admin/service/private/src/activator.c
@@ -44,6 +44,7 @@
 struct config_admin_bundle {
 	bundle_context_pt context;
 	service_registration_pt configAdminFactoryReg;
+	configuration_admin_factory_pt configAdminFactoryInstance;
 };
 
 typedef struct config_admin_bundle *config_admin_bundle_t;
@@ -66,6 +67,7 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 		(*userData) = bi;
 		bi->context = context;
 		bi->configAdminFactoryReg = NULL;
+		bi->configAdminFactoryInstance = NULL;
 
 		status = CELIX_SUCCESS;
 
@@ -80,9 +82,8 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
 	config_admin_bundle_t bi = (config_admin_bundle_t) userData;
 
 	service_factory_pt configAdminFactory;
-	configuration_admin_factory_pt configAdminFactoryInstance;
 
-	status = configurationAdminFactory_create(bi->context, &configAdminFactory, &configAdminFactoryInstance);
+	status = configurationAdminFactory_create(bi->context, &configAdminFactory, &bi->configAdminFactoryInstance);
 	if (status != CELIX_SUCCESS){
 		return status;
 	}
@@ -93,7 +94,7 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
 	}
 	printf("[ SUCCESS ]: Activator - ConfigAdminFactory Registered \n");
 
-	status = configurationAdminFactory_start(configAdminFactoryInstance);
+	status = configurationAdminFactory_start(bi->configAdminFactoryInstance);
 	if (status != CELIX_SUCCESS){
 		return status;
 	}
@@ -107,8 +108,9 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context)
 	celix_status_t status = CELIX_SUCCESS;
 
 	config_admin_bundle_t bi = (config_admin_bundle_t) userData;
-
+	configurationAdminFactory_stop(bi->configAdminFactoryInstance);
 	serviceRegistration_unregister(bi->configAdminFactoryReg);
+	configurationAdminFactory_destroy(context, bi->configAdminFactoryInstance);
 
 	bi->configAdminFactoryReg = NULL;
 

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/service/private/src/configuration_admin_factory.c
----------------------------------------------------------------------
diff --git a/config_admin/service/private/src/configuration_admin_factory.c b/config_admin/service/private/src/configuration_admin_factory.c
index d2eced5..9377ba5 100644
--- a/config_admin/service/private/src/configuration_admin_factory.c
+++ b/config_admin/service/private/src/configuration_admin_factory.c
@@ -48,7 +48,7 @@ struct configuration_admin_factory{
 //	configuration_permission_t configurationPermission;
 //	event_dispatcher_t eventDispatcher;
 //	plugin_manager_t pluginManager;
-	managed_service_tracker_t managedServiceTrackerHandle;
+	managed_service_tracker_pt managedServiceTrackerHandle;
 	service_tracker_pt managedServiceTracker;
 //	managed_service_factory_ptracker_t managedServiceFactoryTracker;
 	configuration_store_pt configurationStore;
@@ -70,7 +70,7 @@ celix_status_t configurationAdminFactory_create( bundle_context_pt context, serv
 
 	configuration_admin_factory_pt this = calloc(1, sizeof(*this));
 	configuration_store_pt configurationStore;
-	managed_service_tracker_t managedServiceTrackerHandle;
+	managed_service_tracker_pt managedServiceTrackerHandle;
 	service_tracker_pt managedServiceTracker;
 
 	// (1) SERVICE FACTORY
@@ -104,12 +104,17 @@ celix_status_t configurationAdminFactory_create( bundle_context_pt context, serv
 	(*factory)->getService = configurationAdminFactory_getService;
 	(*factory)->ungetService = configurationAdminFactory_ungetService;
 
-	printf("[ SUCCESS ]: ConfigAdminFactory - Initialized \n");
 	*instance = this;
 	return CELIX_SUCCESS;
 
 }
 
+celix_status_t configurationAdminFactory_destroy( bundle_context_pt context, configuration_admin_factory_pt instance){
+	managedServiceTracker_destroy(context, instance->managedServiceTrackerHandle, instance->managedServiceTracker);
+	configurationStore_destroy(instance->configurationStore);
+	free(instance);
+	return CELIX_SUCCESS;
+}
 /* ========== IMPLEMENTS SERVICE FACTORY ========== */
 
 /* ---------- public ---------- */
@@ -118,7 +123,7 @@ celix_status_t configurationAdminFactory_getService(void *factory, bundle_pt bun
 
 	celix_status_t status;
 
-	configuration_admin_factory_pt configAdminFactory = ((service_factory_pt) factory)->factory;
+	configuration_admin_factory_pt configAdminFactory = (configuration_admin_factory_pt) factory;
 	configuration_admin_service_pt confAdminService;
 
 	// TODO
@@ -131,11 +136,11 @@ celix_status_t configurationAdminFactory_getService(void *factory, bundle_pt bun
 		return status;
 	}
 
-	/* DEBUG CODE */
+	/* DEBUG CODE *
 		char* location;
 		bundle_getBundleLocation(bundle, &location);
 		printf("[ SUCCESS ]: ConfigAdminFactory - get configAdminService (bundle=%s) \n ",location);
-	/* END DEBUG CODE */
+	* END DEBUG CODE */
 
 	(*service) = confAdminService;
 	return CELIX_SUCCESS;
@@ -155,19 +160,19 @@ celix_status_t configurationAdminFactory_ungetService(void *factory, bundle_pt b
 celix_status_t configurationAdminFactory_start(configuration_admin_factory_pt factory){
 
 	celix_status_t status;
-
+	printf("%s\n", __func__);
 	status = serviceTracker_open(factory->managedServiceTracker);
 	if( status!=CELIX_SUCCESS ){
 		printf("[ ERROR ]: ConfigAdminFactory - ManagedServiceTracker not opened \n");
 		return status;
 	}
 
-	printf("[ SUCCESS ]: ConfigAdminFactory - ManagedServiceTracker opened \n");
 	return CELIX_SUCCESS;
 }
 
 celix_status_t configurationAdminFactory_stop(configuration_admin_factory_pt factory){
-	return CELIX_SUCCESS;
+	celix_status_t status = serviceTracker_close(factory->managedServiceTracker);
+	return status;;
 }
 
 celix_status_t configurationAdminFactory_checkConfigurationPermission(configuration_admin_factory_pt factory){
@@ -182,12 +187,10 @@ celix_status_t configurationAdminFactory_notifyConfigurationUpdated(configuratio
 
 	if (isFactory == true){
 
-		printf("[ DEBUG ]: ConfigAdminFactory - notifyConfigUpdated Factory \n");
 		return CELIX_SUCCESS;
 
 	}else{
 
-		printf("[ DEBUG ]: ConfigAdminFactory - notifyConfigUpdated \n");
 		return managedServiceTracker_notifyUpdated(factory->managedServiceTrackerHandle,configuration);
 
 	}

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/service/private/src/configuration_admin_impl.c
----------------------------------------------------------------------
diff --git a/config_admin/service/private/src/configuration_admin_impl.c b/config_admin/service/private/src/configuration_admin_impl.c
index 5edaba1..5bda485 100644
--- a/config_admin/service/private/src/configuration_admin_impl.c
+++ b/config_admin/service/private/src/configuration_admin_impl.c
@@ -72,13 +72,17 @@ celix_status_t configurationAdmin_create(configuration_admin_factory_pt factory,
 	(*service)->getConfiguration2 = configurationAdmin_getConfiguration2;
 	(*service)->listConfigurations = configurationAdmin_listConfigurations;
 
-	printf("[ SUCCESS ]: ConfigAdmin - Initialized \n");
 	return CELIX_SUCCESS;
 
 }
 
+celix_status_t configurationAdmin_destroy(configuration_admin_service_pt *service) {
+	free(service);
+	return CELIX_SUCCESS;
+}
 /* ========== IMPLEMENTATION ========== */
 
+
 /* ---------- public ---------- */
 
 celix_status_t configurationAdmin_createFactoryConfiguration(configuration_admin_pt configAdmin, char *factoryPid, configuration_pt *configuration){
@@ -114,8 +118,6 @@ celix_status_t configurationAdmin_getConfiguration(configuration_admin_pt config
 		return CELIX_ILLEGAL_ARGUMENT;
 	}
 
-	printf("[ DEBUG ]: ConfigAdmin - getBundleLocation \n");
-
 
 	/* ---------- pseudo code ---------- */
 	/*
@@ -132,7 +134,7 @@ celix_status_t configurationAdmin_getConfiguration(configuration_admin_pt config
 
 
 	// (4) config.getBundleLocation != NULL ?
-	if ( configuration_getBundleLocation2(config,false,&configBundleLocation) == CELIX_SUCCESS ){
+	if ( configuration_getBundleLocation2(config->handle,false,&configBundleLocation) == CELIX_SUCCESS ){
 
 		if ( strcmp(configAdminBundleLocation,configBundleLocation) != 0 ){
 
@@ -146,13 +148,12 @@ celix_status_t configurationAdmin_getConfiguration(configuration_admin_pt config
 
 	// (5) config.bind(bundle)
 	bool dummy;
-	if ( configuration_bind(config, configAdmin->bundle, &dummy) != CELIX_SUCCESS){
+	if ( configuration_bind(config->handle, configAdmin->bundle, &dummy) != CELIX_SUCCESS){
 		*configuration = NULL;
 		printf("[ ERROR]: ConfigAdmin - bind Config.");
 		return CELIX_ILLEGAL_STATE;
 	}
 
-	printf("[ SUCCESS ]: ConfigAdmin - get Configuration \n");
 	*configuration = config;
 	return CELIX_SUCCESS;
 

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/service/private/src/configuration_impl.c
----------------------------------------------------------------------
diff --git a/config_admin/service/private/src/configuration_impl.c b/config_admin/service/private/src/configuration_impl.c
index 6897e75..9462a9a 100644
--- a/config_admin/service/private/src/configuration_impl.c
+++ b/config_admin/service/private/src/configuration_impl.c
@@ -48,35 +48,54 @@
 #include "configuration_admin_factory.h"
 #include "configuration_store.h"
 
-struct configuration{
+struct configuration_impl {
 
 	configuration_admin_factory_pt configurationAdminFactory;
-	configuration_store_pt configurationStore;
+	configuration_store_pt 		configurationStore;
 
-	char *bundleLocation;
-	char *factoryPid;
-	char *pid;
-	properties_pt dictionary;
+	configuration_pt	        configuration_interface;
+	char 						*bundleLocation;
+	char 						*factoryPid;
+	char 						*pid;
+	properties_pt 				dictionary;
 
-	bool deleted; // Not sure if it's needed
-	bundle_pt boundBundle;
+	bool 						deleted; // Not sure if it's needed
+	bundle_pt 					boundBundle;
 
 	celix_thread_mutex_t        mutex;
 };
 
 
+
+// External interface functions
+// see configuration.h
+celix_status_t configuration_delete(void* configuration);
+celix_status_t configuration_equals(void* thisConfiguration, void* otherConfiguration, bool *equals);
+celix_status_t configuration_getBundleLocation(void *configuration, char **bundleLocation);
+celix_status_t configuration_getFactoryPid(void *handle, char **factoryPid);
+celix_status_t configuration_hashCode(void *handle, int *hashCode);
+celix_status_t configuration_setBundleLocation(void *handle, char *bundleLocation);
+celix_status_t configuration_update(void *handle, properties_pt properties);
+
+
+// Configuration admin internal functions
+// see configuration_impl.h
+//static celix_status_t configuration_getBundleLocation2(configuration_impl_pt configuration, bool checkPermission, char **location);
+
+
+// static functions
+
 // org.eclipse.equinox.internal.cm
-celix_status_t configuration_lock(configuration_pt configuration);
-celix_status_t configuration_unlock(configuration_pt configuration);
-celix_status_t configuration_getBundleLocation2(configuration_pt configuration, bool checkPermission, char **location);
-celix_status_t configuration_getFactoryPid2(configuration_pt configuration, bool checkDeleted, char **factoryPid);
-celix_status_t configuration_getPid2(configuration_pt configuration, bool checkDeleted, char **pid);
-static celix_status_t configuration_updateDictionary(configuration_pt configuration, properties_pt properties);
+static celix_status_t configuration_getFactoryPid2(configuration_impl_pt configuration, bool checkDeleted, char **factoryPid);
+static celix_status_t configuration_getPid2(configuration_impl_pt configuration, bool checkDeleted, char **pid);
+static celix_status_t configuration_updateDictionary(configuration_impl_pt configuration, properties_pt properties);
 
 // org.apache.felix.cm.impl
-static celix_status_t configuration_setBundleLocationProperty(configuration_pt configuration, properties_pt *properties);
-static celix_status_t configuration_setAutoProperties(configuration_pt configuration, properties_pt *properties, bool withBundleLocation);
+static celix_status_t configuration_setBundleLocationProperty(configuration_impl_pt configuration, properties_pt *properties);
+static celix_status_t configuration_setAutoProperties(configuration_impl_pt configuration, properties_pt *properties, bool withBundleLocation);
+
 
+static celix_status_t configuration_checkDeleted(configuration_impl_pt configuration);
 
 /* ========== CONSTRUCTOR ========== */
 
@@ -86,35 +105,63 @@ celix_status_t configuration_create( configuration_admin_factory_pt factory, con
 									 char *factoryPid, char *pid, char *bundleLocation,
 									 configuration_pt *configuration){
 
-	configuration_pt config;
+	struct configuration *config;
+	struct configuration_impl *conf_impl;
     celix_thread_mutexattr_t	mutex_attr;
 
-
+    config = calloc(1, sizeof(struct configuration));
+    if (config == NULL) return CELIX_ENOMEM;
+    conf_impl = calloc(1, sizeof(struct configuration_impl));
+    if (conf_impl == NULL) {
+    	free (config);
+    	return CELIX_ENOMEM;
+    }
+
+    config->configuration_delete = configuration_delete;
+    config->configuration_equals = configuration_equals;
+    config->configuration_getBundleLocation = configuration_getBundleLocation;
+    config->configuration_getFactoryPid = configuration_getFactoryPid;
+    config->configuration_getPid = configuration_getPid;
+    config->configuration_getProperties = configuration_getProperties;
+    config->configuration_hashCode = configuration_hashCode;
+    config->configuration_setBundleLocation = configuration_setBundleLocation;
+    config->configuration_update = configuration_update;
+/*
 	config = calloc(1,sizeof(struct configuration));
 	if(!config){
 		printf("[ ERROR ]: Configuration{PID=%s} - Not created (ENOMEM) \n",pid);
 		return CELIX_ENOMEM;
 	}
-
-	config->configurationAdminFactory  = factory;
-	config->configurationStore = store;
-
-	config->factoryPid = factoryPid;
-	config->pid = pid;
-	config->bundleLocation = bundleLocation;
-	config->dictionary = NULL;
-
-	config->deleted = false;
-	config->boundBundle = NULL;
+*/
+	conf_impl->configurationAdminFactory  = factory;
+	conf_impl->configurationStore = store;
+
+	if (factoryPid != NULL)
+		conf_impl->factoryPid = strdup(factoryPid);
+	else
+		conf_impl->factoryPid = NULL;
+	if (pid != NULL)
+		conf_impl->pid = strdup(pid);
+	else
+		conf_impl->pid = NULL;
+	if (bundleLocation != NULL)
+		conf_impl->bundleLocation = strdup(bundleLocation);
+	else
+		conf_impl->bundleLocation = NULL;
+	conf_impl->dictionary = NULL;
+
+	conf_impl->deleted = false;
+	conf_impl->boundBundle = NULL;
 
     celixThreadMutexAttr_create(&mutex_attr);
     celixThreadMutexAttr_settype(&mutex_attr, CELIX_THREAD_MUTEX_RECURSIVE);  // why recursive?
-	if( celixThreadMutex_create(&config->mutex, &mutex_attr) != CELIX_SUCCESS ){
+	if( celixThreadMutex_create(&conf_impl->mutex, &mutex_attr) != CELIX_SUCCESS ){
 		printf("[ ERROR ]: Configuration{PID=%s} - Not created (MUTEX) \n",pid);
 		return CELIX_ILLEGAL_ARGUMENT;
 	}
 
-	printf("[ SUCCESS]: Configuration{PID=%s}  - Created \n", pid);
+	conf_impl->configuration_interface = config;
+	config->handle = conf_impl;
 	*configuration = config;
 	return CELIX_SUCCESS;
 }
@@ -124,35 +171,63 @@ celix_status_t configuration_create2(configuration_admin_factory_pt factory, con
 									 configuration_pt *configuration){
 
 	configuration_pt config;
+	configuration_impl_pt conf_impl;
+
     celix_thread_mutexattr_t	mutex_attr;
+    char *value;
 
 	config = calloc(1, sizeof(struct configuration));
-	if(!config){
-		printf("[ ERROR ]: Configuration - Not created (ENOMEM) \n");
-		return CELIX_ENOMEM;
-	}
-
-	config->configurationAdminFactory  = factory;
-	config->configurationStore = store;
-
-	config->factoryPid = properties_get(dictionary,(char *)SERVICE_FACTORYPID);
-	config->pid = properties_get(dictionary, (char *)OSGI_FRAMEWORK_SERVICE_PID);
-	config->bundleLocation = properties_get(dictionary, (char *)SERVICE_BUNDLELOCATION);
-	config->dictionary = NULL;
-
-	config->deleted = false;
-	config->boundBundle = NULL;
+    if (config == NULL) return CELIX_ENOMEM;
+    conf_impl = calloc(1, sizeof(struct configuration_impl));
+    if (conf_impl == NULL) {
+    	free (config);
+    	return CELIX_ENOMEM;
+    }
+
+    config->configuration_delete = configuration_delete;
+    config->configuration_equals = configuration_equals;
+    config->configuration_getBundleLocation = configuration_getBundleLocation;
+    config->configuration_getFactoryPid = configuration_getFactoryPid;
+    config->configuration_getPid = configuration_getPid;
+    config->configuration_getProperties = configuration_getProperties;
+    config->configuration_hashCode = configuration_hashCode;
+    config->configuration_setBundleLocation = configuration_setBundleLocation;
+    config->configuration_update = configuration_update;
+
+	conf_impl->configurationAdminFactory  = factory;
+	conf_impl->configurationStore = store;
+
+	value = properties_get(dictionary,(char *)SERVICE_FACTORYPID);
+	if (value != NULL)
+		conf_impl->factoryPid = strdup(value);
+	else
+		conf_impl->factoryPid = NULL;
+	value = properties_get(dictionary, (char *)OSGI_FRAMEWORK_SERVICE_PID);
+	if (value != NULL)
+		conf_impl->pid = strdup(value);
+	else
+		conf_impl->pid = NULL;
+	value = properties_get(dictionary, (char *)SERVICE_BUNDLELOCATION);
+	if (value != NULL)
+		conf_impl->bundleLocation = strdup(value);
+	else
+		conf_impl->bundleLocation = NULL;
+	conf_impl->dictionary = NULL;
+
+	conf_impl->deleted = false;
+	conf_impl->boundBundle = NULL;
 
     celixThreadMutexAttr_create(&mutex_attr);
     celixThreadMutexAttr_settype(&mutex_attr, CELIX_THREAD_MUTEX_RECURSIVE);  // why recursive?
-	if( celixThreadMutex_create(&config->mutex, &mutex_attr) != CELIX_SUCCESS ){
-		printf("[ ERROR ]: Configuration{PID=%s} - Not created (MUTEX) \n", config->pid);
+	if( celixThreadMutex_create(&conf_impl->mutex, &mutex_attr) != CELIX_SUCCESS ){
+		printf("[ ERROR ]: Configuration{PID=%s} - Not created (MUTEX) \n", conf_impl->pid);
 		return CELIX_ILLEGAL_ARGUMENT;
 	}
     celixThreadMutexAttr_destroy(&mutex_attr);
-	configuration_updateDictionary(config, dictionary);
+	configuration_updateDictionary(conf_impl, dictionary);
 
-	printf("[ SUCCESS]: Configuration{PID=%s}  - Created \n", config->pid);
+	conf_impl->configuration_interface = config;
+	config->handle = conf_impl;
 	*configuration = config;
 	return CELIX_SUCCESS;
 
@@ -164,159 +239,169 @@ celix_status_t configuration_create2(configuration_admin_factory_pt factory, con
 /* ---------- public ---------- */
 // specifications
 
-celix_status_t configuration_delete(configuration_pt configuration){
+celix_status_t configuration_delete(void *handle){
+	configuration_impl_pt conf = (configuration_impl_pt)handle;
+
 	printf("TODO: Implement configuration_delete\n");
-	celixThreadMutex_destroy(&configuration->mutex);
+	celixThreadMutex_destroy(&conf->mutex);
+	if (conf->factoryPid != NULL)
+		free(conf->factoryPid);
+	if (conf->pid != NULL)
+		free(conf->pid);
+	if (conf->bundleLocation != NULL)
+		free(conf->bundleLocation);
+	free(conf->configuration_interface);
+	free(conf);
 	return CELIX_SUCCESS;
 }
 
-celix_status_t configuration_equals(configuration_pt thisConfiguration, configuration_pt otherConfiguration, bool *equals){
+celix_status_t configuration_equals(void* thisConfiguration, void *otherConfiguration, bool *equals){
 	return CELIX_SUCCESS;
 }
 
-celix_status_t configuration_getBundleLocation(configuration_pt configuration, char **bundleLocation){
-	return configuration_getBundleLocation2( configuration, true, bundleLocation);
+celix_status_t configuration_getBundleLocation(void *handle, char **bundleLocation){
+	return configuration_getBundleLocation2( handle, true, bundleLocation);
 }
 
-celix_status_t configuration_getFactoryPid(configuration_pt configuration, char **factoryPid){
-	return configuration_getFactoryPid2(configuration, true, factoryPid);
+celix_status_t configuration_getFactoryPid(void *handle, char **factoryPid){
+	return configuration_getFactoryPid2(handle, true, factoryPid);
 }
 
-celix_status_t configuration_getPid(configuration_pt configuration, char **pid){
-	return configuration_getPid2(configuration, true, pid);
+celix_status_t configuration_getPid(void *handle, char **pid){
+	return configuration_getPid2(handle, true, pid);
 }
 
-celix_status_t configuration_getProperties(configuration_pt configuration, properties_pt *properties){
+celix_status_t configuration_getProperties(void *handle, properties_pt *properties){
 
-	printf("[ DEBUG ]: Configuration{PID=%s} - getProperties \n",configuration->pid);
+    configuration_impl_pt conf = (configuration_impl_pt) handle;
 
-	properties_pt copy = configuration->dictionary;
+	properties_pt copy = conf->dictionary;
 
 	// (1) configuration.lock
-	configuration_lock(configuration);
+	configuration_lock(conf);
 
 	// (2) configuration.checkDeleted
-	if ( configuration_checkDeleted(configuration) != CELIX_SUCCESS ){
-		configuration_unlock(configuration);
+	if ( configuration_checkDeleted(conf) != CELIX_SUCCESS ){
+		configuration_unlock(conf);
 		return CELIX_ILLEGAL_STATE;
 	}
 	// (3) Have the Configuration properties ?
-	if ( configuration->dictionary == NULL ){
-		printf("[ DEBUG ]: configuration_getProperties results NULL \n");
+	if ( conf->dictionary == NULL ){
 		*properties = NULL;
-		configuration_unlock(configuration);
+		configuration_unlock(conf);
 		return CELIX_SUCCESS;
 	}
 
 	// (4) configuration.setAutoProperties
-	if ( configuration_setAutoProperties(configuration, &copy, false) != CELIX_SUCCESS ){
-		configuration_unlock(configuration);
+	if ( configuration_setAutoProperties(conf, &copy, false) != CELIX_SUCCESS ){
+		configuration_unlock(conf);
 		return CELIX_ILLEGAL_ARGUMENT;
 	}
 
 	// (5) return
 	*properties = copy;
-	configuration_unlock(configuration);
+	configuration_unlock(conf);
 	return CELIX_SUCCESS;
 }
 
-celix_status_t configuration_hashCode(configuration_pt configuration, int *hashCode){
+celix_status_t configuration_hashCode(void *handle, int *hashCode){
 	return CELIX_SUCCESS;
 }
 
-celix_status_t configuration_setBundleLocation(configuration_pt configuration, char *bundleLocation){
+celix_status_t configuration_setBundleLocation(void *handle, char *bundleLocation){
 
-	configuration_lock(configuration);
+	configuration_impl_pt	conf = (configuration_impl_pt)handle;
+	configuration_lock(conf);
 
-	if ( configuration_checkDeleted(configuration) != CELIX_SUCCESS ){
-		configuration_unlock(configuration);
+	if ( configuration_checkDeleted(conf) != CELIX_SUCCESS ){
+		configuration_unlock(conf);
 		return CELIX_ILLEGAL_STATE;
 	}
 
 	//	TODO configurationAdminFactory.checkConfigurationPermission
 
-	configuration->bundleLocation = bundleLocation;
-	configuration->boundBundle = NULL; // always reset the boundBundle when setBundleLocation is called
+	conf->bundleLocation = bundleLocation;
+	conf->boundBundle = NULL; // always reset the boundBundle when setBundleLocation is called
 
-	configuration_unlock(configuration);
+	configuration_unlock(conf);
 
 	return CELIX_SUCCESS;
 }
 
-celix_status_t configuration_update(configuration_pt configuration, properties_pt properties){
+celix_status_t configuration_update(void *handle, properties_pt properties){
+
+	configuration_impl_pt conf = (configuration_impl_pt)handle;
 
-	printf("[ DEBUG ]: Configuration{PID=%s} - update \n", configuration->pid);
 
 	celix_status_t status;
 
 	// (1)
-	configuration_lock(configuration);
+	configuration_lock(conf);
 
 	// (2)
-	if ( configuration_checkDeleted(configuration) != CELIX_SUCCESS ){
-		configuration_unlock(configuration);
+	if ( configuration_checkDeleted(conf) != CELIX_SUCCESS ){
+		configuration_unlock(conf);
 		return CELIX_ILLEGAL_STATE;
 	}
 	// (3)
-	configuration_updateDictionary(configuration,properties);
+	configuration_updateDictionary(conf, properties);
 
 	// (4)
-	status = configurationStore_saveConfiguration(configuration->configurationStore,configuration->pid,configuration);
+	status = configurationStore_saveConfiguration(conf->configurationStore, conf->pid, conf->configuration_interface);
 	if (status != CELIX_SUCCESS){
-		configuration_unlock(configuration);
+		configuration_unlock(conf);
 		return status;
 	}
 
 	// (5)
 	bool isFactory;
-	if (configuration->factoryPid == NULL){
+	if (conf->factoryPid == NULL){
 		isFactory = false;
 	} else{
 		isFactory = true;
 	}
 
-	status = configurationAdminFactory_notifyConfigurationUpdated(configuration->configurationAdminFactory, configuration, isFactory);
+	status = configurationAdminFactory_notifyConfigurationUpdated(conf->configurationAdminFactory, conf->configuration_interface, isFactory);
 	if (status != CELIX_SUCCESS){
-		configuration_unlock(configuration);
+		configuration_unlock(conf);
 		return status;
 	}
 
 	// (6)
-	status = configurationAdminFactory_dispatchEvent(configuration->configurationAdminFactory, CONFIGURATION_EVENT_CM_UPDATED, configuration->factoryPid, configuration->pid);
+	status = configurationAdminFactory_dispatchEvent(conf->configurationAdminFactory, CONFIGURATION_EVENT_CM_UPDATED, conf->factoryPid, conf->pid);
 	if (status != CELIX_SUCCESS){
-		configuration_unlock(configuration);
+		configuration_unlock(conf);
 		return status;
 	}
 
 	// (7)
-	configuration_unlock(configuration);
-	printf("[ SUCCESS ]: Configuration{PID=%s} - update \n",configuration->pid);
+	configuration_unlock(conf);
 	return CELIX_SUCCESS;
 }
 
 /* ---------- protected ---------- */
 // org.eclipse.equinox.cm.impl
 
-celix_status_t configuration_lock(configuration_pt configuration){
+celix_status_t configuration_lock(configuration_impl_pt configuration){
 //	printf("[ DEBUG ]: Configuration{PID=%s} - LOCK \n",configuration->pid);
 	celixThreadMutex_lock(&configuration->mutex);
 	return CELIX_SUCCESS;
 }
 
-celix_status_t configuration_unlock(configuration_pt configuration){
+celix_status_t configuration_unlock(configuration_impl_pt configuration){
 //	printf("[ DEBUG ]: Configuration{PID=%s} - UNLOCK \n",configuration->pid);
 	celixThreadMutex_unlock(&configuration->mutex);
 	return CELIX_SUCCESS;
 }
 
-celix_status_t configuration_checkLocked(configuration_pt configuration){
+celix_status_t configuration_checkLocked(configuration_impl_pt configuration){
 	// Not used
 	return CELIX_SUCCESS;
 }
 
-celix_status_t configuration_bind(configuration_pt configuration, bundle_pt bundle, bool *isBind){
+celix_status_t configuration_bind(configuration_impl_pt configuration, bundle_pt bundle, bool *isBind){
 
-	printf("[ DEBUG ]: Configuration{PID=%s} - bind(START) \n",configuration->pid);
+//	printf("[ DEBUG ]: Configuration{PID=%s} - bind(START) \n",configuration->pid);
 
 	char *bundleLocation;
 
@@ -339,14 +424,14 @@ celix_status_t configuration_bind(configuration_pt configuration, bundle_pt bund
 			if ( strcmp(configuration->bundleLocation, bundleLocation) == 0 ){ // (3): Yes
 				// bind up configuration with bundle
 				configuration->boundBundle = bundle;
-				printf("[ DEBUG ]: Configuration{PID=%s} - bind (bound with Bundle{%s}) \n",configuration->pid,bundleLocation);
+//				printf("[ DEBUG ]: Configuration{PID=%s} - bind (bound with Bundle{%s}) \n",configuration->pid,bundleLocation);
 			}
 			// (3): No
 
 		}else{// (2): No
 			// bind up configuration with bundle
 			configuration->boundBundle = bundle;
-			printf("[ DEBUG ]: Configuration{PID=%s}) - bind (not located and now bound with Bundle) \n",configuration->pid);
+//			printf("[ DEBUG ]: Configuration{PID=%s}) - bind (not located and now bound with Bundle) \n",configuration->pid);
 		}
 
 	}// (1): Yes
@@ -364,16 +449,16 @@ celix_status_t configuration_bind(configuration_pt configuration, bundle_pt bund
 	configuration_unlock(configuration);
 
 	*isBind = bind;
-	printf("[ DEBUG ]: Configuration{PID=%s} - bind(END) \n",configuration->pid);
+//	printf("[ DEBUG ]: Configuration{PID=%s} - bind(END) \n",configuration->pid);
 	return CELIX_SUCCESS;
 
 }
 
-celix_status_t configuration_unbind(configuration_pt configuration, bundle_pt bundle){
+celix_status_t configuration_unbind(configuration_impl_pt configuration, bundle_pt bundle){
 	return CELIX_SUCCESS;
 }
 
-celix_status_t configuration_getBundleLocation2(configuration_pt configuration, bool checkPermission, char **location){
+celix_status_t configuration_getBundleLocation2(configuration_impl_pt configuration, bool checkPermission, char **location){
 
 	celix_status_t status;
 
@@ -413,13 +498,11 @@ celix_status_t configuration_getBundleLocation2(configuration_pt configuration,
 	return CELIX_SUCCESS;
 }
 
-celix_status_t configuration_getFactoryPid2(configuration_pt configuration, bool checkDeleted, char **factoryPid){
+static celix_status_t configuration_getFactoryPid2(configuration_impl_pt configuration, bool checkDeleted, char **factoryPid){
 	return CELIX_SUCCESS;
 }
 
-celix_status_t configuration_getPid2(configuration_pt configuration, bool checkDeleted, char **pid){
-
-	printf("[ DEBUG ]: Configuration{PID=%s} - getPid \n", configuration->pid);
+static celix_status_t configuration_getPid2(configuration_impl_pt configuration, bool checkDeleted, char **pid){
 
 	configuration_lock(configuration);
 
@@ -439,7 +522,7 @@ celix_status_t configuration_getPid2(configuration_pt configuration, bool checkD
 
 // org.eclipse.equinox.internal.cm modified to fit with org.apache.felix.cm.impl
 // change due to ConfigurationStore implementation
-celix_status_t configuration_getAllProperties(configuration_pt configuration, properties_pt *properties){
+celix_status_t configuration_getAllProperties(configuration_impl_pt configuration, properties_pt *properties){
 
 	celix_status_t status;
 
@@ -485,13 +568,13 @@ celix_status_t configuration_getAllProperties(configuration_pt configuration, pr
 
 }
 
-celix_status_t configuration_isDeleted(configuration_pt configuration, bool *isDeleted){
+celix_status_t configuration_isDeleted(configuration_impl_pt configuration, bool *isDeleted){
 	return CELIX_SUCCESS;
 }
 
 /* ---------- private ---------- */
 
-celix_status_t configuration_checkDeleted(configuration_pt configuration){
+celix_status_t configuration_checkDeleted(configuration_impl_pt configuration){
 
 	if ( configuration->deleted ){
 		printf("[CELIX_ILLEGAL_STATE ]: configuration(pid=%s) deleted \n", configuration->pid);
@@ -502,7 +585,7 @@ celix_status_t configuration_checkDeleted(configuration_pt configuration){
 }
 
 // configuration->dictionary must not contain keys reserved to ConfigAdmin (i.e. "service.pid")
-celix_status_t configuration_updateDictionary(configuration_pt configuration, properties_pt properties){
+celix_status_t configuration_updateDictionary(configuration_impl_pt configuration, properties_pt properties){
 
 	properties_pt newDictionary = NULL;
 
@@ -528,7 +611,7 @@ celix_status_t configuration_updateDictionary(configuration_pt configuration, pr
 
 /* ---------- protected ---------- */
 #if 0
-celix_status_t configuration_getPool(configuration_pt configuration, apr_pool_t **pool){
+celix_status_t configuration_getPool(configuration_impl_pt configuration, apr_pool_t **pool){
 
 	printf("[ DEBUG ]: Configuration{PID=%s} - get Pool \n",configuration->pid);
 
@@ -546,7 +629,7 @@ celix_status_t configuration_getPool(configuration_pt configuration, apr_pool_t
 
 
 // properties_pt as input and output
-celix_status_t configuration_setAutoProperties(configuration_pt configuration, properties_pt *properties, bool withBundleLocation){
+celix_status_t configuration_setAutoProperties(configuration_impl_pt configuration, properties_pt *properties, bool withBundleLocation){
 
 	//(1) configuration.lock
 	configuration_lock(configuration);
@@ -575,7 +658,7 @@ celix_status_t configuration_setAutoProperties(configuration_pt configuration, p
 
 }
 
-celix_status_t configuration_setBundleLocationProperty(configuration_pt configuration, properties_pt *properties){
+celix_status_t configuration_setBundleLocationProperty(configuration_impl_pt configuration, properties_pt *properties){
 
 	char *boundLocation;
 

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/service/private/src/configuration_store.c
----------------------------------------------------------------------
diff --git a/config_admin/service/private/src/configuration_store.c b/config_admin/service/private/src/configuration_store.c
index 457e02a..1343568 100644
--- a/config_admin/service/private/src/configuration_store.c
+++ b/config_admin/service/private/src/configuration_store.c
@@ -44,10 +44,14 @@
 #include "properties.h"
 #include "utils.h"
 /* celix.config_admin.private*/
+#include "configuration_admin_factory.h"
+#include "configuration.h"
 #include "configuration_impl.h"
 
 #define STORE_DIR "store"
 #define PID_EXT ".pid"
+#define MAX_CONFIG_PROPERTY_LEN		128
+
 
 struct configuration_store {
 
@@ -63,7 +67,7 @@ struct configuration_store {
 };
 
 static celix_status_t configurationStore_createCache(configuration_store_pt store);
-static celix_status_t configurationStore_getConfigurationFile(char *pid, char* storePath, configuration_pt configuration, int *file);
+static celix_status_t configurationStore_getConfigurationFile(char *pid, char* storePath, int *file);
 static celix_status_t configurationStore_writeConfigurationFile(int fd, properties_pt properties);
 static celix_status_t configurationStore_readCache(configuration_store_pt store);
 static celix_status_t configurationStore_readConfigurationFile(const char *name, int size, properties_pt *dictionary);
@@ -100,7 +104,6 @@ celix_status_t configurationStore_create(bundle_context_pt context, configuratio
 
     configurationStore_readCache((*store));
 
-    printf("[ SUCCESS ]: ConfigStore - Initialized \n");
     return CELIX_SUCCESS;
 }
 
@@ -115,27 +118,23 @@ celix_status_t configurationStore_destroy(configuration_store_pt store) {
 // org.eclipse.equinox.internal.cm
 celix_status_t configurationStore_lock(configuration_store_pt store) {
     celixThreadMutex_lock(&store->mutex);
-    printf("[ SUCCESS ]: ConfigStore - LOCK \n");
     return CELIX_SUCCESS;
 }
 
 celix_status_t configurationStore_unlock(configuration_store_pt store) {
     celixThreadMutex_unlock(&store->mutex);
-    printf("[ SUCCESS ]: ConfigStore - UNLOCK \n");
     return CELIX_SUCCESS;
 }
 
 celix_status_t configurationStore_saveConfiguration(configuration_store_pt store, char *pid, configuration_pt configuration) {
 
-    printf("[ DEBUG ]: ConfigStore - saveConfig{PID=%s} \n", pid);
-
     celix_status_t status;
 
     //(1) config.checkLocked
 
     //(2) configurationStore.getFile
     int configFile;
-    status = configurationStore_getConfigurationFile(pid, (char *) STORE_DIR, configuration, &configFile);
+    status = configurationStore_getConfigurationFile(pid, (char *) STORE_DIR, &configFile);
     if (status != CELIX_SUCCESS) {
         return status;
     }
@@ -143,13 +142,12 @@ celix_status_t configurationStore_saveConfiguration(configuration_store_pt store
     //(4) configProperties = config.getAllProperties
 
     properties_pt configProperties = NULL;
-    status = configuration_getAllProperties(configuration, &configProperties);
+    status = configuration_getAllProperties(configuration->handle, &configProperties);
     if (status != CELIX_SUCCESS) {
         printf("[ ERROR ]: ConfigStore - config{PID=%s}.getAllProperties \n", pid);
         return status;
     }
 
-    printf("properties_pt SIZE = %i \n", hashMap_size(configProperties));
 
     //(5) configStore.writeFile(file,properties)
     status = configurationStore_writeConfigurationFile(configFile, configProperties);
@@ -180,7 +178,6 @@ celix_status_t configurationStore_getConfiguration(configuration_store_pt store,
         }
 
         hashMap_put(store->configurations, pid, config);
-        printf("[ DEBUG ]: ConfigStore - getConfig(PID=%s) (new one stored) \n", pid);
     }
 
     *configuration = config;
@@ -194,7 +191,6 @@ celix_status_t configurationStore_createFactoryConfiguration(configuration_store
 celix_status_t configurationStore_findConfiguration(configuration_store_pt store, char *pid, configuration_pt *configuration) {
 
     *configuration = hashMap_get(store->configurations, pid);
-    printf("[ DEBUG ]: ConfigStore - findConfig(PID=%s) \n", pid);
     return CELIX_SUCCESS;
 
 }
@@ -218,7 +214,6 @@ celix_status_t configurationStore_createCache(configuration_store_pt store) {
     int result = mkdir((const char*) STORE_DIR, 0777);
 
     if ((result == 0) || ((result == -1) && (errno == EEXIST))) {
-        printf("[ SUCCESS ]: ConfigStore - Cache OK \n");
         return CELIX_SUCCESS;
     }
 
@@ -227,22 +222,18 @@ celix_status_t configurationStore_createCache(configuration_store_pt store) {
 
 }
 
-celix_status_t configurationStore_getConfigurationFile(char *pid, char* storePath, configuration_pt configuration, int *file) {
+celix_status_t configurationStore_getConfigurationFile(char *pid, char* storePath, int *file) {
 
     // (1) The full path to the file
-    char *fname = strdup((const char *) storePath);
-    strcat(fname, strdup("/"));
-    strcat(fname, strdup((const char *) pid));
-    strcat(fname, strdup((const char *) PID_EXT));
+    char fname[PATH_MAX];
+    strcpy(fname, storePath);
+    strcat(fname, "/");
+    strcat(fname, (const char *) pid);
+    strcat(fname, (const char *) PID_EXT);
 
-    printf("[ DEBUG ]: ConfigStore - getFile(%s) \n", fname);
     // (2) configuration.getPool
-#if 0
-    apr_pool_t *fpool;
-    configuration_getPool(configuration, &fpool);
-#endif
     // (3) file.open
-    if ((*file = open((const char*) fname, O_CREAT | O_RDWR)) < 0) {
+    if ((*file = open((const char*) fname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0) {
         printf("[ ERROR ]: ConfigStore - getFile(IO_EXCEPTION) \n");
         return CELIX_FILE_IO_EXCEPTION;
     }
@@ -251,41 +242,31 @@ celix_status_t configurationStore_getConfigurationFile(char *pid, char* storePat
 
 celix_status_t configurationStore_writeConfigurationFile(int file, properties_pt properties) {
 
-    printf("[ DEBUG ]: ConfigStore - write \n");
-
     if (properties == NULL || hashMap_size(properties) <= 0) {
         return CELIX_SUCCESS;
     }
     // size >0
 
-    char *buffer;
-    bool iterator0 = true;
+    char buffer[128];
 
     hash_map_iterator_pt iterator = hashMapIterator_create(properties);
     while (hashMapIterator_hasNext(iterator)) {
 
         hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
 
-        char * line = strdup(hashMapEntry_getKey(entry));
-        strcat(line, strdup("="));
-        strcat(line, strdup(hashMapEntry_getValue(entry)));
-        strcat(line, "\n");
+        strcpy(buffer, hashMapEntry_getKey(entry));
+        strcat(buffer, "=");
+        strcat(buffer, hashMapEntry_getValue(entry));
+        strcat(buffer, "\n");
 
-        if (iterator0) {
-            buffer = line;
-            iterator0 = false;
-        } else {
-            strcat(buffer, strdup(line));
-        }
-    }
+        int buffLength = strlen((const char *) buffer);
 
-    int buffLength = strlen((const char *) buffer);
-
-    if (write(file, (const void *) buffer, buffLength) != buffLength) {
-        printf("[ ERROR ]: ConfigStore - writing in Cache incomplete \n");
-        return CELIX_FILE_IO_EXCEPTION;
+    	if (write(file, (const void *) buffer, buffLength) != buffLength) {
+            printf("[ ERROR ]: ConfigStore - writing in Cache incomplete \n");
+            return CELIX_FILE_IO_EXCEPTION;
+        }
     }
-
+    hashMapIterator_destroy(iterator);
     return CELIX_SUCCESS;
 
 }
@@ -319,15 +300,18 @@ celix_status_t configurationStore_readCache(configuration_store_pt store) {
     while ((res == 0) && (dp != NULL)) {
 
         if ((strcmp((dp->d_name), ".") != 0) && (strcmp((dp->d_name), "..") != 0) && (strpbrk(dp->d_name, "~") == NULL)) {
-
+	    char storeRoot[512];
+            snprintf(storeRoot, sizeof(storeRoot), "%s/%s", STORE_DIR, dp->d_name);
             // (2.1) file.readData
-            if (stat(dp->d_name, &st) == 0) {
+            if (stat(storeRoot, &st) == 0) {
                 status = configurationStore_readConfigurationFile(dp->d_name, st.st_size, &properties);
                 if (status != CELIX_SUCCESS) {
                     closedir(cache);
                     return status;
                 }
             }
+            else
+                perror("stat");
             // (2.2) new configuration
             status = configuration_create2(store->configurationAdminFactory, store, properties, &configuration);
             if (status != CELIX_SUCCESS) {
@@ -336,7 +320,7 @@ celix_status_t configurationStore_readCache(configuration_store_pt store) {
             }
 
             // (2.3) configurations.put
-            configuration_getPid(configuration, &pid);
+            configuration_getPid(configuration->handle, &pid);
             hashMap_put(store->configurations, pid, configuration);
         }
         res = readdir_r(cache, (struct dirent*) &u, &dp);

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/service/private/src/managed_service_impl.c
----------------------------------------------------------------------
diff --git a/config_admin/service/private/src/managed_service_impl.c b/config_admin/service/private/src/managed_service_impl.c
index ee5e797..243a57e 100644
--- a/config_admin/service/private/src/managed_service_impl.c
+++ b/config_admin/service/private/src/managed_service_impl.c
@@ -48,3 +48,8 @@ celix_status_t managedService_create(bundle_context_pt context, managed_service_
 	return CELIX_SUCCESS;
 
 }
+
+celix_status_t managedService_destroy(managed_service_pt service) {
+	free(service);
+	return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/service/private/src/managed_service_tracker.c
----------------------------------------------------------------------
diff --git a/config_admin/service/private/src/managed_service_tracker.c b/config_admin/service/private/src/managed_service_tracker.c
index 104b85e..0e47ec0 100644
--- a/config_admin/service/private/src/managed_service_tracker.c
+++ b/config_admin/service/private/src/managed_service_tracker.c
@@ -55,39 +55,39 @@ struct managed_service_tracker {
 
     configuration_admin_factory_pt configurationAdminfactory;
     configuration_store_pt configurationStore;
-    updated_thread_pool_t updatedThreadPool; // according to org.equinox is our "SerializableTaskQueue"
+    updated_thread_pool_pt updatedThreadPool; // according to org.equinox is our "SerializableTaskQueue"
 
     hash_map_pt managedServices;
     hash_map_pt managedServicesReferences;
     celix_thread_mutex_t managedServicesReferencesMutex;
 };
 
-static celix_status_t managedServiceTracker_createHandle(bundle_context_pt context, configuration_admin_factory_pt factory, configuration_store_pt store, managed_service_tracker_t *tracker);
-static celix_status_t managedServiceTracker_createCustomized(bundle_context_pt context, managed_service_tracker_t trackerHandle, service_tracker_pt *tracker);
+static celix_status_t managedServiceTracker_createHandle(bundle_context_pt context, configuration_admin_factory_pt factory, configuration_store_pt store, managed_service_tracker_pt *tracker);
+static celix_status_t managedServiceTracker_createCustomized(bundle_context_pt context, managed_service_tracker_pt trackerHandle, service_tracker_pt *tracker);
 
-static celix_status_t managedServiceTracker_add(managed_service_tracker_t tracker, service_reference_pt reference, char * pid, managed_service_service_pt service);
-//static celix_status_t managedServiceTracker_remove(managed_service_tracker_t tracker, service_reference_pt reference, char * pid);
-static celix_status_t managedServiceTracker_trackManagedService(managed_service_tracker_t tracker, char *pid, service_reference_pt reference, managed_service_service_pt service);
-//static celix_status_t managedServiceTracker_untrackManagedService(managed_service_tracker_t tracker, char *pid, service_reference_pt reference);
-static celix_status_t managedServiceTracker_getManagedService(managed_service_tracker_t tracker, char *pid, managed_service_service_pt *service);
-static celix_status_t managedServiceTracker_getManagedServiceReference(managed_service_tracker_t tracker, char *pid, service_reference_pt *reference);
+static celix_status_t managedServiceTracker_add(managed_service_tracker_pt tracker, service_reference_pt reference, char * pid, managed_service_service_pt service);
+static celix_status_t managedServiceTracker_remove(managed_service_tracker_pt tracker, service_reference_pt reference, char * pid);
+static celix_status_t managedServiceTracker_trackManagedService(managed_service_tracker_pt tracker, char *pid, service_reference_pt reference, managed_service_service_pt service);
+static celix_status_t managedServiceTracker_untrackManagedService(managed_service_tracker_pt tracker, char *pid, service_reference_pt reference);
+static celix_status_t managedServiceTracker_getManagedService(managed_service_tracker_pt tracker, char *pid, managed_service_service_pt *service);
+static celix_status_t managedServiceTracker_getManagedServiceReference(managed_service_tracker_pt tracker, char *pid, service_reference_pt *reference);
 //static celix_status_t managedServiceTracker_getPidForManagedService(managed_service_service_pt *service, char **pid);
-static celix_status_t managedServiceTracker_asynchUpdated(managed_service_tracker_t trackerHandle, managed_service_service_pt service, properties_pt properties);
+celix_status_t managedServiceTracker_asynchUpdated(managed_service_tracker_pt trackerHandle, managed_service_service_pt service, properties_pt properties);
 
-static celix_status_t managedServiceTracker_getBundleContext(managed_service_tracker_t trackerHandle, bundle_context_pt *context);
+static celix_status_t managedServiceTracker_getBundleContext(managed_service_tracker_pt trackerHandle, bundle_context_pt *context);
 
-static celix_status_t managedServiceTracker_lockManagedServicesReferences(managed_service_tracker_t handle);
-static celix_status_t managedServiceTracker_unlockManagedServicesReferences(managed_service_tracker_t handle);
+static celix_status_t managedServiceTracker_lockManagedServicesReferences(managed_service_tracker_pt handle);
+static celix_status_t managedServiceTracker_unlockManagedServicesReferences(managed_service_tracker_pt handle);
 
 /* ========== CONSTRUCTOR ========== */
 
 /* ---------- public ---------- */
 
-celix_status_t managedServiceTracker_create(bundle_context_pt context, configuration_admin_factory_pt factory, configuration_store_pt store, managed_service_tracker_t *trackerHandle, service_tracker_pt *tracker) {
+celix_status_t managedServiceTracker_create(bundle_context_pt context, configuration_admin_factory_pt factory, configuration_store_pt store, managed_service_tracker_pt *trackerHandle, service_tracker_pt *tracker) {
 
     celix_status_t status;
 
-    managed_service_tracker_t managedServiceTrackerHandle;
+    managed_service_tracker_pt managedServiceTrackerHandle;
     service_tracker_pt managedServiceTrackerCustomized;
 
     status = managedServiceTracker_createHandle(context, factory, store, &managedServiceTrackerHandle);
@@ -113,12 +113,12 @@ celix_status_t managedServiceTracker_create(bundle_context_pt context, configura
 
 /* ---------- private ---------- */
 
-celix_status_t managedServiceTracker_createHandle(bundle_context_pt context, configuration_admin_factory_pt factory, configuration_store_pt store, managed_service_tracker_t *tracker) {
+celix_status_t managedServiceTracker_createHandle(bundle_context_pt context, configuration_admin_factory_pt factory, configuration_store_pt store, managed_service_tracker_pt *tracker) {
 
     celix_status_t status;
 
-    updated_thread_pool_t updatedThreadPool = NULL;
-    managed_service_tracker_t this = calloc(1, sizeof(*this));
+    updated_thread_pool_pt updatedThreadPool = NULL;
+    managed_service_tracker_pt this = calloc(1, sizeof(*this));
 
     if (!this) {
         printf("[ ERROR ]: TrackerInstance - Not initialized (ENOMEM) \n");
@@ -152,7 +152,7 @@ celix_status_t managedServiceTracker_createHandle(bundle_context_pt context, con
 
 }
 
-celix_status_t managedServiceTracker_createCustomized(bundle_context_pt context, managed_service_tracker_t trackerHandle, service_tracker_pt *tracker) {
+celix_status_t managedServiceTracker_createCustomized(bundle_context_pt context, managed_service_tracker_pt trackerHandle, service_tracker_pt *tracker) {
     celix_status_t status;
 
     service_tracker_customizer_pt customizer = NULL;
@@ -178,13 +178,21 @@ celix_status_t managedServiceTracker_createCustomized(bundle_context_pt context,
     return CELIX_SUCCESS;
 }
 
+celix_status_t managedServiceTracker_destroy(bundle_context_pt context, managed_service_tracker_pt mgServTr, service_tracker_pt tracker) {
+	updatedThreadPool_destroy(mgServTr->updatedThreadPool);
+	celixThreadMutex_destroy(&mgServTr->managedServicesReferencesMutex);
+	serviceTracker_destroy(tracker);
+	return CELIX_SUCCESS;
+}
+
+
+
 /* ========== IMPLEMENTS CUSTOMIZED TRACKER ========== */
 
 /* ---------- public ---------- */
 
 celix_status_t managedServiceTracker_addingService(void * handle, service_reference_pt reference, void **service) {
 
-    printf("[ DEBUG ]: Tracker - Adding Service \n");
 
     celix_status_t status;
 
@@ -192,12 +200,12 @@ celix_status_t managedServiceTracker_addingService(void * handle, service_refere
 
     bundle_context_pt context = NULL;
 
-    managed_service_tracker_t managedServiceTracker_i = handle;	//instance
+    managed_service_tracker_pt managedServiceTracker_i = handle;	//instance
     managed_service_service_pt managedService_s = NULL;			//service
 
     // (1) reference.getPid
 
-    status = serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_ID, &pid);
+    status = serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_PID, &pid);
     if (status != CELIX_SUCCESS || pid == NULL) {
         *service = NULL;
         printf(" [ ERROR ]: Tracker - PID is NULL \n");
@@ -227,7 +235,7 @@ celix_status_t managedServiceTracker_addingService(void * handle, service_refere
         return CELIX_ILLEGAL_ARGUMENT;
     }
 
-    /* DEBUG CODE */
+    /* DEBUG CODE *
 
     service_registration_pt registration = NULL;
     serviceReference_getServiceRegistration(reference, &registration);
@@ -236,13 +244,15 @@ celix_status_t managedServiceTracker_addingService(void * handle, service_refere
 
     printf("[ DEBUG ]: Tracker - AddingService ( SUCCESS BundleCtxt - getService{Name=%s,PID=%s}  ) \n", serviceName, pid);
 
-    /* ENF OF DEBUG CODE */
+    * ENF OF DEBUG CODE */
 
     // (3) trackerInstance.AddManagedServiceToLocalList
     configurationStore_lock(managedServiceTracker_i->configurationStore);
 
     status = managedServiceTracker_add(managedServiceTracker_i, reference, pid, managedService_s);
-
+    if (status != CELIX_SUCCESS) {
+        bundleContext_ungetService(context, reference, NULL);
+    }
     configurationStore_unlock(managedServiceTracker_i->configurationStore);
 
     if (status != CELIX_SUCCESS) {
@@ -264,14 +274,28 @@ celix_status_t managedServiceTracker_modifiedService(void * handle, service_refe
 }
 
 celix_status_t managedServiceTracker_removedService(void * handle, service_reference_pt reference, void * service) {
-    return CELIX_SUCCESS;
+    celix_status_t status = CELIX_SUCCESS;
+    char *pid;
+    managed_service_tracker_pt managedServiceTracker_i = handle;	//instance
+    bundle_context_pt context;
+
+
+    status = serviceReference_getProperty(reference, (char *)OSGI_FRAMEWORK_SERVICE_PID, &pid);
+    if (status != CELIX_SUCCESS || pid == NULL){
+	return CELIX_ILLEGAL_ARGUMENT;
+    }
+    if ( managedServiceTracker_getBundleContext(managedServiceTracker_i, &context) != CELIX_SUCCESS ){
+	return CELIX_ILLEGAL_ARGUMENT;
+    }
+    status = managedServiceTracker_remove(managedServiceTracker_i, reference, pid);
+
+    return status;
+
 }
 
 /* ---------- private ---------- */
 // org.eclipse.equinox.internal.cm.ManagedServiceTracker
-celix_status_t managedServiceTracker_add(managed_service_tracker_t tracker, service_reference_pt reference, char *pid, managed_service_service_pt service) {
-
-    printf("[ DEBUG ]: Tracker - Add (Service{PID=%s}) \n", pid);
+celix_status_t managedServiceTracker_add(managed_service_tracker_pt tracker, service_reference_pt reference, char *pid, managed_service_service_pt service) {
 
     celix_status_t status;
 
@@ -304,7 +328,7 @@ celix_status_t managedServiceTracker_add(managed_service_tracker_t tracker, serv
 
             // (2) bind the Configuration with the ManagedService
             bool dummy;
-            if ((configuration_bind(configuration, bundle, &dummy) != CELIX_SUCCESS)) {
+            if ((configuration_bind(configuration->handle, bundle, &dummy) != CELIX_SUCCESS)) {
                 return CELIX_ILLEGAL_ARGUMENT;
             }
 
@@ -315,11 +339,8 @@ celix_status_t managedServiceTracker_add(managed_service_tracker_t tracker, serv
 
             // End of new code
 
-            printf("[ SUCCESS ]: Tracker - Add (Service{PID=%s} tracked) \n", pid);
-
             // TODO: It must be considered in case of fail if untrack the ManagedService
 
-            printf("[ DEBUG ]: Tracker - Add (Service{PID=%s} AsynchUpdated - NULL props) \n", pid);
             return managedServiceTracker_asynchUpdated(tracker, service, NULL);
 
         } else {
@@ -328,13 +349,12 @@ celix_status_t managedServiceTracker_add(managed_service_tracker_t tracker, serv
 
     } else {
 
-        printf("[ DEBUG ]: Tracker - Add (Service{PID=%s} - LOCK Config) \n", pid);
-        configuration_lock(configuration);
+        configuration_lock(configuration->handle);
 
         if (managedServiceTracker_trackManagedService(tracker, pid, reference, service) == CELIX_SUCCESS) {
 
             if (serviceReference_getBundle(reference, &bundle) != CELIX_SUCCESS) {
-                configuration_unlock(configuration);
+                configuration_unlock(configuration->handle);
                 printf("[ERROR ]: Tracker - Add (Service{PID=%s} Reference - getBundle NULL)", pid);
                 return CELIX_ILLEGAL_ARGUMENT;
             }
@@ -342,45 +362,41 @@ celix_status_t managedServiceTracker_add(managed_service_tracker_t tracker, serv
             // TODO configuration.isDeleted ? - with only using one calling bundle OK
 
             bool isBind;
-            if ((configuration_bind(configuration, bundle, &isBind) == CELIX_SUCCESS) && (isBind == true)) { // config.bind(bundle)
+            if ((configuration_bind(configuration->handle, bundle, &isBind) == CELIX_SUCCESS) && (isBind == true)) { // config.bind(bundle)
 
-                if (configuration_getProperties(configuration, &properties) != CELIX_SUCCESS) {
-                    configuration_unlock(configuration);
+                if (configuration_getProperties(configuration->handle, &properties) != CELIX_SUCCESS) {
+                    configuration_unlock(configuration->handle);
                     return CELIX_ILLEGAL_ARGUMENT;
                 }
 
                 if (configurationAdminFactory_modifyConfiguration(tracker->configurationAdminfactory, reference, properties) != CELIX_SUCCESS) {
-                    configuration_unlock(configuration);
+                    configuration_unlock(configuration->handle);
                     return CELIX_ILLEGAL_ARGUMENT;
                 }
-                printf("[ DEBUG ]: Tracker - Add Service{PID=%s} (AsynchUpdated - existing Configuration) \n", pid);
 
                 status = managedServiceTracker_asynchUpdated(tracker, service, properties);
-                printf("[ DEBUG ]: Tracker - Add Service{PID=%s} (UNLOCK Config) \n", pid);
 
-                configuration_unlock(configuration);
+                configuration_unlock(configuration->handle);
 
                 return status;
 
             } else {
-                printf("[ WARNING ]: Tracker - Add Service{PID=%s} ( Configuration for Service could not be bound ) $s \n", pid);
-                configuration_unlock(configuration);
+                configuration_unlock(configuration->handle);
                 return CELIX_ILLEGAL_STATE;
             }
 
         } else {
-            configuration_unlock(configuration);
+            configuration_unlock(configuration->handle);
             return CELIX_ILLEGAL_ARGUMENT; // the service was already tracked
         }
     }
 }
 
-/* TODO
- celix_status_t managedServiceTracker_remove(managed_service_tracker_t tracker, service_reference_pt reference, char * pid){
- return CELIX_SUCCESS;
- }
- */
-celix_status_t managedServiceTracker_trackManagedService(managed_service_tracker_t tracker, char *pid, service_reference_pt reference, managed_service_service_pt service) {
+celix_status_t managedServiceTracker_remove(managed_service_tracker_pt tracker, service_reference_pt reference, char * pid){
+	return managedServiceTracker_untrackManagedService(tracker, pid, reference);
+}
+
+celix_status_t managedServiceTracker_trackManagedService(managed_service_tracker_pt tracker, char *pid, service_reference_pt reference, managed_service_service_pt service) {
 
     managedServiceTracker_lockManagedServicesReferences(tracker);
 
@@ -398,13 +414,19 @@ celix_status_t managedServiceTracker_trackManagedService(managed_service_tracker
     return CELIX_SUCCESS;
 }
 
-/* TODO
- celix_status_t managedServiceTracker_untrackManagedService(managed_service_tracker_t tracker, char *pid, service_reference_pt reference){
- return CELIX_SUCCESS;
- }
- */
+celix_status_t managedServiceTracker_untrackManagedService(managed_service_tracker_pt tracker, char *pid, service_reference_pt reference){
+    managedServiceTracker_lockManagedServicesReferences(tracker);
 
-celix_status_t managedServiceTracker_getManagedService(managed_service_tracker_t tracker, char *pid, managed_service_service_pt *service) {
+    if ( hashMap_containsKey(tracker->managedServicesReferences, pid) ){
+	hashMap_remove(tracker->managedServicesReferences, pid);
+	hashMap_remove(tracker->managedServices, pid);
+    }
+    managedServiceTracker_unlockManagedServicesReferences(tracker);
+    return CELIX_SUCCESS;
+
+}
+
+celix_status_t managedServiceTracker_getManagedService(managed_service_tracker_pt tracker, char *pid, managed_service_service_pt *service) {
 
     celix_status_t status;
     managed_service_service_pt serv = NULL;
@@ -424,7 +446,7 @@ celix_status_t managedServiceTracker_getManagedService(managed_service_tracker_t
     return status;
 }
 
-celix_status_t managedServiceTracker_getManagedServiceReference(managed_service_tracker_t tracker, char *pid, service_reference_pt *reference) {
+celix_status_t managedServiceTracker_getManagedServiceReference(managed_service_tracker_pt tracker, char *pid, service_reference_pt *reference) {
 
     celix_status_t status;
     service_reference_pt ref = NULL;
@@ -450,7 +472,7 @@ celix_status_t managedServiceTracker_getManagedServiceReference(managed_service_
  }
  */
 
-celix_status_t managedServiceTracker_asynchUpdated(managed_service_tracker_t trackerHandle, managed_service_service_pt service, properties_pt properties) {
+celix_status_t managedServiceTracker_asynchUpdated(managed_service_tracker_pt trackerHandle, managed_service_service_pt service, properties_pt properties) {
 
     return updatedThreadPool_push(trackerHandle->updatedThreadPool, service, properties);
 
@@ -460,13 +482,12 @@ celix_status_t managedServiceTracker_asynchUpdated(managed_service_tracker_t tra
 
 /* ---------- public ---------- */
 
-celix_status_t managedServiceTracker_notifyDeleted(managed_service_tracker_t tracker, configuration_pt configuration) {
+celix_status_t managedServiceTracker_notifyDeleted(managed_service_tracker_pt tracker, configuration_pt configuration) {
     return CELIX_SUCCESS;
 }
 
-celix_status_t managedServiceTracker_notifyUpdated(managed_service_tracker_t tracker, configuration_pt configuration) {
+celix_status_t managedServiceTracker_notifyUpdated(managed_service_tracker_pt tracker, configuration_pt configuration) {
 
-    printf("[ DEBUG ]: Tracker - NotifyUpdated \n");
 
     char *pid;
 
@@ -477,12 +498,12 @@ celix_status_t managedServiceTracker_notifyUpdated(managed_service_tracker_t tra
     managed_service_service_pt service = NULL;
 
     // (1) config.checkLocked
-    if (configuration_checkLocked(configuration) != CELIX_SUCCESS) { //TODO not yet implemented
+    if (configuration_checkLocked(configuration->handle) != CELIX_SUCCESS) { //TODO not yet implemented
         return CELIX_ILLEGAL_ARGUMENT;
     }
 
     // (2) config.getPid
-    if (configuration_getPid(configuration, &pid) != CELIX_SUCCESS) {
+    if (configuration_getPid(configuration->handle, &pid) != CELIX_SUCCESS) {
         return CELIX_ILLEGAL_ARGUMENT;
     }
 
@@ -500,7 +521,7 @@ celix_status_t managedServiceTracker_notifyUpdated(managed_service_tracker_t tra
 
     //	(4.2) config.bind(reference.getBundle)
     bool isBind;
-    if (configuration_bind(configuration, bundle, &isBind) != CELIX_SUCCESS || isBind == false) {
+    if (configuration_bind(configuration->handle, bundle, &isBind) != CELIX_SUCCESS || isBind == false) {
         printf("[ ERROR ]: Tracker - Notify (Service{PID=%s} Permission Error) \n", pid);
         return CELIX_ILLEGAL_STATE;
     }
@@ -508,7 +529,7 @@ celix_status_t managedServiceTracker_notifyUpdated(managed_service_tracker_t tra
     // (5) if (reference != null && config.bind(reference.getBundle()))
 
     // (5.1) properties = config.getProperties
-    if (configuration_getProperties(configuration, &properties) != CELIX_SUCCESS) {
+    if (configuration_getProperties(configuration->handle, &properties) != CELIX_SUCCESS) {
         printf("[ ERROR ]: Tracker - Notify (Service{PID=%s} Wrong Properties) \n", pid);
         return CELIX_ILLEGAL_ARGUMENT;
     }
@@ -526,36 +547,35 @@ celix_status_t managedServiceTracker_notifyUpdated(managed_service_tracker_t tra
 
     // (5.4) asynchUpdate(service,properties)
     if ((properties == NULL) || (properties != NULL && hashMap_size(properties) == 0)) {
-        printf("[ DEBUG ]: Tracker - Notify (AsynchUpdated Service{PID=%s} - NULL props) \n", pid);
         return managedServiceTracker_asynchUpdated(tracker, service, NULL);
     } else {
-        printf("[ DEBUG ]: Tracker - Notify (AsynchUpdated Service{PID=%s} - existing props) \n", pid);
         return managedServiceTracker_asynchUpdated(tracker, service, properties);
     }
+    return CELIX_ILLEGAL_ARGUMENT;
 }
 
 /* ---------- private ---------- */
 
-celix_status_t managedServiceTracker_getBundleContext(managed_service_tracker_t trackerHandle, bundle_context_pt *context) {
+celix_status_t managedServiceTracker_getBundleContext(managed_service_tracker_pt trackerHandle, bundle_context_pt *context) {
 
     if (trackerHandle->context != NULL) {
         *context = trackerHandle->context;
-        return CELIX_SUCCESS;
     } else {
         printf("[ ERROR ]: Tracker - getBundleContext (NULL context) \n");
         *context = NULL;
         return CELIX_ILLEGAL_ARGUMENT;
     }
+    return CELIX_SUCCESS;
 }
 
-celix_status_t managedServiceTracker_lockManagedServicesReferences(managed_service_tracker_t handle) {
+celix_status_t managedServiceTracker_lockManagedServicesReferences(managed_service_tracker_pt handle) {
 
     celixThreadMutex_lock(&handle->managedServicesReferencesMutex);
     return CELIX_SUCCESS;
 
 }
 
-celix_status_t managedServiceTracker_unlockManagedServicesReferences(managed_service_tracker_t handle) {
+celix_status_t managedServiceTracker_unlockManagedServicesReferences(managed_service_tracker_pt handle) {
 
     celixThreadMutex_unlock(&handle->managedServicesReferencesMutex);
     return CELIX_SUCCESS;

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/service/private/src/updated_thread_pool.c
----------------------------------------------------------------------
diff --git a/config_admin/service/private/src/updated_thread_pool.c b/config_admin/service/private/src/updated_thread_pool.c
index acf0afe..922bd26 100644
--- a/config_admin/service/private/src/updated_thread_pool.c
+++ b/config_admin/service/private/src/updated_thread_pool.c
@@ -65,7 +65,7 @@ static celix_status_t updatedThreadPool_wrapDataCallback(managed_service_service
 
 /* ---------- public ---------- */
 
-celix_status_t updatedThreadPool_create(bundle_context_pt context, int maxThreads, updated_thread_pool_t *updatedThreadPool){
+celix_status_t updatedThreadPool_create(bundle_context_pt context, int maxThreads, updated_thread_pool_pt *updatedThreadPool){
 
 	*updatedThreadPool = calloc(1, sizeof(**updatedThreadPool));
 	if (!*updatedThreadPool){
@@ -87,38 +87,28 @@ celix_status_t updatedThreadPool_create(bundle_context_pt context, int maxThread
 
 }
 
+celix_status_t updatedThreadPool_destroy(updated_thread_pool_pt pool) {
+	thpool_destroy(pool->threadPool);
+	free(pool);
+	return CELIX_SUCCESS;
+}
 /* ========== IMPLEMENTATION ========== */
 
 /* ---------- public ---------- */
 
-celix_status_t updatedThreadPool_push(updated_thread_pool_t updatedThreadPool, managed_service_service_pt service, properties_pt properties){
+celix_status_t updatedThreadPool_push(updated_thread_pool_pt updatedThreadPool, managed_service_service_pt service, properties_pt properties){
 
 	data_callback_t data = NULL;
 
-	// TODO apr_thread_mutex_lock(instance->mutex)?
-//	if ( apr_thread_pool_busy_count(updatedThreadPool->threadPool) < updatedThreadPool->maxTreads ) {
-
-		if ( updatedThreadPool_wrapDataCallback(service, properties, &data) != CELIX_SUCCESS ){
-			return CELIX_ILLEGAL_ARGUMENT;
-		}
-
-		if (thpool_add_work(updatedThreadPool->threadPool, updateThreadPool_updatedCallback, data) == 0) {
-//		if ( apr_thread_pool_push(updatedThreadPool->threadPool, updateThreadPool_updatedCallback, data,
-//				APR_THREAD_TASK_PRIORITY_NORMAL, NULL) != APR_SUCCESS ){
-
-			printf("[ ERROR ]: UpdatedThreadPool - Push (apr_thread_pool_push) \n ");
-			return CELIX_ILLEGAL_STATE;
-
-		}
-
-//	} else {
-
-//		printf("[ ERROR ]: UpdatedThreadPool - Push (Full!) \n ");
-//		return CELIX_ILLEGAL_STATE;
+	if ( updatedThreadPool_wrapDataCallback(service, properties, &data) != CELIX_SUCCESS ){
+		return CELIX_ILLEGAL_ARGUMENT;
+	}
 
-//	}
+	if (thpool_add_work(updatedThreadPool->threadPool, updateThreadPool_updatedCallback, data) != 0) {
+		printf("[ ERROR ]: UpdatedThreadPool - add_work \n ");
+		return CELIX_ILLEGAL_STATE;
+	}
 
-	printf("[ SUCCESS ]:  UpdatedThreadPool - Push \n");
 	return CELIX_SUCCESS;
 }
 
@@ -126,9 +116,6 @@ celix_status_t updatedThreadPool_push(updated_thread_pool_t updatedThreadPool, m
 
 void *updateThreadPool_updatedCallback(void *data) {
 
-
-	printf("[ DEBUG ]: UpdatedThreadPool - Callback \n");
-
 	data_callback_t params = data;
 
 	managed_service_service_pt managedServiceService = params->managedServiceService;

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/service/public/include/configuration.h
----------------------------------------------------------------------
diff --git a/config_admin/service/public/include/configuration.h b/config_admin/service/public/include/configuration.h
index b872d23..f25af23 100644
--- a/config_admin/service/public/include/configuration.h
+++ b/config_admin/service/public/include/configuration.h
@@ -35,9 +35,32 @@
 #include "properties.h"
 
 
+// Note: the term interface is used because configuration is not a service, it is not
+//       registered in the service registry but it is owned by the config_admin
+struct configuration
+{
+	void 	*handle;	// pointer to configuration datastore
+	/* METHODS */
+	celix_status_t (*configuration_delete)(void *handle);
+
+	celix_status_t (*configuration_equals)(void *thisConfiguration, void *otherConfiguration, bool *equals);
+
+	celix_status_t (*configuration_getBundleLocation)(void *handle, char **bundleLocation);
+	celix_status_t (*configuration_getFactoryPid)(void *handle, char **factoryPid);
+	celix_status_t (*configuration_getPid)(void *handle, char **pid);
+	celix_status_t (*configuration_getProperties)(void *handle, properties_pt *properties);
+
+	celix_status_t (*configuration_hashCode)(void *handle, int *hashCode);
+
+	celix_status_t (*configuration_setBundleLocation)(void *handle, char *bundleLocation);
+
+	celix_status_t (*configuration_update)(void *handle, properties_pt properties);
+
+};
+
 typedef struct configuration *configuration_pt;
 
-/* METHODS */
+/* METHODS
 celix_status_t configuration_delete(configuration_pt configuration);
 
 celix_status_t configuration_equals(configuration_pt thisConfiguration, configuration_pt otherConfiguration, bool *equals);
@@ -52,6 +75,6 @@ celix_status_t configuration_hashCode(configuration_pt configuration, int *hashC
 celix_status_t configuration_setBundleLocation(configuration_pt configuration, char *bundleLocation);
 
 celix_status_t configuration_update(configuration_pt configuration, properties_pt properties);
-
+*/
 
 #endif /* CONFIGURATION_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/service/public/include/managed_service.h
----------------------------------------------------------------------
diff --git a/config_admin/service/public/include/managed_service.h b/config_admin/service/public/include/managed_service.h
index 10f8570..b666e51 100644
--- a/config_admin/service/public/include/managed_service.h
+++ b/config_admin/service/public/include/managed_service.h
@@ -49,6 +49,6 @@ struct managed_service_service{
 };
 
 celix_status_t managedService_create(bundle_context_pt context, managed_service_service_pt *service);
-
+celix_status_t managedService_destroy(managed_service_pt service);
 
 #endif /* MANAGED_SERVICE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/framework/private/src/service_registry.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_registry.c b/framework/private/src/service_registry.c
index daa030f..ab9c324 100644
--- a/framework/private/src/service_registry.c
+++ b/framework/private/src/service_registry.c
@@ -649,7 +649,9 @@ celix_status_t serviceRegistry_ungetService(service_registry_pt registry, bundle
         if (count == 0) {
             serviceReference_getService(reference, &service);
             serviceReference_getServiceRegistration(reference, &reg);
-            serviceRegistration_ungetService(reg, bundle, &service);
+            if (reg != NULL) {
+                serviceRegistration_ungetService(reg, bundle, &service);
+            }
         }
     } else {
         serviceRegistry_logIllegalReference(registry, reference, refStatus);


Mime
View raw message