You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2017/11/20 20:33:42 UTC

[45/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/api/dm_service_dependency.h
----------------------------------------------------------------------
diff --git a/dependency_manager/api/dm_service_dependency.h b/dependency_manager/api/dm_service_dependency.h
new file mode 100644
index 0000000..fb34230
--- /dev/null
+++ b/dependency_manager/api/dm_service_dependency.h
@@ -0,0 +1,171 @@
+/**
+ *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.
+ */
+/*
+ * dm_service_dependency.h
+ *
+ *  \date       8 Oct 2014
+ *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#ifndef DM_SERVICE_DEPENDENCY_H_
+#define DM_SERVICE_DEPENDENCY_H_
+
+#include "service_reference.h"
+#include "celix_errno.h"
+#include "dm_info.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct dm_service_dependency *dm_service_dependency_pt;
+
+typedef enum dm_service_dependency_strategy_enum {
+	DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING,
+	DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
+} dm_service_dependency_strategy_t;
+
+typedef int (*service_set_fpt)(void *handle, const void* service);
+typedef int (*service_add_fpt)(void *handle, const void* service);
+typedef int (*service_change_fpt)(void *handle, const void* service);
+typedef int (*service_remove_fpt)(void *handle, const void* service);
+typedef int (*service_swap_fpt)(void *handle, const void* oldService, const void* newService);
+
+typedef celix_status_t (*service_set_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
+typedef celix_status_t (*service_add_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
+typedef celix_status_t (*service_change_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
+typedef celix_status_t (*service_remove_with_ref_fpt)(void *handle, service_reference_pt reference, const void* service);
+typedef celix_status_t (*service_swap_with_ref_fpt)(void *handle, service_reference_pt oldReference, const void* oldService, service_reference_pt newReference, const void* newService);
+
+/**
+ * Create a service dependency.
+ * Caller has ownership.
+ */
+celix_status_t serviceDependency_create(dm_service_dependency_pt *dependency_ptr);
+
+/**
+ * Destroys a service dependency.
+ * Caller has ownership.
+ */
+celix_status_t serviceDependency_destroy(dm_service_dependency_pt *dependency_ptr);
+
+/**
+ * Specify if the service dependency is required. default is false
+ */
+celix_status_t serviceDependency_setRequired(dm_service_dependency_pt dependency, bool required);
+
+/**
+ * Specify if the servide dependency should add a C language filter for this dependency if no "service.lang" part if found the in the provided filter.
+ * Default is false
+ */
+celix_status_t serviceDependency_setAddCLanguageFilter(dm_service_dependency_pt dependency, bool addCLangFilter);
+
+
+/**
+ * Specify if the service dependency update strategy.
+ *
+ * The DM_SERVICE_DEPENDENCY_STRATEGY_LOCKING strategy notifies the component in case the dependencies set
+ * changes (e.g. a dependency is added/removed): the component is responsible for protecting via locks
+ * the dependencies list and check (always under lock) if the service he's depending on is still available.
+ *
+ * The DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND (default when no strategy is explicitly set) reliefs the programmer
+ * from dealing with service dependencies' consistency issues: in case this strategy is adopted, the component
+ * is stopped and restarted (i.e. temporarily suspended) upon service dependencies' changes.
+ *
+ * Default strategy is DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND
+ */
+celix_status_t serviceDependency_setStrategy(dm_service_dependency_pt dependency,dm_service_dependency_strategy_t strategy);
+
+/**
+ * Return the service dependency update strategy.
+ */
+celix_status_t serviceDependency_getStrategy(dm_service_dependency_pt dependency,dm_service_dependency_strategy_t* strategy);
+
+/**
+ * Set the service name, version range and filter.
+ *
+ * @param serviceName The service name. Must have a value.
+ * @param serviceVersionRange The service version range, can be a NULL pointer.
+ * @param filter The (additional) filter to use (e.g. "(location=front)"). Can be a NULL pointer.
+ */
+celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency, const char* serviceName, const char* serviceVersionRange, const char* filter);
+
+/**
+ * Returns the service depenendy filter.
+ */
+celix_status_t serviceDependency_getFilter(dm_service_dependency_pt dependency, const char** filter);
+
+/**
+ * Set the set, add, change, remove and swap function callbacks when services specified by the service dependency
+ * are (respectively) set, added, changed, removed or swapped.
+ * The first argument of the callbacks will be the component implement (@see component_getImplementation)
+ * The second the argument a pointer to an instance of a service struct of the specified service dependency.
+ */
+celix_status_t serviceDependency_setCallbacks(dm_service_dependency_pt dependency, service_set_fpt set, service_add_fpt add, service_change_fpt change, service_remove_fpt remove, service_swap_fpt swap);
+
+/**
+ * Set the set, add, change, remove and swap function callbacks when services specified by the service dependency
+ * are (respectively) set, added, changed, removed or swapped.
+ * The first argument of the callbacks will be the component implement (@see component_getImplementation)
+ * The second argument of th callbacks will be a pointer to an instance of a service struct of the specified service dependency.
+ * The third argument of th callbacks will be a pointer to a service reference of the a service instance of the specified service dependency.
+ */
+celix_status_t serviceDependency_setCallbacksWithServiceReference(dm_service_dependency_pt dependency, service_set_with_ref_fpt set, service_add_with_ref_fpt add, service_change_with_ref_fpt change, service_remove_with_ref_fpt remove, service_swap_with_ref_fpt swap);
+
+/**
+ * Specifies which field member (pointer to) to update when a service dependencies is set.
+ * If provided the provided service_lock will be used for locking when updating the service instance.
+ */
+celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_pt dependency, celix_thread_mutex_t *service_lock, const void** field);
+
+#define serviceDependency_setCallbacksSafe(dep, cmpType, servType, set, add, change, remove, swap) \
+	do { \
+		int (*tmpSet)(cmpType, servType) = set; \
+		int (*tmpAdd)(cmpType, servType) = add; \
+		int (*tmpChange)(cmpType, servType) = change; \
+		int (*tmpRemove)(cmpType, servType) = remove; \
+		int (*tmpSwap)(cmpType, servType, servType) = swap; \
+		serviceDependency_setCallbacks((dep), (service_set_fpt)tmpSet, (service_add_fpt)tmpAdd, (service_change_fpt)tmpChange, (service_remove_fpt)tmpRemove, (service_swap_fpt)tmpSwap); \
+	} while(0)
+
+/**
+ * Set the callback handle to be used in the callbacks. Note that this normally should not be set, because the
+ * result of component_getImplementation() is used
+ * This can be used in rare cases when the callbacks are actually interceptors. e.g. in the case of C++ support.
+ */
+celix_status_t serviceDependency_setCallbackHandle(dm_service_dependency_pt dependency, void* handle);
+
+/**
+ * Creates a service dependency info. The service dependency info struct contains information about the service dependency.
+ * The caller is the owner
+ */
+celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_pt, dm_service_dependency_info_pt *info);
+
+/**
+ * Destroy a provided service dependency info struct.
+ */
+void dependency_destroyDependencyInfo(dm_service_dependency_info_pt info);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DM_SERVICE_DEPENDENCY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/include/dm_component_impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_component_impl.h b/dependency_manager/private/include/dm_component_impl.h
deleted file mode 100644
index 495197c..0000000
--- a/dependency_manager/private/include/dm_component_impl.h
+++ /dev/null
@@ -1,48 +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.
- */
-/*
- * dm_component_impl.h
- *
- *  \date       22 Feb 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#ifndef COMPONENT_IMPL_H_
-#define COMPONENT_IMPL_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "dm_component.h"
-#include "dm_service_dependency_impl.h"
-#include "dm_event.h"
-
-celix_status_t component_start(dm_component_pt component);
-
-celix_status_t component_stop(dm_component_pt component);
-
-celix_status_t component_handleEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* COMPONENT_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/include/dm_dependency.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_dependency.h b/dependency_manager/private/include/dm_dependency.h
deleted file mode 100644
index 6923239..0000000
--- a/dependency_manager/private/include/dm_dependency.h
+++ /dev/null
@@ -1,41 +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.
- */
-/*
- * dm_dependency.h
- *
- *  \date       22 Feb 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#ifndef DM_DEPENDENCY_H_
-#define DM_DEPENDENCY_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DM_DEPENDENCY_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/include/dm_dependency_manager_impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_dependency_manager_impl.h b/dependency_manager/private/include/dm_dependency_manager_impl.h
deleted file mode 100644
index c673605..0000000
--- a/dependency_manager/private/include/dm_dependency_manager_impl.h
+++ /dev/null
@@ -1,45 +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.
- */
-/*
- * dm_dependency_manager_impl.h
- *
- *  \date       15 Oct 2015
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#ifndef CELIX_DM_DEPENDENCY_MANAGER_IMPL_H
-#define CELIX_DM_DEPENDENCY_MANAGER_IMPL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-struct dm_dependency_manager {
-    array_list_pt components;
-
-    pthread_mutex_t mutex;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //CELIX_DM_DEPENDENCY_MANAGER_IMPL_H

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/include/dm_event.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_event.h b/dependency_manager/private/include/dm_event.h
deleted file mode 100644
index 1cccd47..0000000
--- a/dependency_manager/private/include/dm_event.h
+++ /dev/null
@@ -1,72 +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.
- */
-/*
- * dm_event.h
- *
- *  \date       17 Oct 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#ifndef DM_EVENT_H_
-#define DM_EVENT_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "service_reference.h"
-#include "bundle_context.h"
-#include "bundle.h"
-
-enum dm_event_type {
-	DM_EVENT_ADDED,
-	DM_EVENT_CHANGED,
-	DM_EVENT_REMOVED,
-	DM_EVENT_SWAPPED,
-};
-
-typedef enum dm_event_type dm_event_type_e;
-
-struct dm_event {
-	const void* service;
-	unsigned long serviceId;
-	long ranking;
-	service_reference_pt reference;
-	bundle_context_pt context;
-	bundle_pt bundle;
-	dm_event_type_e event_type;
-};
-
-typedef struct dm_event *dm_event_pt;
-
-
-celix_status_t event_create(dm_event_type_e event_type, bundle_pt bundle, bundle_context_pt context, service_reference_pt reference, const void* service, dm_event_pt *event);
-celix_status_t event_destroy(dm_event_pt* event);
-
-celix_status_t event_equals(const void* a, const void* b, bool* equals);
-
-celix_status_t event_getService(dm_event_pt event, const void** service);
-celix_status_t event_compareTo(dm_event_pt event, dm_event_pt compareTo, int* compare);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DM_EVENT_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/include/dm_service_dependency_impl.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_service_dependency_impl.h b/dependency_manager/private/include/dm_service_dependency_impl.h
deleted file mode 100644
index 7026ebf..0000000
--- a/dependency_manager/private/include/dm_service_dependency_impl.h
+++ /dev/null
@@ -1,104 +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.
- */
-/*
- * dm_service_dependency_impl.h
- *
- *  \date       16 Oct 2015
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#ifndef DM_SERVICE_DEPENDENCY_IMPL_H_
-#define DM_SERVICE_DEPENDENCY_IMPL_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdbool.h>
-
-#include "dm_event.h"
-#include "service_tracker.h"
-#include "service_tracker_customizer.h"
-
-#include "dm_service_dependency.h"
-#include "dm_component.h"
-
-struct dm_service_dependency {
-	dm_component_pt component;
-	bool available;
-	bool instanceBound;
-	bool required;
-	dm_service_dependency_strategy_t strategy;
-
-	void* callbackHandle; //This handle can be set to be used instead of the component implementation
-	service_set_fpt set;
-	service_add_fpt add;
-	service_change_fpt change;
-	service_remove_fpt remove;
-	service_swap_fpt swap;
-
-	service_set_with_ref_fpt set_with_ref;
-	service_add_with_ref_fpt add_with_ref;
-	service_change_with_ref_fpt change_with_ref;
-	service_remove_with_ref_fpt remove_with_ref;
-	service_swap_with_ref_fpt swap_with_ref;
-
-	const void **autoConfigure;
-	celix_thread_mutex_t lock;
-
-	bool isStarted;
-
-	bool addCLanguageFilter;
-	char *tracked_service;
-	char *tracked_filter_unmodified;
-	char *tracked_filter;
-
-	service_tracker_pt tracker;
-	service_tracker_customizer_pt tracker_customizer;
-};
-
-celix_status_t serviceDependency_start(dm_service_dependency_pt dependency);
-celix_status_t serviceDependency_stop(dm_service_dependency_pt dependency);
-celix_status_t serviceDependency_setInstanceBound(dm_service_dependency_pt dependency, bool instanceBound);
-celix_status_t serviceDependency_setAutoConfig(dm_service_dependency_pt dependency, void **autoConfigure);
-celix_status_t serviceDependency_setAvailable(dm_service_dependency_pt dependency, bool available);
-
-celix_status_t serviceDependency_setComponent(dm_service_dependency_pt dependency, dm_component_pt component);
-//celix_status_t serviceDependency_removeComponent(dm_service_dependency_pt dependency, dm_component_pt component);
-
-celix_status_t serviceDependency_invokeSet(dm_service_dependency_pt dependency, dm_event_pt event);
-celix_status_t serviceDependency_invokeAdd(dm_service_dependency_pt dependency, dm_event_pt event);
-celix_status_t serviceDependency_invokeChange(dm_service_dependency_pt dependency, dm_event_pt event);
-celix_status_t serviceDependency_invokeRemove(dm_service_dependency_pt dependency, dm_event_pt event);
-celix_status_t serviceDependency_invokeSwap(dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent);
-celix_status_t serviceDependency_isAvailable(dm_service_dependency_pt dependency, bool *available);
-celix_status_t serviceDependency_isRequired(dm_service_dependency_pt dependency, bool *required);
-celix_status_t serviceDependency_isInstanceBound(dm_service_dependency_pt dependency, bool *instanceBound);
-celix_status_t serviceDependency_isAutoConfig(dm_service_dependency_pt dependency, bool *autoConfig);
-
-celix_status_t serviceDependency_getAutoConfig(dm_service_dependency_pt dependency, const void*** autoConfigure);
-celix_status_t serviceDependency_unlock(dm_service_dependency_pt dependency);
-celix_status_t serviceDependency_lock(dm_service_dependency_pt dependency);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DM_SERVICE_DEPENDENCY_IMPL_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/include/dm_shell_list_command.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_shell_list_command.h b/dependency_manager/private/include/dm_shell_list_command.h
deleted file mode 100644
index 6ab0581..0000000
--- a/dependency_manager/private/include/dm_shell_list_command.h
+++ /dev/null
@@ -1,42 +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.
- */
-
-#ifndef DM_SHELL_LIST_COMMAND_H_
-#define DM_SHELL_LIST_COMMAND_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include "command.h"
-
-typedef struct dm_command_handle {
-    bundle_context_pt context;
-    bool useColors;
-} dm_command_handle_t;
-
-void dmListCommand_execute(dm_command_handle_t* handle, char * line, FILE *out, FILE *err);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //DM_SHELL_LSIT_COMMAND_H_
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/src/dm_activator.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_activator.c b/dependency_manager/private/src/dm_activator.c
deleted file mode 100644
index 8de3bf1..0000000
--- a/dependency_manager/private/src/dm_activator.c
+++ /dev/null
@@ -1,119 +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.
- */
-
-#include "dm_activator.h"
-
-#include <stdlib.h>
-
-struct dm_dependency_activator_base {
-    dm_dependency_manager_pt manager;
-    bundle_context_pt context;
-    service_registration_pt reg;
-    dm_info_service_pt info;
-    void* userData;
-};
-
-typedef struct dm_dependency_activator_base * dependency_activator_base_pt;
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-    celix_status_t status = CELIX_ENOMEM;
-
-    dependency_activator_base_pt dependency_activator = calloc(1, sizeof(struct dm_dependency_activator_base));
-    dm_info_service_pt serv = calloc(1, sizeof(*serv));
-
-    if (dependency_activator != NULL && serv != NULL) {
-        dependency_activator->context = context;
-        dm_create(context, &dependency_activator->userData);
-        dependency_activator->info = serv;
-
-        status = dependencyManager_create(dependency_activator->context, &dependency_activator->manager);
-    } else {
-        status = CELIX_ENOMEM;
-
-    }
-
-    if (status == CELIX_SUCCESS) {
-        *userData = dependency_activator;
-    } else {
-        if (dependency_activator != NULL) {
-            dependencyManager_destroy(dependency_activator->manager);
-        }
-        free(dependency_activator);
-        free(serv);
-    }
-
-    return status;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-    celix_status_t status;
-    dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
-
-
-    status = dm_init(dependency_activator->userData, context, dependency_activator->manager);
-
-    if (status == CELIX_SUCCESS) {
-        //Create the service
-        dependency_activator->info->handle = dependency_activator->manager;
-        dependency_activator->info->getInfo = (void *) dependencyManager_getInfo;
-        dependency_activator->info->destroyInfo = (void *) dependencyManager_destroyInfo;
-
-        status = bundleContext_registerService(context, DM_INFO_SERVICE_NAME, dependency_activator->info, NULL,
-                                               &(dependency_activator->reg));
-    }
-
-    return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context __attribute__((unused))) {
-    celix_status_t status = CELIX_SUCCESS;
-    dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
-
-    // Remove the service
-    status = serviceRegistration_unregister(dependency_activator->reg);
-    dependencyManager_removeAllComponents(dependency_activator->manager);
-
-    return status;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context __attribute__((unused))) {
-    celix_status_t status = CELIX_SUCCESS;
-    dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
-
-    if(dependency_activator==NULL){
-        return CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    status = dm_destroy(dependency_activator->userData, dependency_activator->context,
-                        dependency_activator->manager);
-
-    if (status == CELIX_SUCCESS) {
-        dependencyManager_destroy(dependency_activator->manager);
-    }
-
-    dependency_activator->userData = NULL;
-    dependency_activator->manager = NULL;
-
-    if (dependency_activator != NULL) {
-        free(dependency_activator->info);
-    }
-    free(dependency_activator);
-
-    return status;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/src/dm_component_impl.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_component_impl.c b/dependency_manager/private/src/dm_component_impl.c
deleted file mode 100644
index 13a2ee0..0000000
--- a/dependency_manager/private/src/dm_component_impl.c
+++ /dev/null
@@ -1,1442 +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.
- */
-/*
- * dm_component_impl.c
- *
- *  \date       9 Oct 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "constants.h"
-#include "filter.h"
-#include "dm_component_impl.h"
-
-
-typedef struct dm_executor_struct * dm_executor_pt;
-
-struct dm_component_struct {
-    char id[DM_COMPONENT_MAX_ID_LENGTH];
-    char name[DM_COMPONENT_MAX_NAME_LENGTH];
-    bundle_context_pt context;
-    array_list_pt dm_interfaces;
-
-    void* implementation;
-
-    init_fpt callbackInit;
-    start_fpt callbackStart;
-    stop_fpt callbackStop;
-    deinit_fpt callbackDeinit;
-
-    array_list_pt dependencies; //protected by mutex
-    pthread_mutex_t mutex;
-
-    dm_component_state_t state;
-    bool isStarted;
-    bool active;
-
-    bool setCLanguageProperty;
-
-    hash_map_pt dependencyEvents; //protected by mutex
-
-    dm_executor_pt executor;
-};
-
-typedef struct dm_interface_struct {
-    char* serviceName;
-    const void* service;
-    properties_pt properties;
-    service_registration_pt registration;
-} dm_interface_t;
-
-struct dm_executor_struct {
-    pthread_t runningThread;
-    bool runningThreadSet;
-    linked_list_pt workQueue;
-    pthread_mutex_t mutex;
-};
-
-typedef struct dm_executor_task_struct {
-    dm_component_pt component;
-    void (*command)(void *command_ptr, void *data);
-    void *data;
-} dm_executor_task_t;
-
-typedef struct dm_handle_event_type_struct {
-	dm_service_dependency_pt dependency;
-	dm_event_pt event;
-	dm_event_pt newEvent;
-} *dm_handle_event_type_pt;
-
-static celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t  currentThread __attribute__((unused)));
-static celix_status_t executor_execute(dm_executor_pt executor);
-static celix_status_t executor_executeTask(dm_executor_pt executor, dm_component_pt component, void (*command), void *data);
-static celix_status_t executor_schedule(dm_executor_pt executor, dm_component_pt component, void (*command), void *data);
-static celix_status_t executor_create(dm_component_pt component __attribute__((unused)), dm_executor_pt *executor);
-static void executor_destroy(dm_executor_pt executor);
-
-static celix_status_t component_invokeRemoveRequiredDependencies(dm_component_pt component);
-static celix_status_t component_invokeRemoveInstanceBoundDependencies(dm_component_pt component);
-static celix_status_t component_invokeRemoveOptionalDependencies(dm_component_pt component);
-static celix_status_t component_registerServices(dm_component_pt component);
-static celix_status_t component_unregisterServices(dm_component_pt component);
-static celix_status_t component_invokeAddOptionalDependencies(dm_component_pt component);
-static celix_status_t component_invokeAddRequiredInstanceBoundDependencies(dm_component_pt component);
-static celix_status_t component_invokeAddRequiredDependencies(dm_component_pt component);
-static celix_status_t component_invokeAutoConfigInstanceBoundDependencies(dm_component_pt component);
-static celix_status_t component_invokeAutoConfigDependencies(dm_component_pt component);
-static celix_status_t component_configureImplementation(dm_component_pt component, dm_service_dependency_pt dependency);
-static celix_status_t component_allInstanceBoundAvailable(dm_component_pt component, bool *available);
-static celix_status_t component_allRequiredAvailable(dm_component_pt component, bool *available);
-static celix_status_t component_performTransition(dm_component_pt component, dm_component_state_t oldState, dm_component_state_t newState, bool *transition);
-static celix_status_t component_calculateNewState(dm_component_pt component, dm_component_state_t currentState, dm_component_state_t *newState);
-static celix_status_t component_handleChange(dm_component_pt component);
-static celix_status_t component_startDependencies(dm_component_pt component __attribute__((unused)), array_list_pt dependencies);
-static celix_status_t component_getDependencyEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt *event_pptr);
-static celix_status_t component_updateInstance(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, bool update, bool add);
-
-static celix_status_t component_addTask(dm_component_pt component, dm_service_dependency_pt dep);
-static celix_status_t component_startTask(dm_component_pt component, void * data __attribute__((unused)));
-static celix_status_t component_stopTask(dm_component_pt component, void * data __attribute__((unused)));
-static celix_status_t component_removeTask(dm_component_pt component, dm_service_dependency_pt dependency);
-static celix_status_t component_handleEventTask(dm_component_pt component, dm_handle_event_type_pt data);
-
-static celix_status_t component_handleAdded(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
-static celix_status_t component_handleChanged(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
-static celix_status_t component_handleRemoved(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event);
-static celix_status_t component_handleSwapped(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent);
-
-static celix_status_t component_suspend(dm_component_pt component, dm_service_dependency_pt dependency);
-static celix_status_t component_resume(dm_component_pt component, dm_service_dependency_pt dependency);
-
-celix_status_t component_create(bundle_context_pt context, const char *name, dm_component_pt *out) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    dm_component_pt component = calloc(1, sizeof(*component));
-
-    if (!component) {
-        status = CELIX_ENOMEM;
-    } else {
-        snprintf(component->id, DM_COMPONENT_MAX_ID_LENGTH, "%p", component);
-        snprintf(component->name, DM_COMPONENT_MAX_NAME_LENGTH, "%s", name == NULL ? "n/a" : name);
-
-        component->context = context;
-
-	    arrayList_create(&component->dm_interfaces);
-        arrayList_create(&(component)->dependencies);
-        pthread_mutex_init(&(component)->mutex, NULL);
-
-        component->implementation = NULL;
-
-        component->callbackInit = NULL;
-        component->callbackStart = NULL;
-        component->callbackStop = NULL;
-        component->callbackDeinit = NULL;
-
-        component->state = DM_CMP_STATE_INACTIVE;
-        component->isStarted = false;
-        component->active = false;
-
-        component->setCLanguageProperty = false;
-
-        component->dependencyEvents = hashMap_create(NULL, NULL, NULL, NULL);
-
-        component->executor = NULL;
-        executor_create(component, &component->executor);
-    }
-
-    if (status == CELIX_SUCCESS) {
-        *out = component;
-    }
-
-    return status;
-}
-
-void component_destroy(dm_component_pt component) {
-	if (component) {
-		unsigned int i;
-
-		for (i = 0; i < arrayList_size(component->dm_interfaces); i++) {
-		    dm_interface_t *interface = arrayList_get(component->dm_interfaces, i);
-
-			if(interface->properties!=NULL){
-				properties_destroy(interface->properties);
-			}
-		    free (interface->serviceName);
-            free (interface);
-		}
-		arrayList_destroy(component->dm_interfaces);
-
-		executor_destroy(component->executor);
-
-		hash_map_iterator_pt iter = hashMapIterator_create(component->dependencyEvents);
-		while(hashMapIterator_hasNext(iter)){
-			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-			dm_service_dependency_pt sdep = (dm_service_dependency_pt)hashMapEntry_getKey(entry);
-			array_list_pt eventList = (array_list_pt)hashMapEntry_getValue(entry);
-			serviceDependency_destroy(&sdep);
-			arrayList_destroy(eventList);
-		}
-		hashMapIterator_destroy(iter);
-
-		hashMap_destroy(component->dependencyEvents, false, false);
-
-		arrayList_destroy(component->dependencies);
-		pthread_mutex_destroy(&component->mutex);
-
-		free(component);
-	}
-}
-
-celix_status_t component_addServiceDependency(dm_component_pt component, dm_service_dependency_pt dep) {
-    celix_status_t status = CELIX_SUCCESS;
-
-	executor_executeTask(component->executor, component, component_addTask, dep);
-
-    return status;
-}
-
-
-static celix_status_t component_addTask(dm_component_pt component, dm_service_dependency_pt dep) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    array_list_pt bounds = NULL;
-    arrayList_create(&bounds);
-
-    array_list_pt events = NULL;
-    arrayList_createWithEquals(event_equals, &events);
-
-    pthread_mutex_lock(&component->mutex);
-    hashMap_put(component->dependencyEvents, dep, events);
-    arrayList_add(component->dependencies, dep);
-    pthread_mutex_unlock(&component->mutex);
-
-    serviceDependency_setComponent(dep, component);
-
-    if (component->state != DM_CMP_STATE_INACTIVE) {
-        serviceDependency_setInstanceBound(dep, true);
-        arrayList_add(bounds, dep);
-    }
-    component_startDependencies(component, bounds);
-    component_handleChange(component);
-
-    arrayList_destroy(bounds);
-
-    return status;
-}
-
-dm_component_state_t component_currentState(dm_component_pt cmp) {
-    return cmp->state;
-}
-
-void * component_getImplementation(dm_component_pt cmp) {
-    return cmp->implementation;
-}
-
-const char * component_getName(dm_component_pt cmp) {
-    return cmp->name;
-}
-
-celix_status_t component_removeServiceDependency(dm_component_pt component, dm_service_dependency_pt dependency) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    executor_executeTask(component->executor, component, component_removeTask, dependency);
-
-    return status;
-}
-
-celix_status_t component_removeTask(dm_component_pt component, dm_service_dependency_pt dependency) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    arrayList_removeElement(component->dependencies, dependency);
-    pthread_mutex_unlock(&component->mutex);
-
-    if (component->state != DM_CMP_STATE_INACTIVE) {
-        serviceDependency_stop(dependency);
-    }
-
-    pthread_mutex_lock(&component->mutex);
-    array_list_pt events = hashMap_remove(component->dependencyEvents, dependency);
-    pthread_mutex_unlock(&component->mutex);
-
-	serviceDependency_destroy(&dependency);
-
-    while (!arrayList_isEmpty(events)) {
-    	dm_event_pt event = arrayList_remove(events, 0);
-    	event_destroy(&event);
-    }
-    arrayList_destroy(events);
-
-    component_handleChange(component);
-
-    return status;
-}
-
-celix_status_t component_start(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    component->active = true;
-    executor_executeTask(component->executor, component, component_startTask, NULL);
-
-    return status;
-}
-
-celix_status_t component_startTask(dm_component_pt component, void  *data __attribute__((unused))) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    component->isStarted = true;
-    component_handleChange(component);
-
-    return status;
-}
-
-celix_status_t component_stop(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    component->active = false;
-    executor_executeTask(component->executor, component, component_stopTask, NULL);
-
-    return status;
-}
-
-celix_status_t component_stopTask(dm_component_pt component, void *data __attribute__((unused))) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    component->isStarted = false;
-    component_handleChange(component);
-    component->active = false;
-
-    return status;
-}
-
-celix_status_t component_setCLanguageProperty(dm_component_pt component, bool setCLangProp) {
-    component->setCLanguageProperty = setCLangProp;
-    return CELIX_SUCCESS;
-}
-
-celix_status_t component_addInterface(dm_component_pt component, const char* serviceName, const char* serviceVersion, const void* service, properties_pt properties) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (component->active) {
-        return CELIX_ILLEGAL_STATE;
-    } else {
-        dm_interface_t *interface = (dm_interface_t *) calloc(1, sizeof(*interface));
-        char *name = strdup(serviceName);
-
-        if (properties == NULL) {
-            properties = properties_create();
-        }
-
-        if ((properties_get(properties, CELIX_FRAMEWORK_SERVICE_VERSION) == NULL) && (serviceVersion != NULL)) {
-            properties_set(properties, CELIX_FRAMEWORK_SERVICE_VERSION, serviceVersion);
-        }
-
-        if (component->setCLanguageProperty && properties_get(properties, CELIX_FRAMEWORK_SERVICE_LANGUAGE) == NULL) { //always set default lang to C
-            properties_set(properties, CELIX_FRAMEWORK_SERVICE_LANGUAGE, CELIX_FRAMEWORK_SERVICE_C_LANGUAGE);
-        }
-
-        if (interface && name) {
-            interface->serviceName = name;
-            interface->service = service;
-            interface->properties = properties;
-            interface->registration = NULL;
-            arrayList_add(component->dm_interfaces, interface);
-        } else {
-            free(interface);
-            free(name);
-            status = CELIX_ENOMEM;
-        }
-    }
-
-    return status;
-}
-
-celix_status_t component_getInterfaces(dm_component_pt component, array_list_pt *out) {
-    celix_status_t status = CELIX_SUCCESS;
-    array_list_pt names = NULL;
-    arrayList_create(&names);
-    celixThreadMutex_lock(&component->mutex);
-    int size = arrayList_size(component->dm_interfaces);
-    int i;
-    for (i = 0; i < size; i += 1) {
-        dm_interface_info_pt info = calloc(1, sizeof(*info));
-        dm_interface_t *interface = arrayList_get(component->dm_interfaces, i);
-        info->name = strdup(interface->serviceName);
-        properties_copy(interface->properties, &info->properties);
-        arrayList_add(names, info);
-    }
-    celixThreadMutex_unlock(&component->mutex);
-
-    if (status == CELIX_SUCCESS) {
-        *out = names;
-    }
-
-    return status;
-}
-
-celix_status_t component_handleEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	dm_handle_event_type_pt data = calloc(1, sizeof(*data));
-	data->dependency = dependency;
-	data->event = event;
-	data->newEvent = NULL;
-
-	status = executor_executeTask(component->executor, component, component_handleEventTask, data);
-//	component_handleEventTask(component, data);
-
-	return status;
-}
-
-celix_status_t component_handleEventTask(dm_component_pt component, dm_handle_event_type_pt data) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	switch (data->event->event_type) {
-		case DM_EVENT_ADDED:
-			component_handleAdded(component,data->dependency, data->event);
-			break;
-		case DM_EVENT_CHANGED:
-			component_handleChanged(component,data->dependency, data->event);
-			break;
-		case DM_EVENT_REMOVED:
-			component_handleRemoved(component,data->dependency, data->event);
-			break;
-		case DM_EVENT_SWAPPED:
-			component_handleSwapped(component,data->dependency, data->event, data->newEvent);
-			break;
-		default:
-			break;
-	}
-
-	free(data);
-
-	return status;
-}
-
-static celix_status_t component_suspend(dm_component_pt component, dm_service_dependency_pt dependency) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	dm_service_dependency_strategy_t strategy;
-	serviceDependency_getStrategy(dependency, &strategy);
-	if (strategy == DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND &&  component->callbackStop != NULL) {
-		status = component->callbackStop(component->implementation);
-	}
-
-	return status;
-}
-
-static celix_status_t component_resume(dm_component_pt component, dm_service_dependency_pt dependency) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	dm_service_dependency_strategy_t strategy;
-	serviceDependency_getStrategy(dependency, &strategy);
-	if (strategy == DM_SERVICE_DEPENDENCY_STRATEGY_SUSPEND &&  component->callbackStop != NULL) {
-		status = component->callbackStart(component->implementation);
-	}
-
-	return status;
-}
-
-celix_status_t component_handleAdded(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-    arrayList_add(events, event);
-    pthread_mutex_unlock(&component->mutex);
-
-    serviceDependency_setAvailable(dependency, true);
-
-    switch (component->state) {
-        case DM_CMP_STATE_WAITING_FOR_REQUIRED: {
-            serviceDependency_invokeSet(dependency, event);
-            bool required = false;
-            serviceDependency_isRequired(dependency, &required);
-            if (required) {
-                component_handleChange(component);
-            }
-            break;
-        }
-        case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
-            bool instanceBound = false;
-            serviceDependency_isInstanceBound(dependency, &instanceBound);
-            bool required = false;
-            serviceDependency_isRequired(dependency, &required);
-            if (!instanceBound) {
-                if (required) {
-                    serviceDependency_invokeSet(dependency, event);
-                    serviceDependency_invokeAdd(dependency, event);
-                }
-                dm_event_pt event = NULL;
-                component_getDependencyEvent(component, dependency, &event);
-                component_updateInstance(component, dependency, event, false, true);
-            }
-
-            if (required) {
-                component_handleChange(component);
-            }
-            break;
-        }
-        case DM_CMP_STATE_TRACKING_OPTIONAL:
-		    component_suspend(component,dependency);
-            serviceDependency_invokeSet(dependency, event);
-            serviceDependency_invokeAdd(dependency, event);
-		    component_resume(component,dependency);
-            dm_event_pt event = NULL;
-            component_getDependencyEvent(component, dependency, &event);
-            component_updateInstance(component, dependency, event, false, true);
-            break;
-        default:
-            break;
-    }
-
-    return status;
-}
-
-celix_status_t component_handleChanged(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-    int index = arrayList_indexOf(events, event);
-    if (index < 0) {
-	pthread_mutex_unlock(&component->mutex);
-        status = CELIX_BUNDLE_EXCEPTION;
-    } else {
-        dm_event_pt old = arrayList_remove(events, (unsigned int) index);
-        arrayList_add(events, event);
-        pthread_mutex_unlock(&component->mutex);
-
-        serviceDependency_invokeSet(dependency, event);
-        switch (component->state) {
-            case DM_CMP_STATE_TRACKING_OPTIONAL:
-			    component_suspend(component,dependency);
-                serviceDependency_invokeChange(dependency, event);
-			    component_resume(component,dependency);
-                dm_event_pt hevent = NULL;
-                component_getDependencyEvent(component, dependency, &hevent);
-                component_updateInstance(component, dependency, hevent, true, false);
-                break;
-            case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
-                bool instanceBound = false;
-                serviceDependency_isInstanceBound(dependency, &instanceBound);
-                if (!instanceBound) {
-                    serviceDependency_invokeChange(dependency, event);
-                    dm_event_pt hevent = NULL;
-                    component_getDependencyEvent(component, dependency, &hevent);
-                    component_updateInstance(component, dependency, hevent, true, false);
-                }
-                break;
-            }
-            default:
-                break;
-        }
-
-        event_destroy(&old);
-    }
-
-    return status;
-}
-
-celix_status_t component_handleRemoved(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-    int size = arrayList_size(events);
-    if (arrayList_contains(events, event)) {
-        size--;
-    }
-    pthread_mutex_unlock(&component->mutex);
-    serviceDependency_setAvailable(dependency, size > 0);
-    component_handleChange(component);
-
-    pthread_mutex_lock(&component->mutex);
-    int index = arrayList_indexOf(events, event);
-    if (index < 0) {
-	pthread_mutex_unlock(&component->mutex);
-        status = CELIX_BUNDLE_EXCEPTION;
-    } else {
-        dm_event_pt old = arrayList_remove(events, (unsigned int) index);
-        pthread_mutex_unlock(&component->mutex);
-
-
-        switch (component->state) {
-            case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
-                serviceDependency_invokeSet(dependency, event);
-                bool instanceBound = false;
-                serviceDependency_isInstanceBound(dependency, &instanceBound);
-                if (!instanceBound) {
-                    bool required = false;
-                    serviceDependency_isRequired(dependency, &required);
-                    if (required) {
-                        serviceDependency_invokeRemove(dependency, event);
-                    }
-                    dm_event_pt hevent = NULL;
-                    component_getDependencyEvent(component, dependency, &hevent);
-                    component_updateInstance(component, dependency, hevent, false, false);
-                }
-                break;
-            }
-            case DM_CMP_STATE_TRACKING_OPTIONAL:
-			    component_suspend(component,dependency);
-                serviceDependency_invokeSet(dependency, event);
-                serviceDependency_invokeRemove(dependency, event);
-			    component_resume(component,dependency);
-                dm_event_pt hevent = NULL;
-                component_getDependencyEvent(component, dependency, &hevent);
-                component_updateInstance(component, dependency, hevent, false, false);
-                break;
-            default:
-                break;
-        }
-
-        event_destroy(&event);
-        if (old) {
-            event_destroy(&old);
-        }
-    }
-
-    return status;
-}
-
-celix_status_t component_handleSwapped(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-    int index = arrayList_indexOf(events, event);
-    if (index < 0) {
-	pthread_mutex_unlock(&component->mutex);
-        status = CELIX_BUNDLE_EXCEPTION;
-    } else {
-        dm_event_pt old = arrayList_remove(events, (unsigned int) index);
-        arrayList_add(events, newEvent);
-        pthread_mutex_unlock(&component->mutex);
-
-        serviceDependency_invokeSet(dependency, event);
-
-        switch (component->state) {
-            case DM_CMP_STATE_WAITING_FOR_REQUIRED:
-                break;
-            case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
-                bool instanceBound = false;
-                serviceDependency_isInstanceBound(dependency, &instanceBound);
-                if (!instanceBound) {
-                    bool required = false;
-                    serviceDependency_isRequired(dependency, &required);
-                    if (required) {
-                        serviceDependency_invokeSwap(dependency, event, newEvent);
-                    }
-                }
-                break;
-            }
-            case DM_CMP_STATE_TRACKING_OPTIONAL:
-			    component_suspend(component,dependency);
-                serviceDependency_invokeSwap(dependency, event, newEvent);
-			    component_resume(component,dependency);
-                break;
-            default:
-                break;
-        }
-
-        event_destroy(&event);
-        if (old) {
-            event_destroy(&old);
-        }
-    }
-
-    return status;
-}
-
-celix_status_t component_updateInstance(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt event, bool update, bool add) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    bool autoConfig = false;
-
-    serviceDependency_isAutoConfig(dependency, &autoConfig);
-
-    if (autoConfig) {
-        const void *service = NULL;
-        const void **field = NULL;
-
-        if (event != NULL) {
-            event_getService(event, &service);
-        }
-        serviceDependency_getAutoConfig(dependency, &field);
-        serviceDependency_lock(dependency);
-        *field = service;
-        serviceDependency_unlock(dependency);
-    }
-
-    return status;
-}
-
-celix_status_t component_startDependencies(dm_component_pt component __attribute__((unused)), array_list_pt dependencies) {
-    celix_status_t status = CELIX_SUCCESS;
-    array_list_pt required_dependencies = NULL;
-    arrayList_create(&required_dependencies);
-
-    for (unsigned int i = 0; i < arrayList_size(dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(dependencies, i);
-        bool required = false;
-        serviceDependency_isRequired(dependency, &required);
-        if (required) {
-            arrayList_add(required_dependencies, dependency);
-            continue;
-        }
-
-        serviceDependency_start(dependency);
-    }
-
-    for (unsigned int i = 0; i < arrayList_size(required_dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(required_dependencies, i);
-        serviceDependency_start(dependency);
-    }
-
-    arrayList_destroy(required_dependencies);
-
-    return status;
-}
-
-celix_status_t component_stopDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-        pthread_mutex_unlock(&component->mutex);
-        serviceDependency_stop(dependency);
-        pthread_mutex_lock(&component->mutex);
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_handleChange(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    dm_component_state_t oldState;
-    dm_component_state_t newState;
-
-    bool transition = false;
-    do {
-        oldState = component->state;
-        status = component_calculateNewState(component, oldState, &newState);
-        if (status == CELIX_SUCCESS) {
-            component->state = newState;
-            status = component_performTransition(component, oldState, newState, &transition);
-        }
-
-        if (status != CELIX_SUCCESS) {
-            break;
-        }
-    } while (transition);
-
-    return status;
-}
-
-celix_status_t component_calculateNewState(dm_component_pt component, dm_component_state_t currentState, dm_component_state_t *newState) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (currentState == DM_CMP_STATE_INACTIVE) {
-        if (component->isStarted) {
-            *newState = DM_CMP_STATE_WAITING_FOR_REQUIRED;
-        } else {
-            *newState = currentState;
-        }
-    } else if (currentState == DM_CMP_STATE_WAITING_FOR_REQUIRED) {
-        if (!component->isStarted) {
-            *newState = DM_CMP_STATE_INACTIVE;
-        } else {
-            bool available = false;
-            component_allRequiredAvailable(component, &available);
-
-            if (available) {
-                *newState = DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED;
-            } else {
-                *newState = currentState;
-            }
-        }
-    } else if (currentState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED) {
-        if (!component->isStarted) {
-            *newState = DM_CMP_STATE_WAITING_FOR_REQUIRED;
-        } else {
-            bool available = false;
-            component_allRequiredAvailable(component, &available);
-
-            if (available) {
-                bool instanceBoundAvailable = false;
-                component_allInstanceBoundAvailable(component, &instanceBoundAvailable);
-
-                if (instanceBoundAvailable) {
-                    *newState = DM_CMP_STATE_TRACKING_OPTIONAL;
-                } else {
-                    *newState = currentState;
-                }
-            } else {
-                *newState = currentState;
-            }
-        }
-    } else if (currentState == DM_CMP_STATE_TRACKING_OPTIONAL) {
-        bool instanceBoundAvailable = false;
-        bool available = false;
-
-        component_allInstanceBoundAvailable(component, &instanceBoundAvailable);
-        component_allRequiredAvailable(component, &available);
-
-        if (component->isStarted && available && instanceBoundAvailable) {
-            *newState = currentState;
-        } else {
-            *newState = DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED;
-        }
-    } else {
-        //should not reach
-        *newState = DM_CMP_STATE_INACTIVE;
-        status = CELIX_BUNDLE_EXCEPTION;
-    }
-
-    return status;
-}
-
-celix_status_t component_performTransition(dm_component_pt component, dm_component_state_t oldState, dm_component_state_t newState, bool *transition) {
-    celix_status_t status = CELIX_SUCCESS;
-    //printf("performing transition for %s in thread %i from %i to %i\n", component->name, (int) pthread_self(), oldState, newState);
-
-    if (oldState == newState) {
-        *transition = false;
-    } else if (oldState == DM_CMP_STATE_INACTIVE && newState == DM_CMP_STATE_WAITING_FOR_REQUIRED) {
-        component_startDependencies(component, component->dependencies);
-        *transition = true;
-    } else if (oldState == DM_CMP_STATE_WAITING_FOR_REQUIRED && newState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED) {
-        component_invokeAddRequiredDependencies(component);
-        component_invokeAutoConfigDependencies(component);
-        if (component->callbackInit) {
-        	status = component->callbackInit(component->implementation);
-        }
-        *transition = true;
-    } else if (oldState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED && newState == DM_CMP_STATE_TRACKING_OPTIONAL) {
-        component_invokeAddRequiredInstanceBoundDependencies(component);
-        component_invokeAutoConfigInstanceBoundDependencies(component);
-		component_invokeAddOptionalDependencies(component);
-        if (component->callbackStart) {
-        	status = component->callbackStart(component->implementation);
-        }
-        component_registerServices(component);
-        *transition = true;
-    } else if (oldState == DM_CMP_STATE_TRACKING_OPTIONAL && newState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED) {
-        component_unregisterServices(component);
-        if (component->callbackStop) {
-        	status = component->callbackStop(component->implementation);
-        }
-		component_invokeRemoveOptionalDependencies(component);
-        component_invokeRemoveInstanceBoundDependencies(component);
-        *transition = true;
-    } else if (oldState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED && newState == DM_CMP_STATE_WAITING_FOR_REQUIRED) {
-    	if (component->callbackDeinit) {
-    		status = component->callbackDeinit(component->implementation);
-    	}
-        component_invokeRemoveRequiredDependencies(component);
-        *transition = true;
-    } else if (oldState == DM_CMP_STATE_WAITING_FOR_REQUIRED && newState == DM_CMP_STATE_INACTIVE) {
-        component_stopDependencies(component);
-        *transition = true;
-    }
-
-    return status;
-}
-
-celix_status_t component_allRequiredAvailable(dm_component_pt component, bool *available) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    *available = true;
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-        bool required = false;
-        bool instanceBound = false;
-
-        serviceDependency_isRequired(dependency, &required);
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (required && !instanceBound) {
-            bool isAvailable = false;
-            serviceDependency_isAvailable(dependency, &isAvailable);
-            if (!isAvailable) {
-                *available = false;
-                break;
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_allInstanceBoundAvailable(dm_component_pt component, bool *available) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    *available = true;
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-        bool required = false;
-        bool instanceBound = false;
-
-        serviceDependency_isRequired(dependency, &required);
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (required && instanceBound) {
-            bool isAvailable = false;
-            serviceDependency_isAvailable(dependency, &isAvailable);
-            if (!isAvailable) {
-                *available = false;
-                break;
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeAddRequiredDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool required = false;
-        bool instanceBound = false;
-
-        serviceDependency_isRequired(dependency, &required);
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (required && !instanceBound) {
-            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-            if (events) {
-				for (unsigned int j = 0; j < arrayList_size(events); j++) {
-					dm_event_pt event = arrayList_get(events, j);
-					serviceDependency_invokeAdd(dependency, event);
-				}
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeAutoConfigDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool autoConfig = false;
-        bool instanceBound = false;
-
-        serviceDependency_isAutoConfig(dependency, &autoConfig);
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (autoConfig && !instanceBound) {
-            component_configureImplementation(component, dependency);
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeAutoConfigInstanceBoundDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool autoConfig = false;
-        bool instanceBound = false;
-
-        serviceDependency_isAutoConfig(dependency, &autoConfig);
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (autoConfig && instanceBound) {
-            component_configureImplementation(component, dependency);
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeAddRequiredInstanceBoundDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool required = false;
-        bool instanceBound = false;
-
-        serviceDependency_isRequired(dependency, &required);
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (instanceBound && required) {
-            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-            if (events) {
-				for (unsigned int j = 0; j < arrayList_size(events); j++) {
-					dm_event_pt event = arrayList_get(events, j);
-					serviceDependency_invokeAdd(dependency, event);
-				}
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeAddOptionalDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool required = false;
-
-        serviceDependency_isRequired(dependency, &required);
-
-        if (!required) {
-            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-            if (events) {
-				for (unsigned int j = 0; j < arrayList_size(events); j++) {
-					dm_event_pt event = arrayList_get(events, j);
-					serviceDependency_invokeAdd(dependency, event);
-				}
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeRemoveOptionalDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool required = false;
-
-        serviceDependency_isRequired(dependency, &required);
-
-        if (!required) {
-            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-            if (events) {
-				for (unsigned int j = 0; j < arrayList_size(events); j++) {
-					dm_event_pt event = arrayList_get(events, j);
-					serviceDependency_invokeRemove(dependency, event);
-				}
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeRemoveInstanceBoundDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool instanceBound = false;
-
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (instanceBound) {
-            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-            if (events) {
-				for (unsigned int j = 0; j < arrayList_size(events); j++) {
-					dm_event_pt event = arrayList_get(events, j);
-					serviceDependency_invokeRemove(dependency, event);
-				}
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_invokeRemoveRequiredDependencies(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    pthread_mutex_lock(&component->mutex);
-    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
-
-        bool required = false;
-        bool instanceBound = false;
-
-        serviceDependency_isRequired(dependency, &required);
-        serviceDependency_isInstanceBound(dependency, &instanceBound);
-
-        if (!instanceBound && required) {
-            array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-            if (events) {
-				for (unsigned int j = 0; j < arrayList_size(events); j++) {
-					dm_event_pt event = arrayList_get(events, j);
-					serviceDependency_invokeRemove(dependency, event);
-				}
-            }
-        }
-    }
-    pthread_mutex_unlock(&component->mutex);
-
-    return status;
-}
-
-celix_status_t component_getDependencyEvent(dm_component_pt component, dm_service_dependency_pt dependency, dm_event_pt *event_pptr) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-    *event_pptr = NULL;
-
-    if (events) {
-        for (unsigned int j = 0; j < arrayList_size(events); j++) {
-            dm_event_pt event_ptr = arrayList_get(events, j);
-            if (*event_pptr != NULL) {
-                int compare = 0;
-                event_compareTo(event_ptr, *event_pptr, &compare);
-                if (compare > 0) {
-                    *event_pptr = event_ptr;
-                }
-            } else {
-                *event_pptr = event_ptr;
-            }
-        }
-    }
-
-    return status;
-}
-
-celix_status_t component_configureImplementation(dm_component_pt component, dm_service_dependency_pt dependency) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    const void **field = NULL;
-
-    array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
-    if (events) {
-        const void *service = NULL;
-        dm_event_pt event = NULL;
-        component_getDependencyEvent(component, dependency, &event);
-        if (event != NULL) {
-            event_getService(event, &service);
-            serviceDependency_getAutoConfig(dependency, &field);
-            serviceDependency_lock(dependency);
-            *field = service;
-            serviceDependency_unlock(dependency);
-        }
-    }
-
-    return status;
-}
-
-celix_status_t component_registerServices(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    if (component->context != NULL) {
-	    unsigned int i;
-        for (i = 0; i < arrayList_size(component->dm_interfaces); i++) {
-            dm_interface_t *interface = arrayList_get(component->dm_interfaces, i);
-                properties_pt regProps = NULL;
-                properties_copy(interface->properties, &regProps);
-                bundleContext_registerService(component->context, interface->serviceName, interface->service, regProps, &interface->registration);
-        }
-    }
-
-    return status;
-}
-
-celix_status_t component_unregisterServices(dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    unsigned int i;
-
-    for (i = 0; i < arrayList_size(component->dm_interfaces); i++) {
-	dm_interface_t *interface = arrayList_get(component->dm_interfaces, i);
-
-	serviceRegistration_unregister(interface->registration);
-	interface->registration = NULL;
-    }
-
-    return status;
-}
-
-celix_status_t component_setCallbacks(dm_component_pt component, init_fpt init, start_fpt start, stop_fpt stop, deinit_fpt deinit) {
-	if (component->active) {
-		return CELIX_ILLEGAL_STATE;
-	}
-	component->callbackInit = init;
-	component->callbackStart = start;
-	component->callbackStop = stop;
-	component->callbackDeinit = deinit;
-	return CELIX_SUCCESS;
-}
-
-celix_status_t component_isAvailable(dm_component_pt component, bool *available) {
-    *available = component->state == DM_CMP_STATE_TRACKING_OPTIONAL;
-    return CELIX_SUCCESS;
-}
-
-celix_status_t component_setImplementation(dm_component_pt component, void *implementation) {
-    component->implementation = implementation;
-    return CELIX_SUCCESS;
-}
-
-celix_status_t component_getBundleContext(dm_component_pt component, bundle_context_pt *context) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!component) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		*context = component->context;
-	}
-
-	return status;
-}
-
-
-static celix_status_t executor_create(dm_component_pt component __attribute__((unused)), dm_executor_pt *executor) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    *executor = malloc(sizeof(**executor));
-    if (!*executor) {
-        status = CELIX_ENOMEM;
-    } else {
-        linkedList_create(&(*executor)->workQueue);
-        pthread_mutex_init(&(*executor)->mutex, NULL);
-        (*executor)->runningThreadSet = false;
-    }
-
-    return status;
-}
-
-static void executor_destroy(dm_executor_pt executor) {
-
-	if (executor) {
-		pthread_mutex_destroy(&executor->mutex);
-		linkedList_destroy(executor->workQueue);
-
-		free(executor);
-	}
-}
-
-static celix_status_t executor_schedule(dm_executor_pt executor, dm_component_pt component, void (*command), void *data) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    dm_executor_task_t *task = NULL;
-    task = malloc(sizeof(*task));
-    if (!task) {
-        status = CELIX_ENOMEM;
-    } else {
-        task->component = component;
-        task->command = command;
-        task->data = data;
-
-        pthread_mutex_lock(&executor->mutex);
-        linkedList_addLast(executor->workQueue, task);
-        pthread_mutex_unlock(&executor->mutex);
-    }
-
-    return status;
-}
-
-static celix_status_t executor_executeTask(dm_executor_pt executor, dm_component_pt component, void (*command), void *data) {
-    celix_status_t status = CELIX_SUCCESS;
-
-    // Check thread and executor thread, if the same, execute immediately.
-//    bool execute = false;
-//    pthread_mutex_lock(&executor->mutex);
-//    pthread_t currentThread = pthread_self();
-//    if (pthread_equal(executor->runningThread, currentThread)) {
-//        execute = true;
-//    }
-//    pthread_mutex_unlock(&executor->mutex);
-
-    // For now, just schedule.
-    executor_schedule(executor, component, command, data);
-    executor_execute(executor);
-
-    return status;
-}
-
-static celix_status_t executor_execute(dm_executor_pt executor) {
-    celix_status_t status = CELIX_SUCCESS;
-    pthread_t currentThread = pthread_self();
-
-    pthread_mutex_lock(&executor->mutex);
-    bool execute = false;
-    if (!executor->runningThreadSet) {
-        executor->runningThread = currentThread;
-        executor->runningThreadSet = true;
-        execute = true;
-    }
-    pthread_mutex_unlock(&executor->mutex);
-    if (execute) {
-        executor_runTasks(executor, currentThread);
-    }
-
-    return status;
-}
-
-static celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t currentThread __attribute__((unused))) {
-    celix_status_t status = CELIX_SUCCESS;
-//    bool execute = false;
-
-    do {
-        dm_executor_task_t *entry = NULL;
-        pthread_mutex_lock(&executor->mutex);
-        while ((entry = linkedList_removeFirst(executor->workQueue)) != NULL) {
-            pthread_mutex_unlock(&executor->mutex);
-
-            entry->command(entry->component, entry->data);
-
-            pthread_mutex_lock(&executor->mutex);
-
-            free(entry);
-        }
-        executor->runningThreadSet = false;
-        pthread_mutex_unlock(&executor->mutex);
-
-//        pthread_mutex_lock(&executor->mutex);
-//        if (executor->runningThread == NULL) {
-//            executor->runningThread = currentThread;
-//            execute = true;
-//        }
-//        pthread_mutex_unlock(&executor->mutex);
-    } while (!linkedList_isEmpty(executor->workQueue)); // && execute
-
-    return status;
-}
-
-celix_status_t component_getComponentInfo(dm_component_pt component, dm_component_info_pt *out) {
-    celix_status_t status = CELIX_SUCCESS;
-    int i;
-    int size;
-    dm_component_info_pt info = NULL;
-    info = calloc(1, sizeof(*info));
-
-    if (info == NULL) {
-        return CELIX_ENOMEM;
-    }
-
-    arrayList_create(&info->dependency_list);
-    component_getInterfaces(component, &info->interfaces);
-    info->active = false;
-    memcpy(info->id, component->id, DM_COMPONENT_MAX_ID_LENGTH);
-    memcpy(info->name, component->name, DM_COMPONENT_MAX_NAME_LENGTH);
-
-    switch (component->state) {
-        case DM_CMP_STATE_INACTIVE :
-            info->state = strdup("INACTIVE");
-            break;
-        case DM_CMP_STATE_WAITING_FOR_REQUIRED :
-            info->state = strdup("WAITING_FOR_REQUIRED");
-            break;
-        case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED :
-            info->state = strdup("INSTANTIATED_AND_WAITING_FOR_REQUIRED");
-            break;
-        case DM_CMP_STATE_TRACKING_OPTIONAL :
-            info->state = strdup("TRACKING_OPTIONAL");
-            info->active = true;
-            break;
-        default :
-            info->state = strdup("UNKNOWN");
-            break;
-    }
-
-    celixThreadMutex_lock(&component->mutex);
-    size = arrayList_size(component->dependencies);
-    for (i = 0; i < size; i += 1) {
-        dm_service_dependency_pt dep = arrayList_get(component->dependencies, i);
-        dm_service_dependency_info_pt depInfo = NULL;
-        status = serviceDependency_getServiceDependencyInfo(dep, &depInfo);
-        if (status == CELIX_SUCCESS) {
-            arrayList_add(info->dependency_list, depInfo);
-        } else {
-            break;
-        }
-    }
-    celixThreadMutex_unlock(&component->mutex);
-
-    if (status == CELIX_SUCCESS) {
-        *out = info;
-    } else if (info != NULL) {
-        component_destroyComponentInfo(info);
-    }
-
-    return status;
-}
-
-void component_destroyComponentInfo(dm_component_info_pt info) {
-    int i;
-    int size;
-    if (info != NULL) {
-        free(info->state);
-
-        if (info->interfaces != NULL) {
-            size = arrayList_size(info->interfaces);
-            for (i = 0; i < size; i += 1) {
-                dm_interface_info_pt intfInfo = arrayList_get(info->interfaces, i);
-                free(intfInfo->name);
-                properties_destroy(intfInfo->properties);
-                free(intfInfo);
-            }
-            arrayList_destroy(info->interfaces);
-        }
-        if (info->dependency_list != NULL) {
-            size = arrayList_size(info->dependency_list);
-            for (i = 0; i < size; i += 1) {
-                dm_service_dependency_info_pt depInfo = arrayList_get(info->dependency_list, i);
-                dependency_destroyDependencyInfo(depInfo);
-            }
-            arrayList_destroy(info->dependency_list);
-        }
-    }
-    free(info);
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/src/dm_dependency_manager_impl.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_dependency_manager_impl.c b/dependency_manager/private/src/dm_dependency_manager_impl.c
deleted file mode 100644
index 4864be1..0000000
--- a/dependency_manager/private/src/dm_dependency_manager_impl.c
+++ /dev/null
@@ -1,129 +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.
- */
-
-/*
- * dm_dependency_manager_impl.c
- *
- *  \date       26 Jul 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-
-#include <pthread.h>
-#include <stdlib.h>
-#include <dm_dependency_manager.h>
-
-#include "bundle_context.h"
-#include "dm_component_impl.h"
-#include "dm_dependency_manager_impl.h"
-
-
-celix_status_t dependencyManager_create(bundle_context_pt context __attribute__((unused)), dm_dependency_manager_pt *manager) {
-	celix_status_t status = CELIX_ENOMEM;
-
-	(*manager) = calloc(1, sizeof(**manager));
-
-	if (*manager) {
-		arrayList_create(&(*manager)->components);
-
-		status = CELIX_SUCCESS;
-	}
-
-	return status;
-
-}
-
-void dependencyManager_destroy(dm_dependency_manager_pt manager) {
-	if (manager != NULL) {
-		arrayList_destroy(manager->components);
-		free(manager);
-	}
-}
-
-celix_status_t dependencyManager_add(dm_dependency_manager_pt manager, dm_component_pt component) {
-	celix_status_t status;
-
-	arrayList_add(manager->components, component);
-	status = component_start(component);
-
-	return status;
-}
-
-celix_status_t dependencyManager_removeAllComponents(dm_dependency_manager_pt manager) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	unsigned int i=0;
-	unsigned int size = arrayList_size(manager->components);
-
-	for(;i<size;i++){
-		dm_component_pt cmp = arrayList_get(manager->components, i);
-//		printf("Stopping comp %s\n", component_getName(cmp));
-		component_stop(cmp);
-	}
-
-	while (!arrayList_isEmpty(manager->components)) {
-		dm_component_pt cmp = arrayList_remove(manager->components, 0);
-//        printf("Removing comp %s\n", component_getName(cmp));
-        component_destroy(cmp);
-	}
-
-	return status;
-}
-
-celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt *out) {
-	celix_status_t status = CELIX_SUCCESS;
-	int i;
-	int size;
-	dm_component_info_pt cmpInfo = NULL;
-	dm_dependency_manager_info_pt info = calloc(1, sizeof(*info));
-
-	celixThreadMutex_lock(&manager->mutex);
-
-	if (info != NULL) {
-		arrayList_create(&info->components);
-		size = arrayList_size(manager->components);
-		for (i = 0; i < size; i += 1) {
-			dm_component_pt cmp = arrayList_get(manager->components, i);
-			cmpInfo = NULL;
-			component_getComponentInfo(cmp, &cmpInfo);
-			arrayList_add(info->components, cmpInfo);
-		}
-	} else {
-		status = CELIX_ENOMEM;
-	}
-
-	celixThreadMutex_unlock(&manager->mutex);
-
-	if (status == CELIX_SUCCESS) {
-		*out = info;
-	}
-
-	return status;
-}
-
-void dependencyManager_destroyInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt info) {
-    unsigned int i = 0;
-    for (; i < arrayList_size(info->components); i += 1) {
-        dm_component_info_pt cmpinfo = (dm_component_info_pt)arrayList_get(info->components, i);
-        component_destroyComponentInfo(cmpinfo);
-    }
-    arrayList_destroy(info->components);
-    free(info);
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dependency_manager/private/src/dm_event.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_event.c b/dependency_manager/private/src/dm_event.c
deleted file mode 100644
index 9341832..0000000
--- a/dependency_manager/private/src/dm_event.c
+++ /dev/null
@@ -1,105 +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.
- */
-
-/*
- * dm_event.c
- *
- *  \date       18 Dec 2014
- *  \author     <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- *  \copyright  Apache License, Version 2.0
- */
-
-#include <stdlib.h>
-#include <constants.h>
-#include <utils.h>
-
-#include "dm_event.h"
-
-celix_status_t event_create(dm_event_type_e event_type, bundle_pt bundle, bundle_context_pt context, service_reference_pt reference, const void *service, dm_event_pt *event) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*event = calloc(1, sizeof(**event));
-	if (!*event) {
-		status = CELIX_ENOMEM;
-	}
-
-	const char* serviceIdStr = NULL;
-	serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &serviceIdStr);
-	unsigned long servId = strtoul(serviceIdStr,NULL,10);
-
-	//FIXME service ranking can dynamicly change, but service reference can be removed at any time.
-	const char* rankingStr = NULL;
-	serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_RANKING, &rankingStr);
-	long ranking = rankingStr == NULL ? 0 : atol(rankingStr);
-
-	if (status == CELIX_SUCCESS) {
-		(*event)->bundle = bundle;
-		(*event)->event_type = event_type;
-		(*event)->context = context;
-		(*event)->reference = reference;
-		(*event)->service = service;
-		(*event)->serviceId = servId;
-		(*event)->ranking = ranking;
-	}
-
-	return status;
-}
-
-celix_status_t event_destroy(dm_event_pt *event) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!*event) {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-
-	if (status == CELIX_SUCCESS) {
-		free(*event);
-		*event = NULL;
-	}
-
-	return status;
-}
-
-celix_status_t event_equals(const void *a, const void *b, bool *equals) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	if (!a || !b) {
-		*equals = false;
-	} else {
-		dm_event_pt a_ptr = (dm_event_pt)a;
-		dm_event_pt b_ptr = (dm_event_pt)b;
-
-		*equals = a_ptr->serviceId == b_ptr->serviceId;
-	}
-
-	return status;
-}
-
-celix_status_t event_compareTo(dm_event_pt event, dm_event_pt compareTo, int *compare) {
-	celix_status_t status = CELIX_SUCCESS;
-
-	*compare = utils_compareServiceIdsAndRanking(event->serviceId, event->ranking, compareTo->serviceId, compareTo->ranking);
-
-	return status;
-}
-
-celix_status_t event_getService(dm_event_pt event, const void **service) {
-	*service = event->service;
-	return CELIX_SUCCESS;
-}