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 2018/12/11 21:01:54 UTC

[celix] branch feature/CELIX-426-cxx-api updated (b4ce49f -> 287afbe)

This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a change to branch feature/CELIX-426-cxx-api
in repository https://gitbox.apache.org/repos/asf/celix.git.


    from b4ce49f  CELIX-446: Refactors for effc c++ warnings (gcc8)
     add 77ffca3  CELIX-446: Updates runtimes.cmake to use a celix prefix and refactors deployments -> containers
     add 4fb26cf  CELIX-446: Fixes a wrong cmake function call in the Celix Runtimes cmake
     add a5192fc  Fixed memory leak in DM shell command
     add 7885778  CELIX-448: Added component_removeInterface / C++ Component::removeCInterface
     add 6779498  CELIX-424: Update doap file and moves Dockerfile to misc dir
     add 3f24edf  CELIX-449: Restructure of some parts of the documentation to make it easier to integrate with the celix-site.
     add c4de907  CELIX-451: Adds celix_bundle_dir for copying files. Also remove mongoose example and adds a new civetweb example.
     add 8109f6c  CELIX-451: Add celix_bundle_add_files CMake command
     add d180316  CELIX-452: Add the usage of retain/release concept in the framework.c so that serviceListeners lock can be kept local.
     add ab36969  CELIX-451: Removes warnings for the civetweb compilation
     add 3415b8f  CELIX-452: Moves the typedef of service_reference to celix_types.h
     add d855903  CELIX-452: And sync call for the release/retain concept for service_tracker/service listener. This ensure that the removing calls for services/service_listeners only return when there are no users anymore.
     add 02ee6c4  CELIX-452: Improves the service listener locking. The retain/release on service listener now first check if service listener matches
     add bcda87f  CELIX-452: Changes the behaviour of the serviceTracker_close, so that removing the service listener is done on a separate thread.
     add 246369e  CELIX-452: Adds missing service tracker stub for mock based framework tests
     add ba03fb8  CELIX-452: Adds a missing null check
     add 66f89bb  CELIX-452: Removes an erroneous if statement.
     add bd24774  Adds celix array list remove functions for the supported types and the unit test for those functions
     add 07f354c  Fixed typos
     add 7690621  Markdown format issue resolved
     add 25fcbcd  CELIX-453: Updates behaviour of fw_getProperty so that env can be used to override properties.
     add 6e25c0d  CELIX-453: Fixes a clang error
     add 57f1693  CELIX-453: Fixes some issues in the array_list and properties update
     add e573d9a  CELIX-453: Fixes a memleak in the properties unit tests
     add c9e777f  Fixed leaks in pubsub
     add 7158795  CELIX-438: Adds some additional api refactoring.
     add e30a70f  CELIX-454: Refactors pubsub discovery and topology manager trying to prevent race conditions
     add 69596cf  CELIX-454: More PubSub refactoring. Started creating a new skeleton for psa udpmc based on a updated pubsub spi.
     add 2eb219e  CELIX-454: More PubSub. The UDPMC is now somewhat working again, but still needs some testing.
     add ffb97ff  CELIX-454: Removes some now unused sources
     add 00454ef  CELIX-454: Refactors the pubsub zmq admin.
     add f1dfdbd  CELIX-454: Removes now unused psa zmq source files
     add b635e27  CELIX-454: Some bug and mem leak fixes for the PSA refactoring
     add d311fa7  CELIX-434: Updates cache behaviour.
     add dac1102  CELIX-454: More bug and mem leak fixing
     add 436f84d  CELIX-434: Fixes an issue with the bundle cache unit tests
     add b29bb91  CELIX-434: Adds default cache dir configuration to add_celix_docker_container
     add 07a491b  CELIX-454: Fixes an typo in the psa service
     add 3fafef6  CELIX-454: Fixes some bugs
     add 8a81ff6  CELIX-454: Adds some missing cleanup for the UDP MC pubsub admin.
     add 3a5ff67  CELIX-454: Adds service version to the publisher service registrations
     add 1a26edb  CELIX-454: Fixes a bug in the serviceTrackerTracker call wich ignored the provided service name.
     add 535bb88  CELIX-454: Moves a debug log statement so that it only occurs when new endpoint are discovered
     add 4d33bcd  CELIX-454: Refactors bundle locking handling in the framework. The current situation can lead to deadlocks. This is still wip.
     add f94fb54  CELIX-454: Fixes a framework shutdown issue
     add 2eb029d   CELIX-454: Fixes some issues in the pubsub zmq admin
     add d813507  CELIX-454: Removes unused static function
     add ef40f48  CELIX-454: Fixes a bug in the pubsub discovery where discovered endpoint listener where not correctly removed.
     add ca2d090  CELIX-454: Updates OSX deployment target for travis build.
     add 7b4433b  Report error to user if serializaton fails
     add 63d7f82  CELIX-454: Adds a apple specific version for the celixThreadCondition_timedwaitRelative impl that does not use the clock_gettime.
     add d0b1902  CELIX-454: Update log for deleting bundle cache, so that this only happens if a dir inside a bundle cache can not be deleted.
     add c3f2e82  CELIX-454: Fixes some mem leaks, correct cleanup for service listeners and ensures that onlye a single framework shutdown thread will be started for multiple shutdown requests.
     add 3b56bce  CELIX-454: Correct wrong mem free in the pubsub match functions
     add 24def68  Removed sleep in zmqadmin read-thread and fixed doublke destroy of property
     add 23d9c0a  CELIX-454: Fixes a wrongly timed mem free
     add d11ecb9  CELIX-454: Removes multipart support for the pubsub zmq.
     add 1ffdd94  CELIX-454: Reverts wrong removal of common pubsub header struct
     add 8345658  CELIX-433: Started on making installable celix containers, beginning with making it possible to configure bundles paths and making improves the handling of embedded properties.
     add 33a93db  CELIX-433: Moves the generation of config.properties to the main.c/main.cc program for a celix container.
     add 68f69f8  CELIX-454: Update match algorithm in the pubsub topology manager, so that rematches (teardown followed by setup) are done if new psa are added.
     add bd38363  Removed potential null-dereference when retrieving hook services
     add 6f9b23d  Added DM-Cxx fucntion to remove previously registered component callbacks
     add 12d5caf  CELIX-454: Fixes an issue in the runtime scripts, where a existing of a certain file was assumed.
     add acf87f6  CELIX-433: Adds container option to use the config.properties instead of the now default generated executable
     add 3526100  CELIX-433: Documents the add_celix_container USE_CONFIG option
     add 2492416  CELIX-438: Add a dependency manager API with the celix prefix. Also add a compile options to enable deprecated compiler warning for the 'old' api.
     add 6c158a3  CELIX-438: Replaces uses of add_compile_definitions to add_definitions
     add 976026c  CELIX-438: Removes usage of a deprecated function and update some struct initializations.
     add 2400f6e  CELIX-438: Adding missing header include
     add f153cf7  CELIX-438: Replaces deprecated api call
     add 60f327d  CELIX-438: Replaces deprecated api call
     add 79852c5  CELIX-438: Updates dm example linkage
     add f7779cc  Fix in RSA discovery-etcd: remote services where not published in etcd
     add 83b124f  CELIX-438: Replaces linked link usage to celix_array_list in dm_component
     add dcd5bda  CELIX-438: Fixes an issue of double removings of components becuase the dm_deinit was triggered after the bundle_stop
     add 009fd05  CELIX-438: Fixes an issue in the dm component with task handling
     add 392f12e  CELIX-438: Updates updated celix dm api
     new 287afbe  Merge branch 'develop' into feature/CELIX-426-cxx-api

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .travis.yml                                        |     2 +-
 CMakeLists.txt                                     |     4 +-
 bundles/config_admin/service/CMakeLists.txt        |     1 +
 bundles/deployment_admin/CMakeLists.txt            |     1 +
 bundles/device_access/device_access/CMakeLists.txt |     1 +
 .../device_access/driver_locator/CMakeLists.txt    |     1 +
 .../example/refining_driver/src/refining_driver.c  |     8 +-
 bundles/event_admin/event_admin/CMakeLists.txt     |     1 +
 .../event_admin/private/include/event_admin_impl.h |     2 +-
 bundles/event_admin/event_handler/CMakeLists.txt   |     1 +
 .../private/include/event_handler_impl.h           |     2 +-
 bundles/event_admin/event_publisher/CMakeLists.txt |     1 +
 .../private/include/event_publisher_impl.h         |     2 +-
 bundles/log_service/CMakeLists.txt                 |     1 +
 bundles/log_service/loghelper_include/log_helper.h |     2 +-
 bundles/log_service/src/log_helper.c               |    21 +-
 .../log_writer/log_writer_stdout/CMakeLists.txt    |     1 +
 .../log_writer/log_writer_syslog/CMakeLists.txt    |     3 +-
 bundles/pubsub/examples/CMakeLists.txt             |   145 +-
 .../pubsub/msg_descriptors/poi1.properties         |     3 +
 .../pubsub/msg_descriptors/poi2.properties         |     3 +
 .../private/include/pubsub_publisher_private.h     |    13 +-
 .../publisher/private/src/ps_pub_activator.c       |   108 +-
 .../publisher/private/src/pubsub_publisher.c       |    14 +-
 bundles/pubsub/pubsub_admin_udp_mc/CMakeLists.txt  |     8 +-
 bundles/pubsub/pubsub_admin_udp_mc/src/large_udp.c |     2 +-
 .../pubsub/pubsub_admin_udp_mc/src/psa_activator.c |   169 +-
 .../pubsub_admin_udp_mc/src/pubsub_admin_impl.c    |  1160 --
 .../pubsub_admin_udp_mc/src/pubsub_admin_impl.h    |    97 -
 .../pubsub_admin_udp_mc/src/pubsub_udpmc_admin.c   |   684 +
 .../pubsub_admin_udp_mc/src/pubsub_udpmc_admin.h   |    62 +
 .../pubsub_admin_udp_mc/src/pubsub_udpmc_common.c  |    30 +-
 .../pubsub_admin_udp_mc/src/pubsub_udpmc_common.h  |    30 +-
 .../src/pubsub_udpmc_topic_receiver.c              |   427 +
 .../src/pubsub_udpmc_topic_receiver.h              |    47 +
 .../src/pubsub_udpmc_topic_sender.c                |   341 +
 .../src/pubsub_udpmc_topic_sender.h                |    49 +
 .../pubsub_admin_udp_mc/src/topic_publication.c    |   453 -
 .../pubsub_admin_udp_mc/src/topic_publication.h    |    57 -
 .../pubsub_admin_udp_mc/src/topic_subscription.c   |   635 -
 .../pubsub_admin_udp_mc/src/topic_subscription.h   |    60 -
 bundles/pubsub/pubsub_admin_zmq/CMakeLists.txt     |    14 +-
 .../pubsub/pubsub_admin_zmq/src/psa_activator.c    |   215 +-
 .../pubsub_admin_zmq/src/pubsub_admin_impl.c       |  1183 --
 .../pubsub_admin_zmq/src/pubsub_admin_impl.h       |   113 -
 .../src/pubsub_psa_zmq_constants.h                 |     2 +
 .../pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c |   706 +
 .../pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.h |    62 +
 .../pubsub_admin_zmq/src/pubsub_zmq_common.c       |    55 +
 .../pubsub_admin_zmq/src/pubsub_zmq_common.h       |    56 +
 .../src/pubsub_zmq_topic_receiver.c                |   464 +
 .../src/pubsub_zmq_topic_receiver.h                |    43 +
 .../pubsub_admin_zmq/src/pubsub_zmq_topic_sender.c |   406 +
 .../pubsub_admin_zmq/src/pubsub_zmq_topic_sender.h |    47 +
 .../pubsub_admin_zmq/src/topic_publication.c       |   640 -
 .../pubsub_admin_zmq/src/topic_publication.h       |    49 -
 .../pubsub_admin_zmq/src/topic_subscription.c      |   761 -
 .../pubsub_admin_zmq/src/topic_subscription.h      |    60 -
 bundles/pubsub/pubsub_discovery/CMakeLists.txt     |     9 +-
 bundles/pubsub/pubsub_discovery/src/etcd_common.c  |    82 -
 bundles/pubsub/pubsub_discovery/src/etcd_common.h  |    28 -
 bundles/pubsub/pubsub_discovery/src/etcd_watcher.c |   322 -
 bundles/pubsub/pubsub_discovery/src/etcd_watcher.h |    38 -
 bundles/pubsub/pubsub_discovery/src/etcd_writer.c  |   217 -
 bundles/pubsub/pubsub_discovery/src/etcd_writer.h  |    39 -
 .../pubsub/pubsub_discovery/src/psd_activator.c    |   172 +-
 .../pubsub_discovery/src/pubsub_discovery_impl.c   |   840 +-
 .../pubsub_discovery/src/pubsub_discovery_impl.h   |    84 +-
 .../pubsub/pubsub_serializer_json/CMakeLists.txt   |     3 +-
 .../pubsub_serializer_json/src/ps_activator.c      |   108 -
 .../src/ps_json_serializer_activator.c             |    59 +
 .../src/pubsub_serializer_impl.h                   |     9 +-
 bundles/pubsub/pubsub_spi/CMakeLists.txt           |     2 +-
 .../include/publisher_endpoint_announce.h          |    40 -
 bundles/pubsub/pubsub_spi/include/pubsub_admin.h   |    53 +-
 .../pubsub/pubsub_spi/include/pubsub_admin_match.h |    47 -
 bundles/pubsub/pubsub_spi/include/pubsub_common.h  |    25 +-
 .../pubsub/pubsub_spi/include/pubsub_constants.h   |    19 +-
 .../pubsub/pubsub_spi/include/pubsub_endpoint.h    |    51 +-
 .../pubsub/pubsub_spi/include/pubsub_listeners.h   |    50 +
 .../pubsub/pubsub_spi/include/pubsub_serializer.h  |    18 +-
 bundles/pubsub/pubsub_spi/include/pubsub_utils.h   |    44 +-
 bundles/pubsub/pubsub_spi/src/pubsub_admin_match.c |   169 -
 bundles/pubsub/pubsub_spi/src/pubsub_endpoint.c    |   382 +-
 bundles/pubsub/pubsub_spi/src/pubsub_utils.c       |    40 +-
 bundles/pubsub/pubsub_spi/src/pubsub_utils_match.c |   226 +
 .../pubsub/pubsub_topology_manager/CMakeLists.txt  |     1 +
 .../pubsub_topology_manager/src/pstm_activator.c   |   259 +-
 .../src/pubsub_topology_manager.c                  |  1383 +-
 .../src/pubsub_topology_manager.h                  |   112 +-
 .../discovery_common/src/discovery.c               |     2 +
 .../discovery_common/src/discovery_activator.c     |     2 +-
 .../remote_services/discovery_etcd/CMakeLists.txt  |     1 +
 .../discovery_etcd/src/etcd_watcher.c              |     4 +-
 .../remote_services/discovery_shm/CMakeLists.txt   |     1 +
 .../remote_service_admin_dfi/CMakeLists.txt        |     1 +
 .../remote_service_admin_shm/CMakeLists.txt        |     1 +
 .../topology_manager/CMakeLists.txt                |     1 +
 .../topology_manager/src/activator.c               |     6 +-
 .../remote_services/topology_manager/src/scope.c   |     9 +-
 .../topology_manager/src/topology_manager.c        |     4 +-
 .../topology_manager/src/topology_manager.h        |     2 +-
 bundles/shell/remote_shell/CMakeLists.txt          |     3 +-
 bundles/shell/shell/CMakeLists.txt                 |     1 +
 bundles/shell/shell/include/shell.h                |     2 +-
 bundles/shell/shell/src/activator.c                |     8 +-
 bundles/shell/shell/src/dm_shell_list_command.c    |   114 +-
 bundles/shell/shell/src/lb_command.c               |   345 +-
 bundles/shell/shell/src/std_commands.h             |     2 +-
 bundles/shell/shell_bonjour/CMakeLists.txt         |     1 +
 .../shell_bonjour/private/src/bonjour_shell.c      |     2 +-
 bundles/shell/shell_tui/CMakeLists.txt             |     1 +
 cmake/celix_project/AddGTest.cmake                 |     4 +-
 cmake/cmake_celix/BundlePackaging.cmake            |   164 +-
 cmake/cmake_celix/ContainerPackaging.cmake         |   193 +-
 cmake/cmake_celix/DockerPackaging.cmake            |    27 +-
 cmake/cmake_celix/Manifest.template.in             |     1 +
 cmake/cmake_celix/OCIPacking.cmake                 |   156 +
 cmake/cmake_celix/Runtimes.cmake                   |   112 +-
 cmake/cmake_celix/runtime_common.sh.in             |    41 +-
 doap/doap_Celix.rdf                                |    13 +-
 .../bundles}/log_service/README.md                 |     0
 .../bundles}/log_writer/README.md                  |     0
 .../bundles}/remote_services/README.md             |    10 +
 .../remote_services/discovery_etcd/README.md       |     0
 .../bundles}/remote_shell/README.md                |     0
 .../shell => documents/bundles}/shell/README.md    |     0
 .../bundles}/shell_tui/README.md                   |     0
 documents/cmake_commands/readme.md                 |    15 +-
 documents/getting_started/readme.md                |     6 +-
 .../readme.md}                                     |     0
 .../readme.md}                                     |     0
 .../readme.md}                                     |     0
 documents/roadmap/api_v3/celix/celix.h             |  1896 --
 documents/roadmap/api_v3/readme.md                 |   283 -
 documents/subprojects/readme.md                    |    37 +-
 examples/celix-examples/CMakeLists.txt             |     4 +-
 .../bar/private/src/bar_activator.c                |    13 +-
 .../foo1/private/src/foo1_activator.c              |    28 +-
 .../foo2/private/src/foo2.c                        |     2 +-
 .../foo2/private/src/foo2_activator.c              |    30 +-
 .../{bundle_example_c => civetweb}/CMakeLists.txt  |    17 +-
 .../celix-examples/civetweb/civetweb/civetweb.c    | 19792 +++++++++++++++++++
 .../celix-examples/civetweb/civetweb/civetweb.h    |  1498 ++
 .../civetweb/civetweb/handle_form.inl              |   981 +
 examples/celix-examples/civetweb/civetweb/md5.inl  |   471 +
 examples/celix-examples/civetweb/civetweb/sha1.inl |   323 +
 .../celix-examples/civetweb/civetweb/timer.inl     |   246 +
 .../root => civetweb/resources}/index.html         |    22 +-
 .../resources/script.js}                           |    38 +-
 .../celix-examples/civetweb/src/bundle_activator.c |   111 +
 examples/celix-examples/dm_example/CMakeLists.txt  |     5 +-
 .../dm_example/phase1/CMakeLists.txt               |    11 -
 .../dm_example/phase1/src/phase1_activator.c       |    47 +-
 .../dm_example/phase1/src/phase1_cmp.c             |     6 +-
 .../dm_example/phase1/src/phase1_cmp.h             |     2 +-
 .../dm_example/phase2a/CMakeLists.txt              |    11 -
 .../dm_example/phase2a/src/phase2a_activator.c     |    59 +-
 .../dm_example/phase2b/CMakeLists.txt              |    11 -
 .../dm_example/phase2b/src/phase2b_activator.c     |    60 +-
 .../dm_example/phase3/CMakeLists.txt               |    11 -
 .../dm_example/phase3/src/phase3_activator.c       |    62 +-
 .../dm_example/phase3/src/phase3_cmp.c             |     2 +-
 .../celix-examples/dm_example_cxx/CMakeLists.txt   |     2 +
 .../dm_example_cxx/phase1/src/Phase1Activator.cc   |    54 +-
 ...{Phase1Activator.cc => Phase1Activator.cc.orig} |    49 +
 .../dm_example_cxx/phase1/src/Phase1Activator.h    |    18 +-
 .../{Phase1Activator.h => Phase1Activator.h.orig}  |    19 +
 .../celix-examples/embedding/private/src/main.c    |     8 +-
 .../hello_world/private/src/activator.c            |     8 +-
 .../hello_world_test/private/src/activator.c       |     8 +-
 .../log_service_example/src/activator.c            |     8 +-
 examples/celix-examples/mongoose/CMakeLists.txt    |    42 -
 .../mongoose/private/include/mongoose.h            |   218 -
 .../mongoose/private/src/activator.c               |    79 -
 .../celix-examples/mongoose/private/src/mongoose.c |  4076 ----
 .../service_hook_example/src/activator.c           |    12 +-
 .../src/dynamic_provider_example.c                 |     2 +-
 .../shell_command_example/src/activator.c          |     4 +-
 libs/dependency_manager/src/dm_activator.c         |    10 +-
 libs/dependency_manager_cxx/src/dm_activator.cc    |    24 +-
 libs/etcdlib/api/etcd.h                            |    16 +-
 libs/etcdlib/src/etcd.c                            |   115 +-
 libs/etcdlib/test/etcdlib_test.c                   |    35 +-
 libs/framework/CMakeLists.txt                      |     1 +
 .../framework/gtest/src/cxx_BundleContext_tests.cc |     7 +-
 libs/framework/gtest/src/cxx_Bundle_tests.cc       |     3 +-
 libs/framework/include/bundle.h                    |    86 +-
 libs/framework/include/bundle_activator.h          |    16 +-
 libs/framework/include/bundle_context.h            |   248 +-
 .../{bundle_context.h => bundle_context.h.orig}    |   129 +-
 libs/framework/include/bundle_revision.h           |     4 +-
 libs/framework/include/celix/BundleActivator.h     |    10 +-
 libs/framework/include/celix/BundleContext.h       |     2 +-
 libs/framework/include/celix/Constants.h           |     4 +-
 libs/framework/include/celix/dm/Component.h        |    37 +-
 libs/framework/include/celix/dm/Component_Impl.h   |    43 +-
 .../framework/include/celix/dm/DependencyManager.h |    73 +-
 ...ependencyManager.h => DependencyManager.h.orig} |    37 +-
 libs/framework/include/celix/dm/DmActivator.h      |    14 +-
 .../framework/include/celix/dm/ServiceDependency.h |    16 +-
 .../include/celix/dm/ServiceDependency_Impl.h      |    88 +-
 .../include/celix/impl/BundleContextImpl.h         |    18 +-
 libs/framework/include/celix/impl/FrameworkImpl.h  |     8 +-
 libs/framework/include/celix_api.h                 |    27 +-
 libs/framework/include/celix_bundle.h              |     8 +-
 libs/framework/include/celix_bundle_context.h      |    94 +-
 ...undle_context.h => celix_bundle_context.h.orig} |    97 +-
 libs/framework/include/celix_constants.h           |    46 +-
 libs/framework/include/celix_dependency_manager.h  |    86 +
 .../{dm_component.h => celix_dm_component.h}       |    68 +-
 libs/framework/include/celix_dm_info.h             |    76 +
 .../include/celix_dm_service_dependency.h          |   169 +
 libs/framework/include/celix_framework.h           |     1 -
 libs/framework/include/celix_framework_factory.h   |     2 +-
 libs/framework/include/celix_launcher.h            |    14 +-
 .../{service_event.h => celix_service_event.h}     |    49 +-
 .../framework/include/celix_service_listener.h     |    25 +-
 libs/framework/include/celix_types.h               |    51 +-
 libs/framework/include/constants.h                 |    14 +-
 libs/framework/include/constants.h.orig            |    95 +
 libs/framework/include/dm_activator.h              |    12 +-
 libs/framework/include/dm_component.h              |    57 +-
 libs/framework/include/dm_dependency_manager.h     |    18 +-
 libs/framework/include/dm_info.h                   |    76 -
 libs/framework/include/dm_service_dependency.h     |    36 +-
 libs/framework/include/framework.h                 |    20 +-
 .../include/{framework.h => framework.h.orig}      |    22 +-
 libs/framework/include/framework_event.h           |     1 +
 libs/framework/include/listener_hook_service.h     |     6 +-
 libs/framework/include/manifest.h                  |     4 +-
 libs/framework/include/module.h                    |    14 +-
 libs/framework/include/service_event.h             |    42 +-
 libs/framework/include/service_listener.h          |    28 +-
 libs/framework/include/service_reference.h         |    17 +-
 ...ervice_reference.h => service_reference.h.orig} |    17 +-
 libs/framework/include/service_registration.h      |     5 +-
 libs/framework/include/service_registry.h          |    42 +-
 libs/framework/include/service_tracker.h           |    27 +-
 .../framework/include/service_tracker_customizer.h |     7 +
 libs/framework/private/mock/bundle_cache_mock.c    |     2 +-
 libs/framework/private/mock/bundle_context_mock.c  |     7 +-
 .../private/mock/dm_dependency_manager_mock.c      |    24 +-
 libs/framework/private/mock/framework_mock.c       |    15 +-
 .../{framework_mock.c => framework_mock.c.orig}    |    16 +-
 libs/framework/private/mock/manifest_parser_mock.c |     9 +-
 libs/framework/private/mock/module_mock.c          |     7 +
 .../private/mock/service_registration_mock.c       |     9 +-
 .../framework/private/mock/service_tracker_stub.c  |     8 +-
 libs/framework/private/test/bundle_cache_test.cpp  |    10 +-
 .../framework/private/test/bundle_context_test.cpp |     4 +-
 libs/framework/private/test/bundle_test.cpp        |    51 -
 .../private/test/service_reference_test.cpp        |     1 +
 .../private/test/service_registration_test.cpp     |     9 +-
 .../private/test/service_registry_test.cpp         |     2 +-
 .../test/service_tracker_customizer_test.cpp       |     2 +-
 .../private/test/service_tracker_test.cpp          |    20 +-
 libs/framework/src/bundle.c                        |   128 +-
 libs/framework/src/bundle_cache.c                  |    67 +-
 libs/framework/src/bundle_cache.h                  |     3 +-
 libs/framework/src/bundle_cache_private.h          |     1 +
 libs/framework/src/bundle_context.c                |   175 +-
 .../{bundle_context.c => bundle_context.c.orig}    |   175 +-
 libs/framework/src/bundle_context_private.h        |     9 +-
 libs/framework/src/bundle_private.h                |     8 +-
 libs/framework/src/celix_launcher.c                |   187 +-
 libs/framework/src/dm_component_impl.c             |   444 +-
 libs/framework/src/dm_component_impl.h             |     6 +-
 libs/framework/src/dm_dependency_manager_impl.c    |   215 +-
 libs/framework/src/dm_dependency_manager_impl.h    |    21 +-
 libs/framework/src/dm_service_dependency.c         |   299 +-
 libs/framework/src/dm_service_dependency_impl.h    |    63 +-
 libs/framework/src/framework.c                     |  2321 ++-
 .../src/{framework.c => framework.c.orig}          |  1520 +-
 libs/framework/src/framework_private.h             |    64 +-
 ...ramework_private.h => framework_private.h.orig} |    63 +-
 libs/framework/src/manifest_parser.c               |    10 +
 libs/framework/src/manifest_parser.h               |     1 +
 libs/framework/src/module.c                        |    28 +-
 libs/framework/src/service_registry.c              |    35 +-
 libs/framework/src/service_tracker.c               |   874 +-
 libs/framework/src/service_tracker.c.orig          |   996 +
 libs/framework/src/service_tracker_customizer.c    |     2 +-
 .../src/service_tracker_customizer_private.h       |    49 -
 libs/framework/src/service_tracker_private.h       |    50 +-
 libs/framework/tst/CMakeLists.txt                  |     4 +-
 .../framework/tst/bundle_context_bundles_tests.cpp |    70 +-
 .../framework/tst/bundle_context_services_test.cpp |    16 +-
 .../CMakeLists.txt}                                |     4 +-
 libs/utils/CMakeLists.txt                          |     4 +
 libs/utils/include/array_list.h                    |    67 +-
 libs/utils/include/celix_array_list.h              |    33 +-
 libs/utils/include/celix_properties.h              |    25 +-
 libs/utils/include/celix_threads.h                 |     7 +
 libs/utils/include/celix_utils_api.h               |     5 +
 libs/utils/include/filter.h                        |     2 +-
 libs/utils/include/hash_map.h                      |     4 +-
 libs/utils/include/linked_list.h                   |    56 +-
 libs/utils/include/properties.h                    |    35 +-
 libs/utils/include/thpool.h                        |     4 +-
 libs/utils/private/test/array_list_test.cpp        |    32 +
 libs/utils/private/test/filter_test.cpp            |     2 +-
 libs/utils/private/test/properties_test.cpp        |   111 +
 libs/utils/src/array_list.c                        |   143 +-
 libs/utils/src/array_list_private.h                |     4 +-
 libs/utils/src/celix_threads.c                     |    34 +-
 libs/utils/src/filter.c                            |    83 +-
 libs/utils/src/hash_map.c                          |     2 +-
 libs/utils/src/properties.c                        |   139 +-
 Dockerfile.Android => misc/Dockerfile.Android      |     0
 {documents => misc}/roadmap/improvement_ideas.md   |     0
 {documents => misc}/roadmap/roadmap.md             |     0
 312 files changed, 38361 insertions(+), 19352 deletions(-)
 delete mode 100644 bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_admin_impl.c
 delete mode 100644 bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_admin_impl.h
 create mode 100644 bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_admin.c
 create mode 100644 bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_admin.h
 copy libs/framework/src/celix_framework_factory.c => bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_common.c (53%)
 copy libs/utils/src/version_private.h => bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_common.h (62%)
 create mode 100644 bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_receiver.c
 create mode 100644 bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_receiver.h
 create mode 100644 bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_sender.c
 create mode 100644 bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_sender.h
 delete mode 100644 bundles/pubsub/pubsub_admin_udp_mc/src/topic_publication.c
 delete mode 100644 bundles/pubsub/pubsub_admin_udp_mc/src/topic_publication.h
 delete mode 100644 bundles/pubsub/pubsub_admin_udp_mc/src/topic_subscription.c
 delete mode 100644 bundles/pubsub/pubsub_admin_udp_mc/src/topic_subscription.h
 delete mode 100644 bundles/pubsub/pubsub_admin_zmq/src/pubsub_admin_impl.c
 delete mode 100644 bundles/pubsub/pubsub_admin_zmq/src/pubsub_admin_impl.h
 create mode 100644 bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c
 create mode 100644 bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.h
 create mode 100644 bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_common.c
 create mode 100644 bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_common.h
 create mode 100644 bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.c
 create mode 100644 bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_receiver.h
 create mode 100644 bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_sender.c
 create mode 100644 bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_topic_sender.h
 delete mode 100644 bundles/pubsub/pubsub_admin_zmq/src/topic_publication.c
 delete mode 100644 bundles/pubsub/pubsub_admin_zmq/src/topic_publication.h
 delete mode 100644 bundles/pubsub/pubsub_admin_zmq/src/topic_subscription.c
 delete mode 100644 bundles/pubsub/pubsub_admin_zmq/src/topic_subscription.h
 delete mode 100644 bundles/pubsub/pubsub_discovery/src/etcd_common.c
 delete mode 100644 bundles/pubsub/pubsub_discovery/src/etcd_common.h
 delete mode 100644 bundles/pubsub/pubsub_discovery/src/etcd_watcher.c
 delete mode 100644 bundles/pubsub/pubsub_discovery/src/etcd_watcher.h
 delete mode 100644 bundles/pubsub/pubsub_discovery/src/etcd_writer.c
 delete mode 100644 bundles/pubsub/pubsub_discovery/src/etcd_writer.h
 delete mode 100644 bundles/pubsub/pubsub_serializer_json/src/ps_activator.c
 create mode 100644 bundles/pubsub/pubsub_serializer_json/src/ps_json_serializer_activator.c
 delete mode 100644 bundles/pubsub/pubsub_spi/include/publisher_endpoint_announce.h
 delete mode 100644 bundles/pubsub/pubsub_spi/include/pubsub_admin_match.h
 create mode 100644 bundles/pubsub/pubsub_spi/include/pubsub_listeners.h
 delete mode 100644 bundles/pubsub/pubsub_spi/src/pubsub_admin_match.c
 create mode 100644 bundles/pubsub/pubsub_spi/src/pubsub_utils_match.c
 create mode 100644 cmake/cmake_celix/OCIPacking.cmake
 rename {bundles => documents/bundles}/log_service/README.md (100%)
 rename {bundles => documents/bundles}/log_writer/README.md (100%)
 rename {bundles => documents/bundles}/remote_services/README.md (92%)
 rename {bundles => documents/bundles}/remote_services/discovery_etcd/README.md (100%)
 rename {bundles/shell => documents/bundles}/remote_shell/README.md (100%)
 rename {bundles/shell => documents/bundles}/shell/README.md (100%)
 rename {bundles/shell => documents/bundles}/shell_tui/README.md (100%)
 rename documents/getting_started/{using_services_with_c.md => services_with_c/readme.md} (100%)
 rename documents/getting_started/{using_services_with_cxx.md => services_with_cxx/readme.md} (100%)
 rename documents/getting_started/{creating_a_simple_bundle.md => simple_bundle/readme.md} (100%)
 delete mode 100644 documents/roadmap/api_v3/celix/celix.h
 delete mode 100644 documents/roadmap/api_v3/readme.md
 copy examples/celix-examples/{bundle_example_c => civetweb}/CMakeLists.txt (65%)
 create mode 100644 examples/celix-examples/civetweb/civetweb/civetweb.c
 create mode 100644 examples/celix-examples/civetweb/civetweb/civetweb.h
 create mode 100644 examples/celix-examples/civetweb/civetweb/handle_form.inl
 create mode 100644 examples/celix-examples/civetweb/civetweb/md5.inl
 create mode 100644 examples/celix-examples/civetweb/civetweb/sha1.inl
 create mode 100644 examples/celix-examples/civetweb/civetweb/timer.inl
 rename examples/celix-examples/{mongoose/root => civetweb/resources}/index.html (65%)
 copy examples/celix-examples/{bundle_example_cxx/src/BundleActivator.cc => civetweb/resources/script.js} (50%)
 create mode 100644 examples/celix-examples/civetweb/src/bundle_activator.c
 copy examples/celix-examples/dm_example_cxx/phase1/src/{Phase1Activator.cc => Phase1Activator.cc.orig} (59%)
 copy examples/celix-examples/dm_example_cxx/phase1/src/{Phase1Activator.h => Phase1Activator.h.orig} (67%)
 delete mode 100644 examples/celix-examples/mongoose/CMakeLists.txt
 delete mode 100644 examples/celix-examples/mongoose/private/include/mongoose.h
 delete mode 100644 examples/celix-examples/mongoose/private/src/activator.c
 delete mode 100644 examples/celix-examples/mongoose/private/src/mongoose.c
 copy libs/framework/include/{bundle_context.h => bundle_context.h.orig} (55%)
 copy libs/framework/include/celix/dm/{DependencyManager.h => DependencyManager.h.orig} (80%)
 copy libs/framework/include/{celix_bundle_context.h => celix_bundle_context.h.orig} (87%)
 create mode 100644 libs/framework/include/celix_dependency_manager.h
 copy libs/framework/include/{dm_component.h => celix_dm_component.h} (54%)
 create mode 100644 libs/framework/include/celix_dm_info.h
 create mode 100644 libs/framework/include/celix_dm_service_dependency.h
 copy libs/framework/include/{service_event.h => celix_service_event.h} (63%)
 copy examples/celix-examples/services_example_cxx/api/calc.h => libs/framework/include/celix_service_listener.h (73%)
 create mode 100644 libs/framework/include/constants.h.orig
 delete mode 100644 libs/framework/include/dm_info.h
 copy libs/framework/include/{framework.h => framework.h.orig} (68%)
 copy libs/framework/include/{service_reference.h => service_reference.h.orig} (88%)
 copy libs/framework/private/mock/{framework_mock.c => framework_mock.c.orig} (95%)
 rename bundles/pubsub/pubsub_discovery/src/pubsub_discovery.h => libs/framework/private/mock/service_tracker_stub.c (84%)
 copy libs/framework/src/{bundle_context.c => bundle_context.c.orig} (85%)
 copy libs/framework/src/{framework.c => framework.c.orig} (68%)
 copy libs/framework/src/{framework_private.h => framework_private.h.orig} (80%)
 create mode 100644 libs/framework/src/service_tracker.c.orig
 delete mode 100644 libs/framework/src/service_tracker_customizer_private.h
 copy libs/framework/tst/{config.properties.in => subdir/CMakeLists.txt} (85%)
 rename Dockerfile.Android => misc/Dockerfile.Android (100%)
 rename {documents => misc}/roadmap/improvement_ideas.md (100%)
 rename {documents => misc}/roadmap/roadmap.md (100%)


[celix] 01/01: Merge branch 'develop' into feature/CELIX-426-cxx-api

Posted by pn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch feature/CELIX-426-cxx-api
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 287afbef21be5c371ba43243e6b35debaca7e134
Merge: b4ce49f 392f12e
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Tue Dec 11 22:01:44 2018 +0100

    Merge branch 'develop' into feature/CELIX-426-cxx-api

 .travis.yml                                        |     2 +-
 CMakeLists.txt                                     |     4 +-
 bundles/config_admin/service/CMakeLists.txt        |     1 +
 bundles/deployment_admin/CMakeLists.txt            |     1 +
 bundles/device_access/device_access/CMakeLists.txt |     1 +
 .../device_access/driver_locator/CMakeLists.txt    |     1 +
 .../example/refining_driver/src/refining_driver.c  |     8 +-
 bundles/event_admin/event_admin/CMakeLists.txt     |     1 +
 .../event_admin/private/include/event_admin_impl.h |     2 +-
 bundles/event_admin/event_handler/CMakeLists.txt   |     1 +
 .../private/include/event_handler_impl.h           |     2 +-
 bundles/event_admin/event_publisher/CMakeLists.txt |     1 +
 .../private/include/event_publisher_impl.h         |     2 +-
 bundles/log_service/CMakeLists.txt                 |     1 +
 bundles/log_service/loghelper_include/log_helper.h |     2 +-
 bundles/log_service/src/log_helper.c               |    21 +-
 .../log_writer/log_writer_stdout/CMakeLists.txt    |     1 +
 .../log_writer/log_writer_syslog/CMakeLists.txt    |     3 +-
 bundles/pubsub/examples/CMakeLists.txt             |   145 +-
 .../pubsub/msg_descriptors/poi1.properties         |     3 +
 .../pubsub/msg_descriptors/poi2.properties         |     3 +
 .../private/include/pubsub_publisher_private.h     |    13 +-
 .../publisher/private/src/ps_pub_activator.c       |   108 +-
 .../publisher/private/src/pubsub_publisher.c       |    14 +-
 bundles/pubsub/pubsub_admin_udp_mc/CMakeLists.txt  |     8 +-
 bundles/pubsub/pubsub_admin_udp_mc/src/large_udp.c |     2 +-
 .../pubsub/pubsub_admin_udp_mc/src/psa_activator.c |   169 +-
 .../pubsub_admin_udp_mc/src/pubsub_admin_impl.c    |  1160 --
 .../pubsub_admin_udp_mc/src/pubsub_admin_impl.h    |    97 -
 .../pubsub_admin_udp_mc/src/pubsub_udpmc_admin.c   |   684 +
 .../pubsub_admin_udp_mc/src/pubsub_udpmc_admin.h   |    62 +
 .../pubsub_admin_udp_mc/src/pubsub_udpmc_common.c  |    33 +-
 .../pubsub_admin_udp_mc/src/pubsub_udpmc_common.h  |    31 +-
 .../src/pubsub_udpmc_topic_receiver.c              |   427 +
 .../src/pubsub_udpmc_topic_receiver.h              |    47 +
 .../src/pubsub_udpmc_topic_sender.c                |   341 +
 .../src/pubsub_udpmc_topic_sender.h                |    49 +
 .../pubsub_admin_udp_mc/src/topic_publication.c    |   453 -
 .../pubsub_admin_udp_mc/src/topic_publication.h    |    57 -
 .../pubsub_admin_udp_mc/src/topic_subscription.c   |   635 -
 .../pubsub_admin_udp_mc/src/topic_subscription.h   |    60 -
 bundles/pubsub/pubsub_admin_zmq/CMakeLists.txt     |    14 +-
 .../pubsub/pubsub_admin_zmq/src/psa_activator.c    |   215 +-
 .../pubsub_admin_zmq/src/pubsub_admin_impl.c       |  1183 --
 .../pubsub_admin_zmq/src/pubsub_admin_impl.h       |   113 -
 .../src/pubsub_psa_zmq_constants.h                 |     2 +
 .../pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c |   706 +
 .../pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.h |    62 +
 .../pubsub_admin_zmq/src/pubsub_zmq_common.c       |    55 +
 .../pubsub_admin_zmq/src/pubsub_zmq_common.h       |    56 +
 .../src/pubsub_zmq_topic_receiver.c                |   464 +
 .../src/pubsub_zmq_topic_receiver.h                |    43 +
 .../pubsub_admin_zmq/src/pubsub_zmq_topic_sender.c |   406 +
 .../pubsub_admin_zmq/src/pubsub_zmq_topic_sender.h |    47 +
 .../pubsub_admin_zmq/src/topic_publication.c       |   640 -
 .../pubsub_admin_zmq/src/topic_publication.h       |    49 -
 .../pubsub_admin_zmq/src/topic_subscription.c      |   761 -
 .../pubsub_admin_zmq/src/topic_subscription.h      |    60 -
 bundles/pubsub/pubsub_discovery/CMakeLists.txt     |     9 +-
 bundles/pubsub/pubsub_discovery/src/etcd_common.c  |    82 -
 bundles/pubsub/pubsub_discovery/src/etcd_watcher.c |   322 -
 bundles/pubsub/pubsub_discovery/src/etcd_watcher.h |    38 -
 bundles/pubsub/pubsub_discovery/src/etcd_writer.c  |   217 -
 bundles/pubsub/pubsub_discovery/src/etcd_writer.h  |    39 -
 .../pubsub/pubsub_discovery/src/psd_activator.c    |   172 +-
 .../pubsub_discovery/src/pubsub_discovery_impl.c   |   840 +-
 .../pubsub_discovery/src/pubsub_discovery_impl.h   |    84 +-
 .../pubsub/pubsub_serializer_json/CMakeLists.txt   |     3 +-
 .../pubsub_serializer_json/src/ps_activator.c      |   108 -
 .../src/ps_json_serializer_activator.c             |    59 +
 .../src/pubsub_serializer_impl.h                   |     9 +-
 bundles/pubsub/pubsub_spi/CMakeLists.txt           |     2 +-
 .../include/publisher_endpoint_announce.h          |    40 -
 bundles/pubsub/pubsub_spi/include/pubsub_admin.h   |    53 +-
 .../pubsub/pubsub_spi/include/pubsub_admin_match.h |    47 -
 bundles/pubsub/pubsub_spi/include/pubsub_common.h  |    25 +-
 .../pubsub/pubsub_spi/include/pubsub_constants.h   |    19 +-
 .../pubsub/pubsub_spi/include/pubsub_endpoint.h    |    51 +-
 .../pubsub/pubsub_spi/include/pubsub_listeners.h   |    50 +
 .../pubsub/pubsub_spi/include/pubsub_serializer.h  |    18 +-
 bundles/pubsub/pubsub_spi/include/pubsub_utils.h   |    44 +-
 bundles/pubsub/pubsub_spi/src/pubsub_admin_match.c |   169 -
 bundles/pubsub/pubsub_spi/src/pubsub_endpoint.c    |   382 +-
 bundles/pubsub/pubsub_spi/src/pubsub_utils.c       |    40 +-
 bundles/pubsub/pubsub_spi/src/pubsub_utils_match.c |   226 +
 .../pubsub/pubsub_topology_manager/CMakeLists.txt  |     1 +
 .../pubsub_topology_manager/src/pstm_activator.c   |   259 +-
 .../src/pubsub_topology_manager.c                  |  1383 +-
 .../src/pubsub_topology_manager.h                  |   112 +-
 .../discovery_common/src/discovery.c               |     2 +
 .../discovery_common/src/discovery_activator.c     |     2 +-
 .../remote_services/discovery_etcd/CMakeLists.txt  |     1 +
 .../discovery_etcd/src/etcd_watcher.c              |     4 +-
 .../remote_services/discovery_shm/CMakeLists.txt   |     1 +
 .../remote_service_admin_dfi/CMakeLists.txt        |     1 +
 .../remote_service_admin_shm/CMakeLists.txt        |     1 +
 .../topology_manager/CMakeLists.txt                |     1 +
 .../topology_manager/src/activator.c               |     6 +-
 .../remote_services/topology_manager/src/scope.c   |     9 +-
 .../topology_manager/src/topology_manager.c        |     4 +-
 .../topology_manager/src/topology_manager.h        |     2 +-
 bundles/shell/remote_shell/CMakeLists.txt          |     3 +-
 bundles/shell/shell/CMakeLists.txt                 |     1 +
 bundles/shell/shell/include/shell.h                |     2 +-
 bundles/shell/shell/src/activator.c                |     8 +-
 bundles/shell/shell/src/dm_shell_list_command.c    |   114 +-
 bundles/shell/shell/src/lb_command.c               |   345 +-
 bundles/shell/shell/src/std_commands.h             |     2 +-
 bundles/shell/shell_bonjour/CMakeLists.txt         |     1 +
 .../shell_bonjour/private/src/bonjour_shell.c      |     2 +-
 bundles/shell/shell_tui/CMakeLists.txt             |     1 +
 cmake/celix_project/AddGTest.cmake                 |     4 +-
 cmake/cmake_celix/BundlePackaging.cmake            |   164 +-
 cmake/cmake_celix/ContainerPackaging.cmake         |   193 +-
 cmake/cmake_celix/DockerPackaging.cmake            |    27 +-
 cmake/cmake_celix/Manifest.template.in             |     1 +
 cmake/cmake_celix/OCIPacking.cmake                 |   156 +
 cmake/cmake_celix/Runtimes.cmake                   |   112 +-
 cmake/cmake_celix/runtime_common.sh.in             |    41 +-
 doap/doap_Celix.rdf                                |    13 +-
 .../bundles}/log_service/README.md                 |     0
 .../bundles}/log_writer/README.md                  |     0
 .../bundles}/remote_services/README.md             |    10 +
 .../remote_services/discovery_etcd/README.md       |     0
 .../bundles}/remote_shell/README.md                |     0
 .../shell => documents/bundles}/shell/README.md    |     0
 .../bundles}/shell_tui/README.md                   |     0
 documents/cmake_commands/readme.md                 |    15 +-
 documents/getting_started/readme.md                |     6 +-
 .../readme.md}                                     |     0
 .../readme.md}                                     |     0
 .../readme.md}                                     |     0
 documents/roadmap/api_v3/celix/celix.h             |  1896 --
 documents/roadmap/api_v3/readme.md                 |   283 -
 documents/subprojects/readme.md                    |    37 +-
 examples/celix-examples/CMakeLists.txt             |     4 +-
 .../bar/private/src/bar_activator.c                |    13 +-
 .../foo1/private/src/foo1_activator.c              |    28 +-
 .../foo2/private/src/foo2.c                        |     2 +-
 .../foo2/private/src/foo2_activator.c              |    30 +-
 .../celix-examples/civetweb}/CMakeLists.txt        |    35 +-
 .../celix-examples/civetweb/civetweb/civetweb.c    | 19792 +++++++++++++++++++
 .../celix-examples/civetweb/civetweb/civetweb.h    |  1498 ++
 .../civetweb/civetweb/handle_form.inl              |   981 +
 examples/celix-examples/civetweb/civetweb/md5.inl  |   471 +
 examples/celix-examples/civetweb/civetweb/sha1.inl |   323 +
 .../celix-examples/civetweb/civetweb/timer.inl     |   246 +
 .../root => civetweb/resources}/index.html         |    22 +-
 .../celix-examples/civetweb/resources/script.js    |    44 +
 .../celix-examples/civetweb/src/bundle_activator.c |   111 +
 examples/celix-examples/dm_example/CMakeLists.txt  |     5 +-
 .../dm_example/phase1/CMakeLists.txt               |    11 -
 .../dm_example/phase1/src/phase1_activator.c       |    47 +-
 .../dm_example/phase1/src/phase1_cmp.c             |     6 +-
 .../dm_example/phase1/src/phase1_cmp.h             |     2 +-
 .../dm_example/phase2a/CMakeLists.txt              |    11 -
 .../dm_example/phase2a/src/phase2a_activator.c     |    59 +-
 .../dm_example/phase2b/CMakeLists.txt              |    11 -
 .../dm_example/phase2b/src/phase2b_activator.c     |    60 +-
 .../dm_example/phase3/CMakeLists.txt               |    11 -
 .../dm_example/phase3/src/phase3_activator.c       |    62 +-
 .../dm_example/phase3/src/phase3_cmp.c             |     2 +-
 .../celix-examples/dm_example_cxx/CMakeLists.txt   |     2 +
 .../dm_example_cxx/phase1/src/Phase1Activator.cc   |    54 +-
 ...{Phase1Activator.cc => Phase1Activator.cc.orig} |    49 +
 .../dm_example_cxx/phase1/src/Phase1Activator.h    |    18 +-
 .../{Phase1Activator.h => Phase1Activator.h.orig}  |    19 +
 .../celix-examples/embedding/private/src/main.c    |     8 +-
 .../hello_world/private/src/activator.c            |     8 +-
 .../hello_world_test/private/src/activator.c       |     8 +-
 .../log_service_example/src/activator.c            |     8 +-
 examples/celix-examples/mongoose/CMakeLists.txt    |    42 -
 .../mongoose/private/include/mongoose.h            |   218 -
 .../mongoose/private/src/activator.c               |    79 -
 .../celix-examples/mongoose/private/src/mongoose.c |  4076 ----
 .../service_hook_example/src/activator.c           |    12 +-
 .../src/dynamic_provider_example.c                 |     2 +-
 .../shell_command_example/src/activator.c          |     4 +-
 libs/dependency_manager/src/dm_activator.c         |    10 +-
 libs/dependency_manager_cxx/src/dm_activator.cc    |    24 +-
 libs/etcdlib/api/etcd.h                            |    16 +-
 libs/etcdlib/src/etcd.c                            |   115 +-
 libs/etcdlib/test/etcdlib_test.c                   |    35 +-
 libs/framework/CMakeLists.txt                      |     1 +
 .../framework/gtest/src/cxx_BundleContext_tests.cc |     7 +-
 libs/framework/gtest/src/cxx_Bundle_tests.cc       |     3 +-
 libs/framework/include/bundle.h                    |    86 +-
 libs/framework/include/bundle_activator.h          |    16 +-
 libs/framework/include/bundle_context.h            |   248 +-
 .../{bundle_context.h => bundle_context.h.orig}    |   129 +-
 libs/framework/include/bundle_revision.h           |     4 +-
 libs/framework/include/celix/BundleActivator.h     |    10 +-
 libs/framework/include/celix/BundleContext.h       |     2 +-
 libs/framework/include/celix/Constants.h           |     4 +-
 libs/framework/include/celix/dm/Component.h        |    37 +-
 libs/framework/include/celix/dm/Component_Impl.h   |    43 +-
 .../framework/include/celix/dm/DependencyManager.h |    73 +-
 ...ependencyManager.h => DependencyManager.h.orig} |    37 +-
 libs/framework/include/celix/dm/DmActivator.h      |    14 +-
 .../framework/include/celix/dm/ServiceDependency.h |    16 +-
 .../include/celix/dm/ServiceDependency_Impl.h      |    88 +-
 .../include/celix/impl/BundleContextImpl.h         |    18 +-
 libs/framework/include/celix/impl/FrameworkImpl.h  |     8 +-
 libs/framework/include/celix_api.h                 |    27 +-
 libs/framework/include/celix_bundle.h              |     8 +-
 libs/framework/include/celix_bundle_context.h      |    94 +-
 ...undle_context.h => celix_bundle_context.h.orig} |    97 +-
 libs/framework/include/celix_constants.h           |    46 +-
 libs/framework/include/celix_dependency_manager.h  |    86 +
 .../{dm_component.h => celix_dm_component.h}       |    68 +-
 libs/framework/include/celix_dm_info.h             |    76 +
 .../include/celix_dm_service_dependency.h          |   169 +
 libs/framework/include/celix_framework.h           |     1 -
 libs/framework/include/celix_framework_factory.h   |     2 +-
 libs/framework/include/celix_launcher.h            |    14 +-
 .../{service_event.h => celix_service_event.h}     |    49 +-
 .../framework/include/celix_service_listener.h     |    26 +-
 libs/framework/include/celix_types.h               |    51 +-
 libs/framework/include/constants.h                 |    14 +-
 libs/framework/include/constants.h.orig            |    95 +
 libs/framework/include/dm_activator.h              |    12 +-
 libs/framework/include/dm_component.h              |    57 +-
 libs/framework/include/dm_dependency_manager.h     |    18 +-
 libs/framework/include/dm_info.h                   |    76 -
 libs/framework/include/dm_service_dependency.h     |    36 +-
 libs/framework/include/framework.h                 |    20 +-
 .../include/{framework.h => framework.h.orig}      |    22 +-
 libs/framework/include/framework_event.h           |     1 +
 libs/framework/include/listener_hook_service.h     |     6 +-
 libs/framework/include/manifest.h                  |     4 +-
 libs/framework/include/module.h                    |    14 +-
 libs/framework/include/service_event.h             |    42 +-
 libs/framework/include/service_listener.h          |    28 +-
 libs/framework/include/service_reference.h         |    17 +-
 ...ervice_reference.h => service_reference.h.orig} |    17 +-
 libs/framework/include/service_registration.h      |     5 +-
 libs/framework/include/service_registry.h          |    42 +-
 libs/framework/include/service_tracker.h           |    27 +-
 .../framework/include/service_tracker_customizer.h |     7 +
 libs/framework/private/mock/bundle_cache_mock.c    |     2 +-
 libs/framework/private/mock/bundle_context_mock.c  |     7 +-
 .../private/mock/dm_dependency_manager_mock.c      |    24 +-
 libs/framework/private/mock/framework_mock.c       |    15 +-
 .../{framework_mock.c => framework_mock.c.orig}    |    16 +-
 libs/framework/private/mock/manifest_parser_mock.c |     9 +-
 libs/framework/private/mock/module_mock.c          |     7 +
 .../private/mock/service_registration_mock.c       |     9 +-
 .../framework/private/mock/service_tracker_stub.c  |     8 +-
 libs/framework/private/test/bundle_cache_test.cpp  |    10 +-
 .../framework/private/test/bundle_context_test.cpp |     4 +-
 libs/framework/private/test/bundle_test.cpp        |    51 -
 .../private/test/service_reference_test.cpp        |     1 +
 .../private/test/service_registration_test.cpp     |     9 +-
 .../private/test/service_registry_test.cpp         |     2 +-
 .../test/service_tracker_customizer_test.cpp       |     2 +-
 .../private/test/service_tracker_test.cpp          |    20 +-
 libs/framework/src/bundle.c                        |   128 +-
 libs/framework/src/bundle_cache.c                  |    67 +-
 libs/framework/src/bundle_cache.h                  |     3 +-
 libs/framework/src/bundle_cache_private.h          |     1 +
 libs/framework/src/bundle_context.c                |   175 +-
 .../{bundle_context.c => bundle_context.c.orig}    |   175 +-
 libs/framework/src/bundle_context_private.h        |     9 +-
 libs/framework/src/bundle_private.h                |     8 +-
 libs/framework/src/celix_launcher.c                |   187 +-
 libs/framework/src/dm_component_impl.c             |   444 +-
 libs/framework/src/dm_component_impl.h             |     6 +-
 libs/framework/src/dm_dependency_manager_impl.c    |   215 +-
 libs/framework/src/dm_dependency_manager_impl.h    |    21 +-
 libs/framework/src/dm_service_dependency.c         |   299 +-
 libs/framework/src/dm_service_dependency_impl.h    |    63 +-
 libs/framework/src/framework.c                     |  2321 ++-
 .../src/{framework.c => framework.c.orig}          |  1520 +-
 libs/framework/src/framework_private.h             |    64 +-
 ...ramework_private.h => framework_private.h.orig} |    63 +-
 libs/framework/src/manifest_parser.c               |    10 +
 libs/framework/src/manifest_parser.h               |     1 +
 libs/framework/src/module.c                        |    28 +-
 libs/framework/src/service_registry.c              |    35 +-
 libs/framework/src/service_tracker.c               |   874 +-
 libs/framework/src/service_tracker.c.orig          |   996 +
 libs/framework/src/service_tracker_customizer.c    |     2 +-
 .../src/service_tracker_customizer_private.h       |    49 -
 libs/framework/src/service_tracker_private.h       |    50 +-
 libs/framework/tst/CMakeLists.txt                  |     4 +-
 .../framework/tst/bundle_context_bundles_tests.cpp |    70 +-
 .../framework/tst/bundle_context_services_test.cpp |    16 +-
 .../framework/tst/subdir/CMakeLists.txt            |    23 +-
 libs/utils/CMakeLists.txt                          |     4 +
 libs/utils/include/array_list.h                    |    67 +-
 libs/utils/include/celix_array_list.h              |    33 +-
 libs/utils/include/celix_properties.h              |    25 +-
 libs/utils/include/celix_threads.h                 |     7 +
 libs/utils/include/celix_utils_api.h               |     5 +
 libs/utils/include/filter.h                        |     2 +-
 libs/utils/include/hash_map.h                      |     4 +-
 libs/utils/include/linked_list.h                   |    56 +-
 libs/utils/include/properties.h                    |    35 +-
 libs/utils/include/thpool.h                        |     4 +-
 libs/utils/private/test/array_list_test.cpp        |    32 +
 libs/utils/private/test/filter_test.cpp            |     2 +-
 libs/utils/private/test/properties_test.cpp        |   111 +
 libs/utils/src/array_list.c                        |   143 +-
 libs/utils/src/array_list_private.h                |     4 +-
 libs/utils/src/celix_threads.c                     |    34 +-
 libs/utils/src/filter.c                            |    83 +-
 libs/utils/src/hash_map.c                          |     2 +-
 libs/utils/src/properties.c                        |   139 +-
 Dockerfile.Android => misc/Dockerfile.Android      |     0
 {documents => misc}/roadmap/improvement_ideas.md   |     0
 {documents => misc}/roadmap/roadmap.md             |     0
 311 files changed, 38405 insertions(+), 19328 deletions(-)

diff --cc cmake/celix_project/AddGTest.cmake
index 5573c7e,0000000..2b91c54
mode 100644,000000..100644
--- a/cmake/celix_project/AddGTest.cmake
+++ b/cmake/celix_project/AddGTest.cmake
@@@ -1,43 -1,0 +1,43 @@@
 +# 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(ExternalProject)
 +ExternalProject_Add(
 +        googletest_project
 +        GIT_REPOSITORY https://github.com/google/googletest.git
 +        GIT_TAG master
 +        PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gtest
 +        INSTALL_COMMAND ""
 +)
 +
 +ExternalProject_Get_Property(googletest_project source_dir binary_dir)
 +
 +file(MAKE_DIRECTORY ${source_dir}/googletest/include)
 +add_library(gtest IMPORTED STATIC GLOBAL)
 +add_dependencies(gtest googletest_project)
 +set_target_properties(gtest PROPERTIES
-         IMPORTED_LOCATION "${binary_dir}/googlemock/gtest/libgtest.a"
++        IMPORTED_LOCATION "${binary_dir}/lib/libgtest.a"
 +        INTERFACE_INCLUDE_DIRECTORIES "${source_dir}/googletest/include"
 +)
 +
 +file(MAKE_DIRECTORY ${source_dir}/googlemock/include)
 +add_library(gmock IMPORTED STATIC GLOBAL)
 +add_dependencies(gmock googletest_project)
 +set_target_properties(gmock PROPERTIES
-         IMPORTED_LOCATION "${binary_dir}/googlemock/libgmock.a"
++        IMPORTED_LOCATION "${binary_dir}/lib/libgmock.a"
 +        INTERFACE_INCLUDE_DIRECTORIES "${source_dir}/googlemock/include"
 +)
diff --cc examples/celix-examples/CMakeLists.txt
index 7edfd30,15a6361..9421e4b
--- a/examples/celix-examples/CMakeLists.txt
+++ b/examples/celix-examples/CMakeLists.txt
@@@ -21,10 -21,16 +21,12 @@@ else (
      set(EXAMPLES true) #celix_subproject is only available in the celix project -> using examples dir in other project is also supported
  endif ()
  if (EXAMPLES)
+     add_definitions(-DADD_CELIX_DEPRECATED_WARNING) #ensure that no deprecated api is used in the examples
+ 
      add_subdirectory(bundle_example_c)
 -
 -    add_subdirectory(hello_world)
 -    add_subdirectory(hello_world_test)
 +    add_subdirectory(bundle_example_cxx)
  
      add_subdirectory(services_example_c)
 -
 -    add_subdirectory(best_practice_example_c)
      add_subdirectory(services_example_cxx)
  
      add_subdirectory(dm_example)
diff --cc examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
index aa33f22,c4895e4..e03d926
--- a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
+++ b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
@@@ -17,6 -17,6 +17,7 @@@
   * under the License.
   */
  
++#include "celix/BundleActivator.h"
  #include "Phase1Cmp.h"
  #include "Phase1Activator.h"
  #include "IPhase2.h"
@@@ -36,39 -40,60 +37,70 @@@ struct InvalidCServ 
      virtual void baz(double __attribute__((unused)) arg) {} //not a valid pod
  };
  
- CELIX_GEN_CXX_BUNDLE_ACTIVATOR(Phase1Activator)
 -void Phase1Activator::init() {
 -    auto cmp = std::shared_ptr<Phase1Cmp>(new Phase1Cmp());
++CELIX_GEN_CXX_BUNDLE_ACTIVATOR(Phase1Activator);
 +
 +celix_status_t Phase1Activator::start(celix::BundleContext& ctx) {
 +    auto &mng = ctx.getDependencyManager();
 +    auto cmp = std::unique_ptr<Phase1Cmp>(new Phase1Cmp());
  
 -    Properties cmdProps;
 +    celix::Properties cmdProps;
      cmdProps[OSGI_SHELL_COMMAND_NAME] = "phase1_info";
      cmdProps[OSGI_SHELL_COMMAND_USAGE] = "phase1_info";
      cmdProps[OSGI_SHELL_COMMAND_DESCRIPTION] = "Print information about the Phase1Cmp";
  
  
 -    cmd.handle = cmp.get();
 -    cmd.executeCommand = [](void *handle, char* line, FILE* out, FILE *err) {
 -        Phase1Cmp* cmp = (Phase1Cmp*)handle;
 -        return cmp->infoCmd(line, out, err);
 +    this->cmd.handle = cmp.get();
 +    this->cmd.executeCommand = [](void *handle, char* line, FILE* out, FILE *err) {
 +        Phase1Cmp* c = (Phase1Cmp*)handle;
 +        return c->infoCmd(line, out, err);
      };
  
-     //auto tst = std::unique_ptr<InvalidCServ>(new InvalidCServ{});
-     //tst->handle = cmp.get();
+     Properties addProps;
+     addProps[OSGI_SHELL_COMMAND_NAME] = "add";
+     addProps[OSGI_SHELL_COMMAND_USAGE] = "add";
+     addProps[OSGI_SHELL_COMMAND_DESCRIPTION] = "add dummy service";
+ 
+ 
+     addCmd.handle = this;
+     addCmd.executeCommand = [](void *handle, char* /*line*/, FILE* out, FILE */*err*/) {
+         Phase1Activator* act = (Phase1Activator*)handle;
+         fprintf(out, "Adding dummy interface");
+         act->phase1cmp->addCInterface(act->dummySvc, "DUMMY_SERVICE");
+         return 0;
+     };
+ 
+     Properties removeProps;
+     removeProps[OSGI_SHELL_COMMAND_NAME] = "remove";
+     removeProps[OSGI_SHELL_COMMAND_USAGE] = "remove";
+     removeProps[OSGI_SHELL_COMMAND_DESCRIPTION] = "remove dummy service";
+ 
+ 
+     removeCmd.handle = this;
+     removeCmd.executeCommand = [](void *handle, char* /*line*/, FILE* out, FILE */*err*/) {
+         Phase1Activator* act = (Phase1Activator*)handle;
+         fprintf(out, "Removing dummy interface");
+         act->phase1cmp->removeCInterface(act->dummySvc);
+         return 0;
+     };
+ 
+     auto tst = std::unique_ptr<InvalidCServ>(new InvalidCServ{});
+     tst->handle = cmp.get();
+ 
  
 -    phase1cmp = &mng.createComponent(cmp)  //using a pointer a instance. Also supported is lazy initialization (default constructor needed) or a rvalue reference (move)
++    phase1cmp = &mng.createComponent(std::move(cmp))  //using a pointer a instance. Also supported is lazy initialization (default constructor needed) or a rvalue reference (move)
+         .addInterface<IPhase1>(IPHASE1_VERSION)
+         //.addInterface<IPhase2>() -> Compile error (static assert), because Phase1Cmp does not implement IPhase2
+         .addCInterface(&cmd, OSGI_SHELL_COMMAND_SERVICE_NAME, "", cmdProps)
+         .addCInterface(&addCmd, OSGI_SHELL_COMMAND_SERVICE_NAME, "", addProps)
+         .addCInterface(&removeCmd, OSGI_SHELL_COMMAND_SERVICE_NAME, "", removeProps)
+         //.addCInterface(tst.get(), "TEST_SRV") -> Compile error (static assert), because InvalidCServ is not a pod
+         .addInterface<srv::info::IName>(INAME_VERSION)
+         .setCallbacks(&Phase1Cmp::init, &Phase1Cmp::start, &Phase1Cmp::stop, &Phase1Cmp::deinit);
 +
-     mng.createComponent(std::move(cmp))  //using a pointer a instance. Also supported is lazy initialization (default constructor needed) or a rvalue reference (move)
-                     .addInterface<IPhase1>(IPHASE1_VERSION)
-                      //.addInterface<IPhase2>() -> Compile error (static assert), because Phase1Cmp does not implement IPhase2
-                     .addCInterface(&cmd, OSGI_SHELL_COMMAND_SERVICE_NAME, "", cmdProps)
-                     //.addCInterface(tst.get(), "TEST_SRV") -> Compile error (static assert), because InvalidCServ is not a pod
-                     .addInterface<srv::info::IName>(INAME_VERSION)
-                     .setCallbacks(&Phase1Cmp::init, &Phase1Cmp::start, &Phase1Cmp::stop, &Phase1Cmp::deinit);
 +    return CELIX_SUCCESS;
 +}
 +
 +celix_status_t Phase1Activator::stop(celix::BundleContext &) {
 +    //nothing to do
 +    return CELIX_SUCCESS;
  }
diff --cc examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc.orig
index aa33f22,c4895e4..37f856d
--- a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc.orig
+++ b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc.orig
@@@ -36,39 -40,60 +36,88 @@@ struct InvalidCServ 
      virtual void baz(double __attribute__((unused)) arg) {} //not a valid pod
  };
  
++<<<<<<< HEAD
 +CELIX_GEN_CXX_BUNDLE_ACTIVATOR(Phase1Activator)
 +
 +celix_status_t Phase1Activator::start(celix::BundleContext& ctx) {
 +    auto &mng = ctx.getDependencyManager();
 +    auto cmp = std::unique_ptr<Phase1Cmp>(new Phase1Cmp());
++=======
+ void Phase1Activator::init() {
+     auto cmp = std::shared_ptr<Phase1Cmp>(new Phase1Cmp());
++>>>>>>> develop
  
 -    Properties cmdProps;
 +    celix::Properties cmdProps;
      cmdProps[OSGI_SHELL_COMMAND_NAME] = "phase1_info";
      cmdProps[OSGI_SHELL_COMMAND_USAGE] = "phase1_info";
      cmdProps[OSGI_SHELL_COMMAND_DESCRIPTION] = "Print information about the Phase1Cmp";
  
  
 -    cmd.handle = cmp.get();
 -    cmd.executeCommand = [](void *handle, char* line, FILE* out, FILE *err) {
 -        Phase1Cmp* cmp = (Phase1Cmp*)handle;
 -        return cmp->infoCmd(line, out, err);
 +    this->cmd.handle = cmp.get();
 +    this->cmd.executeCommand = [](void *handle, char* line, FILE* out, FILE *err) {
 +        Phase1Cmp* c = (Phase1Cmp*)handle;
 +        return c->infoCmd(line, out, err);
      };
  
++<<<<<<< HEAD
 +    //auto tst = std::unique_ptr<InvalidCServ>(new InvalidCServ{});
 +    //tst->handle = cmp.get();
 +
 +
 +    mng.createComponent(std::move(cmp))  //using a pointer a instance. Also supported is lazy initialization (default constructor needed) or a rvalue reference (move)
 +                    .addInterface<IPhase1>(IPHASE1_VERSION)
 +                     //.addInterface<IPhase2>() -> Compile error (static assert), because Phase1Cmp does not implement IPhase2
 +                    .addCInterface(&cmd, OSGI_SHELL_COMMAND_SERVICE_NAME, "", cmdProps)
 +                    //.addCInterface(tst.get(), "TEST_SRV") -> Compile error (static assert), because InvalidCServ is not a pod
 +                    .addInterface<srv::info::IName>(INAME_VERSION)
 +                    .setCallbacks(&Phase1Cmp::init, &Phase1Cmp::start, &Phase1Cmp::stop, &Phase1Cmp::deinit);
 +    return CELIX_SUCCESS;
 +}
 +
 +celix_status_t Phase1Activator::stop(celix::BundleContext &) {
 +    //nothing to do
 +    return CELIX_SUCCESS;
++=======
+     Properties addProps;
+     addProps[OSGI_SHELL_COMMAND_NAME] = "add";
+     addProps[OSGI_SHELL_COMMAND_USAGE] = "add";
+     addProps[OSGI_SHELL_COMMAND_DESCRIPTION] = "add dummy service";
+ 
+ 
+     addCmd.handle = this;
+     addCmd.executeCommand = [](void *handle, char* /*line*/, FILE* out, FILE */*err*/) {
+         Phase1Activator* act = (Phase1Activator*)handle;
+         fprintf(out, "Adding dummy interface");
+         act->phase1cmp->addCInterface(act->dummySvc, "DUMMY_SERVICE");
+         return 0;
+     };
+ 
+     Properties removeProps;
+     removeProps[OSGI_SHELL_COMMAND_NAME] = "remove";
+     removeProps[OSGI_SHELL_COMMAND_USAGE] = "remove";
+     removeProps[OSGI_SHELL_COMMAND_DESCRIPTION] = "remove dummy service";
+ 
+ 
+     removeCmd.handle = this;
+     removeCmd.executeCommand = [](void *handle, char* /*line*/, FILE* out, FILE */*err*/) {
+         Phase1Activator* act = (Phase1Activator*)handle;
+         fprintf(out, "Removing dummy interface");
+         act->phase1cmp->removeCInterface(act->dummySvc);
+         return 0;
+     };
+ 
+     auto tst = std::unique_ptr<InvalidCServ>(new InvalidCServ{});
+     tst->handle = cmp.get();
+ 
+ 
+     phase1cmp = &mng.createComponent(cmp)  //using a pointer a instance. Also supported is lazy initialization (default constructor needed) or a rvalue reference (move)
+         .addInterface<IPhase1>(IPHASE1_VERSION)
+         //.addInterface<IPhase2>() -> Compile error (static assert), because Phase1Cmp does not implement IPhase2
+         .addCInterface(&cmd, OSGI_SHELL_COMMAND_SERVICE_NAME, "", cmdProps)
+         .addCInterface(&addCmd, OSGI_SHELL_COMMAND_SERVICE_NAME, "", addProps)
+         .addCInterface(&removeCmd, OSGI_SHELL_COMMAND_SERVICE_NAME, "", removeProps)
+         //.addCInterface(tst.get(), "TEST_SRV") -> Compile error (static assert), because InvalidCServ is not a pod
+         .addInterface<srv::info::IName>(INAME_VERSION)
+         .setCallbacks(&Phase1Cmp::init, &Phase1Cmp::start, &Phase1Cmp::stop, &Phase1Cmp::deinit);
++>>>>>>> develop
  }
diff --cc examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h
index 9c8f5a6,76ba839..f438a8e
--- a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h
+++ b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h
@@@ -20,17 -20,25 +20,29 @@@
  #ifndef CELIX_PHASE1ACTIVATOR_H
  #define CELIX_PHASE1ACTIVATOR_H
  
+ #include "celix/dm/DmActivator.h"
 +#include "celix/IBundleActivator.h"
  #include "command.h"
++#include "Phase1Cmp.h"
  
 -using namespace celix::dm;
+ struct DummyService {
+     void *handle;
+ };
  
 -class Phase1Activator : public DmActivator {
 +class Phase1Activator : public celix::IBundleActivator {
 +public:
-     virtual ~Phase1Activator(){}
-     celix_status_t start(celix::BundleContext& _ctx) override;
-     celix_status_t stop(celix::BundleContext& _ctx) override;
++    virtual ~Phase1Activator() {}
++
++    celix_status_t start(celix::BundleContext &_ctx) override;
++
++    celix_status_t stop(celix::BundleContext &_ctx) override;
++
 +private:
      command_service_t cmd {nullptr, nullptr};
+     command_service_t addCmd {nullptr, nullptr};
+     command_service_t removeCmd {nullptr, nullptr};
+     Component<Phase1Cmp> *phase1cmp{nullptr};
+     DummyService *dummySvc{new DummyService};
 -    public:
 -    Phase1Activator(DependencyManager& mng) : DmActivator(mng) {}
 -    Phase1Activator(const Phase1Activator&) = delete;
 -    Phase1Activator& operator=(const Phase1Activator&) = delete;
 -    virtual void init();
  };
  
  #endif //CELIX_PHASE1ACTIVATOR_H
diff --cc examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h.orig
index 9c8f5a6,76ba839..f63281c
--- a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h.orig
+++ b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h.orig
@@@ -20,17 -20,25 +20,36 @@@
  #ifndef CELIX_PHASE1ACTIVATOR_H
  #define CELIX_PHASE1ACTIVATOR_H
  
 -#include "celix/dm/DmActivator.h"
 +#include "celix/IBundleActivator.h"
  #include "command.h"
  
++<<<<<<< HEAD
 +
 +class Phase1Activator : public celix::IBundleActivator {
 +public:
 +    virtual ~Phase1Activator(){}
 +    celix_status_t start(celix::BundleContext& _ctx) override;
 +    celix_status_t stop(celix::BundleContext& _ctx) override;
 +private:
 +    command_service_t cmd {nullptr, nullptr};
++=======
+ using namespace celix::dm;
+ struct DummyService {
+     void *handle;
+ };
+ 
+ class Phase1Activator : public DmActivator {
+     command_service_t cmd {nullptr, nullptr};
+     command_service_t addCmd {nullptr, nullptr};
+     command_service_t removeCmd {nullptr, nullptr};
+     Component<Phase1Cmp> *phase1cmp{nullptr};
+     DummyService *dummySvc{new DummyService};
+     public:
+     Phase1Activator(DependencyManager& mng) : DmActivator(mng) {}
+     Phase1Activator(const Phase1Activator&) = delete;
+     Phase1Activator& operator=(const Phase1Activator&) = delete;
+     virtual void init();
++>>>>>>> develop
  };
  
  #endif //CELIX_PHASE1ACTIVATOR_H
diff --cc examples/celix-examples/shell_command_example/src/activator.c
index ca42deb,0000000..50a481b
mode 100644,000000..100644
--- a/examples/celix-examples/shell_command_example/src/activator.c
+++ b/examples/celix-examples/shell_command_example/src/activator.c
@@@ -1,81 -1,0 +1,81 @@@
 +/**
 + *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 <stdio.h>
 +#include <stdlib.h>
 +
 +#include "celix_bundle_activator.h"
 +#include "constants.h"
 +
 +#include "command.h"
 +
 +typedef struct activator_data {
 +    celix_bundle_context_t *ctx;
 +    command_service_t svc;
 +    long svcId;
 +} activator_data_t;
 +
 +struct useShellServiceHandle {
 +    activator_data_t* data;
 +    FILE *out;
 +    int count;
 +};
 +
 +static void useShellService(void *handle, void *_svc __attribute__((unused)), const celix_properties_t *props) {
 +    struct useShellServiceHandle *useHandle = handle;
-     const char *name = celix_properties_getWithDefault(props, OSGI_SHELL_COMMAND_NAME, "Not Found");
++    const char *name = celix_properties_get(props, OSGI_SHELL_COMMAND_NAME, "Not Found");
 +    fprintf(useHandle->out, "%i: Command %s found\n", useHandle->count++, name);
 +}
 +
 +static celix_status_t executeCommand(void *handle, char * commandLine, FILE *outStream, FILE *errorStream) {
 +    activator_data_t *data = handle;
 +    struct useShellServiceHandle useHandle = { .data = data, .out = outStream, .count = 0};
 +
 +    celix_service_use_options_t opts = CELIX_EMPTY_SERVICE_USE_OPTIONS;
 +    opts.filter.serviceName = OSGI_SHELL_COMMAND_SERVICE_NAME;
 +    opts.useWithProperties = useShellService;
 +    opts.callbackHandle = &useHandle;
 +    celix_bundleContext_useServicesWithOptions(data->ctx, &opts);
 +    fprintf(outStream, "Found %i command_service_t services\n", useHandle.count);
 +
 +    return CELIX_SUCCESS;
 +}
 +
 +
 +static celix_status_t activator_start(activator_data_t *data, celix_bundle_context_t *ctx) {
 +    data->ctx = ctx;
 +    data->svc.handle = data;
 +    data->svc.executeCommand = executeCommand;
 +
 +    data->svcId = -1L;
 +    celix_properties_t *props = celix_properties_create();
 +    celix_properties_set(props, OSGI_SHELL_COMMAND_NAME, "c_exmpl");
 +    data->svcId = celix_bundleContext_registerService(ctx, &data->svc, OSGI_SHELL_COMMAND_SERVICE_NAME, props);
 +    printf("Registered command service with service id %li\n", data->svcId);
 +
 +    return CELIX_SUCCESS;
 +}
 +
 +static celix_status_t activator_stop(activator_data_t *data, celix_bundle_context_t *ctx) {
 +    celix_bundleContext_unregisterService(ctx, data->svcId);
 +    printf("Unregistered command service with service id %li\n", data->svcId);
 +    return CELIX_SUCCESS;
 +}
 +
- CELIX_GEN_BUNDLE_ACTIVATOR(activator_data_t, activator_start, activator_stop)
++CELIX_GEN_BUNDLE_ACTIVATOR(activator_data_t, activator_start, activator_stop)
diff --cc libs/framework/CMakeLists.txt
index 4deedc6,348f106..75aab2d
--- a/libs/framework/CMakeLists.txt
+++ b/libs/framework/CMakeLists.txt
@@@ -183,9 -180,10 +183,10 @@@ if (ENABLE_TESTING AND FRAMEWORK_TESTS
          private/mock/bundle_cache_mock.c
          private/mock/manifest_mock.c
          private/mock/dm_dependency_manager_mock.c
+         private/mock/service_tracker_stub.c
          src/celix_errorcodes.c
          private/mock/celix_log_mock.c
 -        src/framework.c)
 +            src/framework.c)
      target_link_libraries(framework_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} ${UUID} Celix::utils pthread dl)
  
      add_executable(manifest_parser_test
diff --cc libs/framework/gtest/src/cxx_BundleContext_tests.cc
index dbb4824,0000000..ec3bdb7
mode 100644,000000..100644
--- a/libs/framework/gtest/src/cxx_BundleContext_tests.cc
+++ b/libs/framework/gtest/src/cxx_BundleContext_tests.cc
@@@ -1,253 -1,0 +1,252 @@@
 +/**
 + *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 "gtest/gtest.h"
 +
 +#include "celix/FrameworkFactory.h"
 +
 +class BundleContextTest : public ::testing::Test {
 +public:
 +    BundleContextTest() {
 +        celix::Properties config{};
-         config["org.osgi.framework.storage.clean"] = "onFirstInit";
-         config["org.osgi.framework.storage"] = "test-cache"; //TODO tmp dir?
++        config["org.osgi.framework.storage"] = "test-cache";
 +        this->fw_ptr = std::unique_ptr<celix::Framework>{celix::FrameworkFactory::newFramework(std::move(config))};
 +    }
 +
 +    ~BundleContextTest(){}
 +
 +    celix::Framework& framework() { return *(this->fw_ptr); }
 +private:
 +    std::unique_ptr<celix::Framework> fw_ptr{nullptr};
 +};
 +
 +//Test interface
 +class ITestSvc {
 +public:
 +    static constexpr const char * const NAME = "ITestSvc";
 +
 +    virtual ~ITestSvc(){};
 +    virtual int calc(int input) = 0;
 +};
 +
 +//Test implementation
 +class TestImpl : public ITestSvc {
 +public:
 +    virtual ~TestImpl(){};
 +    int calc(int input) override { return input * 42; }
 +};
 +
 +
 +TEST_F(BundleContextTest, TestInstallBundle) {
 +    auto &ctx = this->framework().getFrameworkContext();
 +
 +    long id;
 +
 +    //invalid
 +    id = ctx.installBundle("Invalid loc", false);
 +    EXPECT_TRUE(id < 0);
 +
 +    id = ctx.installBundle("bundle1.zip", false);
 +    EXPECT_TRUE(id > 0);
 +
 +    long again = ctx.installBundle("bundle1.zip", false);
 +    EXPECT_EQ(id, again);
 +}
 +
 +TEST_F(BundleContextTest, RegisterCServiceTest) {
 +    struct test_svc {
 +        void *dummy;
 +    };
 +
 +    auto &ctx = this->framework().getFrameworkContext();
 +
 +    test_svc svc1;
 +
 +    long svcId = ctx.registerCService(&svc1, "test service");
 +    EXPECT_TRUE(svcId > 0);
 +    ctx.unregisterService(svcId);
 +
 +    long svcId2 = ctx.registerCService(&svc1, "test service");
 +    EXPECT_TRUE(svcId2 > 0);
 +    EXPECT_NE(svcId, svcId2); //new registration new id
 +    ctx.unregisterService(svcId2);
 +
 +    //NOTE compile error -> cxxSvc is not POD
 +    //TestImpl cxxSvc{};
 +    //ctx.registerCService(ITestSvc::NAME, &cxxSvc);
 +}
 +
 +TEST_F(BundleContextTest, RegisterServiceTest) {
 +    auto &ctx = this->framework().getFrameworkContext();
 +
 +    TestImpl svc1;
 +
 +    long svcId = ctx.registerService<ITestSvc>(&svc1, ITestSvc::NAME);
 +    EXPECT_TRUE(svcId > 0);
 +    ctx.unregisterService(svcId);
 +
 +    long svcId2 = ctx.registerService<ITestSvc>(&svc1, ITestSvc::NAME);
 +    EXPECT_TRUE(svcId2 > 0);
 +    EXPECT_NE(svcId, svcId2); //new registration new id
 +    ctx.unregisterService(svcId2);
 +}
 +
 +TEST_F(BundleContextTest, UseService) {
 +    auto &ctx = this->framework().getFrameworkContext();
 +
 +    TestImpl svc1;
 +
 +    long svcId = ctx.registerService<ITestSvc>(&svc1, ITestSvc::NAME);
 +    EXPECT_TRUE(svcId > 0);
 +
 +
 +    int result = -1;
 +    std::function<void(ITestSvc &svc, const celix::Properties&, const celix::Bundle&)> func = [&result](ITestSvc &svc, const celix::Properties&, const celix::Bundle&) {
 +        result = svc.calc(1);
 +    };
 +    bool called = ctx.useService<ITestSvc>(ITestSvc::NAME, func);
 +    EXPECT_TRUE(called);
 +    EXPECT_EQ(result, 42);
 +
 +//    result = -1;
 +//    called = ctx.useServiceWithId<ITestSvc>(svcId, ITestSvc::NAME, [&result](ITestSvc &svc, const celix::Properties&, const celix::Bundle&) {
 +//        result = svc.calc(2);
 +//    });
 +//    EXPECT_TRUE(called);
 +//    EXPECT_EQ(result, 84);
 +
 +    ctx.unregisterService(svcId);
 +}
 +
 +TEST_F(BundleContextTest, UseServices) {
 +    auto &ctx = this->framework().getFrameworkContext();
 +
 +    TestImpl svc;
 +
 +    long svcId1 = ctx.registerService<ITestSvc>(&svc, "test service");
 +    EXPECT_TRUE(svcId1 > 0);
 +
 +    long svcId2 = ctx.registerService<ITestSvc>(&svc, "test service");
 +    EXPECT_TRUE(svcId2 > 0);
 +
 +
 +    int result = 0;
 +    auto func = [&result](ITestSvc &svc, const celix::Properties&, const celix::Bundle&) {
 +        result += svc.calc(1);
 +    };
 +    ctx.useServices<ITestSvc>("test service", func);
 +    EXPECT_EQ(result, 84); //two times
 +
 +    ctx.unregisterService(svcId1);
 +
 +    ctx.useServices<ITestSvc>("test service", func);
 +    EXPECT_EQ(result, 126); //one time
 +
 +    ctx.unregisterService(svcId2);
 +}
 +
 +
 +TEST_F(BundleContextTest, TrackService) {
 +    auto &ctx = this->framework().getFrameworkContext();
 +
 +    int count = 0;
 +
 +    ITestSvc *svc1 = (ITestSvc*)0x100; //no ranking
 +    ITestSvc *svc2 = (ITestSvc*)0x200; //no ranking
 +    ITestSvc *svc3 = (ITestSvc*)0x300; //10 ranking
 +    ITestSvc *svc4 = (ITestSvc*)0x400; //5 ranking
 +
 +
 +    auto set = [&](ITestSvc *svc) {
 +        static int callCount = 0;
 +        callCount += 1;
 +        if (callCount == 1) {
 +            //first time svc1 should be set (oldest service with equal ranking
 +            EXPECT_EQ(svc1, svc);
 +        } else if (callCount == 2) {
 +            EXPECT_EQ(svc3, svc);
 +            //second time svc3 should be set (highest ranking)
 +        } else if (callCount == 3) {
 +            //third time svc4 should be set (highest ranking
 +            EXPECT_EQ(svc4, svc);
 +        }
 +
 +        count = callCount;
 +    };
 +
 +    long svcId1 = ctx.registerService(svc1, "NA");
 +    long svcId2 = ctx.registerService(svc2, "NA");
 +
 +    //starting tracker should lead to first set call
 +    long trackerId = ctx.trackService<ITestSvc>("NA", set);
 +    EXPECT_TRUE(trackerId > 0);
 +
 +    //register svc3 should lead to second set call
 +    celix::Properties props3{};
 +    props3[OSGI_FRAMEWORK_SERVICE_RANKING] = "10";
 +    long svcId3 = ctx.registerService(svc3, "NA", std::move(props3));
 +
 +    //register svc4 should lead to no set (lower ranking)
 +    celix::Properties props4{};
 +    props4[OSGI_FRAMEWORK_SERVICE_RANKING] = "10";
 +    long svcId4 = ctx.registerService(svc4, "NA", props4);
 +
 +    //unregister svc3 should lead to set (new highest ranking)
 +    ctx.unregisterService(svcId3);
 +
 +    ctx.stopTracker(trackerId);
 +    ctx.unregisterService(svcId1);
 +    ctx.unregisterService(svcId4);
 +    ctx.unregisterService(svcId2);
 +
 +    EXPECT_EQ(3, count); //check if the set is called the expected times
 +}
 +
 +TEST_F(BundleContextTest, useBundleTest) {
 +    auto &ctx = this->framework().getFrameworkContext();
 +    int count = 0;
 +
 +    ctx.useBundle(0, [&count](const celix::Bundle &bnd) {
 +        count++;
 +        long id = bnd.getBundleId();
 +        EXPECT_EQ(0, id);
 +    });
 +
 +    EXPECT_EQ(1, count);
 +};
 +
 +
 +TEST_F(BundleContextTest, useBundlesTest) {
 +    auto &ctx = this->framework().getFrameworkContext();
 +    int count = 0;
 +
 +    auto use = [&count](const celix::Bundle &bnd) {
 +        count++;
 +        long id = bnd.getBundleId();
 +        EXPECT_TRUE(id >= 0);
 +    };
 +
 +    ctx.useBundles(use);
-     EXPECT_EQ(1, count);
++    EXPECT_EQ(0, count); //note framework bundle is by default not used in the useBundles callback
 +
 +    count = 0;
 +    ctx.installBundle("bundle1.zip", true);
 +    ctx.useBundles(use);
-     EXPECT_EQ(2, count);
++    EXPECT_EQ(1, count);
 +};
diff --cc libs/framework/gtest/src/cxx_Bundle_tests.cc
index e7eb0d8,0000000..2f037bf
mode 100644,000000..100644
--- a/libs/framework/gtest/src/cxx_Bundle_tests.cc
+++ b/libs/framework/gtest/src/cxx_Bundle_tests.cc
@@@ -1,66 -1,0 +1,65 @@@
 +/**
 + *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 "gtest/gtest.h"
 +
 +#include "celix/FrameworkFactory.h"
 +
 +class BundleTest : public ::testing::Test {
 +public:
 +    BundleTest() {
 +        celix::Properties config{};
-         config["org.osgi.framework.storage.clean"] = "onFirstInit";
 +        config["org.osgi.framework.storage"] = "test-cache"; //TODO tmp dir?
 +        this->fw_ptr = std::unique_ptr<celix::Framework>{celix::FrameworkFactory::newFramework(std::move(config))};
 +    }
 +
 +    ~BundleTest(){}
 +
 +    celix::Framework& framework() { return *(this->fw_ptr); }
 +private:
 +    std::unique_ptr<celix::Framework> fw_ptr{nullptr};
 +};
 +
 +TEST_F(BundleTest, getInfoFromFrameworkBundle) {
 +    auto &bnd = this->framework().getFrameworkBundle();
 +
 +    long id = bnd.getBundleId();
 +    EXPECT_EQ(0, id); //framework bundle is 0
 +
 +    //TODO FIXME returned name is id
 +//    std::string name = bnd.getBundleName();
 +//    EXPECT_EQ("system", name);
 +
 +    std::string sym = bnd.getBundleSymbolicName();
-     EXPECT_EQ("framework", sym);
++    EXPECT_EQ("Framework", sym);
 +
 +    std::string loc = bnd.getBundleLocation();
 +    EXPECT_EQ("System Bundle", loc);
 +
 +    celix::BundleState state = bnd.getState();
 +    EXPECT_EQ(celix::BundleState::ACTIVE, state);
 +
 +    //TODO
 +//    std::string cache = bnd.getBundleCache(); //TODO make getCacheLoc?
 +//    EXPECT_TRUE(!cache.emtpy());
 +
 +    //TODO returns "" should be framework version
 +//    std::string version = bnd.getBundleVersion();
 +//    EXPECT_EQ("2.2.0", version);
 +}
diff --cc libs/framework/include/bundle_context.h.orig
index 74f904e,8c2e3aa..45f79dd
--- a/libs/framework/include/bundle_context.h.orig
+++ b/libs/framework/include/bundle_context.h.orig
@@@ -41,129 -42,129 +42,255 @@@
  #ifdef __cplusplus
  extern "C" {
  #endif
++<<<<<<< HEAD
 +    
 +    celix_status_t
 +    bundleContext_create(framework_pt framework, framework_logger_pt, bundle_pt bundle, bundle_context_pt *bundle_context);
 +    
 +    celix_status_t bundleContext_destroy(bundle_context_pt context);
 +    
 +    FRAMEWORK_EXPORT celix_status_t bundleContext_getBundle(bundle_context_pt context, bundle_pt *bundle);
 +    
 +    FRAMEWORK_EXPORT celix_status_t bundleContext_getFramework(bundle_context_pt context, framework_pt *framework);
 +    
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_installBundle(bundle_context_pt context, const char *location, bundle_pt *bundle);
 +    
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_installBundle2(bundle_context_pt context, const char *location, const char *inputFile, bundle_pt *bundle);
 +    
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_registerService(bundle_context_pt context, const char *serviceName, const void *svcObj,
 +                                  properties_pt properties, service_registration_pt *service_registration);
 +    
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_registerServiceFactory(bundle_context_pt context, const char *serviceName, service_factory_pt factory,
 +                                         properties_pt properties, service_registration_pt *service_registration);
 +    
 +    /**
 +     * Get a service reference for the bundle context. When the service reference is no longer needed use bundleContext_ungetServiceReference.
 +     * ServiceReference are coupled to a bundle context. Do not share service reference between bundles. Exchange the service.id instead.
 +     *
 +     * @param context The bundle context
 +     * @param serviceName The name of the service (objectClass) to get
 +     * @param service_reference _output_ The found service reference, or NULL when no service is found.
 +     * @return CELIX_SUCCESS on success
 +     */
 +    FRAMEWORK_EXPORT celix_status_t bundleContext_getServiceReference(bundle_context_pt context, const char *serviceName,
 +                                                                      service_reference_pt *service_reference);
 +    
 +    /** Same as bundleContext_getServiceReference, but than for a optional serviceName combined with a optional filter.
 +     * The resulting array_list should be destroyed by the caller. For all service references return a unget should be called.
 +     *
 +     * @param context the bundle context
 +     * @param serviceName the serviceName, can be NULL
 +     * @param filter the filter, can be NULL. If present will be combined (and) with the serviceName
 +     * @param service_references _output_ a array list, can be size 0.
 +     * @return CELIX_SUCCESS on success
 +     */
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_getServiceReferences(bundle_context_pt context, const char *serviceName, const char *filter,
 +                                       array_list_pt *service_references);
 +    
 +    /**
 +     * Retains (increases the ref count) the provided service reference. Can be used to retain a service reference.
 +     * Note that this is a deviation from the OSGi spec, due to the fact that C has no garbage collect.
 +     *
 +     * @param context the bundle context
 +     * @param reference the service reference to retain
 +     * @return CELIX_SUCCES on success
 +     */
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_retainServiceReference(bundle_context_pt context, service_reference_pt reference);
 +    
 +    /**
 +     * Ungets the service references. If the ref counter of the service refernce goes to 0, the reference will be destroyed.
 +     * This is coupled with the bundleContext_getServiceReference(s) and bundleContext_retainServiceReferenc.
 +     * Note: That this is a deviation from the OSGi standard, due to the fact that C has no garbage collect.
 +     *
 +     * @param context The bundle context.
 +     * @param reference the service reference to unget
 +     * @return CELIX_SUCCESS on success.
 +     */
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_ungetServiceReference(bundle_context_pt context, service_reference_pt reference);
 +    
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_getService(bundle_context_pt context, service_reference_pt reference, void **service_instance);
 +    
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_ungetService(bundle_context_pt context, service_reference_pt reference, bool *result);
 +    
 +    FRAMEWORK_EXPORT celix_status_t bundleContext_getBundles(bundle_context_pt context, array_list_pt *bundles);
 +    
 +    FRAMEWORK_EXPORT celix_status_t bundleContext_getBundleById(bundle_context_pt context, long id, bundle_pt *bundle);
 +    
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_addServiceListener(bundle_context_pt context, service_listener_pt listener, const char *filter);
 +    
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_removeServiceListener(bundle_context_pt context, service_listener_pt listener);
 +    
 +    FRAMEWORK_EXPORT celix_status_t bundleContext_addBundleListener(bundle_context_pt context, bundle_listener_pt listener);
 +    
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_removeBundleListener(bundle_context_pt context, bundle_listener_pt listener);
 +    
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_addFrameworkListener(bundle_context_pt context, framework_listener_pt listener);
 +    
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_removeFrameworkListener(bundle_context_pt context, framework_listener_pt listener);
 +    
 +    /**
 +     * Gets the config property - or environment variable if the config property does not exist - for the provided name.
 +     *
 +     * @param context The bundle context.
 +     * @param name The name of the config property / environment variable to get.
 +     * @param value A ptr to the output value. This will be set when a value is found or else will be set to NULL.
 +     * @return 0 if successful.
 +     */
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_getProperty(bundle_context_pt context, const char *name, const char **value);
 +    
 +    /**
 +     * Gets the config property - or environment variable if the config property does not exist - for the provided name.
 +     *
 +     * @param context The bundle context.
 +     * @param name The name of the config property / environment variable to get.
 +     * @param defaultValue The default value to return if no value is found.
 +     * @param value A ptr to the output value. This will be set when a value is found or else will be set to NULL.
 +     * @return 0 if successful.
 +     */
 +    FRAMEWORK_EXPORT celix_status_t
 +    bundleContext_getPropertyWithDefault(bundle_context_pt context, const char *name, const char *defaultValue, const char **value);
 +    
 +    
++=======
+ 
+ celix_status_t
+ bundleContext_create(celix_framework_t *framework, framework_logger_pt, celix_bundle_t *bundle, celix_bundle_context_t **bundle_context);
+ 
+ celix_status_t bundleContext_destroy(celix_bundle_context_t *context);
+ 
+ FRAMEWORK_EXPORT celix_status_t bundleContext_getBundle(celix_bundle_context_t *context, celix_bundle_t **bundle);
+ 
+ FRAMEWORK_EXPORT celix_status_t bundleContext_getFramework(celix_bundle_context_t *context, celix_framework_t **framework);
+ 
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_installBundle(celix_bundle_context_t *context, const char *location, celix_bundle_t **bundle);
+ 
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_installBundle2(celix_bundle_context_t *context, const char *location, const char *inputFile, celix_bundle_t **bundle);
+ 
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_registerService(celix_bundle_context_t *context, const char *serviceName, const void *svcObj,
+                               celix_properties_t *properties, service_registration_pt *service_registration);
+ 
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_registerServiceFactory(celix_bundle_context_t *context, const char *serviceName, service_factory_pt factory,
+                                      celix_properties_t *properties, service_registration_pt *service_registration);
+ 
+ /**
+  * Get a service reference for the bundle context. When the service reference is no longer needed use bundleContext_ungetServiceReference.
+  * ServiceReference are coupled to a bundle context. Do not share service reference between bundles. Exchange the service.id instead.
+  * 
+  * @param context The bundle context
+  * @param serviceName The name of the service (objectClass) to get
+  * @param service_reference _output_ The found service reference, or NULL when no service is found.
+  * @return CELIX_SUCCESS on success
+  */
+ FRAMEWORK_EXPORT celix_status_t bundleContext_getServiceReference(celix_bundle_context_t *context, const char *serviceName,
+                                                                   service_reference_pt *service_reference);
+ 
+ /** Same as bundleContext_getServiceReference, but than for a optional serviceName combined with a optional filter.
+  * The resulting array_list should be destroyed by the caller. For all service references return a unget should be called.
+  * 
+  * @param context the bundle context
+  * @param serviceName the serviceName, can be NULL
+  * @param filter the filter, can be NULL. If present will be combined (and) with the serviceName 
+  * @param service_references _output_ a array list, can be size 0. 
+  * @return CELIX_SUCCESS on success
+  */
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_getServiceReferences(celix_bundle_context_t *context, const char *serviceName, const char *filter,
+                                    celix_array_list_t **service_references);
+ 
+ /**
+  * Retains (increases the ref count) the provided service reference. Can be used to retain a service reference.
+  * Note that this is a deviation from the OSGi spec, due to the fact that C has no garbage collect.
+  * 
+  * @param context the bundle context
+  * @param reference the service reference to retain
+  * @return CELIX_SUCCES on success
+  */
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_retainServiceReference(celix_bundle_context_t *context, service_reference_pt reference);
+ 
+ /**
+  * Ungets the service references. If the ref counter of the service refernce goes to 0, the reference will be destroyed.
+  * This is coupled with the bundleContext_getServiceReference(s) and bundleContext_retainServiceReferenc.
+  * Note: That this is a deviation from the OSGi standard, due to the fact that C has no garbage collect.
+  * 
+  * @param context The bundle context.
+  * @param reference the service reference to unget
+  * @return CELIX_SUCCESS on success.
+  */
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_ungetServiceReference(celix_bundle_context_t *context, service_reference_pt reference);
+ 
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_getService(celix_bundle_context_t *context, service_reference_pt reference, void **service_instance);
+ 
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_ungetService(celix_bundle_context_t *context, service_reference_pt reference, bool *result);
+ 
+ FRAMEWORK_EXPORT celix_status_t bundleContext_getBundles(celix_bundle_context_t *context, celix_array_list_t **bundles);
+ 
+ FRAMEWORK_EXPORT celix_status_t bundleContext_getBundleById(celix_bundle_context_t *context, long id, celix_bundle_t **bundle);
+ 
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_addServiceListener(celix_bundle_context_t *context, celix_service_listener_t *listener, const char *filter);
+ 
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_removeServiceListener(celix_bundle_context_t *context, celix_service_listener_t *listener);
+ 
+ FRAMEWORK_EXPORT celix_status_t bundleContext_addBundleListener(celix_bundle_context_t *context, bundle_listener_pt listener);
+ 
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_removeBundleListener(celix_bundle_context_t *context, bundle_listener_pt listener);
+ 
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_addFrameworkListener(celix_bundle_context_t *context, framework_listener_pt listener);
+ 
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_removeFrameworkListener(celix_bundle_context_t *context, framework_listener_pt listener);
+ 
+ /**
+  * Gets the config property - or environment variable if the config property does not exist - for the provided name.
+  *
+  * @param context The bundle context.
+  * @param name The name of the config property / environment variable to get.
+  * @param value A ptr to the output value. This will be set when a value is found or else will be set to NULL.
+  * @return 0 if successful.
+  */
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_getProperty(celix_bundle_context_t *context, const char *name, const char **value);
+ 
+ /**
+  * Gets the config property - or environment variable if the config property does not exist - for the provided name.
+  *
+  * @param context The bundle context.
+  * @param name The name of the config property / environment variable to get.
+  * @param defaultValue The default value to return if no value is found.
+  * @param value A ptr to the output value. This will be set when a value is found or else will be set to NULL.
+  * @return 0 if successful.
+  */
+ FRAMEWORK_EXPORT celix_status_t
+ bundleContext_getPropertyWithDefault(celix_bundle_context_t *context, const char *name, const char *defaultValue, const char **value);
+ 
+ 
++>>>>>>> develop
  #ifdef __cplusplus
  }
  #endif
diff --cc libs/framework/include/celix/BundleActivator.h
index 855b3dd,0000000..7c36448
mode 100644,000000..100644
--- a/libs/framework/include/celix/BundleActivator.h
+++ b/libs/framework/include/celix/BundleActivator.h
@@@ -1,104 -1,0 +1,104 @@@
 +/**
 + *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 <memory>
 +
 +#include "celix/IBundleActivator.h"
 +#include "celix/Framework.h"
 +
 +#ifndef CXX_CELIX_BUNDLEACTIVATOR_H
 +#define CXX_CELIX_BUNDLEACTIVATOR_H
 +
 +namespace celix {
 +    /**
 +     * The BundleActivatorAdapter adapts the C bundle activator calls to a C++ bundle activator.
 +     * The Type parameter (T) is the C++ bundle activator and needs to support:
 +     * - A public default constructor.
 +     * - Implementing the celix::IBundleActivator interface, which contains:
 +     *      - A public destructor.
 +     *      - A public 'celix_status_t start(celix::BundleContext &ctx)` method.
 +     *      - A public 'celix_status_t start(celix::BundleContext &ctx)` method.
 +     */
 +    template<typename T>
 +    class BundleActivatorAdapter {
 +    private:
 +        std::unique_ptr<celix::Framework> fw{};
 +        std::unique_ptr<celix::BundleContext> ctx{};
 +        std::unique_ptr<celix::IBundleActivator> activator{};
 +    public:
-         BundleActivatorAdapter(bundle_context_t *c_ctx) {
++        BundleActivatorAdapter(celix_bundle_context_t *c_ctx) {
 +            this->fw = std::unique_ptr<celix::Framework>{new celix::impl::FrameworkImpl{c_ctx}}; \
 +            this->ctx = std::unique_ptr<celix::BundleContext>{new celix::BundleContext{c_ctx, *this->fw}}; \
 +            this->activator = nullptr;
 +        }
 +
 +        ~BundleActivatorAdapter() {
 +            this->ctx = nullptr;
 +            this->fw = nullptr;
 +            this->activator = nullptr;
 +        }
 +
 +        celix_status_t start() noexcept  {
 +            this->activator = std::unique_ptr<celix::IBundleActivator>{new T};
 +            celix_status_t status = this->activator->start(*this->ctx);
 +            if (status == CELIX_SUCCESS) {
 +                this->ctx->getDependencyManager().start();
 +            }
 +            return status;
 +        }
 +
 +        celix_status_t stop() noexcept {
 +            celix_status_t status = this->activator->stop(*this->ctx);
 +            if (status == CELIX_SUCCESS) {
 +                this->ctx->getDependencyManager().stop();
 +            }
 +            this->activator = nullptr; //implicit delete
 +            return status;
 +        }
 +    };
 +}
 +
 +/**
 + * This macro generated the required bundle activator symbols, which uses the celix::BundleActivatorAdapter to
 + * adapt the C bundle activator calls to the provided C++ bundle activator class.
 + */
 +#define CELIX_GEN_CXX_BUNDLE_ACTIVATOR(clazz)                                                                          \
- extern "C" celix_status_t bundleActivator_create(bundle_context_t *c_ctx, void **userData) {                           \
++extern "C" celix_status_t bundleActivator_create(celix_bundle_context_t *c_ctx, void **userData) {                           \
 +    auto *data = new celix::BundleActivatorAdapter<clazz>{c_ctx};                                                      \
 +    *userData = data;                                                                                                  \
 +    return CELIX_SUCCESS;                                                                                              \
 +}                                                                                                                      \
 +                                                                                                                       \
- extern "C" celix_status_t bundleActivator_start(void *userData, bundle_context_t *) {                                  \
++extern "C" celix_status_t bundleActivator_start(void *userData, celix_bundle_context_t *) {                                  \
 +    auto *data = static_cast<celix::BundleActivatorAdapter<clazz>*>(userData);                                         \
 +    return data->start();                                                                                              \
 +}                                                                                                                      \
 +                                                                                                                       \
- extern "C" celix_status_t bundleActivator_stop(void *userData, bundle_context_t *) {                                   \
++extern "C" celix_status_t bundleActivator_stop(void *userData, celix_bundle_context_t *) {                                   \
 +    auto *data = static_cast<celix::BundleActivatorAdapter<clazz>*>(userData);                                         \
 +    return data->stop();                                                                                               \
 +}                                                                                                                      \
 +                                                                                                                       \
- extern "C" celix_status_t bundleActivator_destroy(void *userData, bundle_context_t*) {                                 \
++extern "C" celix_status_t bundleActivator_destroy(void *userData, celix_bundle_context_t*) {                                 \
 +    auto *data = static_cast<celix::BundleActivatorAdapter<clazz>*>(userData);                                         \
 +    delete data;                                                                                                       \
 +    return CELIX_SUCCESS;                                                                                              \
 +}                                                                                                                      \
 +
 +#endif //CXX_CELIX_BUNDLEACTIVATOR_H
diff --cc libs/framework/include/celix/BundleContext.h
index b3ce0b4,0000000..b5d4e2a
mode 100644,000000..100644
--- a/libs/framework/include/celix/BundleContext.h
+++ b/libs/framework/include/celix/BundleContext.h
@@@ -1,291 -1,0 +1,291 @@@
 +/**
 + *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 <string>
 +#include <vector>
 +#include <functional>
 +#include <memory>
 +
 +#include "celix/Constants.h"
 +#include "celix/Properties.h"
 +#include "celix/Bundle.h"
 +#include "celix/IServiceFactory.h"
 +#include "celix/ServiceAdapter.h"
 +
 +#ifndef CXX_CELIX_BUNDLECONTEXT_H
 +#define CXX_CELIX_BUNDLECONTEXT_H
 +
 +namespace celix {
 +
 +    //forward declarations
 +    class BundleContext;
 +    class Framework;
 +    namespace dm {
 +        class DependencyManager;
 +    }
 +
 +    template<typename I>
 +    struct ServiceRegistrationOptions {
 +        using type = I;
 +
 +        ServiceRegistrationOptions(I& _svc, const std::string& _serviceName) : svc{&_svc}, serviceName{_serviceName} {};
 +        ServiceRegistrationOptions(celix::IServiceFactory<I>& _factory, const std::string& _serviceName) : factory{&_factory}, serviceName{_serviceName} {};
 +
 +        ServiceRegistrationOptions(const ServiceRegistrationOptions&) = delete;
 +        ServiceRegistrationOptions& operator=(const ServiceRegistrationOptions&) = delete;
 +        ServiceRegistrationOptions(ServiceRegistrationOptions&&) = delete;
 +        ServiceRegistrationOptions& operator=(ServiceRegistrationOptions&) = delete;
 +
 +        I *svc{nullptr};
 +        celix::IServiceFactory<I> *factory{nullptr};
 +
 +        const std::string serviceName;
 +
 +        celix::Properties properties{};
 +        std::string serviceVersion{};
 +        std::string serviceLanguage{celix::Constants::SERVICE_CXX_LANG};
 +    };
 +
 +    template<typename I>
 +    struct ServiceFilterOptions {
 +        using type = I;
 +
 +        ServiceFilterOptions(const std::string &_serviceName) : serviceName{_serviceName} {};
 +
 +        std::string serviceName;
 +
 +        std::string versionRange{};
 +        std::string filter{};
 +        std::string serviceLanguage{celix::Constants::SERVICE_CXX_LANG};
 +    };
 +
 +
 +    template<typename I>
 +    struct ServiceUseOptions {
 +        using type = I;
 +
 +        ServiceUseOptions(const std::string &serviceName) : filter{ServiceFilterOptions<I>{serviceName}} {};
 +
 +        ServiceFilterOptions<I> filter;
 +
 +        /*
 +         * Callbacks
 +         */
 +        std::function<void(I &svc)> use{};
 +        std::function<void(I &svc, const celix::Properties &props)> useWithProperties{};
 +        std::function<void(I &svc, const celix::Properties &props, celix::Bundle &svcOwner)> useWithOwner{};
 +    };
 +
 +    template<typename I>
 +    struct ServiceTrackingOptions {
 +        using type = I;
 +
 +        ServiceTrackingOptions(const std::string serviceName) : filter{ServiceFilterOptions<I>{serviceName}} {};
 +
 +        ServiceFilterOptions<I> filter;
 +
 +        std::function<void(I* svc)> set{};
 +        std::function<void(I* svc)> add{};
 +        std::function<void(I* svc)> remove{};
 +
 +        std::function<void(I* svc, const celix::Properties &props)> setWithProperties{};
 +        std::function<void(I* svc, const celix::Properties &props)> addWithProperties{};
 +        std::function<void(I* svc, const celix::Properties &props)> removeWithProperties{};
 +
 +        std::function<void(I* svc, const celix::Properties &props, const celix::Bundle &svcOwner)> setWithOwner{};
 +        std::function<void(I* svc, const celix::Properties &props, const celix::Bundle &svcOwner)> addWithOwner{};
 +        std::function<void(I* svc, const celix::Properties &props, const celix::Bundle &svcOwner)> removeWithOwner{};
 +    };
 +
 +
 +    struct BundleRegistrationOptions {
 +        std::string id{};
 +        std::string name{};
 +        std::string version{};
 +
 +        bool autoStart{true};
 +
 +        std::function<void(celix::BundleContext &ctx)> start{};
 +        std::function<void(celix::BundleContext &ctx)> stop{};
 +
 +        celix::Properties manifest{};
 +
 +        //If manifest symbol and manifest len symbol is set, this is used instead of the properties as manifest
 +        std::string manifestSymbol{};
 +        std::string manifestLenSymbol{};
 +
 +        std::string resourceSymbol{};
 +        std::string resourceLenSymbol{};
 +    };
 +
 +    class BundleContext {
 +    public:
 +        BundleContext(celix_bundle_context_t *ctx, celix::Framework& fw); //TODO hide somehow ... friend ?
 +        virtual ~BundleContext();
 +
 +        //TODO document, only possible if a service wrapper is available
 +        template<typename I>
 +        long registerService(I *svcWithWrapper, celix::Properties props = {}) noexcept;
 +
 +        template<typename I>
 +        long registerService(I *svc, const std::string &serviceName, celix::Properties props = {}) noexcept;
 +
 +        template<typename I>
 +        long registerCService(I *svc, const std::string &serviceName, celix::Properties props = {}) noexcept;
 +
 +        template<typename I>
 +        long registerServiceFactory(celix::IServiceFactory<I> *svc, const std::string &serviceName, celix::Properties props = {});
 +
 +        template<typename I>
 +        long registerCServiceFactory(celix::IServiceFactory<I> *svc, const std::string &serviceName, celix::Properties props = {});
 +
 +        template<typename I>
 +        long registerServiceWithOptions(const celix::ServiceRegistrationOptions<I>& opts) noexcept;
 +
 +        //TODO register std::function ?
 +
 +        void unregisterService(long serviceId) noexcept;
 +
 +
 +        /**
 +        * track service for the provided service type, service name, optional version range and optional filter.
 +        * The highest ranking services will used for the callback.
 +        * If a new and higher ranking services the callback with be called again with the new service.
 +        * If a service is removed a the callback with be called with next highest ranking service or NULL as service.
 +        *
 +        * @param serviceName The required service name to track
 +        * @param set is a required callback, which will be called when a new highest ranking service is set.
 +        * @return the tracker id or < 0 if unsuccessful.
 +        */
 +        template<typename I>
 +        long trackService(const std::string &serviceName, std::function<void(I *svc)> set) noexcept;
 +
 +        /**
 +        * track service for the provided service type using a ServiceUsageAdaptor.
 +        * The highest ranking services will used for the callback.
 +        * If a new and higher ranking services the callback with be called again with the new service.
 +        * If a service is removed a the callback with be called with next highest ranking service or NULL as service.
 +        *
 +        * @param serviceName The required service name to track
 +        * @param set is a required callback, which will be called when a new highest ranking service is set.
 +        * @return the tracker id or < 0 if unsuccessful.
 +        */
 +        template<typename I>
 +        long trackService(std::function<void(I *svc)> set) noexcept;
 +
 +        /**
 +         * track services for the provided serviceName and/or filter.
 +         *
 +         * @param serviceName The required service name to track
 +         * @param add is a required callback, which will be called when a service is added and initially for the existing service.
 +         * @param remove is a required callback, which will be called when a service is removed
 +         * @return the tracker id or < 0 if unsuccessful.
 +         */
 +        template<typename I>
 +        long trackServices(const std::string &serviceName, std::function<void(I *svc)> add, std::function<void(I *svc)> remove) noexcept;
 +
 +        //TODO add trackCService(s) variants
 +
 +        /**
 +         * track services using the provided tracking options
 +         *
 +         * @param opts The tracking options
 +         * @return the tracker id or < 0 if unsuccessful.
 +         */
 +        template<typename I>
 +        long trackServicesWithOptions(const celix::ServiceTrackingOptions<I>& opts) noexcept;
 +
 +        //TODO remove if WithOptions is available
 +        template<typename I>
 +        bool useServiceWithId(long serviceId, const std::string &/*serviceName*/ /*sanity*/, const std::function<void(I &svc, const celix::Properties &props, const celix::Bundle &svcOwner)> &use) noexcept;
 +
 +        template<typename I>
 +        bool useServiceWithId(long serviceId, const std::string &/*serviceName*/ /*sanity*/, const std::function<void(I &svc)> &use) noexcept;
 +
 +        //TODO remove if WithOptions is available
 +        template<typename I>
 +        bool useService(const std::string &serviceName, const std::function<void(I &svc, const celix::Properties &props, const celix::Bundle &svcOwner)> &use) noexcept;
 +
 +        template<typename I>
 +        bool useService(const std::string &serviceName, const std::function<void(I &svc)> &use) noexcept;
 +
 +        //TODO remove if WithOptions is available
 +        template<typename I>
 +        void useServices(const std::string &serviceName, const std::function<void(I &svc, const celix::Properties &props, const celix::Bundle &svcOwner)> &use) noexcept;
 +
 +        template<typename I>
 +        void useServices(const std::string &serviceName, const std::function<void(I &svc)> &use) noexcept;
 +
 +        //TODO rest of variants with service & wrapper for useServiceWithId, useService and useServices
 +        template<typename I>
 +        bool useService(const std::function<void(I &svc)> &use) noexcept;
 +
 +        template<typename I>
 +        void useServices(const std::function<void(I &svc)> &use) noexcept;
 +
 +
 +        //TODO add useService(s)WithOptions
 +        //TODO add useCService(s) variants
 +
 +        /**
 +         * Note ordered by service rank.
 +         */
 +        std::vector<long> findServices(const std::string &serviceName, const std::string &versionRange = "", const std::string &filter = "", const std::string &lang = "") noexcept;
 +
 +        //TODO also support getting int, long, unsigned int, etc??
 +        std::string getProperty(const std::string &key, std::string defaultValue = "") noexcept;
 +
 +        //TODO options
 +
 +        //track bundle
 +        //TODO
 +
 +        //track service tracker
 +        //TODO
 +
 +        /**
 +         * Stop the tracker with the provided track id.
 +         * Could be a service tracker, bundle tracker or service tracker tracker.
 +         * Only works for the trackers owned by the bundle of the bundle context.
 +         *
 +         * Will log a error if the provided tracker id is unknown. Will silently ignore trackerId < 0.
 +         */
 +        void stopTracker(long trackerId) noexcept;
 +
 +        celix::Framework& getFramework() noexcept;
 +
 +        celix::Bundle& getBundle() noexcept;
 +
 +        celix::dm::DependencyManager& getDependencyManager() noexcept;
 +
 +        long installBundle(const std::string &bundleLocation, bool autoStart = true) noexcept;
 +
 +        void useBundles(const std::function<void(const celix::Bundle &bnd)> &use) noexcept;
 +
-         bool useBundle(long bundleId, const std::function<void(const celix::Bundle &bnd)> &use) noexcept;
++        void useBundle(long bundleId, const std::function<void(const celix::Bundle &bnd)> &use) noexcept;
 +    private:
 +        struct Impl;
 +        std::unique_ptr<celix::BundleContext::Impl> pimpl{nullptr};
 +    };
 +
 +}
 +
 +#endif //CXX_CELIX_BUNDLECONTEXT_H
 +
 +#include "celix/impl/BundleContextImpl.h"
diff --cc libs/framework/include/celix/Constants.h
index b957f61,0000000..6788b7e
mode 100644,000000..100644
--- a/libs/framework/include/celix/Constants.h
+++ b/libs/framework/include/celix/Constants.h
@@@ -1,47 -1,0 +1,45 @@@
 +/**
 + *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 CXX_CELIX_CONSTANTS_H
 +#define CXX_CELIX_CONSTANTS_H
 +
 +#include "celix_constants.h"
 +
 +namespace celix {
 +    class Constants {
 +    public:
 +        static constexpr const char *const SERVICE_NAME = OSGI_FRAMEWORK_OBJECTCLASS;
 +        static constexpr const char *const SERVICE_ID = OSGI_FRAMEWORK_SERVICE_ID;
 +        static constexpr const char *const SERVICE_PID = OSGI_FRAMEWORK_SERVICE_PID;
 +        static constexpr const char *const SERVICE_RANKING = OSGI_FRAMEWORK_SERVICE_RANKING;
 +
 +        static constexpr const char *const SERVICE_VERSION = CELIX_FRAMEWORK_SERVICE_VERSION;
 +        static constexpr const char *const SERVICE_LANGUAGE = CELIX_FRAMEWORK_SERVICE_LANGUAGE;
 +        static constexpr const char *const SERVICE_C_LANG = CELIX_FRAMEWORK_SERVICE_C_LANGUAGE;
 +        static constexpr const char *const SERVICE_CXX_LANG = CELIX_FRAMEWORK_SERVICE_CXX_LANGUAGE;
-         static constexpr const char *const SERVICE_SHARED_LANG = CELIX_FRAMEWORK_SERVICE_SHARED_LANGUAGE; //e.g. marker services
 +
 +        static constexpr const char *const FRAMEWORK_STORAGE = OSGI_FRAMEWORK_FRAMEWORK_STORAGE;
-         static constexpr const char *const FRAMEWORK_CLEAN = OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN;
-         static constexpr const char *const FRAMEWORK_CLEAN_ON_FIRST_INIT = OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT;
++        static constexpr const char *const FRAMEWORK_CLEAN = OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_NAME;
 +        static constexpr const char *const FRAMEWORK_UUID = OSGI_FRAMEWORK_FRAMEWORK_UUID;
 +    };
 +}
 +
 +#endif //CXX_CELIX_CONSTANTS_H
diff --cc libs/framework/include/celix/dm/DependencyManager.h
index 538edb1,c00872d..6a5ee57
--- a/libs/framework/include/celix/dm/DependencyManager.h
+++ b/libs/framework/include/celix/dm/DependencyManager.h
@@@ -25,42 -22,46 +25,54 @@@
  #include "celix/dm/Component.h"
  #include "celix/dm/ServiceDependency.h"
  
 -#include "bundle_context.h"
  #include "celix_bundle_context.h"
- #include "dm_dependency_manager.h"
+ #include "celix_dependency_manager.h"
  
  #include <vector>
  #include <mutex>
  
 -#ifndef CELIX_DM_DEPENDENCYMANAGER_H
 -#define CELIX_DM_DEPENDENCYMANAGER_H
 -
  namespace celix { namespace dm {
 -
 +    
      class DependencyManager {
      public:
-         DependencyManager(bundle_context_pt ctx) : context(ctx) {
+         DependencyManager(celix_bundle_context_t *ctx) : context(ctx) {
 -                this->cDepMan = celix_bundleContext_getDependencyManager(ctx);
 +            this->cDepMan = celix_bundleContext_getDependencyManager(ctx);
          }
 -
 +        
          virtual ~DependencyManager() {
 -                this->cDepMan = nullptr;
 +            this->cDepMan = nullptr;
          }
 -
 -        DependencyManager(DependencyManager&& mgr) : componentsMutex{} {
 -                std::lock_guard<std::recursive_mutex> lock(this->componentsMutex);
 -                mgr.context = this->context;
 -                mgr.queuedComponents = std::move(this->queuedComponents);
 -                mgr.startedComponents = std::move(this->startedComponents);
 -                mgr.cDepMan = this->cDepMan;
 -                this->cDepMan = nullptr;
 -                this->context = nullptr;
 +        
-         DependencyManager(DependencyManager&& mgr) : componentsMutex{} {
-             std::lock_guard<std::recursive_mutex> lock(this->componentsMutex);
-             mgr.context = this->context;
-             mgr.queuedComponents = std::move(this->queuedComponents);
-             mgr.startedComponents = std::move(this->startedComponents);
-             mgr.cDepMan = this->cDepMan;
-             this->cDepMan = nullptr;
-             this->context = nullptr;
++        DependencyManager(DependencyManager&& rhs) : componentsMutex{} {
++            std::lock_guard<std::recursive_mutex> lock1(rhs.componentsMutex);
++            std::lock_guard<std::recursive_mutex> lock2(this->componentsMutex);
++            this->context = rhs.context;
++            this->cDepMan = rhs.cDepMan;
++            this->queuedComponents = std::move(rhs.queuedComponents);
++            this->startedComponents = std::move(rhs.startedComponents);
++            rhs.cDepMan = nullptr;
++            rhs.context = nullptr;
          }
--        DependencyManager& operator=(DependencyManager&&) = default;
+ 
++        DependencyManager& operator=(DependencyManager&& rhs) {
++            std::lock_guard<std::recursive_mutex> lock1(rhs.componentsMutex);
++            std::lock_guard<std::recursive_mutex> lock2(this->componentsMutex);
++            this->context = rhs.context;
++            this->cDepMan = rhs.cDepMan;
++            this->queuedComponents = std::move(rhs.queuedComponents);
++            this->startedComponents = std::move(rhs.startedComponents);
++            rhs.cDepMan = nullptr;
++            rhs.context = nullptr;
++            return *this;
++        };
 +        
          DependencyManager(const DependencyManager&) = delete;
          DependencyManager& operator=(const DependencyManager&) = delete;
-         
-         bundle_context_pt bundleContext() const { return context; }
-         dm_dependency_manager_pt cDependencyManager() const { return cDepMan; }
-         
-         
+ 
+         celix_bundle_context_t* bundleContext() const { return context; }
+         celix_dependency_manager_t *cDependencyManager() const { return cDepMan; }
+ 
+ 
          /**
           * Creates and adds a new DM Component for a component of type T.
           *
@@@ -100,48 -101,48 +112,59 @@@
           * Starts the Dependency Manager
           */
          void start() {
 -                std::vector<std::unique_ptr<BaseComponent>> toBeStartedComponents {};
 +            std::vector<std::unique_ptr<BaseComponent>> toBeStartedComponents {};
 +            {
 +                std::lock_guard<std::recursive_mutex> lock(componentsMutex);
 +                for (auto it = queuedComponents.begin(); it != queuedComponents.end(); ++it) {
 +                    toBeStartedComponents.push_back(std::move(*it));
 +                }
 +                queuedComponents.clear();
 +            }
 +            for (auto it = toBeStartedComponents.begin(); it != toBeStartedComponents.end(); ++it) {
 +                
-                 dependencyManager_add(cDepMan, (*it)->cComponent());
++                celix_dependencyManager_add(cDepMan, (*it)->cComponent());
                  {
-                     std::lock_guard<std::recursive_mutex> lock(componentsMutex);
-                     startedComponents.push_back(std::move(*it));
+                         std::lock_guard<std::recursive_mutex> lock(componentsMutex);
+                         for (auto it = queuedComponents.begin(); it != queuedComponents.end(); ++it) {
+                                 toBeStartedComponents.push_back(std::move(*it));
+                         }
+                         queuedComponents.clear();
+                 }
+                 for (auto it = toBeStartedComponents.begin(); it != toBeStartedComponents.end(); ++it) {
+ 
+                         celix_dependencyManager_add(cDepMan, (*it)->cComponent());
+                         {
+                                 std::lock_guard<std::recursive_mutex> lock(componentsMutex);
+                                 startedComponents.push_back(std::move(*it));
+                         }
                  }
 +            }
          }
 -
 +        
          /**
           * Removes a component from the  Dependency Manager and destroys it
           */
          template<typename T>
          void destroyComponent(Component<T> &component) {
-             dependencyManager_remove(cDepMan, component.cComponent());
+             celix_dependencyManager_remove(cDepMan, component.cComponent());
          }
 -
 +        
          /**
           * Stops the Dependency Manager
           */
          void stop() {
-             dependencyManager_removeAllComponents(cDepMan);
-             queuedComponents.clear();
-             startedComponents.clear();
+                 celix_dependencyManager_removeAllComponents(cDepMan);
+                 queuedComponents.clear();
+                 startedComponents.clear();
          }
      private:
-         bundle_context_pt context {nullptr};
+         celix_bundle_context_t *context {nullptr};
++        celix_dependency_manager_t* cDepMan {nullptr};
          std::vector<std::unique_ptr<BaseComponent>> queuedComponents {};
          std::vector<std::unique_ptr<BaseComponent>> startedComponents {};
-         dm_dependency_manager_pt cDepMan {nullptr};
 -        celix_dependency_manager_t* cDepMan {nullptr};
          std::recursive_mutex componentsMutex{};
      };
 -
 +    
  }}
  
  #include "celix/dm/DependencyManager_Impl.h"
diff --cc libs/framework/include/celix/dm/DependencyManager.h.orig
index 538edb1,c00872d..cf4a038
--- a/libs/framework/include/celix/dm/DependencyManager.h.orig
+++ b/libs/framework/include/celix/dm/DependencyManager.h.orig
@@@ -25,42 -22,46 +25,55 @@@
  #include "celix/dm/Component.h"
  #include "celix/dm/ServiceDependency.h"
  
 -#include "bundle_context.h"
  #include "celix_bundle_context.h"
- #include "dm_dependency_manager.h"
+ #include "celix_dependency_manager.h"
  
  #include <vector>
  #include <mutex>
  
 -#ifndef CELIX_DM_DEPENDENCYMANAGER_H
 -#define CELIX_DM_DEPENDENCYMANAGER_H
 -
  namespace celix { namespace dm {
 -
 +    
      class DependencyManager {
      public:
++<<<<<<< HEAD
 +        DependencyManager(bundle_context_pt ctx) : context(ctx) {
 +            this->cDepMan = celix_bundleContext_getDependencyManager(ctx);
++=======
+         DependencyManager(celix_bundle_context_t *ctx) : context(ctx) {
+                 this->cDepMan = celix_bundleContext_getDependencyManager(ctx);
++>>>>>>> develop
          }
 -
 +        
          virtual ~DependencyManager() {
 -                this->cDepMan = nullptr;
 +            this->cDepMan = nullptr;
          }
 -
 +        
          DependencyManager(DependencyManager&& mgr) : componentsMutex{} {
 -                std::lock_guard<std::recursive_mutex> lock(this->componentsMutex);
 -                mgr.context = this->context;
 -                mgr.queuedComponents = std::move(this->queuedComponents);
 -                mgr.startedComponents = std::move(this->startedComponents);
 -                mgr.cDepMan = this->cDepMan;
 -                this->cDepMan = nullptr;
 -                this->context = nullptr;
 +            std::lock_guard<std::recursive_mutex> lock(this->componentsMutex);
 +            mgr.context = this->context;
 +            mgr.queuedComponents = std::move(this->queuedComponents);
 +            mgr.startedComponents = std::move(this->startedComponents);
 +            mgr.cDepMan = this->cDepMan;
 +            this->cDepMan = nullptr;
 +            this->context = nullptr;
          }
          DependencyManager& operator=(DependencyManager&&) = default;
 -
 +        
          DependencyManager(const DependencyManager&) = delete;
          DependencyManager& operator=(const DependencyManager&) = delete;
++<<<<<<< HEAD
 +        
 +        bundle_context_pt bundleContext() const { return context; }
 +        dm_dependency_manager_pt cDependencyManager() const { return cDepMan; }
 +        
 +        
++=======
+ 
+         celix_bundle_context_t* bundleContext() const { return context; }
+         celix_dependency_manager_t *cDependencyManager() const { return cDepMan; }
+ 
+ 
++>>>>>>> develop
          /**
           * Creates and adds a new DM Component for a component of type T.
           *
@@@ -100,48 -101,48 +113,64 @@@
           * Starts the Dependency Manager
           */
          void start() {
 -                std::vector<std::unique_ptr<BaseComponent>> toBeStartedComponents {};
 -                {
 -                        std::lock_guard<std::recursive_mutex> lock(componentsMutex);
 -                        for (auto it = queuedComponents.begin(); it != queuedComponents.end(); ++it) {
 -                                toBeStartedComponents.push_back(std::move(*it));
 -                        }
 -                        queuedComponents.clear();
 +            std::vector<std::unique_ptr<BaseComponent>> toBeStartedComponents {};
 +            {
 +                std::lock_guard<std::recursive_mutex> lock(componentsMutex);
 +                for (auto it = queuedComponents.begin(); it != queuedComponents.end(); ++it) {
 +                    toBeStartedComponents.push_back(std::move(*it));
                  }
++<<<<<<< HEAD
 +                queuedComponents.clear();
 +            }
 +            for (auto it = toBeStartedComponents.begin(); it != toBeStartedComponents.end(); ++it) {
 +                
 +                dependencyManager_add(cDepMan, (*it)->cComponent());
 +                {
 +                    std::lock_guard<std::recursive_mutex> lock(componentsMutex);
 +                    startedComponents.push_back(std::move(*it));
++=======
+                 for (auto it = toBeStartedComponents.begin(); it != toBeStartedComponents.end(); ++it) {
+ 
+                         celix_dependencyManager_add(cDepMan, (*it)->cComponent());
+                         {
+                                 std::lock_guard<std::recursive_mutex> lock(componentsMutex);
+                                 startedComponents.push_back(std::move(*it));
+                         }
++>>>>>>> develop
                  }
 +            }
          }
 -
 +        
          /**
           * Removes a component from the  Dependency Manager and destroys it
           */
          template<typename T>
          void destroyComponent(Component<T> &component) {
-             dependencyManager_remove(cDepMan, component.cComponent());
+             celix_dependencyManager_remove(cDepMan, component.cComponent());
          }
 -
 +        
          /**
           * Stops the Dependency Manager
           */
          void stop() {
++<<<<<<< HEAD
 +            dependencyManager_removeAllComponents(cDepMan);
 +            queuedComponents.clear();
 +            startedComponents.clear();
++=======
+                 celix_dependencyManager_removeAllComponents(cDepMan);
+                 queuedComponents.clear();
+                 startedComponents.clear();
++>>>>>>> develop
          }
      private:
-         bundle_context_pt context {nullptr};
+         celix_bundle_context_t *context {nullptr};
          std::vector<std::unique_ptr<BaseComponent>> queuedComponents {};
          std::vector<std::unique_ptr<BaseComponent>> startedComponents {};
-         dm_dependency_manager_pt cDepMan {nullptr};
+         celix_dependency_manager_t* cDepMan {nullptr};
          std::recursive_mutex componentsMutex{};
      };
 -
 +    
  }}
  
  #include "celix/dm/DependencyManager_Impl.h"
diff --cc libs/framework/include/celix/impl/BundleContextImpl.h
index 85269d7,0000000..63d54e2
mode 100644,000000..100644
--- a/libs/framework/include/celix/impl/BundleContextImpl.h
+++ b/libs/framework/include/celix/impl/BundleContextImpl.h
@@@ -1,710 -1,0 +1,710 @@@
 +/**
 + *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 CELIX_IMPL_BUNDLECONTEXTIMPL_H
 +#define CELIX_IMPL_BUNDLECONTEXTIMPL_H
 +
- #include <mutex>
 +#include <cstring>
++#include <mutex>
 +#include <memory>
 +
 +#include "bundle_context.h"
 +#include "service_tracker.h"
 +
 +#include "celix/impl/BundleImpl.h"
 +#include "celix/dm/DependencyManager.h"
 +#include "celix_service_factory.h"
 +
 +namespace celix {
 +
 +    namespace impl {
 +        struct ServiceTrackingEntryFunctions {
 +            std::function<void(void *)> set{};
 +            std::function<void(void *, const celix::Properties &)> setWithProperties{};
 +            std::function<void(void *, const celix::Properties &, const celix::Bundle &)> setWithOwner{};
 +
 +            std::function<void(void *)> add{};
 +            std::function<void(void *, const celix::Properties &)> addWithProperties{};
 +            std::function<void(void *, const celix::Properties &, const celix::Bundle &)> addWithOwner{};
 +
 +            std::function<void(void *)> remove{};
 +            std::function<void(void *, const celix::Properties &)> removeWithProperties{};
 +            std::function<void(void *, const celix::Properties &, const celix::Bundle &)> removeWithOwner{};
 +        };
 +
 +        struct ServiceRegistrationEntry {
 +            ServiceRegistrationEntry() {
 +                std::memset(&this->cOpts, 0, sizeof(this->cOpts));
 +                std::memset(&this->factory, 0, sizeof(this->factory));
 +            }
 +
 +            celix_service_factory_t factory = {nullptr, nullptr, nullptr};
 +            celix_service_registration_options_t cOpts = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
 +            std::unique_ptr<IServiceAdapterBase> adapter{nullptr};
 +        };
 +
 +        struct ServiceTrackingEntry {
-             celix_service_tracking_options_t cOpts{{nullptr, nullptr, nullptr, nullptr}, nullptr, nullptr, nullptr, nullptr,
-                                                    nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
++            ServiceTrackingEntry() { std::memset(&cOpts, 0, sizeof(cOpts));}
++            celix_service_tracking_options cOpts;
 +            std::unique_ptr<ServiceTrackingEntryFunctions> functions{nullptr};
 +            std::unique_ptr<celix::IServiceAdapterFactoryBase> adapter{nullptr};
 +            std::map<void*, std::unique_ptr<celix::IServiceAdapterBase>> setAdaptersCache{};
 +            std::map<void*, std::unique_ptr<celix::IServiceAdapterBase>> addAndRemoveAdaptersCache{};
 +        };
 +    }
 +
 +    struct BundleContext::Impl {
 +        Impl(celix_bundle_context_t *_c_ctx, celix::Framework &_fw) : c_ctx(_c_ctx), fw(_fw), bnd(c_ctx), dm(c_ctx) {}
 +        ~Impl() = default;
 +
 +        Impl(const Impl&) = delete;
 +        Impl& operator=(const Impl&) = delete;
 +        Impl(Impl&&) = delete;
 +        Impl& operator=(Impl&&) = delete;
 +
 +        //initialized in ctor
-         bundle_context_t *c_ctx;
++        celix_bundle_context_t *c_ctx;
 +        celix::Framework& fw;
 +        celix::impl::BundleImpl bnd;
 +        celix::dm::DependencyManager dm;
 +
 +        std::mutex mutex{};
 +        std::map<long,std::unique_ptr<celix::impl::ServiceTrackingEntry>> trackingEntries{};
 +        std::map<long,celix::impl::ServiceRegistrationEntry> registrationEntries{};
 +
 +        long registerServiceInternal(celix::impl::ServiceRegistrationEntry &&entry) noexcept;
 +
 +        template<typename I>
 +        long trackServicesInternal(const celix::ServiceTrackingOptions<I> &opts, celix::IServiceUsageAdapterFactory<I> *factory);
 +        long trackServicesInternal(std::unique_ptr<celix::impl::ServiceTrackingEntry> entry) noexcept;
 +        bool useServiceInternal(const std::string &serviceName, const std::string &serviceVersionRange, const std::string &serviceLang, const std::function<void(void *svc, const celix::Properties &props, const celix::Bundle &svcOwner)> &use) noexcept;
 +        void useServicesInternal(const std::string &serviceName, const std::string &serviceVersionRange, const std::string &serviceLang, const std::function<void(void *svc, const celix::Properties &props, const celix::Bundle &svcOwner)> &use) noexcept;
 +    };
 +}
 +
 +namespace {
 +    static celix::Properties createFromCProps(const celix_properties_t *c_props) {
 +        celix::Properties result{};
 +        const char *key = nullptr;
 +        CELIX_PROPERTIES_FOR_EACH(const_cast<celix_properties_t *>(c_props), key) {
-             result[key] = celix_properties_get(c_props, key);
++            result[key] = celix_properties_get(c_props, key, nullptr);
 +        }
 +        return result;
 +    }
 +}
 +
- inline celix::BundleContext::BundleContext(bundle_context_t *ctx, celix::Framework& fw) {
++inline celix::BundleContext::BundleContext(celix_bundle_context_t *ctx, celix::Framework& fw) {
 +    this->pimpl = std::unique_ptr<celix::BundleContext::Impl>{new celix::BundleContext::Impl(ctx, fw)};
 +}
 +
 +inline celix::BundleContext::~BundleContext() {
 +    //NOTE no need to destroy the c bundle context -> done by c framework
 +    {
 +        //clearing service registration
 +        std::lock_guard<std::mutex> lock{this->pimpl->mutex};
 +        for (auto &pair : this->pimpl->registrationEntries) {
 +            celix_bundleContext_unregisterService(this->pimpl->c_ctx, pair.first);
 +        }
 +        this->pimpl->registrationEntries.clear();
 +    }
 +
 +    {
 +        //clearing tracker entries
 +        std::lock_guard<std::mutex> lock{this->pimpl->mutex};
 +        for (auto &pair : this->pimpl->trackingEntries) {
 +            celix_bundleContext_stopTracker(this->pimpl->c_ctx, pair.first);
 +        }
 +        this->pimpl->trackingEntries.clear();
 +    }
 +
 +    this->pimpl->c_ctx = nullptr;
 +    this->pimpl = nullptr;
 +}
 +
 +
 +inline void celix::BundleContext::unregisterService(long serviceId) noexcept {
 +    std::lock_guard<std::mutex> lock{this->pimpl->mutex};
 +    celix_bundleContext_unregisterService(this->pimpl->c_ctx, serviceId);
 +    auto it = this->pimpl->registrationEntries.find(serviceId);
 +    if (it != this->pimpl->registrationEntries.end()) {
 +        this->pimpl->registrationEntries.erase(it);
 +    }
 +}
 +
 +inline std::vector<long> celix::BundleContext::findServices(const std::string &/*serviceName*/, const std::string &/*versionRange*/, const std::string &/*filter*/, const std::string &/*lang = ""*/) noexcept {
 +    std::vector<long> result{};
 +//                auto use = [&result](void *, const celix::Properties &props, const celix::Bundle &) {
 +//                    long id = celix::getProperty(props, OSGI_FRAMEWORK_SERVICE_ID, -1);
 +//                    if (id >= 0) {
 +//                        result.push_back(id);
 +//                    }
 +//                };
 +    //TODO useServicesWithOptions this->useServicesInternal(serviceName, versionRange, filter, use);
 +    return result;
 +}
 +
 +inline void celix::BundleContext::stopTracker(long trackerId) noexcept {
 +    std::lock_guard<std::mutex> lock{this->pimpl->mutex};
 +    celix_bundleContext_stopTracker(this->pimpl->c_ctx, trackerId);
 +    auto it = this->pimpl->trackingEntries.find(trackerId);
 +    if (it != this->pimpl->trackingEntries.end()) {
 +        this->pimpl->trackingEntries.erase(it);
 +    }
 +}
 +
 +inline std::string celix::BundleContext::getProperty(const std::string &key, std::string defaultValue) noexcept {
 +    const char *val = nullptr;
 +    bundleContext_getPropertyWithDefault(this->pimpl->c_ctx, key.c_str(), defaultValue.c_str(), &val);
 +    return std::string{val};
 +}
 +
 +
 +//    long celix::BundleContext::registerEmbeddedBundle(
 +//            std::string /*id*/,
 +//            std::function<void(celix::BundleContext & ctx)> /*start*/,
 +//            std::function<void(celix::BundleContext & ctx)> /*stop*/,
 +//            celix::Properties /*manifest*/,
 +//            bool /*autoStart*/
 +//    ) noexcept  {
 +//        return -1; //TODO
 +//    };
 +//
 +//    void registerEmbeddedBundle(const celix::BundleRegistrationOptions &/*opts*/) noexcept override {
 +//        //TODO
 +//    }
 +
 +inline long celix::BundleContext::installBundle(const std::string &bundleLocation, bool autoStart) noexcept {
 +    long bndId = -1;
 +    if (this->pimpl->c_ctx != nullptr) {
-         bundle_t *bnd = nullptr;
++        celix_bundle_t *bnd = nullptr;
 +        bundleContext_installBundle(this->pimpl->c_ctx, bundleLocation.c_str(), &bnd);
 +        if (bnd != nullptr) {
 +            bundle_getBundleId(bnd, &bndId);
 +            if (autoStart) {
 +                bundle_start(bnd);
 +            }
 +        }
 +    }
 +    return bndId;
 +}
 +
 +
 +inline void celix::BundleContext::useBundles(const std::function<void(const celix::Bundle &bnd)> &use) noexcept {
 +    auto c_use = [](void *handle, const celix_bundle_t *c_bnd) {
 +        auto *func =  static_cast<std::function<void(const celix::Bundle &bnd)>*>(handle);
 +        auto m_bnd = const_cast<celix_bundle_t*>(c_bnd);
 +        celix::impl::BundleImpl bnd{m_bnd};
 +        (*func)(bnd);
 +    };
 +    celix_bundleContext_useBundles(this->pimpl->c_ctx, (void*)(&use), c_use);
 +}
 +
- inline bool celix::BundleContext::useBundle(long bundleId, const std::function<void(const celix::Bundle &bnd)> &use) noexcept {
++inline void celix::BundleContext::useBundle(long bundleId, const std::function<void(const celix::Bundle &bnd)> &use) noexcept {
 +    auto c_use = [](void *handle, const celix_bundle_t *c_bnd) {
 +        auto *func =  static_cast<std::function<void(const celix::Bundle &bnd)>*>(handle);
 +        auto m_bnd = const_cast<celix_bundle_t*>(c_bnd);
 +        celix::impl::BundleImpl bnd{m_bnd};
 +        (*func)(bnd);
 +    };
-     return celix_bundleContext_useBundle(this->pimpl->c_ctx, bundleId, (void*)(&use), c_use);
++    celix_bundleContext_useBundle(this->pimpl->c_ctx, bundleId, (void*)(&use), c_use);
 +}
 +
 +inline celix::Framework& celix::BundleContext::getFramework() noexcept {
 +    return this->pimpl->fw;
 +}
 +
 +inline celix::Bundle& celix::BundleContext::getBundle() noexcept {
 +    return this->pimpl->bnd;
 +};
 +
 +inline celix::dm::DependencyManager& celix::BundleContext::getDependencyManager() noexcept {
 +    return this->pimpl->dm;
 +}
 +
 +inline long celix::BundleContext::Impl::registerServiceInternal(celix::impl::ServiceRegistrationEntry&& entry) noexcept {
 +    long svcId = celix_bundleContext_registerServiceWithOptions(this->c_ctx, &entry.cOpts);
 +    if (svcId >= 0) {
 +        std::lock_guard<std::mutex> lock{this->mutex};
 +        this->registrationEntries[svcId] = std::move(entry);
 +    }
 +    return svcId;
 +}
 +
 +inline long celix::BundleContext::Impl::trackServicesInternal(std::unique_ptr<celix::impl::ServiceTrackingEntry> entry) noexcept {
 +    long trkId = celix_bundleContext_trackServicesWithOptions(this->c_ctx, &entry->cOpts);
 +    if (trkId >= 0) {
 +        std::lock_guard<std::mutex> lock{this->mutex};
 +        this->trackingEntries[trkId] = std::move(entry);
 +    }
 +    return trkId;
 +}
 +
 +inline bool celix::BundleContext::Impl::useServiceInternal(
 +        const std::string &serviceName,
 +        const std::string &serviceVersionRange,
 +        const std::string &serviceLang,
 +        const std::function<void(void *svc, const celix::Properties &props, const celix::Bundle &svcOwner)> &use) noexcept {
 +    auto c_use = [](void *handle, void *svc, const celix_properties_t *c_props, const celix_bundle_t *c_svcOwner) {
 +        auto *fn = static_cast<const std::function<void(void *svc, const celix::Properties &props, const celix::Bundle &svcOwner)> *>(handle);
 +        celix::Properties props = createFromCProps(c_props);
 +        celix_bundle_t *m_bnd = const_cast<celix_bundle_t*>(c_svcOwner);
 +        celix::impl::BundleImpl bnd{m_bnd};
 +        (*fn)(svc, props, bnd);
 +    };
 +
 +    celix_service_use_options_t opts;
 +    std::memset(&opts, 0, sizeof(opts));
 +
 +    opts.filter.serviceName = serviceName.empty() ? nullptr : serviceName.c_str();;
 +    opts.filter.versionRange = serviceVersionRange.empty() ? nullptr : serviceVersionRange.c_str();
 +    opts.filter.serviceLanguage = serviceLang.empty() ? celix::Constants::SERVICE_CXX_LANG : serviceLang.c_str();
 +    opts.callbackHandle = (void*)&use;
 +    opts.useWithOwner = c_use;
 +
 +    return celix_bundleContext_useServiceWithOptions(this->c_ctx, &opts);
 +}
 +
 +inline void celix::BundleContext::Impl::useServicesInternal(
 +        const std::string &serviceName,
 +        const std::string &serviceVersionRange,
 +        const std::string &serviceLang,
 +        const std::function<void(void *svc, const celix::Properties &props, const celix::Bundle &svcOwner)> &use) noexcept {
 +    auto c_use = [](void *handle, void *svc, const celix_properties_t *c_props, const celix_bundle_t *c_svcOwner) {
 +        auto *fn = static_cast<const std::function<void(void *svc, const celix::Properties &props, const celix::Bundle &svcOwner)> *>(handle);
 +        celix::Properties props = createFromCProps(c_props);
 +        celix_bundle_t *m_bnd = const_cast<celix_bundle_t*>(c_svcOwner);
 +        celix::impl::BundleImpl bnd{m_bnd};
 +        (*fn)(svc, props, bnd);
 +    };
 +
 +    celix_service_use_options_t opts;
 +    std::memset(&opts, 0, sizeof(opts));
 +
 +    opts.filter.serviceName = serviceName.empty() ? nullptr : serviceName.c_str();;
 +    opts.filter.versionRange = serviceVersionRange.empty() ? nullptr : serviceVersionRange.c_str();
 +    opts.filter.serviceLanguage = serviceLang.empty() ? celix::Constants::SERVICE_CXX_LANG : serviceLang.c_str();
 +    opts.callbackHandle = (void*)&use;
 +    opts.useWithOwner = c_use;
 +
 +    celix_bundleContext_useServicesWithOptions(this->c_ctx, &opts);
 +}
 +
 +template<typename I>
 +long celix::BundleContext::registerService(I *svc, Properties props) noexcept {
 +    using namespace celix;
 +    auto &factory = serviceRegistrationAdapterFactoryFor(svc /*note svc value not used, just the pointer type*/);
 +    auto *adapter = factory.createAdapter(svc);
 +
 +    celix_properties_t *c_props = celix_properties_create();
 +    for (auto &pair : props) {
 +        celix_properties_set(c_props, pair.first.c_str(), pair.second.c_str());
 +    }
 +
 +    celix::impl::ServiceRegistrationEntry re{};
 +    re.cOpts = CELIX_EMPTY_SERVICE_REGISTRATION_OPTIONS;
 +    re.cOpts.svc = static_cast<void*>(adapter->adapt());
 +    re.cOpts.serviceName = factory.serviceName().c_str();
 +    re.cOpts.serviceVersion = factory.serviceVersion().c_str();
 +    re.cOpts.serviceLanguage = factory.serviceLanguage().c_str();
 +    re.cOpts.properties = c_props;
 +    re.adapter = std::unique_ptr<IServiceAdapterBase>{adapter};
 +
 +    return this->pimpl->registerServiceInternal(std::move(re));
 +}
 +
 +template<typename I>
 +long celix::BundleContext::registerService(I *svc, const std::string &serviceName, Properties props) noexcept {
 +    celix::ServiceRegistrationOptions<I> opts{*svc, serviceName};
 +    opts.properties = std::move(props);
 +    return this->registerServiceWithOptions(opts);
 +}
 +
 +template<typename I>
 +long celix::BundleContext::registerCService(I *svc, const std::string &serviceName, Properties props) noexcept {
 +    static_assert(std::is_pod<I>::value, "Service I must be a 'Plain Old Data' object");
 +    celix::ServiceRegistrationOptions<I> opts{*svc, serviceName};
 +    opts.properties = std::move(props);
 +    opts.serviceLanguage = celix::Constants::SERVICE_C_LANG;
 +    return this->registerServiceWithOptions(opts);
 +}
 +
 +template<typename I>
 +long celix::BundleContext::registerServiceFactory(celix::IServiceFactory<I> *factory, const std::string &serviceName, celix::Properties props) {
 +    celix::ServiceRegistrationOptions<I> opts{factory, serviceName};
 +    opts.properties = std::move(props);
 +    return this->registerServiceWithOptions(opts);
 +}
 +
 +template<typename I>
 +long celix::BundleContext::registerCServiceFactory(IServiceFactory<I> *factory, const std::string &serviceName, celix::Properties props) {
 +    static_assert(std::is_pod<I>::value, "Service I must be a 'Plain Old Data' object");
 +    celix::ServiceRegistrationOptions<I> opts{factory, serviceName};
 +    opts.properties = std::move(props);
 +    opts.serviceLanguage = celix::Constants::SERVICE_C_LANG;
 +    return this->registerServiceWithOptions(opts);
 +}
 +
 +template<typename I>
 +long celix::BundleContext::registerServiceWithOptions(const celix::ServiceRegistrationOptions<I>& opts) noexcept {
 +    celix_properties_t *c_props = celix_properties_create();
 +    for (auto &pair : opts.properties) {
 +        celix_properties_set(c_props, pair.first.c_str(), pair.second.c_str());
 +    }
 +
 +    celix::impl::ServiceRegistrationEntry re{};
 +
 +    re.cOpts = CELIX_EMPTY_SERVICE_REGISTRATION_OPTIONS;
 +    if (opts.svc != nullptr) {
 +        re.cOpts.svc = static_cast<void *>(opts.svc);
 +    } else if (opts.factory != nullptr) {
 +        auto c_getService = [](void *handle, const celix_bundle_t *requestingBundle, const celix_properties_t *svcProperties) -> void* {
 +            celix::IServiceFactory<I> *f = static_cast<celix::IServiceFactory<I>*>(handle);
 +            auto mbnd = const_cast<celix_bundle_t*>(requestingBundle);
 +            celix::impl::BundleImpl bundle{mbnd};
 +            celix::Properties props = createFromCProps(svcProperties);
 +            I *svc = f->getService(bundle, props);
 +            return static_cast<void*>(svc);
 +        };
 +        auto c_ungetService = [](void *handle, const celix_bundle_t *requestingBundle, const celix_properties_t *svcProperties) {
 +            celix::IServiceFactory<I> *f = static_cast<celix::IServiceFactory<I>*>(handle);
 +            auto mbnd = const_cast<celix_bundle_t*>(requestingBundle);
 +            celix::impl::BundleImpl bundle{mbnd};
 +            celix::Properties props = createFromCProps(svcProperties);
 +            f->ungetService(bundle, props);
 +        };
 +        re.factory.handle = static_cast<void*>(opts.factory);
 +        re.factory.getService = c_getService;
 +        re.factory.ungetService = c_ungetService;
 +        re.cOpts.factory = &re.factory;
 +    }
 +
 +    re.cOpts.serviceName = opts.serviceName.c_str();
 +    re.cOpts.serviceVersion = opts.serviceVersion.c_str();
 +    re.cOpts.serviceLanguage = opts.serviceLanguage.c_str();
 +    re.cOpts.properties = c_props;
 +
 +    return this->pimpl->registerServiceInternal(std::move(re));
 +}
 +
 +template<typename I>
 +long celix::BundleContext::trackService(std::function<void(I *svc)> set) noexcept {
 +    using namespace celix;
 +    I* dummy = nullptr;
 +    auto &factory = serviceUsageAdapterFactoryFor(dummy);
 +
 +    celix::ServiceTrackingOptions<I> opts{factory.serviceName()};
 +    opts.filter.serviceLanguage = factory.serviceLanguage();
 +    opts.filter.versionRange = factory.serviceVersionRange();
 +    opts.set = set;
 +    return this->pimpl->trackServicesInternal<I>(opts, &factory);
 +}
 +
 +template<typename I>
 +long celix::BundleContext::trackService(const std::string &serviceName, std::function<void(I *svc)> set) noexcept {
 +    celix::ServiceTrackingOptions<I> opts{serviceName};
 +    opts.set = std::move(set);
 +    return this->trackServicesWithOptions<I>(opts);
 +}
 +
 +template<typename I>
 +long celix::BundleContext::trackServices(const std::string &serviceName,
 +        std::function<void(I *svc)> add, std::function<void(I *svc)> remove) noexcept {
 +    celix::ServiceTrackingOptions<I> opts{serviceName};
 +    opts.add = std::move(add);
 +    opts.remove = std::move(remove);
 +    return this->trackServicesWithOptions<I>(opts);
 +}
 +
 +template<typename I>
 +long celix::BundleContext::trackServicesWithOptions(const celix::ServiceTrackingOptions<I> &opts) {
 +    return this->pimpl->trackServicesInternal<I>(opts, nullptr);
 +}
 +
 +template<typename I>
 +static I* svcFor(celix::IServiceUsageAdapterFactory<I> *factory, std::map<void*, std::unique_ptr<celix::IServiceAdapterBase>> &cache, void *svc) {
 +    I* result = nullptr;
 +    if (svc != nullptr) {
 +        if (factory != nullptr) {
 +            //checking cache
 +            auto it = cache.find(svc);
 +            if (it != cache.end()) {
 +                celix::IServiceAdapterBase *base = it->second.get();
 +                auto *adapter = static_cast<celix::IServiceAdapter<I>*>(base);
 +                result = adapter->adapt();
 +            } else {
 +                celix::IServiceAdapter<I> *adapter = factory->createAdapter(svc);
 +                cache[svc] = std::unique_ptr<celix::IServiceAdapterBase>{adapter};
 +                result = adapter->adapt();
 +            }
 +        } else {
 +            result = static_cast<I*>(svc);
 +        }
 +    }
 +    return result;
 +}
 +
 +static inline void updateSetCache(std::map<void*, std::unique_ptr<celix::IServiceAdapterBase>> &cache, void *currentSetSvc) {
 +    if (currentSetSvc == nullptr) {
 +        cache.clear();
 +    } else {
 +        auto it = cache.begin();
 +        while (it != cache.end()) {
 +            if (it->first != currentSetSvc) {
 +                cache.erase(it++);
 +            } else {
 +                ++it;
 +            }
 +        }
 +    }
 +}
 +
 +static inline void removeFromCache(std::map<void*, std::unique_ptr<celix::IServiceAdapterBase>> &cache, void *removedSvc) {
 +    auto it = cache.find(removedSvc);
 +    if (it != cache.end()) {
 +        cache.erase(it);
 +    }
 +}
 +
 +template<typename I>
 +long celix::BundleContext::Impl::trackServicesInternal(const celix::ServiceTrackingOptions<I> &opts, celix::IServiceUsageAdapterFactory<I> *factory) {
 +    auto entry = std::unique_ptr<celix::impl::ServiceTrackingEntry>{new celix::impl::ServiceTrackingEntry()};
 +    auto *entryPtr = entry.get();
 +    entry->functions = std::unique_ptr<celix::impl::ServiceTrackingEntryFunctions>{new celix::impl::ServiceTrackingEntryFunctions()};
 +
 +    auto set = opts.set;
 +    if (set) {
 +        auto voidfunc = [entryPtr, factory, set](void *voidSvc) {
 +            I *typedSvc = svcFor<I>(factory, entryPtr->setAdaptersCache, voidSvc);
 +            set(typedSvc);
 +            updateSetCache(entryPtr->setAdaptersCache, voidSvc);
 +        };
 +        entry->functions->set = voidfunc;
 +        entry->cOpts.set = [](void *handle, void *svc) {
 +            auto *fentry = static_cast<celix::impl::ServiceTrackingEntryFunctions*>(handle);
 +            (fentry->set)(svc);
 +        };
 +    }
 +
 +    auto setWithProperties = opts.setWithProperties;
 +    if (setWithProperties) {
 +        auto voidfunc = [entryPtr, factory, setWithProperties](void *voidSvc, const celix::Properties &props) {
 +            I *typedSvc = svcFor<I>(factory, entryPtr->setAdaptersCache, voidSvc);
 +            setWithProperties(typedSvc, props);
 +            updateSetCache(entryPtr->setAdaptersCache, voidSvc);
 +        };
 +        entry->functions->setWithProperties = voidfunc;
 +        entry->cOpts.setWithProperties = [](void *handle, void *svc, const celix_properties_t *c_props) {
 +            auto *fentry = static_cast<celix::impl::ServiceTrackingEntryFunctions*>(handle);
 +            celix::Properties props = createFromCProps(c_props);
 +            (fentry->setWithProperties)(svc, props);
 +        };
 +    }
 +
 +    auto setWithOwner = opts.setWithOwner;
 +    if (setWithOwner) {
 +        auto voidfunc = [entryPtr, factory, setWithOwner](void *voidSvc, const celix::Properties &props, const celix::Bundle &bnd) {
 +            I *typedSvc = svcFor<I>(factory, entryPtr->setAdaptersCache, voidSvc);
 +            setWithOwner(typedSvc, props, bnd);
 +            updateSetCache(entryPtr->setAdaptersCache, voidSvc);
 +        };
 +        entry->functions->setWithOwner = voidfunc;
 +        entry->cOpts.setWithOwner = [](void *handle, void *svc, const celix_properties_t *c_props, const celix_bundle_t *c_bnd) {
 +            auto *fentry = static_cast<celix::impl::ServiceTrackingEntryFunctions*>(handle);
 +            celix::Properties props = createFromCProps(c_props);
 +            auto m_bnd = const_cast<celix_bundle_t *>(c_bnd);
 +            celix::impl::BundleImpl bnd{m_bnd};
 +            (fentry->setWithOwner)(svc, props, bnd);
 +        };
 +    }
 +
 +    auto add = opts.add;
 +    if (add) {
 +        auto voidfunc = [entryPtr, factory, add](void *voidSvc) {
 +            I *typedSvc = svcFor<I>(factory, entryPtr->addAndRemoveAdaptersCache, voidSvc);
 +            add(typedSvc);
 +        };
 +        entry->functions->add = voidfunc;
 +        entry->cOpts.add = [](void *handle, void *svc) {
 +            auto *fentry = static_cast<celix::impl::ServiceTrackingEntryFunctions*>(handle);
 +            (fentry->add)(svc);
 +        };
 +    }
 +
 +    auto addWithProperties = opts.addWithProperties;
 +    if (addWithProperties) {
 +        auto voidfunc = [entryPtr, factory, addWithProperties](void *voidSvc, const celix::Properties &props) {
 +            I *typedSvc = svcFor<I>(factory, entryPtr->addAndRemoveAdaptersCache, voidSvc);
 +            addWithProperties(typedSvc, props);
 +        };
 +        entry->functions->addWithProperties = voidfunc;
 +        entry->cOpts.addWithProperties = [](void *handle, void *svc, const celix_properties_t *c_props) {
 +            auto *fentry = static_cast<celix::impl::ServiceTrackingEntryFunctions*>(handle);
 +            celix::Properties props = createFromCProps(c_props);
 +            (fentry->addWithProperties)(svc, props);
 +        };
 +    }
 +
 +    auto addWithOwner = opts.addWithOwner;
 +    if (addWithOwner) {
 +        auto voidfunc = [entryPtr, factory, addWithOwner](void *voidSvc, const celix::Properties &props, const celix::Bundle &bnd) {
 +            I *typedSvc = svcFor<I>(factory, entryPtr->addAndRemoveAdaptersCache, voidSvc);
 +            addWithOwner(typedSvc, props, bnd);
 +        };
 +        entry->functions->addWithOwner = voidfunc;
 +        entry->cOpts.addWithOwner = [](void *handle, void *svc, const celix_properties_t *c_props, const celix_bundle_t *c_bnd) {
 +            auto *fentry = static_cast<celix::impl::ServiceTrackingEntryFunctions*>(handle);
 +            celix::Properties props = createFromCProps(c_props);
 +            auto m_bnd = const_cast<celix_bundle_t *>(c_bnd);
 +            celix::impl::BundleImpl bnd{m_bnd};
 +            (fentry->addWithOwner)(svc, props, bnd);
 +        };
 +    }
 +
 +    auto remove = opts.remove;
 +    if (remove) {
 +        auto voidfunc = [entryPtr, factory, remove](void *voidSvc) {
 +            I *typedSvc = svcFor<I>(factory, entryPtr->addAndRemoveAdaptersCache, voidSvc);
 +            remove(typedSvc);
 +            removeFromCache(entryPtr->addAndRemoveAdaptersCache, voidSvc);
 +        };
 +        entry->functions->remove = voidfunc;
 +        entry->cOpts.remove = [](void *handle, void *svc) {
 +            auto *fentry = static_cast<celix::impl::ServiceTrackingEntryFunctions*>(handle);
 +            (fentry->add)(svc);
 +        };
 +    }
 +
 +    auto removeWithProperties = opts.removeWithProperties;
 +    if (removeWithProperties) {
 +        auto voidfunc = [entryPtr, factory, removeWithProperties](void *voidSvc, const celix::Properties &props) {
 +            I *typedSvc = svcFor<I>(factory, entryPtr->addAndRemoveAdaptersCache, voidSvc);
 +            removeWithProperties(typedSvc, props);
 +            removeFromCache(entryPtr->addAndRemoveAdaptersCache, voidSvc);
 +        };
 +        entry->functions->removeWithProperties = voidfunc;
 +        entry->cOpts.removeWithProperties = [](void *handle, void *svc, const celix_properties_t *c_props) {
 +            auto *fentry = static_cast<celix::impl::ServiceTrackingEntryFunctions*>(handle);
 +            celix::Properties props = createFromCProps(c_props);
 +            (fentry->removeWithProperties)(svc, props);
 +        };
 +    }
 +
 +    auto removeWithOwner = opts.removeWithOwner;
 +    if (removeWithOwner) {
 +        auto voidfunc = [entryPtr, factory, removeWithOwner](void *voidSvc, const celix::Properties &props, const celix::Bundle &bnd) {
 +            I *typedSvc = svcFor<I>(factory, entryPtr->addAndRemoveAdaptersCache, voidSvc);
 +            removeWithOwner(typedSvc, props, bnd);
 +            removeFromCache(entryPtr->addAndRemoveAdaptersCache, voidSvc);
 +        };
 +        entry->functions->removeWithOwner = voidfunc;
 +        entry->cOpts.removeWithOwner = [](void *handle, void *svc, const celix_properties_t *c_props, const celix_bundle_t *c_bnd) {
 +            auto *fentry = static_cast<celix::impl::ServiceTrackingEntryFunctions*>(handle);
 +            celix::Properties props = createFromCProps(c_props);
 +            auto m_bnd = const_cast<celix_bundle_t *>(c_bnd);
 +            celix::impl::BundleImpl bnd{m_bnd};
 +            (fentry->removeWithOwner)(svc, props, bnd);
 +        };
 +    }
 +
 +    entry->cOpts.filter.serviceName = opts.filter.serviceName.c_str();
 +    entry->cOpts.filter.serviceLanguage = opts.filter.serviceLanguage.c_str();
 +    entry->cOpts.filter.versionRange = opts.filter.versionRange.c_str();
 +    entry->cOpts.filter.filter = opts.filter.filter.c_str();
 +
 +    entry->cOpts.callbackHandle = entry->functions.get();
 +
 +    return this->trackServicesInternal(std::move(entry));
 +}
 +
 +template<typename I>
 +bool celix::BundleContext::useServiceWithId(long serviceId, const std::string &/*serviceName*/ /*sanity*/, const std::function<void(I &svc, const celix::Properties &props, const celix::Bundle &svcOwner)> &/*use*/) noexcept {
 +    std::string filter = std::string{"(service.id="} + std::to_string(serviceId) + std::string{")"};
 +    //TODO use useServiceWithOptions return this->useService<I>(serviceName, "", filter, use);
 +    return false;
 +}
 +
 +template<typename I>
 +bool celix::BundleContext::useServiceWithId(long serviceId, const std::string &/*serviceName*/ /*sanity*/, const std::function<void(I &svc)> &/*use*/) noexcept {
 +    std::string filter = std::string{"(service.id="} + std::to_string(serviceId) + std::string{")"};
 +    //TODO use useServiceWithOptions return this->useService<I>(serviceName, "", filter, use);
 +    return false;
 +}
 +
 +template<typename I>
 +bool celix::BundleContext::useService(const std::string &serviceName, const std::function<void(I &svc, const celix::Properties &props, const celix::Bundle &svcOwner)> &use) noexcept {
 +    return this->pimpl->useServiceInternal(serviceName, "", "", [use](void *voidSvc, const celix::Properties &props, const celix::Bundle &svcOwner) {
 +        I *typedSvc = static_cast<I*>(voidSvc);
 +        use(*typedSvc, props, svcOwner);
 +    });
 +}
 +
 +template<typename I>
 +bool celix::BundleContext::useService(const std::string &serviceName, const std::function<void(I &svc)> &use) noexcept {
 +    return this->pimpl->useServiceInternal(serviceName, "", "", [use](void *voidSvc, const celix::Properties &, const celix::Bundle &) {
 +        I *typedSvc = static_cast<I*>(voidSvc);
 +        use(*typedSvc);
 +    });
 +}
 +
 +template<typename I>
 +bool celix::BundleContext::useService(const std::function<void(I &svc)> &use) noexcept {
 +    using namespace celix;
 +    I* dummy = nullptr;
 +    auto &factory = serviceUsageAdapterFactoryFor(dummy);
 +    bool called = this->pimpl->useServiceInternal(factory.serviceName(), factory.serviceVersionRange(), factory.serviceLanguage(), [&](void *voidSvc, const celix::Properties&, const celix::Bundle&){
 +        auto *adapter = factory.createAdapter(voidSvc);
 +        auto *adapted = adapter->adapt();
 +        use(*adapted);
 +        free(adapter);
 +    });
 +    return called;
 +}
 +
 +template<typename I>
 +void celix::BundleContext::useServices(const std::function<void(I &svc)> &use) noexcept {
 +    using namespace celix;
 +    I* dummy = nullptr;
 +    auto &factory = serviceUsageAdapterFactoryFor(dummy);
 +    this->pimpl->useServicesInternal(factory.serviceName(), factory.serviceVersionRange(), factory.serviceLanguage(), [&](void *voidSvc, const celix::Properties&, const celix::Bundle&){
 +        auto *adapter = factory.createAdapter(voidSvc);
 +        auto *adapted = adapter->adapt();
 +        use(*adapted);
 +        free(adapter);
 +    });
 +}
 +
 +template<typename I>
 +void celix::BundleContext::useServices(const std::string &serviceName, const std::function<void(I &svc, const celix::Properties &props, const celix::Bundle &svcOwner)> &use) noexcept {
 +    this->pimpl->useServicesInternal(serviceName, "", "", [use](void *voidSvc, const celix::Properties &props, const celix::Bundle &svcOwner) {
 +        I *typedSvc = static_cast<I*>(voidSvc);
 +        use(*typedSvc, props, svcOwner);
 +    });
 +}
 +
 +template<typename I>
 +void celix::BundleContext::useServices(const std::string &serviceName, const std::function<void(I &svc)> &use) noexcept {
 +    this->pimpl->useServicesInternal(serviceName, "", "", [use](void *voidSvc, const celix::Properties &, const celix::Bundle &) {
 +        I *typedSvc = static_cast<I*>(voidSvc);
 +        use(*typedSvc);
 +    });
 +}
 +
 +
 +
 +#endif //CELIX_IMPL_BUNDLECONTEXTIMPL_H
diff --cc libs/framework/include/celix/impl/FrameworkImpl.h
index 45e5ea5,0000000..ba1f636
mode 100644,000000..100644
--- a/libs/framework/include/celix/impl/FrameworkImpl.h
+++ b/libs/framework/include/celix/impl/FrameworkImpl.h
@@@ -1,127 -1,0 +1,127 @@@
 +/**
 + *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 CXX_CELIX_IMPL_FRAMEWORKIMPL_H
 +#define CXX_CELIX_IMPL_FRAMEWORKIMPL_H
 +
 +#include "celix_framework_factory.h"
 +#include "framework.h"
 +
 +#include "celix/impl/BundleContextImpl.h"
 +#include "celix/impl/BundleImpl.h"
 +
 +namespace celix {
 +
 +    namespace impl {
 +
 +        class FrameworkImpl : public celix::Framework {
 +        public:
 +            FrameworkImpl(celix_bundle_context_t *c_ctx) : owner(false) {
 +                bundleContext_getFramework(c_ctx, &this->c_fwm);
 +                this->setFrameworkContext();
 +            }
 +
-             FrameworkImpl(framework_t *c_fw) : owner(false) {
++            FrameworkImpl(celix_framework_t *c_fw) : owner(false) {
 +                //wrapper framework
 +                this->c_fwm = c_fw;
 +                //assume started framework
 +                this->setFrameworkContext();
 +            }
 +
 +            FrameworkImpl(const FrameworkImpl&) = delete;
 +            FrameworkImpl& operator=(const FrameworkImpl&) = delete;
 +            FrameworkImpl(FrameworkImpl&&) = delete;
 +            FrameworkImpl& operator=(FrameworkImpl&&) = delete;
 +
 +            FrameworkImpl(celix::Properties config) : owner(true) {
 +                //framework which also owns the underlining c framework
 +                auto c_config = properties_create();
 +                for (auto &pair : config) {
 +                    properties_set(c_config, pair.first.c_str(), pair.second.c_str());
 +                }
 +                this->c_fwm = frameworkFactory_newFramework(c_config); //should be started
 +
 +                this->setFrameworkContext();
 +            };
 +
 +            virtual ~FrameworkImpl() {
 +                if (this->owner && this->c_fwm != nullptr) {
 +                    framework_stop(this->c_fwm);
 +                    framework_waitForStop(this->c_fwm);
 +                    framework_destroy(this->c_fwm);
 +                }
 +            }
 +
 +            virtual void start() noexcept override {
 +                framework_start(this->c_fwm);
 +            }
 +
 +            virtual void stop() noexcept override {
 +                framework_stop(this->c_fwm);
 +            }
 +
 +            virtual void waitForStop() noexcept override {
 +                framework_waitForStop(this->c_fwm);
 +            }
 +            //TODO also in c virtual void breakWaitForStops() noexcept = 0;
 +
 +            std::string getUUID() const noexcept override {
 +                //TODO return std::string{celix_framework_getUUID(this->c_fwm)};
 +                return "TODO";
 +            }
 +
 +            celix::BundleContext& getFrameworkContext() noexcept override {
 +                BundleContext &ctx = this->bundleContextsCache.at(0);
 +                return ctx;
 +            }
 +
 +            celix::Bundle& getFrameworkBundle() noexcept override {
 +                if (this->fwBundle.size() == 0) {
 +                    celix_bundle_t* c_bnd = nullptr;
 +                    framework_getFrameworkBundle(this->c_fwm, &c_bnd);
 +                    this->fwBundle.emplace_back(c_bnd);
 +
 +                }
 +                return this->fwBundle[0];
 +            }
 +
 +        private:
 +
 +            void setFrameworkContext() {
 +                //create and set framework bundle context (replace invalid bundle context)
-                 bundle_t *fwmBundle = nullptr;
-                 bundle_context_t *fwmCtx = nullptr;
++                celix_bundle_t *fwmBundle = nullptr;
++                celix_bundle_context_t *fwmCtx = nullptr;
 +                framework_getFrameworkBundle(this->c_fwm, &fwmBundle);
 +                bundle_getContext(fwmBundle, &fwmCtx);
 +                this->bundleContextsCache.emplace(std::piecewise_construct,
 +                                                    std::forward_as_tuple(0L),
 +                                                    std::forward_as_tuple(fwmCtx, *this));
 +            }
 +
 +
 +            bool owner;
-             framework_t *c_fwm{nullptr};
++            celix_framework_t *c_fwm{nullptr};
 +            std::map<long,celix::BundleContext> bundleContextsCache{};
 +            std::vector<celix::impl::BundleImpl> fwBundle{}; //optional entry
 +
 +        };
 +    }
 +}
 +
 +#endif //CXX_CELIX_IMPL_FRAMEWORKIMPL_H
diff --cc libs/framework/include/celix_bundle_context.h
index 634145e,fc7d978..5985b2e
--- a/libs/framework/include/celix_bundle_context.h
+++ b/libs/framework/include/celix_bundle_context.h
@@@ -726,12 -770,54 +770,50 @@@ long celix_bundleContext_trackServiceTr
   *
   * @return the dependency manager or NULL if unsuccessful.
   */
- dm_dependency_manager_t* celix_bundleContext_getDependencyManager(celix_bundle_context_t *ctx);
+ celix_dependency_manager_t* celix_bundleContext_getDependencyManager(celix_bundle_context_t *ctx);
  
 -
 -/**
 - * Returns the bundle for this bundle context.
 - */
  celix_bundle_t* celix_bundleContext_getBundle(celix_bundle_context_t *ctx);
  
+ 
+ /**
+  * Gets the config property - or environment variable if the config property does not exist - for the provided name.
+  * @param key The key of the property to receive.
+  * @param defaultVal The default value to use if the property is not found (can be NULL).
+  * @return The property value for the provided key or the provided defaultValue is the key is not found.
+  */
  const char* celix_bundleContext_getProperty(celix_bundle_context_t *ctx, const char *key, const char *defaultVal);
  
+ /**
+  * Gets the config property as converts it to long. If the property is not a valid long, the defaultValue will be returned.
+  * The rest of the behaviour is the same as celix_bundleContext_getProperty.
+ 
+  * @param key The key of the property to receive.
+  * @param defaultVal The default value to use if the property is not found.
+  * @return The property value for the provided key or the provided defaultValue is the key is not found.
+  */
+ long celix_bundleContext_getPropertyAsLong(celix_bundle_context_t *ctx, const char *key, long defaultValue);
+ 
+ /**
+  * Gets the config property as converts it to double. If the property is not a valid double, the defaultValue will be returned.
+  * The rest of the behaviour is the same as celix_bundleContext_getProperty.
+ 
+  * @param key The key of the property to receive.
+  * @param defaultVal The default value to use if the property is not found.
+  * @return The property value for the provided key or the provided defaultValue is the key is not found.
+  */
+ double celix_bundleContext_getPropertyAsDouble(celix_bundle_context_t *ctx, const char *key, double defaultValue);
+ 
+ /**
+  * Gets the config property as converts it to bool. If the property is not a valid bool, the defaultValue will be returned.
+  * The rest of the behaviour is the same as celix_bundleContext_getProperty.
+ 
+  * @param key The key of the property to receive.
+  * @param defaultVal The default value to use if the property is not found.
+  * @return The property value for the provided key or the provided defaultValue is the key is not found.
+  */
+ bool celix_bundleContext_getPropertyAsBool(celix_bundle_context_t *ctx, const char *key, bool defaultValue);
+ 
+ //TODO getPropertyAs for int, uint, ulong, bool, etc
  
  #ifdef __cplusplus
  }
diff --cc libs/framework/include/celix_bundle_context.h.orig
index 634145e,fc7d978..3c655b1
--- a/libs/framework/include/celix_bundle_context.h.orig
+++ b/libs/framework/include/celix_bundle_context.h.orig
@@@ -726,12 -770,54 +770,55 @@@ long celix_bundleContext_trackServiceTr
   *
   * @return the dependency manager or NULL if unsuccessful.
   */
- dm_dependency_manager_t* celix_bundleContext_getDependencyManager(celix_bundle_context_t *ctx);
+ celix_dependency_manager_t* celix_bundleContext_getDependencyManager(celix_bundle_context_t *ctx);
  
 -
 -/**
 - * Returns the bundle for this bundle context.
 - */
  celix_bundle_t* celix_bundleContext_getBundle(celix_bundle_context_t *ctx);
  
++<<<<<<< HEAD
++const char* celix_bundleContext_getProperty(celix_bundle_context_t *ctx, const char *key, const char *defaultVal);
++
++=======
+ 
+ /**
+  * Gets the config property - or environment variable if the config property does not exist - for the provided name.
+  * @param key The key of the property to receive.
+  * @param defaultVal The default value to use if the property is not found (can be NULL).
+  * @return The property value for the provided key or the provided defaultValue is the key is not found.
+  */
  const char* celix_bundleContext_getProperty(celix_bundle_context_t *ctx, const char *key, const char *defaultVal);
  
+ /**
+  * Gets the config property as converts it to long. If the property is not a valid long, the defaultValue will be returned.
+  * The rest of the behaviour is the same as celix_bundleContext_getProperty.
+ 
+  * @param key The key of the property to receive.
+  * @param defaultVal The default value to use if the property is not found.
+  * @return The property value for the provided key or the provided defaultValue is the key is not found.
+  */
+ long celix_bundleContext_getPropertyAsLong(celix_bundle_context_t *ctx, const char *key, long defaultValue);
+ 
+ /**
+  * Gets the config property as converts it to double. If the property is not a valid double, the defaultValue will be returned.
+  * The rest of the behaviour is the same as celix_bundleContext_getProperty.
+ 
+  * @param key The key of the property to receive.
+  * @param defaultVal The default value to use if the property is not found.
+  * @return The property value for the provided key or the provided defaultValue is the key is not found.
+  */
+ double celix_bundleContext_getPropertyAsDouble(celix_bundle_context_t *ctx, const char *key, double defaultValue);
+ 
+ /**
+  * Gets the config property as converts it to bool. If the property is not a valid bool, the defaultValue will be returned.
+  * The rest of the behaviour is the same as celix_bundleContext_getProperty.
+ 
+  * @param key The key of the property to receive.
+  * @param defaultVal The default value to use if the property is not found.
+  * @return The property value for the provided key or the provided defaultValue is the key is not found.
+  */
+ bool celix_bundleContext_getPropertyAsBool(celix_bundle_context_t *ctx, const char *key, bool defaultValue);
+ 
+ //TODO getPropertyAs for int, uint, ulong, bool, etc
++>>>>>>> develop
  
  #ifdef __cplusplus
  }
diff --cc libs/framework/include/celix_constants.h
index 10996a4,0000000..b103e25
mode 100644,000000..100644
--- a/libs/framework/include/celix_constants.h
+++ b/libs/framework/include/celix_constants.h
@@@ -1,80 -1,0 +1,78 @@@
 +/**
 + *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 CELIX_CONSTANTS_H_
 +#define CELIX_CONSTANTS_H_
 +
 +#ifdef __cplusplus
 +extern "C" {
 +#endif
 +
++#include <stdbool.h>
++
 +#define OSGI_FRAMEWORK_OBJECTCLASS "objectClass"
 +#define OSGI_FRAMEWORK_SERVICE_ID "service.id"
 +#define OSGI_FRAMEWORK_SERVICE_PID "service.pid"
 +#define OSGI_FRAMEWORK_SERVICE_RANKING "service.ranking"
 +
 +#define CELIX_FRAMEWORK_SERVICE_VERSION "service.version"
 +#define CELIX_FRAMEWORK_SERVICE_LANGUAGE "service.lang"
 +#define CELIX_FRAMEWORK_SERVICE_C_LANGUAGE "C"
 +#define CELIX_FRAMEWORK_SERVICE_CXX_LANGUAGE "C++"
- #define CELIX_FRAMEWORK_SERVICE_SHARED_LANGUAGE "shared" //e.g. marker services
 +
 +#define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR "Bundle-Activator"
 +
- #define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_CREATE "celix_bundleActivator_create"
- #define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_START "celix_bundleActivator_start"
- #define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP "celix_bundleActivator_stop"
- #define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY "celix_bundleActivator_destroy"
- 
- #define OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_CREATE "bundleActivator_create"
- #define OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_START "bundleActivator_start"
- #define OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_STOP "bundleActivator_stop"
- #define OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_DESTROY "bundleActivator_destroy"
++#define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_CREATE      "celix_bundleActivator_create"
++#define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_START       "celix_bundleActivator_start"
++#define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP        "celix_bundleActivator_stop"
++#define OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY     "celix_bundleActivator_destroy"
 +
++#define OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_CREATE   "bundleActivator_create"
++#define OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_START    "bundleActivator_start"
++#define OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_STOP     "bundleActivator_stop"
++#define OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_DESTROY  "bundleActivator_destroy"
 +
- #define OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_CREATE "dm_create"
- #define OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_INIT "dm_init"
- #define OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_DESTROY "dm_destroy"
++#define OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME  "Bundle-SymbolicName"
++#define OSGI_FRAMEWORK_BUNDLE_VERSION       "Bundle-Version"
++#define OSGI_FRAMEWORK_PRIVATE_LIBRARY      "Private-Library"
++#define OSGI_FRAMEWORK_EXPORT_LIBRARY       "Export-Library"
++#define OSGI_FRAMEWORK_IMPORT_LIBRARY       "Import-Library"
 +
++#define OSGI_FRAMEWORK_FRAMEWORK_STORAGE                "org.osgi.framework.storage"
++#define OSGI_FRAMEWORK_STORAGE_USE_TMP_DIR              "org.osgi.framework.storage.use.tmp.dir"
++#define OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_NAME     "org.osgi.framework.storage.clean"
++#define OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_DEFAULT  true
++#define OSGI_FRAMEWORK_FRAMEWORK_UUID                   "org.osgi.framework.uuid"
 +
- #define OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME "Bundle-SymbolicName"
- #define OSGI_FRAMEWORK_BUNDLE_VERSION "Bundle-Version"
- #define OSGI_FRAMEWORK_PRIVATE_LIBRARY "Private-Library"
- #define OSGI_FRAMEWORK_EXPORT_LIBRARY "Export-Library"
- #define OSGI_FRAMEWORK_IMPORT_LIBRARY "Import-Library"
- 
- #define OSGI_FRAMEWORK_FRAMEWORK_STORAGE "org.osgi.framework.storage"
- #define OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN "org.osgi.framework.storage.clean"
- #define OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT "onFirstInit"
- #define OSGI_FRAMEWORK_FRAMEWORK_UUID "org.osgi.framework.uuid"
++#define CELIX_BUNDLES_PATH_NAME     "CELIX_BUNDLES_PATH"
++#define CELIX_BUNDLES_PATH_DEFAULT  "bundles"
 +
 +#define CELIX_AUTO_START_0 "CELIX_AUTO_START_0"
 +#define CELIX_AUTO_START_1 "CELIX_AUTO_START_1"
 +#define CELIX_AUTO_START_2 "CELIX_AUTO_START_2"
 +#define CELIX_AUTO_START_3 "CELIX_AUTO_START_3"
 +#define CELIX_AUTO_START_4 "CELIX_AUTO_START_4"
 +#define CELIX_AUTO_START_5 "CELIX_AUTO_START_5"
 +
 +
- 
 +#ifdef __cplusplus
 +}
 +#endif
 +
 +#endif /* CONSTANTS_H_ */
diff --cc libs/framework/include/constants.h
index d9680b3,c099312..51c4f9c
--- a/libs/framework/include/constants.h
+++ b/libs/framework/include/constants.h
@@@ -16,5 -16,77 +16,17 @@@
   *specific language governing permissions and limitations
   *under the License.
   */
+ /*
+  * constants.h
+  *
+  *  \date       Apr 29, 2010
+  *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+  *  \copyright	Apache License, Version 2.0
+  */
+ 
+ #ifndef CONSTANTS_H_
+ #define CONSTANTS_H_
+ 
 -#include <stdbool.h>
 -
 -#ifdef __cplusplus
 -extern "C" {
 -#endif
 -
 -static const char *const OSGI_FRAMEWORK_OBJECTCLASS = "objectClass";
 -static const char *const OSGI_FRAMEWORK_SERVICE_ID = "service.id";
 -static const char *const OSGI_FRAMEWORK_SERVICE_PID = "service.pid";
 -static const char *const OSGI_FRAMEWORK_SERVICE_RANKING = "service.ranking";
 -
 -static const char *const CELIX_FRAMEWORK_SERVICE_VERSION = "service.version";
 -static const char *const CELIX_FRAMEWORK_SERVICE_LANGUAGE = "service.lang";
 -static const char *const CELIX_FRAMEWORK_SERVICE_C_LANGUAGE = "C";
 -static const char *const CELIX_FRAMEWORK_SERVICE_CXX_LANGUAGE = "C++";
 -static const char *const CELIX_FRAMEWORK_SERVICE_SHARED_LANGUAGE = "shared"; //e.g. marker services
 -
 -static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR = "Bundle-Activator";
 -
 -static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_CREATE = "celix_bundleActivator_create";
 -static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_START = "celix_bundleActivator_start";
 -static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP = "celix_bundleActivator_stop";
 -static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY = "celix_bundleActivator_destroy";
 -
 -static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_CREATE = "bundleActivator_create";
 -static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_START = "bundleActivator_start";
 -static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_STOP = "bundleActivator_stop";
 -static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_DESTROY = "bundleActivator_destroy";
 -
 -
 -static const char *const OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_CREATE = "dm_create";
 -static const char *const OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_INIT = "dm_init";
 -static const char *const OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_DESTROY = "dm_destroy";
 -
 -
 -static const char *const OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName";
 -static const char *const OSGI_FRAMEWORK_BUNDLE_VERSION = "Bundle-Version";
 -static const char *const OSGI_FRAMEWORK_PRIVATE_LIBRARY = "Private-Library";
 -static const char *const OSGI_FRAMEWORK_EXPORT_LIBRARY = "Export-Library";
 -static const char *const OSGI_FRAMEWORK_IMPORT_LIBRARY = "Import-Library";
 -
 -static const char *const OSGI_FRAMEWORK_FRAMEWORK_STORAGE = "org.osgi.framework.storage";
 -static const char *const OSGI_FRAMEWORK_STORAGE_USE_TMP_DIR = "org.osgi.framework.storage.use.tmp.dir";
 -static const char *const OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_NAME = "org.osgi.framework.storage.clean";
 -static const bool        OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_DEFAULT = true;
 -static const char *const OSGI_FRAMEWORK_FRAMEWORK_UUID = "org.osgi.framework.uuid";
 -
 -static const char *const CELIX_BUNDLES_PATH_NAME = "CELIX_BUNDLES_PATH";
 -static const char *const CELIX_BUNDLES_PATH_DEFAULT = "bundles";
 -
 -#define CELIX_AUTO_START_0 "CELIX_AUTO_START_0"
 -#define CELIX_AUTO_START_1 "CELIX_AUTO_START_1"
 -#define CELIX_AUTO_START_2 "CELIX_AUTO_START_2"
 -#define CELIX_AUTO_START_3 "CELIX_AUTO_START_3"
 -#define CELIX_AUTO_START_4 "CELIX_AUTO_START_4"
 -#define CELIX_AUTO_START_5 "CELIX_AUTO_START_5"
 -
 -
 -#ifdef __cplusplus
 -}
 -#endif
++#include "celix_constants.h"
  
- #include "celix_constants.h"
+ #endif /* CONSTANTS_H_ */
diff --cc libs/framework/include/constants.h.orig
index 0000000,c099312..3e3676c
mode 000000,100644..100644
--- a/libs/framework/include/constants.h.orig
+++ b/libs/framework/include/constants.h.orig
@@@ -1,0 -1,92 +1,95 @@@
+ /**
+  *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.
+  */
++<<<<<<< HEAD
++=======
+ /*
+  * constants.h
+  *
+  *  \date       Apr 29, 2010
+  *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+  *  \copyright	Apache License, Version 2.0
+  */
+ 
+ #ifndef CONSTANTS_H_
+ #define CONSTANTS_H_
+ 
+ #include <stdbool.h>
+ 
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ 
+ static const char *const OSGI_FRAMEWORK_OBJECTCLASS = "objectClass";
+ static const char *const OSGI_FRAMEWORK_SERVICE_ID = "service.id";
+ static const char *const OSGI_FRAMEWORK_SERVICE_PID = "service.pid";
+ static const char *const OSGI_FRAMEWORK_SERVICE_RANKING = "service.ranking";
+ 
+ static const char *const CELIX_FRAMEWORK_SERVICE_VERSION = "service.version";
+ static const char *const CELIX_FRAMEWORK_SERVICE_LANGUAGE = "service.lang";
+ static const char *const CELIX_FRAMEWORK_SERVICE_C_LANGUAGE = "C";
+ static const char *const CELIX_FRAMEWORK_SERVICE_CXX_LANGUAGE = "C++";
+ static const char *const CELIX_FRAMEWORK_SERVICE_SHARED_LANGUAGE = "shared"; //e.g. marker services
+ 
+ static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR = "Bundle-Activator";
+ 
+ static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_CREATE = "celix_bundleActivator_create";
+ static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_START = "celix_bundleActivator_start";
+ static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_STOP = "celix_bundleActivator_stop";
+ static const char *const OSGI_FRAMEWORK_BUNDLE_ACTIVATOR_DESTROY = "celix_bundleActivator_destroy";
+ 
+ static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_CREATE = "bundleActivator_create";
+ static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_START = "bundleActivator_start";
+ static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_STOP = "bundleActivator_stop";
+ static const char *const OSGI_FRAMEWORK_DEPRECATED_BUNDLE_ACTIVATOR_DESTROY = "bundleActivator_destroy";
+ 
+ 
+ static const char *const OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_CREATE = "dm_create";
+ static const char *const OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_INIT = "dm_init";
+ static const char *const OSGI_FRAMEWORK_BUNDLE_DM_ACTIVATOR_DESTROY = "dm_destroy";
+ 
+ 
+ static const char *const OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName";
+ static const char *const OSGI_FRAMEWORK_BUNDLE_VERSION = "Bundle-Version";
+ static const char *const OSGI_FRAMEWORK_PRIVATE_LIBRARY = "Private-Library";
+ static const char *const OSGI_FRAMEWORK_EXPORT_LIBRARY = "Export-Library";
+ static const char *const OSGI_FRAMEWORK_IMPORT_LIBRARY = "Import-Library";
+ 
+ static const char *const OSGI_FRAMEWORK_FRAMEWORK_STORAGE = "org.osgi.framework.storage";
+ static const char *const OSGI_FRAMEWORK_STORAGE_USE_TMP_DIR = "org.osgi.framework.storage.use.tmp.dir";
+ static const char *const OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_NAME = "org.osgi.framework.storage.clean";
+ static const bool        OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_DEFAULT = true;
+ static const char *const OSGI_FRAMEWORK_FRAMEWORK_UUID = "org.osgi.framework.uuid";
+ 
+ static const char *const CELIX_BUNDLES_PATH_NAME = "CELIX_BUNDLES_PATH";
+ static const char *const CELIX_BUNDLES_PATH_DEFAULT = "bundles";
+ 
+ #define CELIX_AUTO_START_0 "CELIX_AUTO_START_0"
+ #define CELIX_AUTO_START_1 "CELIX_AUTO_START_1"
+ #define CELIX_AUTO_START_2 "CELIX_AUTO_START_2"
+ #define CELIX_AUTO_START_3 "CELIX_AUTO_START_3"
+ #define CELIX_AUTO_START_4 "CELIX_AUTO_START_4"
+ #define CELIX_AUTO_START_5 "CELIX_AUTO_START_5"
+ 
+ 
+ #ifdef __cplusplus
+ }
+ #endif
++>>>>>>> develop
+ 
 -#endif /* CONSTANTS_H_ */
++#include "celix_constants.h"
diff --cc libs/framework/include/framework.h.orig
index 4c3b377,0000000..5eb5ef6
mode 100644,000000..100644
--- a/libs/framework/include/framework.h.orig
+++ b/libs/framework/include/framework.h.orig
@@@ -1,63 -1,0 +1,73 @@@
 +/**
 + *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.
 + */
 +/*
 + * framework.h
 + *
 + *  \date       Mar 23, 2010
 + *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
 + *  \copyright	Apache License, Version 2.0
 + */
 +
 +#ifndef FRAMEWORK_H_
 +#define FRAMEWORK_H_
 +
- typedef struct framework *framework_pt;
- typedef struct framework framework_t;
- 
 +#include "celix_errno.h"
 +#include "framework_exports.h"
 +#include "bundle.h"
 +#include "properties.h"
 +#include "bundle_context.h"
 +
 +#ifdef __cplusplus
 +extern "C" {
 +#endif
 +
++<<<<<<< HEAD
 +FRAMEWORK_EXPORT celix_status_t framework_create(framework_t **framework, properties_t *config);
++=======
++// #TODO: Move to FrameworkFactory according the OSGi Spec
++FRAMEWORK_EXPORT celix_status_t framework_create(celix_framework_t **framework, celix_properties_t *config);
++>>>>>>> develop
 +
- FRAMEWORK_EXPORT celix_status_t framework_start(framework_t *framework);
++FRAMEWORK_EXPORT celix_status_t framework_start(celix_framework_t *framework);
 +
- FRAMEWORK_EXPORT celix_status_t framework_stop(framework_t *framework);
++FRAMEWORK_EXPORT celix_status_t framework_stop(celix_framework_t *framework);
 +
- FRAMEWORK_EXPORT celix_status_t framework_destroy(framework_t *framework);
++FRAMEWORK_EXPORT celix_status_t framework_destroy(celix_framework_t *framework);
 +
++<<<<<<< HEAD
 +FRAMEWORK_EXPORT celix_status_t fw_init(framework_t *framework);
 +
 +FRAMEWORK_EXPORT celix_status_t framework_waitForStop(framework_t *framework);
 +
 +FRAMEWORK_EXPORT celix_status_t framework_getFrameworkBundle(framework_t *framework, bundle_pt *bundle);
 +
 +FRAMEWORK_EXPORT bundle_context_t* framework_getContext(framework_t *framework);
++=======
++FRAMEWORK_EXPORT celix_status_t framework_waitForStop(celix_framework_t *framework);
++
++FRAMEWORK_EXPORT celix_status_t framework_getFrameworkBundle(celix_framework_t *framework, celix_bundle_t **bundle);
++
++celix_bundle_context_t* framework_getContext(celix_framework_t *framework);
++>>>>>>> develop
 +
 +#ifdef __cplusplus
 +}
 +#endif
 +
 +#endif /* FRAMEWORK_H_ */
diff --cc libs/framework/include/service_reference.h.orig
index 18b5455,0000000..e314e27
mode 100644,000000..100644
--- a/libs/framework/include/service_reference.h.orig
+++ b/libs/framework/include/service_reference.h.orig
@@@ -1,76 -1,0 +1,73 @@@
 +/**
 + *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.
 + */
- /*
-  * service_reference.h
-  *
-  *  \date       Jul 20, 2010
-  *  \author    	<a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
-  *  \copyright	Apache License, Version 2.0
-  */
 +
 +#ifndef SERVICE_REFERENCE_H_
 +#define SERVICE_REFERENCE_H_
 +
++<<<<<<< HEAD
 +typedef struct serviceReference * service_reference_pt;
 +typedef struct serviceReference service_reference_t;
 +
++=======
++#include "celix_types.h"
++>>>>>>> develop
 +#include "celixbool.h"
 +#include "array_list.h"
 +#include "service_registration.h"
 +#include "bundle.h"
 +#include "framework_exports.h"
 +
 +#ifdef __cplusplus
 +extern "C" {
 +#endif
 +
- FRAMEWORK_EXPORT celix_status_t serviceReference_getBundle(service_reference_pt reference, bundle_pt *bundle);
++FRAMEWORK_EXPORT celix_status_t serviceReference_getBundle(service_reference_pt reference, celix_bundle_t **bundle);
 +
 +FRAMEWORK_EXPORT bool
- serviceReference_isAssignableTo(service_reference_pt reference, bundle_pt requester, const char *serviceName);
++serviceReference_isAssignableTo(service_reference_pt reference, celix_bundle_t *requester, const char *serviceName);
 +
 +FRAMEWORK_EXPORT celix_status_t
 +serviceReference_getProperty(service_reference_pt reference, const char *key, const char **value);
 +
 +FRAMEWORK_EXPORT celix_status_t
 +serviceReference_getPropertyWithDefault(service_reference_pt reference, const char *key, const char* def, const char **value);
 +
 +FRAMEWORK_EXPORT celix_status_t
 +serviceReference_getPropertyKeys(service_reference_pt reference, char **keys[], unsigned int *size);
 +
 +FRAMEWORK_EXPORT celix_status_t
 +serviceReference_getServiceRegistration(service_reference_pt reference, service_registration_pt *registration);
 +
 +FRAMEWORK_EXPORT celix_status_t
 +serviceReference_equals(service_reference_pt reference, service_reference_pt compareTo, bool *equal);
 +
 +FRAMEWORK_EXPORT unsigned int serviceReference_hashCode(const void *referenceP);
 +
 +FRAMEWORK_EXPORT int serviceReference_equals2(const void *reference1, const void *reference2);
 +
 +FRAMEWORK_EXPORT celix_status_t
 +serviceReference_compareTo(service_reference_pt reference, service_reference_pt compareTo, int *compare);
 +
- FRAMEWORK_EXPORT celix_status_t serviceReference_getUsingBundles(service_reference_pt ref, array_list_pt *out);
++FRAMEWORK_EXPORT celix_status_t serviceReference_getUsingBundles(service_reference_pt ref, celix_array_list_t **out);
 +
 +#ifdef __cplusplus
 +}
 +#endif
 +
 +#endif /* SERVICE_REFERENCE_H_ */
diff --cc libs/framework/private/mock/framework_mock.c.orig
index 9933dc0,92420f3..eac98a1
--- a/libs/framework/private/mock/framework_mock.c.orig
+++ b/libs/framework/private/mock/framework_mock.c.orig
@@@ -321,9 -328,10 +322,14 @@@ void celix_framework_useBundles(framewo
  			->withPointerParameters("use", use);
  }
  
++<<<<<<< HEAD
 +bool celix_framework_useBundle(framework_t *fw, long bundleId, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd)) {
++=======
+ void celix_framework_useBundle(framework_t *fw, bool onlyActive, long bundleId, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd)) {
++>>>>>>> develop
  	mock_c()->actualCall("celix_framework_useBundle")
  			->withPointerParameters("fw", fw)
+ 			->withBoolParameters("onlyActive", onlyActive)
  			->withLongIntParameters("bundleId", bundleId)
  			->withPointerParameters("callbackHandle", callbackHandle)
  			->withPointerParameters("use", use);
diff --cc libs/framework/src/bundle_context.c.orig
index 0699068,0000000..8d3a0cc
mode 100644,000000..100644
--- a/libs/framework/src/bundle_context.c.orig
+++ b/libs/framework/src/bundle_context.c.orig
@@@ -1,970 -1,0 +1,1095 @@@
 +/**
 + *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 <stdlib.h>
 +#include <stdio.h>
 +#include <string.h>
++#include <utils.h>
 +
 +#include "constants.h"
 +#include "bundle_context_private.h"
 +#include "framework_private.h"
 +#include "bundle.h"
 +#include "celix_bundle.h"
 +#include "celix_log.h"
 +#include "service_tracker.h"
- #include "dm_dependency_manager.h"
++#include "celix_dependency_manager.h"
++#include "dm_dependency_manager_impl.h"
 +#include "celix_array_list.h"
 +
 +static celix_status_t bundleContext_bundleChanged(void *handle, bundle_event_t *event);
 +static void bundleContext_cleanupBundleTrackers(bundle_context_t *ct);
 +static void bundleContext_cleanupServiceTrackers(bundle_context_t *ctx);
 +static void bundleContext_cleanupServiceTrackerTrackers(bundle_context_t *ctx);
 +
 +celix_status_t bundleContext_create(framework_pt framework, framework_logger_pt logger, bundle_pt bundle, bundle_context_pt *bundle_context) {
 +	celix_status_t status = CELIX_SUCCESS;
 +	bundle_context_pt context = NULL;
 +
 +	if (*bundle_context != NULL && framework == NULL && bundle == NULL) {
 +		status = CELIX_ILLEGAL_ARGUMENT;
 +	} else {
 +        context = malloc(sizeof(*context));
 +        if (!context) {
 +            status = CELIX_ENOMEM;
 +        } else {
 +            context->framework = framework;
 +            context->bundle = bundle;
 +            context->mng = NULL;
 +
 +            celixThreadMutex_create(&context->mutex, NULL);
 +
 +            arrayList_create(&context->svcRegistrations);
 +            context->bundleTrackers = hashMap_create(NULL,NULL,NULL,NULL);
 +            context->serviceTrackers = hashMap_create(NULL,NULL,NULL,NULL);
 +            context->serviceTrackerTrackers =  hashMap_create(NULL,NULL,NULL,NULL);
 +            context->nextTrackerId = 1L;
 +
 +            *bundle_context = context;
 +
 +        }
 +	}
 +
 +	framework_logIfError(logger, status, NULL, "Failed to create context");
 +
 +	return status;
 +}
 +
 +celix_status_t bundleContext_destroy(bundle_context_pt context) {
 +	celix_status_t status = CELIX_SUCCESS;
 +
 +	if (context != NULL) {
 +	    celixThreadMutex_lock(&context->mutex);
 +
 +
 +	    bundleContext_cleanupBundleTrackers(context);
 +	    bundleContext_cleanupServiceTrackers(context);
 +        bundleContext_cleanupServiceTrackerTrackers(context);
 +
 +        //TODO cleanup service registrations
 +
 +	    //NOTE still present service registrations will be cleared during bundle stop in the
 +	    //service registry (serviceRegistry_clearServiceRegistrations).
 +        celixThreadMutex_unlock(&context->mutex);
 +	    celixThreadMutex_destroy(&context->mutex); 
 +	    arrayList_destroy(context->svcRegistrations);
 +
 +	    if (context->mng != NULL) {
- 	        dependencyManager_removeAllComponents(context->mng);
-             dependencyManager_destroy(context->mng);
++	        celix_dependencyManager_removeAllComponents(context->mng);
++            celix_private_dependencyManager_destroy(context->mng);
 +            context->mng = NULL;
 +	    }
 +
 +	    free(context);
 +	} else {
 +		status = CELIX_ILLEGAL_ARGUMENT;
 +	}
 +
 +	framework_logIfError(logger, status, NULL, "Failed to destroy context");
 +
 +	return status;
 +}
 +
 +celix_status_t bundleContext_getBundle(bundle_context_pt context, bundle_pt *out) {
 +	celix_status_t status = CELIX_SUCCESS;
 +    celix_bundle_t *bnd = celix_bundleContext_getBundle(context);
 +    if (context == NULL) {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    }
 +    if (out != NULL) {
 +        *out = bnd;
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to get bundle");
 +
 +	return status;
 +}
 +
 +celix_status_t bundleContext_getFramework(bundle_context_pt context, framework_pt *framework) {
 +	celix_status_t status = CELIX_SUCCESS;
 +
 +	if (context == NULL) {
 +		status = CELIX_ILLEGAL_ARGUMENT;
 +	} else {
 +		*framework = context->framework;
 +	}
 +
 +	framework_logIfError(logger, status, NULL, "Failed to get framework");
 +
 +	return status;
 +}
 +
 +celix_status_t bundleContext_installBundle(bundle_context_pt context, const char * location, bundle_pt *bundle) {
 +	return bundleContext_installBundle2(context, location, NULL, bundle);
 +}
 +
- celix_status_t bundleContext_installBundle2(bundle_context_pt context, const char * location, const char *inputFile, bundle_pt *bundle) {
++celix_status_t bundleContext_installBundle2(bundle_context_pt context, const char *location, const char *inputFile, bundle_pt *bundle) {
 +	celix_status_t status = CELIX_SUCCESS;
 +	bundle_pt b = NULL;
 +
 +	if (context != NULL) {
 +		if (fw_installBundle(context->framework, &b, location, inputFile) != CELIX_SUCCESS) {
 +            status = CELIX_FRAMEWORK_EXCEPTION;
 +		} else {
 +			*bundle = b;
 +		}
 +	} else {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +	}
 +
 +	framework_logIfError(logger, status, NULL, "Failed to install bundle");
 +
 +	return status;
 +}
 +
 +celix_status_t bundleContext_registerService(bundle_context_pt context, const char * serviceName, const void * svcObj,
 +        properties_pt properties, service_registration_pt *service_registration) {
 +	service_registration_pt registration = NULL;
 +	celix_status_t status = CELIX_SUCCESS;
 +
 +	if (context != NULL) {
 +	    fw_registerService(context->framework, &registration, context->bundle, serviceName, svcObj, properties);
 +	    *service_registration = registration;
 +	} else {
 +	    status = CELIX_ILLEGAL_ARGUMENT;
 +	}
 +
 +	framework_logIfError(logger, status, NULL, "Failed to register service. serviceName '%s'", serviceName);
 +
 +	return status;
 +}
 +
 +celix_status_t bundleContext_registerServiceFactory(bundle_context_pt context, const char * serviceName, service_factory_pt factory,
 +        properties_pt properties, service_registration_pt *service_registration) {
 +    service_registration_pt registration = NULL;
 +    celix_status_t status = CELIX_SUCCESS;
 +
 +    if (context != NULL && *service_registration == NULL) {
 +        fw_registerServiceFactory(context->framework, &registration, context->bundle, serviceName, factory, properties);
 +        *service_registration = registration;
 +    } else {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to register service factory");
 +
 +    return status;
 +}
 +
 +celix_status_t bundleContext_getServiceReferences(bundle_context_pt context, const char * serviceName, const char * filter, array_list_pt *service_references) {
 +    celix_status_t status = CELIX_SUCCESS;
 +
 +    if (context != NULL && *service_references == NULL) {
 +        fw_getServiceReferences(context->framework, service_references, context->bundle, serviceName, filter);
 +    } else {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to get service references");
 +
 +	return status;
 +}
 +
 +celix_status_t bundleContext_getServiceReference(bundle_context_pt context, const char * serviceName, service_reference_pt *service_reference) {
 +    service_reference_pt reference = NULL;
 +    array_list_pt services = NULL;
 +    celix_status_t status = CELIX_SUCCESS;
 +
 +    if (serviceName != NULL) {
 +        if (bundleContext_getServiceReferences(context, serviceName, NULL, &services) == CELIX_SUCCESS) {
 +            reference = (arrayList_size(services) > 0) ? arrayList_get(services, 0) : NULL;
 +            arrayList_destroy(services);
 +            *service_reference = reference;
 +        } else {
 +            status = CELIX_ILLEGAL_ARGUMENT;
 +        }
 +    } else {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to get service reference");
 +
 +	return status;
 +}
 +
 +FRAMEWORK_EXPORT celix_status_t bundleContext_retainServiceReference(bundle_context_pt context, service_reference_pt ref) {
 +    celix_status_t status = CELIX_SUCCESS;
 +
 +    if (context != NULL && ref != NULL) {
 +        serviceRegistry_retainServiceReference(context->framework->registry, context->bundle, ref);
 +    } else {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to get service references");
 +
 +    return status;
 +}
 +
 +celix_status_t bundleContext_ungetServiceReference(bundle_context_pt context, service_reference_pt reference) {
 +    celix_status_t status = CELIX_SUCCESS;
 +
 +    if (context != NULL && reference != NULL) {
 +        status = framework_ungetServiceReference(context->framework, context->bundle, reference);
 +    } else {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to unget service_reference");
 +
 +    return status;
 +}
 +
 +celix_status_t bundleContext_getService(bundle_context_pt context, service_reference_pt reference, void** service_instance) {
 +    celix_status_t status = CELIX_SUCCESS;
 +
 +    if (context != NULL && reference != NULL && service_instance != NULL) {
 +        /*NOTE argument service_instance should be considerd a 'const void**'. 
 +        To ensure backwards compatiblity a cast is made instead.
 +        */
 +	    status = fw_getService(context->framework, context->bundle, reference, (const void**) service_instance);
 +    } else {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to get service");
 +
 +    return status;
 +}
 +
 +celix_status_t bundleContext_ungetService(bundle_context_pt context, service_reference_pt reference, bool *result) {
 +    celix_status_t status = CELIX_SUCCESS;
 +
 +    if (context != NULL && reference != NULL) {
 +        status = framework_ungetService(context->framework, context->bundle, reference, result);
 +    } else {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to unget service");
 +
 +    return status;
 +}
 +
 +celix_status_t bundleContext_getBundles(bundle_context_pt context, array_list_pt *bundles) {
 +	celix_status_t status = CELIX_SUCCESS;
 +
 +	if (context == NULL || *bundles != NULL) {
 +		status = CELIX_ILLEGAL_ARGUMENT;
 +	} else {
 +		*bundles = framework_getBundles(context->framework);
 +	}
 +
 +	framework_logIfError(logger, status, NULL, "Failed to get bundles");
 +
 +	return status;
 +}
 +
 +celix_status_t bundleContext_getBundleById(bundle_context_pt context, long id, bundle_pt *bundle) {
 +    celix_status_t status = CELIX_SUCCESS;
 +
 +    if (context == NULL || *bundle != NULL) {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    } else {
 +        *bundle = framework_getBundleById(context->framework, id);
 +        if (*bundle == NULL) {
 +            status = CELIX_BUNDLE_EXCEPTION;
 +        }
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to get bundle [id=%ld]", id);
 +
 +	return status;
 +}
 +
- celix_status_t bundleContext_addServiceListener(bundle_context_pt context, service_listener_pt listener, const char* filter) {
++celix_status_t bundleContext_addServiceListener(bundle_context_pt context, celix_service_listener_t *listener, const char* filter) {
 +    celix_status_t status = CELIX_SUCCESS;
 +
 +    if (context != NULL && listener != NULL) {
 +        fw_addServiceListener(context->framework, context->bundle, listener, filter);
 +    } else {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to add service listener");
 +
 +    return status;
 +}
 +
- celix_status_t bundleContext_removeServiceListener(bundle_context_pt context, service_listener_pt listener) {
++celix_status_t bundleContext_removeServiceListener(bundle_context_pt context, celix_service_listener_t *listener) {
 +    celix_status_t status = CELIX_SUCCESS;
 +
 +    if (context != NULL && listener != NULL) {
 +        fw_removeServiceListener(context->framework, context->bundle, listener);
 +    } else {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to remove service listener");
 +
 +    return status;
 +}
 +
 +celix_status_t bundleContext_addBundleListener(bundle_context_pt context, bundle_listener_pt listener) {
 +    celix_status_t status = CELIX_SUCCESS;
 +
 +    if (context != NULL && listener != NULL) {
 +        fw_addBundleListener(context->framework, context->bundle, listener);
 +    } else {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to add bundle listener");
 +
 +    return status;
 +}
 +
 +celix_status_t bundleContext_removeBundleListener(bundle_context_pt context, bundle_listener_pt listener) {
 +    celix_status_t status = CELIX_SUCCESS;
 +
 +    if (context != NULL && listener != NULL) {
 +        fw_removeBundleListener(context->framework, context->bundle, listener);
 +    } else {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to remove bundle listener");
 +
 +    return status;
 +}
 +
 +celix_status_t bundleContext_addFrameworkListener(bundle_context_pt context, framework_listener_pt listener) {
 +    celix_status_t status = CELIX_SUCCESS;
 +
 +    if (context != NULL && listener != NULL) {
 +        fw_addFrameworkListener(context->framework, context->bundle, listener);
 +    } else {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to add framework listener");
 +
 +    return status;
 +}
 +
 +celix_status_t bundleContext_removeFrameworkListener(bundle_context_pt context, framework_listener_pt listener) {
 +    celix_status_t status = CELIX_SUCCESS;
 +
 +    if (context != NULL && listener != NULL) {
 +        fw_removeFrameworkListener(context->framework, context->bundle, listener);
 +    } else {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to remove framework listener");
 +
 +    return status;
 +}
 +
 +celix_status_t bundleContext_getProperty(bundle_context_pt context, const char *name, const char** value) {
 +	return bundleContext_getPropertyWithDefault(context, name, NULL, value);
 +}
 +
 +celix_status_t bundleContext_getPropertyWithDefault(bundle_context_pt context, const char* name, const char* defaultValue, const char** out) {
 +    const char *val = celix_bundleContext_getProperty(context, name, defaultValue);
 +    if (out != NULL) {
 +        *out = val;
 +    }
 +    return CELIX_SUCCESS;
 +}
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +/**********************************************************************************************************************
 + **********************************************************************************************************************
 + * Updated API
 + **********************************************************************************************************************
 + **********************************************************************************************************************/
 +
 +
 +long celix_bundleContext_registerService(bundle_context_t *ctx, void *svc, const char *serviceName, celix_properties_t *properties) {
 +    celix_service_registration_options_t opts = CELIX_EMPTY_SERVICE_REGISTRATION_OPTIONS;
 +    opts.svc = svc;
 +    opts.serviceName = serviceName;
 +    opts.properties = properties;
 +    return celix_bundleContext_registerServiceWithOptions(ctx, &opts);
 +}
 +
 +
 +long celix_bundleContext_registerServiceFactory(celix_bundle_context_t *ctx, celix_service_factory_t *factory, const char *serviceName, celix_properties_t *props) {
 +    celix_service_registration_options_t opts = CELIX_EMPTY_SERVICE_REGISTRATION_OPTIONS;
 +    opts.factory = factory;
 +    opts.serviceName = serviceName;
 +    opts.properties = props;
 +    return celix_bundleContext_registerServiceWithOptions(ctx, &opts);
 +}
 +
 +long celix_bundleContext_registerServiceWithOptions(bundle_context_t *ctx, const celix_service_registration_options_t *opts) {
 +    long svcId = -1;
 +    service_registration_t *reg = NULL;
 +    celix_properties_t *props = opts->properties;
 +    if (props == NULL) {
 +        props = celix_properties_create();
 +    }
 +    if (opts->serviceVersion != NULL && strncmp("", opts->serviceVersion, 1) != 0) {
 +        celix_properties_set(props, CELIX_FRAMEWORK_SERVICE_VERSION, opts->serviceVersion);
 +    }
 +    const char *lang = opts->serviceLanguage != NULL && strncmp("", opts->serviceLanguage, 1) != 0 ? opts->serviceLanguage : CELIX_FRAMEWORK_SERVICE_C_LANGUAGE;
 +    celix_properties_set(props, CELIX_FRAMEWORK_SERVICE_LANGUAGE, lang);
 +    if (opts->serviceName != NULL && strncmp("", opts->serviceName, 1) != 0) {
 +        if (opts->factory != NULL) {
 +            reg = celix_framework_registerServiceFactory(ctx->framework, ctx->bundle, opts->serviceName, opts->factory, props);
 +        } else {
 +            bundleContext_registerService(ctx, opts->serviceName, opts->svc, props, &reg);
 +        }
 +        svcId = serviceRegistration_getServiceId(reg); //save to call with NULL
 +    } else {
 +        framework_logIfError(logger, CELIX_ILLEGAL_ARGUMENT, NULL, "Required serviceName argument is NULL");
 +    }
 +    if (svcId < 0) {
 +        properties_destroy(props);
 +    } else {
 +        celixThreadMutex_lock(&ctx->mutex);
 +        arrayList_add(ctx->svcRegistrations, reg);
 +        celixThreadMutex_unlock(&ctx->mutex);
 +    }
 +    return svcId;
 +}
 +
 +void celix_bundleContext_unregisterService(bundle_context_t *ctx, long serviceId) {
 +    service_registration_t *found = NULL;
 +    if (ctx != NULL && serviceId >= 0) {
 +        celixThreadMutex_lock(&ctx->mutex);
 +        unsigned int size = arrayList_size(ctx->svcRegistrations);
 +        for (unsigned int i = 0; i < size; ++i) {
 +            service_registration_t *reg = arrayList_get(ctx->svcRegistrations, i);
 +            if (reg != NULL) {
 +                long svcId = serviceRegistration_getServiceId(reg);
 +                if (svcId == serviceId) {
 +                    found = reg;
 +                    arrayList_remove(ctx->svcRegistrations, i);
 +                    break;
 +                }
 +            }
 +        }
 +        celixThreadMutex_unlock(&ctx->mutex);
 +
 +        if (found != NULL) {
 +            serviceRegistration_unregister(found);
 +        } else {
 +            framework_logIfError(logger, CELIX_ILLEGAL_ARGUMENT, NULL,
 +                                 "Provided service id is not used to registered using bundleContext_registerCService/registerServiceForLang");
 +        }
 +    }
 +}
 +
- dm_dependency_manager_t* celix_bundleContext_getDependencyManager(bundle_context_t *ctx) {
-     dm_dependency_manager_t* result = NULL;
++celix_dependency_manager_t* celix_bundleContext_getDependencyManager(bundle_context_t *ctx) {
++    celix_dependency_manager_t* result = NULL;
 +    if (ctx != NULL) {
 +        celixThreadMutex_lock(&ctx->mutex);
 +        if (ctx->mng == NULL) {
-             dependencyManager_create(ctx, &ctx->mng);
++            ctx->mng = celix_private_dependencyManager_create(ctx);
 +        }
 +        if (ctx->mng == NULL) {
 +            framework_logIfError(logger, CELIX_BUNDLE_EXCEPTION, NULL, "Cannot create dependency manager");
 +        }
 +        result = ctx->mng;
 +        celixThreadMutex_unlock(&ctx->mutex);
 +    }
 +    return result;
 +}
 +
 +static celix_status_t bundleContext_bundleChanged(void *listenerSvc, bundle_event_t *event) {
 +    celix_status_t status = CELIX_SUCCESS;
 +    bundle_listener_t *listener = listenerSvc;
 +    celix_bundle_context_bundle_tracker_entry_t *tracker = NULL;
 +    if (listener != NULL) {
 +        tracker = listener->handle;
 +    }
 +
-     if (tracker != NULL) {
++    bool handleEvent = true;
++    if (event->bundleId == 0 /*framework bundle*/)  {
++        handleEvent = tracker->opts.includeFrameworkBundle;
++    }
++
++    if (tracker != NULL && handleEvent) {
 +        void *callbackHandle = tracker->opts.callbackHandle;
 +
 +        if (event->type == OSGI_FRAMEWORK_BUNDLE_EVENT_STARTED && tracker->opts.onStarted != NULL) {
 +            bundle_t *bnd = framework_getBundleById(tracker->ctx->framework, event->bundleId);
 +            tracker->opts.onStarted(callbackHandle, bnd);
 +        } else if (event->type == OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPING && tracker->opts.onStopped != NULL) {
 +            bundle_t *bnd = framework_getBundleById(tracker->ctx->framework, event->bundleId);
 +            tracker->opts.onStopped(callbackHandle, bnd);
 +        }
 +
 +        if (tracker->opts.onBundleEvent != NULL) {
 +            tracker->opts.onBundleEvent(callbackHandle, event);
 +        }
 +    }
 +    return status;
 +}
 +
 +long celix_bundleContext_trackBundlesWithOptions(
 +        bundle_context_t* ctx,
 +        const celix_bundle_tracking_options_t *opts) {
 +    long trackerId = -1;
 +    celix_bundle_context_bundle_tracker_entry_t *entry = calloc(1, sizeof(*entry));
 +    if (entry != NULL) {
 +        memcpy(&entry->opts, opts, sizeof(*opts));
 +        entry->ctx = ctx;
 +        entry->listener.handle = entry;
 +        entry->listener.bundleChanged = bundleContext_bundleChanged;
 +        fw_addBundleListener(ctx->framework, ctx->bundle, &entry->listener);
 +
 +        celixThreadMutex_lock(&ctx->mutex);
 +        entry->trackerId = ctx->nextTrackerId++;
 +        celixThreadMutex_unlock(&ctx->mutex);
 +        trackerId = entry->trackerId;
 +
 +        //loop through all already installed bundles.
 +        // FIXME there is a race condition between installing the listener and looping through the started bundles.
 +        // NOTE move this to the framework, so that the framework can ensure locking to ensure not bundles is missed.
 +        if (entry->opts.onStarted != NULL) {
-             celix_framework_useBundles(ctx->framework, entry->opts.callbackHandle, entry->opts.onStarted);
++            celix_framework_useBundles(ctx->framework, entry->opts.includeFrameworkBundle, entry->opts.callbackHandle, entry->opts.onStarted);
 +        }
 +
 +        celixThreadMutex_lock(&ctx->mutex);
 +        hashMap_put(ctx->bundleTrackers, (void*)entry->trackerId, entry);
 +        celixThreadMutex_unlock(&ctx->mutex);
 +
 +    }
 +    return trackerId;
 +}
 +
 +long celix_bundleContext_trackBundles(
 +        bundle_context_t* ctx,
 +        void* callbackHandle,
 +        void (*onStarted)(void* handle, const bundle_t *bundle),
 +        void (*onStopped)(void *handle, const bundle_t *bundle)) {
 +    celix_bundle_tracking_options_t opts;
 +    memset(&opts, 0, sizeof(opts));
 +    opts.callbackHandle = callbackHandle;
 +    opts.onStarted = onStarted;
 +    opts.onStopped = onStopped;
 +    return celix_bundleContext_trackBundlesWithOptions(ctx, &opts);
 +}
 +
 +
 +void celix_bundleContext_useBundles(
 +        bundle_context_t *ctx,
 +        void *callbackHandle,
 +        void (*use)(void *handle, const bundle_t *bundle)) {
-     celix_framework_useBundles(ctx->framework, callbackHandle, use);
++    celix_framework_useBundles(ctx->framework, false, callbackHandle, use);
 +}
 +
 +bool celix_bundleContext_useBundle(
 +        bundle_context_t *ctx,
 +        long bundleId,
 +        void *callbackHandle,
 +        void (*use)(void *handle, const bundle_t *bundle)) {
++<<<<<<< HEAD
 +    return celix_framework_useBundle(ctx->framework, bundleId, callbackHandle, use);
++=======
++    celix_framework_useBundle(ctx->framework, true, bundleId, callbackHandle, use);
++>>>>>>> develop
 +}
 +
 +static void bundleContext_cleanupBundleTrackers(bundle_context_t *ctx) {
 +    hash_map_iterator_t iter = hashMapIterator_construct(ctx->bundleTrackers);
 +    while (hashMapIterator_hasNext(&iter)) {
 +        celix_bundle_context_bundle_tracker_entry_t *tracker = hashMapIterator_nextValue(&iter);
 +        fw_removeBundleListener(ctx->framework, ctx->bundle, &tracker->listener);
 +        free(tracker);
 +    }
 +    hashMap_destroy(ctx->bundleTrackers, false, false);
 +}
 +
 +static void bundleContext_cleanupServiceTrackers(bundle_context_t *ctx) {
 +    hash_map_iterator_t iter = hashMapIterator_construct(ctx->serviceTrackers);
 +    while (hashMapIterator_hasNext(&iter)) {
 +        celix_service_tracker_t *tracker = hashMapIterator_nextValue(&iter);
 +        celix_serviceTracker_destroy(tracker);
 +    }
 +    hashMap_destroy(ctx->serviceTrackers, false, false);
 +}
 +
 +static void bundleContext_cleanupServiceTrackerTrackers(bundle_context_t *ctx) {
 +    hash_map_iterator_t iter = hashMapIterator_construct(ctx->serviceTrackerTrackers);
 +    while (hashMapIterator_hasNext(&iter)) {
 +        celix_bundle_context_service_tracker_tracker_entry_t *entry = hashMapIterator_nextValue(&iter);
 +        serviceRegistration_unregister(entry->hookReg);
 +        free(entry);
 +    }
 +    hashMap_destroy(ctx->serviceTrackerTrackers, false, false);
 +}
 +
 +
 +void celix_bundleContext_stopTracker(bundle_context_t *ctx, long trackerId) {
 +    if (ctx != NULL && trackerId >0) {
 +        bool found = false;
++        celix_bundle_context_bundle_tracker_entry_t *bundleTracker = NULL;
++        service_tracker_t *serviceTracker = NULL;
++        celix_bundle_context_service_tracker_tracker_entry_t *svcTrackerTracker = NULL;
++
 +        celixThreadMutex_lock(&ctx->mutex);
 +        if (hashMap_containsKey(ctx->bundleTrackers, (void*)trackerId)) {
 +            found = true;
-             celix_bundle_context_bundle_tracker_entry_t *tracker = hashMap_remove(ctx->bundleTrackers, (void*)trackerId);
-             fw_removeBundleListener(ctx->framework, ctx->bundle, &tracker->listener);
-             free(tracker);
++            bundleTracker = hashMap_remove(ctx->bundleTrackers, (void*)trackerId);
 +        } else if (hashMap_containsKey(ctx->serviceTrackers, (void*)trackerId)) {
 +            found = true;
-             service_tracker_t *tracker = hashMap_remove(ctx->serviceTrackers, (void*)trackerId);
-             celix_serviceTracker_destroy(tracker);
++            serviceTracker = hashMap_remove(ctx->serviceTrackers, (void*)trackerId);
 +        } else if (hashMap_containsKey(ctx->serviceTrackerTrackers, (void*)trackerId)) {
 +            found = true;
-             celix_bundle_context_service_tracker_tracker_entry_t *entry = hashMap_remove(ctx->serviceTrackerTrackers, (void*)trackerId);
-             serviceRegistration_unregister(entry->hookReg);
-             free(entry);
++            svcTrackerTracker = hashMap_remove(ctx->serviceTrackerTrackers, (void*)trackerId);
++        }
++        celixThreadMutex_unlock(&ctx->mutex);
++
++        if (bundleTracker != NULL) {
++            fw_removeBundleListener(ctx->framework, ctx->bundle, &bundleTracker->listener);
++            free(bundleTracker);
++        }
++        if (serviceTracker != NULL) {
++            celix_serviceTracker_destroy(serviceTracker);
++        }
++        if (svcTrackerTracker != NULL) {
++            serviceRegistration_unregister(svcTrackerTracker->hookReg);
++            free(svcTrackerTracker->serviceName);
++            free(svcTrackerTracker);
 +        }
 +
 +        if (!found) {
 +            framework_logIfError(logger, CELIX_ILLEGAL_ARGUMENT, NULL, "No tracker with id %li found'", trackerId);
 +        }
-         celixThreadMutex_unlock(&ctx->mutex);
 +    }
 +}
 +
 +long celix_bundleContext_installBundle(bundle_context_t *ctx, const char *bundleLoc, bool autoStart) {
 +    long bundleId = -1;
 +    bundle_t *bnd = NULL;
 +    celix_status_t status = CELIX_SUCCESS;
 +
 +    if (ctx != NULL && fw_installBundle(ctx->framework, &bnd, bundleLoc, NULL) == CELIX_SUCCESS) {
 +        status = bundle_getBundleId(bnd, &bundleId);
 +        if (status == CELIX_SUCCESS && autoStart) {
 +            status = bundle_start(bnd);
 +            if (status != CELIX_SUCCESS) {
 +                bundleId = -1;
 +                bundle_uninstall(bnd);
 +            }
 +        }
 +    }
 +
 +    framework_logIfError(logger, status, NULL, "Failed to install bundle");
 +
 +    return bundleId;
 +}
 +
- static void bundleContext_stopBundle(void *handle, const bundle_t *c_bnd) {
++static void bundleContext_listBundlesCallback(void *handle, const bundle_t *c_bnd) {
++    celix_array_list_t* ids = handle;
++    long id = celix_bundle_getId(c_bnd);
++    if (id > 0) { //note skipping framework bundle id (0)
++        celix_arrayList_addLong(ids, id);
++    }
++}
++
++celix_array_list_t* celix_bundleContext_listBundles(celix_bundle_context_t *ctx) {
++    celix_array_list_t *result = celix_arrayList_create();
++    celix_bundleContext_useBundles(ctx, result, bundleContext_listBundlesCallback);
++    return result;
++}
++
++static void bundleContext_startBundleCallback(void *handle, const bundle_t *c_bnd) {
++    bool *started = handle;
++    *started = false;
++    bundle_t *bnd = (bundle_t*)c_bnd;
++    celix_bundle_state_e state = celix_bundle_getState(bnd);
++    if (state == OSGI_FRAMEWORK_BUNDLE_INSTALLED || state == OSGI_FRAMEWORK_BUNDLE_RESOLVED) {
++        celix_status_t rc = bundle_start(bnd);
++        *started = rc == CELIX_SUCCESS;
++    }
++}
++
++bool celix_bundleContext_startBundle(celix_bundle_context_t *ctx, long bundleId) {
++    bool started = false;
++
++    celix_framework_useBundle(ctx->framework, false, bundleId, &started, bundleContext_startBundleCallback);
++    return started;
++}
++
++
++static void bundleContext_stopBundleCallback(void *handle, const bundle_t *c_bnd) {
++    bool *stopped = handle;
++    *stopped = false;
++    bundle_t *bnd = (bundle_t*)c_bnd;
++    if (celix_bundle_getState(bnd) == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
++        celix_status_t rc = bundle_stop(bnd);
++        *stopped = rc == CELIX_SUCCESS;
++    }
++}
++
++bool celix_bundleContext_stopBundle(celix_bundle_context_t *ctx, long bundleId) {
++    bool stopped = false;
++    celix_framework_useBundle(ctx->framework, true, bundleId, &stopped, bundleContext_stopBundleCallback);
++    return stopped;
++}
++
++static void bundleContext_uninstallBundleCallback(void *handle, const bundle_t *c_bnd) {
 +    bool *uninstalled = handle;
 +    bundle_t *bnd = (bundle_t*)c_bnd; //TODO use mute-able variant ??
 +    if (celix_bundle_getState(bnd) == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
 +        bundle_stop(bnd);
 +    }
 +    bundle_uninstall(bnd);
 +    *uninstalled = true;
 +}
 +
 +bool celix_bundleContext_uninstallBundle(bundle_context_t *ctx, long bundleId) {
 +    bool uninstalled = false;
-     celix_framework_useBundle(ctx->framework, bundleId, &uninstalled, bundleContext_stopBundle);
++    celix_framework_useBundle(ctx->framework, true, bundleId, &uninstalled, bundleContext_uninstallBundleCallback);
 +    return uninstalled;
 +}
 +
 +bool celix_bundleContext_useServiceWithId(
 +        bundle_context_t *ctx,
 +        long serviceId,
 +        const char *serviceName,
 +        void *callbackHandle,
 +        void (*use)(void *handle, void *svc)) {
 +    celix_service_use_options_t opts = CELIX_EMPTY_SERVICE_USE_OPTIONS;
 +
 +    char filter[64];
 +    snprintf(filter, 64, "(%s=%li)", OSGI_FRAMEWORK_SERVICE_ID, serviceId);
 +
 +    opts.filter.serviceName = serviceName;
 +    opts.filter.filter = filter;
 +    opts.callbackHandle = callbackHandle;
 +    opts.use = use;
 +    return celix_bundleContext_useServiceWithOptions(ctx, &opts);
 +}
 +
 +bool celix_bundleContext_useService(
 +        bundle_context_t *ctx,
 +        const char* serviceName,
 +        void *callbackHandle,
 +        void (*use)(void *handle, void *svc)) {
 +    celix_service_use_options_t opts = CELIX_EMPTY_SERVICE_USE_OPTIONS;
 +    opts.filter.serviceName = serviceName;
 +    opts.callbackHandle = callbackHandle;
 +    opts.use = use;
 +    return celix_bundleContext_useServiceWithOptions(ctx, &opts);
 +}
 +
 +
 +void celix_bundleContext_useServices(
 +        bundle_context_t *ctx,
 +        const char* serviceName,
 +        void *callbackHandle,
 +        void (*use)(void *handle, void *svc)) {
 +    celix_service_use_options_t opts = CELIX_EMPTY_SERVICE_USE_OPTIONS;
 +    opts.filter.serviceName = serviceName;
 +    opts.callbackHandle = callbackHandle;
 +    opts.use = use;
 +    celix_bundleContext_useServicesWithOptions(ctx, &opts);
 +}
 +
 +
 +bool celix_bundleContext_useServiceWithOptions(
 +        celix_bundle_context_t *ctx,
 +        const celix_service_use_options_t *opts) {
 +    bool called = false;
 +    celix_service_tracking_options_t trkOpts;
 +    memset(&trkOpts, 0, sizeof(trkOpts));
 +
 +    if (opts != NULL) {
 +        trkOpts.filter.serviceName = opts->filter.serviceName;
 +        trkOpts.filter = opts->filter;
 +        trkOpts.filter.versionRange = opts->filter.versionRange;
 +        trkOpts.filter.serviceLanguage = opts->filter.serviceLanguage;
 +
 +        service_tracker_t *trk = celix_serviceTracker_createWithOptions(ctx, &trkOpts);
 +        if (trk != NULL) {
 +            if (opts->use != NULL) {
 +
 +            }
 +            if (opts->useWithProperties != NULL) {
 +
 +            }
 +            if (opts->useWithOwner != NULL) {
 +
 +            }
 +            called = celix_serviceTracker_useHighestRankingService(trk, opts->filter.serviceName, opts->callbackHandle, opts->use, opts->useWithProperties, opts->useWithOwner);
 +            celix_serviceTracker_destroy(trk);
 +        }
 +    }
 +    return called;
 +}
 +
 +
 +
 +void celix_bundleContext_useServicesWithOptions(
 +        celix_bundle_context_t *ctx,
 +        const celix_service_use_options_t *opts) {
 +    celix_service_tracking_options_t trkOpts = CELIX_EMPTY_SERVICE_TRACKING_OPTIONS;
 +
 +    if (opts != NULL) {
 +        trkOpts.filter.serviceName = opts->filter.serviceName;
 +        trkOpts.filter.filter = opts->filter.filter;
 +        trkOpts.filter.versionRange = opts->filter.versionRange;
 +        trkOpts.filter.serviceLanguage = opts->filter.serviceLanguage;
 +
 +        service_tracker_t *trk = celix_serviceTracker_createWithOptions(ctx, &trkOpts);
 +        if (trk != NULL) {
 +            celix_serviceTracker_useServices(trk, opts->filter.serviceName, opts->callbackHandle, opts->use, opts->useWithProperties, opts->useWithOwner);
 +            celix_serviceTracker_destroy(trk);
 +        }
 +    }
 +}
 +
 +
 +long celix_bundleContext_trackService(
 +        bundle_context_t* ctx,
 +        const char* serviceName,
 +        void* callbackHandle,
 +        void (*set)(void* handle, void* svc)) {
 +    celix_service_tracking_options_t opts = CELIX_EMPTY_SERVICE_TRACKING_OPTIONS;
 +    opts.filter.serviceName = serviceName;
 +    opts.callbackHandle = callbackHandle;
 +    opts.set = set;
 +    return celix_bundleContext_trackServicesWithOptions(ctx, &opts);
 +}
 +
 +
 +long celix_bundleContext_trackServices(
 +        bundle_context_t* ctx,
 +        const char* serviceName,
 +        void* callbackHandle,
 +        void (*add)(void* handle, void* svc),
 +        void (*remove)(void* handle, void* svc)) {
 +    celix_service_tracking_options_t opts = CELIX_EMPTY_SERVICE_TRACKING_OPTIONS;
 +    opts.filter.serviceName = serviceName;
 +    opts.callbackHandle = callbackHandle;
 +    opts.add = add;
 +    opts.remove = remove;
 +    return celix_bundleContext_trackServicesWithOptions(ctx, &opts);
 +}
 +
 +
 +long celix_bundleContext_trackServicesWithOptions(bundle_context_t *ctx, const celix_service_tracking_options_t *opts) {
 +    long trackerId = -1;
 +    celix_service_tracker_t *tracker = celix_serviceTracker_createWithOptions(ctx, opts);
 +    if (tracker != NULL) {
 +        celixThreadMutex_lock(&ctx->mutex);
 +        trackerId = ctx->nextTrackerId++;
 +        hashMap_put(ctx->serviceTrackers, (void*)trackerId, tracker);
 +        celixThreadMutex_unlock(&ctx->mutex);
 +    }
 +    return trackerId;
 +}
 +
 +long celix_bundleContext_findService(celix_bundle_context_t *ctx, const char *serviceName) {
 +    celix_service_filter_options_t opts = CELIX_EMPTY_SERVICE_FILTER_OPTIONS;
 +    opts.serviceName = serviceName;
 +    return celix_bundleContext_findServiceWithOptions(ctx, &opts);
 +}
 +
 +static void bundleContext_retrieveSvcId(void *handle, void *svc __attribute__((unused)), const celix_properties_t *props) {
 +    long *svcId = handle;
 +    *svcId = celix_properties_getAsLong(props, OSGI_FRAMEWORK_SERVICE_ID, -1L);
 +}
 +
 +long celix_bundleContext_findServiceWithOptions(celix_bundle_context_t *ctx, const celix_service_filter_options_t *opts) {
 +    long svcId = -1L;
 +    celix_service_use_options_t useOpts = CELIX_EMPTY_SERVICE_USE_OPTIONS;
 +    memcpy(&useOpts.filter, opts, sizeof(useOpts.filter));
 +    useOpts.callbackHandle = &svcId;
 +    useOpts.useWithProperties = bundleContext_retrieveSvcId;
 +    celix_bundleContext_useServiceWithOptions(ctx, &useOpts);
 +    return svcId;
 +}
 +
 +
 +celix_array_list_t* celix_bundleContext_findServices(celix_bundle_context_t *ctx, const char *serviceName) {
 +    celix_service_filter_options_t opts = CELIX_EMPTY_SERVICE_FILTER_OPTIONS;
 +    opts.serviceName = serviceName;
 +    return celix_bundleContext_findServicesWithOptions(ctx, &opts);
 +}
 +
 +static void bundleContext_retrieveSvcIds(void *handle, void *svc __attribute__((unused)), const celix_properties_t *props) {
 +    celix_array_list_t *list = handle;
 +    if (list != NULL) {
 +        long svcId = celix_properties_getAsLong(props, OSGI_FRAMEWORK_SERVICE_ID, -1L);
 +        celix_arrayList_addLong(list, svcId);
 +    }
 +}
 +
 +celix_array_list_t* celix_bundleContext_findServicesWithOptions(celix_bundle_context_t *ctx, const celix_service_filter_options_t *opts) {
 +    celix_array_list_t* list = celix_arrayList_create();
 +    celix_service_use_options_t useOpts = CELIX_EMPTY_SERVICE_USE_OPTIONS;
 +    memcpy(&useOpts.filter, opts, sizeof(useOpts.filter));
 +    useOpts.callbackHandle = list;
 +    useOpts.useWithProperties = bundleContext_retrieveSvcIds;
 +    celix_bundleContext_useServicesWithOptions(ctx, &useOpts);
 +    return list;
 +}
 +
 +static celix_status_t bundleContext_callServicedTrackerTrackerCallback(void *handle, celix_array_list_t *listeners, bool add) {
 +    celix_bundle_context_service_tracker_tracker_entry_t *entry = handle;
 +    if (entry != NULL) {
 +        size_t size = celix_arrayList_size(listeners);
 +        for (unsigned int i = 0; i < size; ++i) {
 +            listener_hook_info_pt info = arrayList_get(listeners, i);
 +            celix_bundle_t *bnd = NULL;
 +            bundleContext_getBundle(info->context, &bnd);
 +
 +            celix_service_tracker_info_t trkInfo;
 +            memset(&trkInfo, 0, sizeof(trkInfo));
 +            trkInfo.bundleId = celix_bundle_getId(bnd);
 +            trkInfo.filter = celix_filter_create(info->filter);
 +            trkInfo.serviceName = celix_filter_findAttribute(trkInfo.filter, OSGI_FRAMEWORK_OBJECTCLASS);
 +            trkInfo.serviceLanguage = celix_filter_findAttribute(trkInfo.filter, CELIX_FRAMEWORK_SERVICE_LANGUAGE);
-             if (add && entry->add != NULL) {
++            const char *filterSvcName = celix_filter_findAttribute(trkInfo.filter, OSGI_FRAMEWORK_OBJECTCLASS);
++
++            if (add && entry->add != NULL && filterSvcName != NULL && strncmp(filterSvcName, entry->serviceName, 1024*1024) == 0) {
 +                entry->add(entry->callbackHandle, &trkInfo);
-             } else if (entry->remove != NULL) {
++            } else if (entry->remove != NULL && filterSvcName != NULL && strncmp(filterSvcName, entry->serviceName, 1024*1024) == 0) {
 +                entry->remove(entry->callbackHandle, &trkInfo);
 +            }
 +            celix_filter_destroy(trkInfo.filter);
 +        }
 +    }
 +    return CELIX_SUCCESS;
 +}
 +
 +static celix_status_t bundleContext_callServicedTrackerTrackerAdd(void *handle, celix_array_list_t *listeners) {
 +    return bundleContext_callServicedTrackerTrackerCallback(handle, listeners, true);
 +}
 +
 +static celix_status_t bundleContext_callServicedTrackerTrackerRemove(void *handle, celix_array_list_t *listeners) {
 +    return bundleContext_callServicedTrackerTrackerCallback(handle, listeners, false);
 +}
 +
 +long celix_bundleContext_trackServiceTrackers(
 +        celix_bundle_context_t *ctx,
 +        const char *serviceName,
 +        void *callbackHandle,
 +        void (*trackerAdd)(void *handle, const celix_service_tracker_info_t *info),
 +        void (*trackerRemove)(void *handle, const celix_service_tracker_info_t *info)) {
 +
 +    long trackerId = -1L;
 +
++    if (serviceName == NULL) {
++        fw_log(ctx->framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Required serviceName not provided for function ", __FUNCTION__);
++        return trackerId;
++    }
++
 +    celix_bundle_context_service_tracker_tracker_entry_t *entry = calloc(1, sizeof(*entry));
 +
 +    entry->callbackHandle = callbackHandle;
 +    entry->add = trackerAdd;
 +    entry->remove = trackerRemove;
++    entry->serviceName = strndup(serviceName, 1024*1024);
 +
 +    entry->hook.handle = entry;
 +    entry->hook.added = bundleContext_callServicedTrackerTrackerAdd;
 +    entry->hook.removed = bundleContext_callServicedTrackerTrackerRemove;
 +    bundleContext_registerService(ctx, OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, &entry->hook, NULL, &entry->hookReg);
 +
 +    if (entry->hookReg != NULL) {
 +        celixThreadMutex_lock(&ctx->mutex);
 +        entry->trackerId = ctx->nextTrackerId++;
 +        hashMap_put(ctx->serviceTrackerTrackers, (void*)entry->trackerId, entry);
 +        trackerId = entry->trackerId;
 +        celixThreadMutex_unlock(&ctx->mutex);
 +    } else {
 +        framework_log(ctx->framework->logger, OSGI_FRAMEWORK_LOG_ERROR, __FUNCTION__, __BASE_FILE__, __LINE__, "Error registering service listener hook for service tracker tracker\n");
 +        free(entry);
 +    }
 +    return trackerId;
 +}
 +
 +celix_bundle_t* celix_bundleContext_getBundle(celix_bundle_context_t *ctx) {
 +    celix_bundle_t *bnd = NULL;
 +    if (ctx != NULL) {
 +        bnd = ctx->bundle;
 +    }
 +    return bnd;
 +}
 +
 +
 +const char* celix_bundleContext_getProperty(celix_bundle_context_t *ctx, const char *key, const char *defaultVal) {
 +    const char *val = NULL;
 +    if (ctx != NULL) {
 +        fw_getProperty(ctx->framework, key, defaultVal, &val);
 +    }
 +    return val;
 +}
++
++long celix_bundleContext_getPropertyAsLong(celix_bundle_context_t *ctx, const char *key, long defaultValue) {
++    long result = defaultValue;
++    const char *val = celix_bundleContext_getProperty(ctx, key, NULL);
++    if (val != NULL) {
++        char *enptr = NULL;
++        errno = 0;
++        long r = strtol(val, &enptr, 10);
++        if (enptr != val && errno == 0) {
++            result = r;
++        }
++    }
++    return result;
++}
++
++double celix_bundleContext_getPropertyAsDouble(celix_bundle_context_t *ctx, const char *key, double defaultValue) {
++    double result = defaultValue;
++    const char *val = celix_bundleContext_getProperty(ctx, key, NULL);
++    if (val != NULL) {
++        char *enptr = NULL;
++        errno = 0;
++        double r = strtod(val, &enptr);
++        if (enptr != val && errno == 0) {
++            result = r;
++        }
++    }
++    return result;
++}
++
++
++bool celix_bundleContext_getPropertyAsBool(celix_bundle_context_t *ctx, const char *key, bool defaultValue) {
++    bool result = defaultValue;
++    const char *val = celix_bundleContext_getProperty(ctx, key, NULL);
++    if (val != NULL) {
++        char buf[32];
++        snprintf(buf, 32, "%s", val);
++        char *trimmed = utils_stringTrim(buf);
++        if (strncasecmp("true", trimmed, strlen("true")) == 0) {
++            result = true;
++        } else if (strncasecmp("false", trimmed, strlen("false")) == 0) {
++            result = false;
++        }
++    }
++    return result;
++}
diff --cc libs/framework/src/framework.c
index 5ff7c46,de14161..251bf5d
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@@ -107,18 -200,9 +200,9 @@@ celix_status_t fw_refreshHelper_refresh
  celix_status_t fw_refreshHelper_restart(struct fw_refreshHelper * refreshHelper);
  celix_status_t fw_refreshHelper_stop(struct fw_refreshHelper * refreshHelper);
  
- struct fw_serviceListener {
-     bundle_pt bundle;
-     service_listener_pt listener;
-     filter_pt filter;
-     array_list_pt retainedReferences;
- };
- 
- typedef struct fw_serviceListener * fw_service_listener_pt;
- 
  struct fw_bundleListener {
 -	bundle_pt bundle;
 -	bundle_listener_pt listener;
 +    bundle_pt bundle;
 +    bundle_listener_pt listener;
  };
  
  typedef struct fw_bundleListener * fw_bundle_listener_pt;
@@@ -238,13 -386,13 +386,13 @@@ celix_status_t framework_create(framewo
              (*framework)->serviceListeners = NULL;
              (*framework)->bundleListeners = NULL;
              (*framework)->frameworkListeners = NULL;
-             (*framework)->requests = NULL;
+             (*framework)->dispatcher.requests = NULL;
              (*framework)->configurationMap = config;
              (*framework)->logger = logger;
 -
 -
 +            
 +            
              status = CELIX_DO_IF(status, bundle_create(&(*framework)->bundle));
-             status = CELIX_DO_IF(status, arrayList_create(&(*framework)->globalLockWaitersList));
+             status = CELIX_DO_IF(status, bundle_getBundleId((*framework)->bundle, &(*framework)->bundleId));
              status = CELIX_DO_IF(status, bundle_setFramework((*framework)->bundle, (*framework)));
              if (status == CELIX_SUCCESS) {
                  //
@@@ -445,11 -604,10 +604,10 @@@ celix_status_t fw_init(framework_pt fra
          }
          arrayList_destroy(archives);
      }
 -
 +    
      status = CELIX_DO_IF(status, serviceRegistry_create(framework, fw_serviceChanged, &framework->registry));
      status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_STARTING));
-     status = CELIX_DO_IF(status, celixThreadCondition_init(&framework->shutdownGate, NULL));
-     
+ 
      bundle_context_t *context = NULL;
      status = CELIX_DO_IF(status, bundleContext_create(framework, framework->logger, framework->bundle, &context));
      status = CELIX_DO_IF(status, bundle_setContext(framework->bundle, context));
@@@ -490,52 -648,47 +648,47 @@@
              status = CELIX_ENOMEM;
          }
      }
 -
 +    
      if (status != CELIX_SUCCESS) {
 -       fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not init framework");
 +        fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not init framework");
      }
-     
-     framework_releaseBundleLock(framework, framework->bundle);
-     
-     return status;
+ 
+ 	return status;
  }
  
  celix_status_t framework_start(framework_pt framework) {
-     celix_status_t status = CELIX_SUCCESS;
-     bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
-     
-     status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
-     status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
-     if (status == CELIX_SUCCESS) {
-         if ((state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) || (state == OSGI_FRAMEWORK_BUNDLE_RESOLVED)) {
-             status = CELIX_DO_IF(status, fw_init(framework));
-         }
-     }
-     
-     status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
-     if (status == CELIX_SUCCESS) {
-         if (state == OSGI_FRAMEWORK_BUNDLE_STARTING) {
-             status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_ACTIVE));
+ 	celix_status_t status = CELIX_SUCCESS;
+ 	bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
+ 
+ 	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
+ 	if (status == CELIX_SUCCESS) {
+ 	    if ((state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) || (state == OSGI_FRAMEWORK_BUNDLE_RESOLVED)) {
+ 	        status = CELIX_DO_IF(status, fw_init(framework));
          }
-         
-         framework_releaseBundleLock(framework, framework->bundle);
-     }
-     
-     status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STARTED, framework->bundle));
-     status = CELIX_DO_IF(status, fw_fireFrameworkEvent(framework, OSGI_FRAMEWORK_EVENT_STARTED, framework->bundle, 0));
-     
-     if (status != CELIX_SUCCESS) {
-         status = CELIX_BUNDLE_EXCEPTION;
-         fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start framework");
-         fw_fireFrameworkEvent(framework, OSGI_FRAMEWORK_EVENT_ERROR, framework->bundle, status);
+ 	}
+ 
+ 	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
+ 	if (status == CELIX_SUCCESS) {
+ 	    if (state == OSGI_FRAMEWORK_BUNDLE_STARTING) {
+ 	        status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_ACTIVE));
+ 	    }
+ 	}
+ 
+ 	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STARTED, framework->bundle));
+ 	status = CELIX_DO_IF(status, fw_fireFrameworkEvent(framework, OSGI_FRAMEWORK_EVENT_STARTED, framework->bundle, framework->bundleId));
+ 
+ 	if (status != CELIX_SUCCESS) {
+        status = CELIX_BUNDLE_EXCEPTION;
+        fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start framework");
+        fw_fireFrameworkEvent(framework, OSGI_FRAMEWORK_EVENT_ERROR, framework->bundle, status);
      }
-     
+ 
      bundle_context_t *fwCtx = framework_getContext(framework);
 -	if (fwCtx != NULL) {
 +    if (fwCtx != NULL) {
          framework_autoStartConfiguredBundles(fwCtx);
      }
 -
 -	return status;
 +    
 +    return status;
  }
  
  static void framework_autoStartConfiguredBundles(bundle_context_t *fwCtx) {
@@@ -594,94 -747,136 +747,136 @@@ static void framework_autoStartConfigur
  
  
  celix_status_t framework_stop(framework_pt framework) {
 -	return fw_stopBundle(framework, framework->bundle, true);
 +    return fw_stopBundle(framework, framework->bundle, true);
  }
  
- celix_status_t fw_getProperty(framework_pt framework, const char* name, const char* defaultValue, const char** value) {
-     celix_status_t status = CELIX_SUCCESS;
-     
-     if (framework == NULL || name == NULL) {
-         status = CELIX_ILLEGAL_ARGUMENT;
-     } else {
-         if (framework->configurationMap != NULL) {
-             *value = properties_get(framework->configurationMap, name);
-         }
-         if (*value == NULL) {
-             *value = getenv(name);
-         }
-         if (*value == NULL) {
-             *value = defaultValue;
-         }
-     }
-     
-     return status;
+ celix_status_t fw_getProperty(framework_pt framework, const char* name, const char* defaultValue, const char** out) {
+ 	celix_status_t status = CELIX_SUCCESS;
+ 
+ 
+ 	const char *result = NULL;
+ 
+ 	if (framework == NULL || name == NULL) {
+ 		status = CELIX_ILLEGAL_ARGUMENT;
+ 	} else {
+ 		result = getenv(name); //NOTE that an env environment overrides the config.properties values
+ 		if (result == NULL && framework->configurationMap != NULL) {
+ 		    result = properties_get(framework->configurationMap, name);
+ 		}
+                 if (result == NULL) {
+                     result = defaultValue;
+                 }
+ 	}
+ 
+ 	if (out != NULL) {
+ 		*out = result;
+ 	}
+ 
+ 	return status;
  }
  
  celix_status_t fw_installBundle(framework_pt framework, bundle_pt * bundle, const char * location, const char *inputFile) {
 -	return fw_installBundle2(framework, bundle, -1, location, inputFile, NULL);
 +    return fw_installBundle2(framework, bundle, -1, location, inputFile, NULL);
  }
  
- celix_status_t fw_installBundle2(framework_pt framework, bundle_pt * bundle, long id, const char * location, const char *inputFile, bundle_archive_pt archive) {
+ static char* resolveBundleLocation(celix_framework_t *fw, const char *bndLoc, const char *p) {
+     char *result = NULL;
+     if (strnlen(bndLoc, 1) > 0) {
+         if (bndLoc[0] == '/') {
+             //absolute path, just use that
+             asprintf(&result, "%s", bndLoc);
+         } else if (access(bndLoc, F_OK) != -1) {
+             //current relative path points to an existing file, so use that.
+             result = strndup(bndLoc, 1024*1024);
+         } else {
+             //relative path -> resolve using BUNDLES_PATH
+             char *paths = strndup(p, 1024 * 1024);
+             const char *sep = ";";
+             char *savePtr = NULL;
+ 
+             for (char *path = strtok_r(paths, sep, &savePtr); path != NULL; path = strtok_r(NULL, sep, &savePtr)){
+                 char *absPath = NULL;
+                 asprintf(&absPath, "%s/%s", path, bndLoc);
+                 if (access(absPath, F_OK) != -1 ) {
+                     result = absPath;
+                     break;
+                 } else {
+                     free(absPath);
+                 }
+             }
+             free(paths);
+         }
+     }
+     return result;
+ }
+ 
+ celix_status_t fw_installBundle2(framework_pt framework, bundle_pt * bundle, long id, const char *bndLoc, const char *inputFile, bundle_archive_pt archive) {
      celix_status_t status = CELIX_SUCCESS;
-     //    bundle_archive_pt bundle_archive = NULL;
      bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
-     bool locked;
-     
-     status = CELIX_DO_IF(status, framework_acquireInstallLock(framework, location));
-     status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
-     if (status == CELIX_SUCCESS) {
+ 
+     const char *paths = NULL;
+     fw_getProperty(framework, CELIX_BUNDLES_PATH_NAME, CELIX_BUNDLES_PATH_DEFAULT, &paths);
+     char *location = resolveBundleLocation(framework, bndLoc, paths);
+     if (location == NULL) {
+         fw_log(framework->logger, OSGI_FRAMEWORK_LOG_WARNING, "Cannot find bundle %s. Using %s=%s", bndLoc, CELIX_BUNDLES_PATH_NAME, paths);
+         free(location);
+         return CELIX_FILE_IO_EXCEPTION;
+     }
+ 
+     //increase use count of framework bundle to prevent a stop. TODO is concurrent installing of bundles supported? -> else need another lock
+     fw_bundleEntry_increaseUseCount(framework, framework->bundleId);
+ 
+   	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
+   	if (status == CELIX_SUCCESS) {
          if (state == OSGI_FRAMEWORK_BUNDLE_STOPPING || state == OSGI_FRAMEWORK_BUNDLE_UNINSTALLED) {
              fw_log(framework->logger, OSGI_FRAMEWORK_LOG_INFO,  "The framework is being shutdown");
-             status = CELIX_DO_IF(status, framework_releaseInstallLock(framework, location));
              status = CELIX_FRAMEWORK_SHUTDOWN;
          }
 -  	}
 -
 +    }
 +    
      if (status == CELIX_SUCCESS) {
          *bundle = framework_getBundle(framework, location);
          if (*bundle != NULL) {
-             framework_releaseInstallLock(framework, location);
+             fw_bundleEntry_decreaseUseCount(framework, framework->bundleId);
+             free(location);
              return CELIX_SUCCESS;
          }
 -
 +        
          if (archive == NULL) {
              id = framework_getNextBundleId(framework);
 -
 +            
              status = CELIX_DO_IF(status, bundleCache_createArchive(framework->cache, id, location, inputFile, &archive));
 -
 +            
              if (status != CELIX_SUCCESS) {
 -            	bundleArchive_destroy(archive);
 +                bundleArchive_destroy(archive);
              }
          } else {
              // purge revision
              // multiple revisions not yet implemented
          }
 -
 +        
          if (status == CELIX_SUCCESS) {
-             locked = framework_acquireGlobalLock(framework);
-             if (!locked) {
-                 status = CELIX_BUNDLE_EXCEPTION;
-             } else {
-                 status = CELIX_DO_IF(status, bundle_createFromArchive(bundle, framework, archive));
-                 
-                 framework_releaseGlobalLock(framework);
-                 if (status == CELIX_SUCCESS) {
-                     celixThreadMutex_lock(&framework->installedBundleMapLock);
-                     hashMap_put(framework->installedBundleMap, strdup(location), *bundle);
-                     celixThreadMutex_unlock(&framework->installedBundleMapLock);
-                     
-                 } else {
-                     status = CELIX_BUNDLE_EXCEPTION;
-                     status = CELIX_DO_IF(status, bundleArchive_closeAndDelete(archive));
-                 }
-             }
+             status = bundle_createFromArchive(bundle, framework, archive);
+         }
+ 
+         if (status == CELIX_SUCCESS) {
+             long bndId = -1L;
+             bundle_getBundleId(*bundle, &bndId);
+             celix_framework_bundle_entry_t *entry = fw_bundleEntry_create(*bundle);
+             celixThreadMutex_lock(&framework->installedBundles.mutex);
+             celix_arrayList_add(framework->installedBundles.entries, entry);
+             celixThreadMutex_unlock(&framework->installedBundles.mutex);
+ 
+         } else {
+             status = CELIX_BUNDLE_EXCEPTION;
+             status = CELIX_DO_IF(status, bundleArchive_closeAndDelete(archive));
          }
      }
-     
-     framework_releaseInstallLock(framework, location);
-     
+ 
+     fw_bundleEntry_decreaseUseCount(framework, framework->bundleId);
+ 
      if (status != CELIX_SUCCESS) {
 -    	fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not install bundle");
 +        fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not install bundle");
      } else {
          status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_INSTALLED, *bundle));
      }
@@@ -892,28 -1083,29 +1083,29 @@@ celix_status_t framework_updateBundle(f
      status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
      if (handles != NULL) {
          int i;
 -	    for (i = arrayList_size(handles) - 1; i >= 0; i--) {
 -	        void* handle = arrayList_get(handles, i);
 -	        fw_closeLibrary(handle);
 -	    }
 +        for (i = arrayList_size(handles) - 1; i >= 0; i--) {
 +            void* handle = arrayList_get(handles, i);
 +            fw_closeLibrary(handle);
 +        }
      }
 -
 -
 -	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle));
 -	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UPDATED, bundle));
 -
 +    
 +    
 +    status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle));
 +    status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UPDATED, bundle));
 +    
      // Refresh packages?
-     
-     if (status == CELIX_SUCCESS) {
-         if (oldState == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
-             status = CELIX_DO_IF(status, fw_startBundle(framework, bundle, 1));
-         }
-     }
-     
-     framework_releaseBundleLock(framework, bundle);
-     
-     if (status != CELIX_SUCCESS) {
-         module_pt module = NULL;
+ 
+ 	if (status == CELIX_SUCCESS) {
+ 	    if (oldState == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
+ 	        status = CELIX_DO_IF(status, fw_startBundle(framework, bundle, 1));
+ 	    }
+ 	}
+ 
+ 
+     fw_bundleEntry_decreaseUseCount(framework, bndId);
+ 
+ 	if (status != CELIX_SUCCESS) {
+ 	    module_pt module = NULL;
          const char *symbolicName = NULL;
          long id = 0;
          bundle_getCurrentModule(bundle, &module);
@@@ -935,18 -1127,19 +1127,19 @@@ celix_status_t fw_stopBundle(framework_
      celix_bundle_activator_t *activator = NULL;
      bundle_context_t *context = NULL;
      bool wasActive = false;
-     long id = 0;
      char *error = NULL;
-     
-     status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
-     
-     if (record) {
-         status = CELIX_DO_IF(status, bundle_setPersistentStateInactive(bundle));
+ 
+     long bndId = celix_bundle_getId(bundle);
+     fw_bundleEntry_increaseUseCount(framework, bndId);
+ 
+ 
+ 	if (record) {
+ 	    status = CELIX_DO_IF(status, bundle_setPersistentStateInactive(bundle));
      }
 -
 -	status = CELIX_DO_IF(status, bundle_getState(bundle, &state));
 -	if (status == CELIX_SUCCESS) {
 -	    switch (state) {
 +    
 +    status = CELIX_DO_IF(status, bundle_getState(bundle, &state));
 +    if (status == CELIX_SUCCESS) {
 +        switch (state) {
              case OSGI_FRAMEWORK_BUNDLE_UNKNOWN:
                  status = CELIX_ILLEGAL_STATE;
                  error = "state is unknown";
@@@ -985,11 -1177,11 +1177,11 @@@
                  if (activator->stop != NULL) {
                      status = CELIX_DO_IF(status, activator->stop(activator->userData, context));
                      if (status == CELIX_SUCCESS) {
-                         dm_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(context);
-                         dependencyManager_removeAllComponents(mng);
+                         celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(context);
+                         celix_dependencyManager_removeAllComponents(mng);
                      }
                  }
 -	        }
 +            }
              if (status == CELIX_SUCCESS) {
                  if (activator->destroy != NULL) {
                      status = CELIX_DO_IF(status, activator->destroy(activator->userData, context));
@@@ -1014,21 -1207,23 +1207,23 @@@
                      status = CELIX_DO_IF(status, bundleContext_destroy(context));
                      status = CELIX_DO_IF(status, bundle_setContext(bundle, NULL));
                  }
 -
 +                
                  status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_RESOLVED));
              }
-         }
-         
-         if (activator != NULL) {
-             bundle_setActivator(bundle, NULL);
-             free(activator);
-         }
-     }
-     
-     framework_releaseBundleLock(framework, bundle);
-     
-     if (status != CELIX_SUCCESS) {
-         module_pt module = NULL;
+ 	    }
+ 
+ 	    if (activator != NULL) {
+ 	        bundle_setActivator(bundle, NULL);
+ 	        free(activator);
+ 	    }
+ 	}
+ 
+ 
+     fw_bundleEntry_decreaseUseCount(framework, bndId);
+ 
+ 
+ 	if (status != CELIX_SUCCESS) {
+ 	    module_pt module = NULL;
          const char *symbolicName = NULL;
          long id = 0;
          bundle_getCurrentModule(bundle, &module);
@@@ -1039,206 -1234,175 +1234,175 @@@
          } else {
              fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Cannot stop bundle: %s [%ld]", symbolicName, id);
          }
 - 	} else {
 +    } else {
          fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPED, bundle);
-     }
-     
-     return status;
+  	}
+ 
+  	celix_serviceTracker_syncForFramework(framework);
+ 
+ 	return status;
  }
  
  celix_status_t fw_uninstallBundle(framework_pt framework, bundle_pt bundle) {
-     celix_status_t status = CELIX_SUCCESS;
-     bool locked;
-     bundle_archive_pt archive = NULL;
-     const char * location = NULL;
-     bundle_pt target = NULL;
-     char *error = NULL;
-     
-     status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE|OSGI_FRAMEWORK_BUNDLE_STOPPING));
-     status = CELIX_DO_IF(status, fw_stopBundle(framework, bundle, true));
-     if (status == CELIX_SUCCESS) {
-         locked = framework_acquireGlobalLock(framework);
-         if (!locked) {
-             status = CELIX_ILLEGAL_STATE;
-             error = "Unable to acquire the global lock to uninstall the bundle";
-         }
-     }
-     
-     status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
-     status = CELIX_DO_IF(status, bundleArchive_getLocation(archive, &location));
+     celix_status_t status;
+ 
+     celix_framework_bundle_entry_t *entry = NULL;
+     long bndId = -1L;
+     status = bundle_getBundleId(bundle, &bndId);
      if (status == CELIX_SUCCESS) {
-         
-         celixThreadMutex_lock(&framework->installedBundleMapLock);
-         
-         hash_map_entry_pt entry = hashMap_getEntry(framework->installedBundleMap, location);
-         char* entryLocation = hashMapEntry_getKey(entry);
-         
-         target = (bundle_pt) hashMap_remove(framework->installedBundleMap, location);
-         
-         free(entryLocation);
-         if (target != NULL) {
-             status = CELIX_DO_IF(status, bundle_setPersistentStateUninstalled(target));
-             // fw_rememberUninstalledBundle(framework, target);
+         celixThreadMutex_lock(&framework->installedBundles.mutex);
+         int size = celix_arrayList_size(framework->installedBundles.entries);
+         for (int i = 0; i < size; ++i) {
+             celix_framework_bundle_entry_t *visit = celix_arrayList_get(framework->installedBundles.entries, i);
+             if (visit != NULL && visit->bndId == bndId) {
+                 entry = visit;
+                 break;
+             }
          }
-         celixThreadMutex_unlock(&framework->installedBundleMapLock);
-         
+         celixThreadMutex_unlock(&framework->installedBundles.mutex);
+         status = entry != NULL ? CELIX_SUCCESS : CELIX_ILLEGAL_ARGUMENT;
      }
-     
-     framework_releaseGlobalLock(framework);
-     
-     if (status == CELIX_SUCCESS) {
-         if (target == NULL) {
-             fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Could not remove bundle from installed map");
-         }
+ 
+     if (entry != NULL) {
+         //NOTE wait outside installedBundles.mutex
+         fw_bundleEntry_destroy(entry, true); //wait till use count is 0 -> e.g. not used
      }
-     
-     status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED));
-     
+ 
+     status = CELIX_DO_IF(status, fw_stopBundle(framework, bundle, true));
+ 
      // TODO Unload all libraries for transition to unresolved
-     bundle_revision_pt revision = NULL;
-     array_list_pt handles = NULL;
-     status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
-     status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
-     if(handles != NULL){
-         for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
-             void *handle = arrayList_get(handles, i);
-             fw_closeLibrary(handle);
-         }
-     }
-     
+     bundle_archive_t *archive = NULL;
+     bundle_revision_t *revision = NULL;
+ 	array_list_pt handles = NULL;
+ 	status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
+     status = CELIX_DO_IF(status, bundleArchive_setPersistentState(archive, OSGI_FRAMEWORK_BUNDLE_UNINSTALLED)); //set state to uninstalled, so that next framework start will not start bundle.
+ 	status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
+ 	status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
+ 	if(handles != NULL){
+ 		for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
+ 			void *handle = arrayList_get(handles, i);
+ 			fw_closeLibrary(handle);
+ 		}
+ 	}
+ 
      status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle));
 -
 +    
      status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_UNINSTALLED));
      status = CELIX_DO_IF(status, bundleArchive_setLastModified(archive, time(NULL)));
-     
-     framework_releaseBundleLock(framework, bundle);
-     
+ 
      status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNINSTALLED, bundle));
 -
 +    
      if (status == CELIX_SUCCESS) {
-         locked = framework_acquireGlobalLock(framework);
-         if (locked) {
-             bundle_pt bundles[] = { bundle };
-             celix_status_t refreshStatus = fw_refreshBundles(framework, bundles, 1);
-             if (refreshStatus != CELIX_SUCCESS) {
-                 printf("Could not refresh bundle");
-             } else {
-                 bundleArchive_destroy(archive);
-                 status = CELIX_DO_IF(status, bundle_destroy(bundle));
-             }
-             
-             status = CELIX_DO_IF(status, framework_releaseGlobalLock(framework));
+         bundle_pt bundles[] = { bundle };
+         celix_status_t refreshStatus = fw_refreshBundles(framework, bundles, 1);
+         if (refreshStatus != CELIX_SUCCESS) {
+             printf("Could not refresh bundle");
+         } else {
+             bundleArchive_destroy(archive);
+             status = CELIX_DO_IF(status, bundle_destroy(bundle));
          }
      }
 -
 -
 +    
 +    
      if (status != CELIX_SUCCESS) {
-         //        module_pt module = NULL;
-         //        char *symbolicName = NULL;
-         //        long id = 0;
-         //        bundle_getCurrentModule(bundle, &module);
-         //        module_getSymbolicName(module, &symbolicName);
-         //        bundle_getBundleId(bundle, &id);
-         
-         framework_logIfError(framework->logger, status, error, "Cannot uninstall bundle");
+ //        module_pt module = NULL;
+ //        char *symbolicName = NULL;
+ //        long id = 0;
+ //        bundle_getCurrentModule(bundle, &module);
+ //        module_getSymbolicName(module, &symbolicName);
+ //        bundle_getBundleId(bundle, &id);
+ 
+         framework_logIfError(framework->logger, status, "", "Cannot uninstall bundle");
      }
 -
 +    
      return status;
  }
  
  celix_status_t fw_refreshBundles(framework_pt framework, bundle_pt bundles[], int size) {
      celix_status_t status = CELIX_SUCCESS;
-     
-     bool locked = framework_acquireGlobalLock(framework);
-     if (!locked) {
-         framework_releaseGlobalLock(framework);
-         status = CELIX_ILLEGAL_STATE;
-     } else {
-         hash_map_values_pt values;
-         bundle_pt *newTargets;
-         unsigned int nrofvalues;
-         bool restart = false;
-         hash_map_pt map = hashMap_create(NULL, NULL, NULL, NULL);
-         int targetIdx = 0;
-         for (targetIdx = 0; targetIdx < size; targetIdx++) {
-             bundle_pt bundle = bundles[targetIdx];
-             hashMap_put(map, bundle, bundle);
-             fw_populateDependentGraph(framework, bundle, &map);
-         }
-         values = hashMapValues_create(map);
-         hashMapValues_toArray(values, (void ***) &newTargets, &nrofvalues);
-         hashMapValues_destroy(values);
-         
-         hashMap_destroy(map, false, false);
-         
-         if (newTargets != NULL) {
-             int i = 0;
-             struct fw_refreshHelper * helpers;
-             for (i = 0; i < nrofvalues && !restart; i++) {
-                 bundle_pt bundle = (bundle_pt) newTargets[i];
-                 if (framework->bundle == bundle) {
-                     restart = true;
-                 }
-             }
-             
-             helpers = (struct fw_refreshHelper * )malloc(nrofvalues * sizeof(struct fw_refreshHelper));
-             for (i = 0; i < nrofvalues && !restart; i++) {
-                 bundle_pt bundle = (bundle_pt) newTargets[i];
-                 helpers[i].framework = framework;
-                 helpers[i].bundle = bundle;
-                 helpers[i].oldState = OSGI_FRAMEWORK_BUNDLE_INSTALLED;
-             }
-             
-             for (i = 0; i < nrofvalues; i++) {
-                 struct fw_refreshHelper helper = helpers[i];
-                 fw_refreshHelper_stop(&helper);
-                 fw_refreshHelper_refreshOrRemove(&helper);
-             }
-             
-             for (i = 0; i < nrofvalues; i++) {
-                 struct fw_refreshHelper helper = helpers[i];
-                 fw_refreshHelper_restart(&helper);
-             }
-             
-             if (restart) {
-                 bundle_update(framework->bundle, NULL);
+ 
+     hash_map_values_pt values;
+     bundle_pt *newTargets;
+     unsigned int nrofvalues;
+     bool restart = false;
+     hash_map_pt map = hashMap_create(NULL, NULL, NULL, NULL);
+     int targetIdx = 0;
+     for (targetIdx = 0; targetIdx < size; targetIdx++) {
+         bundle_pt bundle = bundles[targetIdx];
+         hashMap_put(map, bundle, bundle);
+         fw_populateDependentGraph(framework, bundle, &map);
+     }
+     values = hashMapValues_create(map);
+     hashMapValues_toArray(values, (void ***) &newTargets, &nrofvalues);
+     hashMapValues_destroy(values);
+ 
+     hashMap_destroy(map, false, false);
+ 
+     if (newTargets != NULL) {
+         int i = 0;
+         struct fw_refreshHelper * helpers;
+         for (i = 0; i < nrofvalues && !restart; i++) {
+             bundle_pt bundle = (bundle_pt) newTargets[i];
+             if (framework->bundle == bundle) {
+                 restart = true;
              }
-             free(helpers);
-             free(newTargets);
          }
-         
-         framework_releaseGlobalLock(framework);
+ 
+         helpers = (struct fw_refreshHelper * )malloc(nrofvalues * sizeof(struct fw_refreshHelper));
+         for (i = 0; i < nrofvalues && !restart; i++) {
+             bundle_pt bundle = (bundle_pt) newTargets[i];
+             helpers[i].framework = framework;
+             helpers[i].bundle = bundle;
+             helpers[i].oldState = OSGI_FRAMEWORK_BUNDLE_INSTALLED;
+         }
+ 
+         for (i = 0; i < nrofvalues; i++) {
+             struct fw_refreshHelper helper = helpers[i];
+             fw_refreshHelper_stop(&helper);
+             fw_refreshHelper_refreshOrRemove(&helper);
+         }
+ 
+         for (i = 0; i < nrofvalues; i++) {
+             struct fw_refreshHelper helper = helpers[i];
+             fw_refreshHelper_restart(&helper);
+         }
+ 
+         if (restart) {
+             bundle_update(framework->bundle, NULL);
+         }
+         free(helpers);
+         free(newTargets);
      }
 -
 +    
      framework_logIfError(framework->logger, status, NULL, "Cannot refresh bundles");
 -
 +    
      return status;
  }
  
  celix_status_t fw_refreshBundle(framework_pt framework, bundle_pt bundle) {
      celix_status_t status = CELIX_SUCCESS;
      bundle_state_e state;
-     
-     status = framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED | OSGI_FRAMEWORK_BUNDLE_RESOLVED);
-     if (status != CELIX_SUCCESS) {
-         printf("Cannot refresh bundle");
-         framework_releaseBundleLock(framework, bundle);
-     } else {
-         bool fire;
-         bundle_getState(bundle, &state);
-         fire = (state != OSGI_FRAMEWORK_BUNDLE_INSTALLED);
-         bundle_refresh(bundle);
-         
-         if (fire) {
-             framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED);
-             fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle);
-         }
-         
-         framework_releaseBundleLock(framework, bundle);
+ 
+     long bndId = celix_bundle_getId(bundle);
+     fw_bundleEntry_increaseUseCount(framework, bndId);
+ 
+ 
+ 
+     bool fire;
+     bundle_getState(bundle, &state);
+     fire = (state != OSGI_FRAMEWORK_BUNDLE_INSTALLED);
+     bundle_refresh(bundle);
+ 
+     if (fire) {
+         framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED);
+         fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle);
      }
-     
+ 
+ 
+     fw_bundleEntry_decreaseUseCount(framework, bndId);
+ 
      framework_logIfError(framework->logger, status, NULL, "Cannot refresh bundle");
 -
 +    
      return status;
  }
  
@@@ -1351,15 -1513,15 +1513,15 @@@ celix_status_t fw_registerService(frame
              array_list_pt infos = NULL;
              service_reference_pt ref = NULL;
              listener_hook_service_pt hook = NULL;
 -
 +            
              status = CELIX_DO_IF(status, arrayList_create(&infos));
 -
 +            
              if (status == CELIX_SUCCESS) {
                  celix_status_t subs = CELIX_SUCCESS;
 -
 +                
                  celixThreadMutex_lock(&framework->serviceListenersLock);
                  for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
-                     fw_service_listener_pt listener =(fw_service_listener_pt) arrayList_get(framework->serviceListeners, i);
+                     celix_fw_service_listener_entry_t *listener = arrayList_get(framework->serviceListeners, i);
                      bundle_context_t *context = NULL;
                      listener_hook_info_pt info = NULL;
                      bundle_context_pt lContext = NULL;
@@@ -1404,13 -1566,17 +1566,17 @@@
                      free(info);
                  }
                  arrayList_destroy(infos);
 -             }
 +            }
          }
-     }
-     
+ 	}
+ 
+ 
+     fw_bundleEntry_decreaseUseCount(framework, bndId);
+ 
+ 
      framework_logIfError(framework->logger, status, error, "Cannot register service: %s", serviceName);
 -
 -	return status;
 +    
 +    return status;
  }
  
  celix_status_t fw_registerServiceFactory(framework_pt framework, service_registration_pt *registration, bundle_pt bundle, const char* serviceName, service_factory_pt factory, properties_pt properties) {
@@@ -1420,16 -1586,18 +1586,18 @@@
          status = CELIX_ILLEGAL_ARGUMENT;
          error = "Service name and factory cannot be null";
      }
-     
-     status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
-     status = CELIX_DO_IF(status, serviceRegistry_registerServiceFactory(framework->registry, bundle, serviceName, factory, properties, registration));
-     if (!framework_releaseBundleLock(framework, bundle)) {
-         status = CELIX_ILLEGAL_STATE;
-         error = "Could not release bundle lock";
-     }
-     
+ 
+     long bndId = celix_bundle_getId(bundle);
+     fw_bundleEntry_increaseUseCount(framework, bndId);
+ 
+ 
+ 	status = CELIX_DO_IF(status, serviceRegistry_registerServiceFactory(framework->registry, bundle, serviceName, factory, properties, registration));
+ 
+ 
+     fw_bundleEntry_decreaseUseCount(framework, bndId);
+ 
      framework_logIfError(framework->logger, status, error, "Cannot register service factory: %s", serviceName);
 -
 +    
      return CELIX_SUCCESS;
  }
  
@@@ -1491,64 -1659,62 +1659,62 @@@ celix_status_t fw_getBundleServicesInUs
  }
  
  celix_status_t framework_ungetService(framework_pt framework, bundle_pt bundle, service_reference_pt reference, bool *result) {
 -	return serviceRegistry_ungetService(framework->registry, bundle, reference, result);
 +    return serviceRegistry_ungetService(framework->registry, bundle, reference, result);
  }
  
- void fw_addServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener, const char* sfilter) {
-     array_list_pt listenerHooks = NULL;
-     unsigned int i;
-     
-     fw_service_listener_pt fwListener = (fw_service_listener_pt) calloc(1, sizeof(*fwListener));
-     bundle_context_t *context = NULL;
-     
-     fwListener->bundle = bundle;
-     arrayList_create(&fwListener->retainedReferences);
-     if (sfilter != NULL) {
-         filter_pt filter = filter_create(sfilter);
-         fwListener->filter = filter;
-     } else {
-         fwListener->filter = NULL;
-     }
-     fwListener->listener = listener;
-     
+ void fw_addServiceListener(framework_pt framework, bundle_pt bundle, celix_service_listener_t *listener, const char* sfilter) {
+ 	array_list_pt listenerHooks = NULL;
+ 	unsigned int i;
+ 
+     celix_fw_service_listener_entry_t *fwListener = listener_create(bundle, sfilter, listener);
+ 
+ 	bundle_context_t *context = NULL;
+ 
      celixThreadMutex_lock(&framework->serviceListenersLock);
 -	arrayList_add(framework->serviceListeners, fwListener);
 +    arrayList_add(framework->serviceListeners, fwListener);
      celixThreadMutex_unlock(&framework->serviceListenersLock);
-     
-     serviceRegistry_getListenerHooks(framework->registry, framework->bundle, &listenerHooks);
-     
-     struct listener_hook_info info;
-     
-     bundle_getContext(bundle, &context);
-     info.context = context;
-     info.removed = false;
-     info.filter = sfilter;
-     
-     for (i = 0; i < arrayList_size(listenerHooks); i++) {
-         service_reference_pt ref = (service_reference_pt) arrayList_get(listenerHooks, i);
-         listener_hook_service_pt hook = NULL;
-         array_list_pt infos = NULL;
-         bool ungetResult = false;
-         
-         fw_getService(framework, framework->bundle, ref, (const void **) &hook);
-         
-         arrayList_create(&infos);
-         arrayList_add(infos, &info);
-         hook->added(hook->handle, infos);
-         serviceRegistry_ungetService(framework->registry, framework->bundle, ref, &ungetResult);
-         serviceRegistry_ungetServiceReference(framework->registry, framework->bundle, ref);
-         arrayList_destroy(infos);
+ 
+     //TODO lock listeners hooks?
+ 	celix_status_t  status = serviceRegistry_getListenerHooks(framework->registry, framework->bundle, &listenerHooks);
+ 
+ 	if (status == CELIX_SUCCESS) {
+         struct listener_hook_info info;
+ 
+         bundle_getContext(bundle, &context);
+         info.context = context;
+         info.removed = false;
+         info.filter = sfilter;
+ 
+         for (i = 0; i < arrayList_size(listenerHooks); i++) {
+             service_reference_pt ref = (service_reference_pt) arrayList_get(listenerHooks, i);
+             listener_hook_service_pt hook = NULL;
+             array_list_pt infos = NULL;
+             bool ungetResult = false;
+ 
+             status = fw_getService(framework, framework->bundle, ref, (const void **) &hook);
+ 
+             if (status == CELIX_SUCCESS && hook != NULL) {
+                 arrayList_create(&infos);
+                 arrayList_add(infos, &info);
+                 hook->added(hook->handle, infos);
+                 serviceRegistry_ungetService(framework->registry, framework->bundle, ref, &ungetResult);
+                 serviceRegistry_ungetServiceReference(framework->registry, framework->bundle, ref);
+                 arrayList_destroy(infos);
+             } else {
+                 fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not retrieve hook service.");
+             }
+         }
+ 
+         arrayList_destroy(listenerHooks);
      }
-     
-     arrayList_destroy(listenerHooks);
  }
  
- void fw_removeServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener) {
-     fw_service_listener_pt match = NULL;
-     
+ void fw_removeServiceListener(framework_pt framework, bundle_pt bundle, celix_service_listener_t *listener) {
+     celix_fw_service_listener_entry_t *match = NULL;
+ 
      bundle_context_t *context;
      bundle_getContext(bundle, &context);
-     
+ 
      int i;
      celixThreadMutex_lock(&framework->serviceListenersLock);
      for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
@@@ -1580,35 -1746,24 +1746,24 @@@
              listener_hook_service_pt hook = NULL;
              array_list_pt infos = NULL;
              bool ungetResult;
 -
 +            
              fw_getService(framework, framework->bundle, ref, (const void **) &hook);
-             
-             arrayList_create(&infos);
-             arrayList_add(infos, &info);
-             hook->removed(hook->handle, infos);
-             serviceRegistry_ungetService(framework->registry, framework->bundle, ref, &ungetResult);
-             serviceRegistry_ungetServiceReference(framework->registry, framework->bundle, ref);
-             arrayList_destroy(infos);
+ 
+             if (hook != NULL) {
+                 arrayList_create(&infos);
+                 arrayList_add(infos, &info);
+                 hook->removed(hook->handle, infos);
+                 serviceRegistry_ungetService(framework->registry, framework->bundle, ref, &ungetResult);
+                 serviceRegistry_ungetServiceReference(framework->registry, framework->bundle, ref);
+                 arrayList_destroy(infos);
+             }
          }
          arrayList_destroy(listenerHooks);
      }
 -
 +    
      if (match != NULL) {
-         //unregistering retained service references. For these refs a unregister event will not be triggered.
-         int rSize = arrayList_size(match->retainedReferences);
-         for (i = 0; i < rSize; i += 1) {
-             service_reference_pt ref = arrayList_get(match->retainedReferences, i);
-             if (ref != NULL) {
-                 serviceRegistry_ungetServiceReference(framework->registry, match->bundle, ref); // decrease retain counter
-             }
-         }
-         
-         match->bundle = NULL;
-         filter_destroy(match->filter);
-         arrayList_destroy(match->retainedReferences);
-         match->filter = NULL;
-         match->listener = NULL;
-         free(match);
+         listener_release(match);
+         listener_waitAndDestroy(framework, match);
      }
  }
  
@@@ -2338,22 -2295,17 +2295,17 @@@ celix_status_t fw_fireBundleEvent(frame
                      }
                  }
              }
-             
-             if (celixThreadMutex_lock(&framework->dispatcherLock) != CELIX_SUCCESS) {
-                 status = CELIX_FRAMEWORK_EXCEPTION;
-             } else {
-                 arrayList_add(framework->requests, request);
-                 celix_status_t bcast_status = celixThreadCondition_broadcast(&framework->dispatcher);
-                 celix_status_t unlock_status = celixThreadMutex_unlock(&framework->dispatcherLock);
-                 if (bcast_status!=0 || unlock_status!=0) {
-                     status = CELIX_FRAMEWORK_EXCEPTION;
-                 }
-             }
+ 
+             celixThreadMutex_lock(&framework->dispatcher.mutex);
+             arrayList_add(framework->dispatcher.requests, request);
+             celixThreadCondition_broadcast(&framework->dispatcher.cond);
+             celixThreadMutex_unlock(&framework->dispatcher.mutex);
+ 
          }
      }
 -
 +    
      framework_logIfError(framework->logger, status, NULL, "Failed to fire bundle event");
-     
+ 
      return status;
  }
  
@@@ -2727,58 -2666,66 +2666,67 @@@ static celix_status_t framework_loadLib
   **********************************************************************************************************************/
  
  
- void celix_framework_useBundles(framework_t *fw, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd)) {
-     celixThreadMutex_lock(&fw->installedBundleMapLock);
-     int size = hashMap_size(fw->installedBundleMap);
-     long bundleIds[size];
-     int i = 0;
-     hash_map_iterator_t iter = hashMapIterator_construct(fw->installedBundleMap);
-     while (hashMapIterator_hasNext(&iter)) {
-         bundle_t *bnd = (bundle_t *) hashMapIterator_nextValue(&iter);
-         long bndId = celix_bundle_getId(bnd);
-         if (bndId >= 0) {
+ void celix_framework_useBundles(framework_t *fw, bool includeFrameworkBundle, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd)) {
+     celix_array_list_t *bundleIds = celix_arrayList_create();
+ 
+     celixThreadMutex_lock(&fw->installedBundles.mutex);
+     int size = celix_arrayList_size(fw->installedBundles.entries);
+     for (int i = 0; i < size; ++i) {
+         celix_framework_bundle_entry_t *entry = celix_arrayList_get(fw->installedBundles.entries, i);
+         if (entry->bndId > 0 || includeFrameworkBundle) {
              //NOTE bundle state is checked in celix_framework_useBundles
-             bundleIds[i++] =bndId;
+             celix_arrayList_addLong(bundleIds, entry->bndId);
          }
      }
-     celixThreadMutex_unlock(&fw->installedBundleMapLock);
-     
-     size = i;
-     for (i = 0; i < size; ++i) {
-         celix_framework_useBundle(fw, bundleIds[i], callbackHandle, use);
+     celixThreadMutex_unlock(&fw->installedBundles.mutex);
+ 
+     //note that stored bundle ids can now already be invalid (race cond),
+     //but the celix_framework_useBundle function should be able to handle this safely.
+ 
+     size = celix_arrayList_size(bundleIds);
+     for (int i = 0; i < size; ++i) {
+         long bndId = celix_arrayList_getLong(bundleIds, i);
+         celix_framework_useBundle(fw, true, bndId, callbackHandle, use);
      }
+ 
+     celix_arrayList_destroy(bundleIds);
  }
  
- bool celix_framework_useBundle(framework_t *fw, long bundleId, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd)) {
-     bool called = false;
+ void celix_framework_useBundle(framework_t *fw, bool onlyActive, long bundleId, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd)) {
      if (bundleId >= 0) {
-         //TODO get bundle lock without throwing errors framework_acquireBundleLock() -> a more simple lock ??
+         fw_bundleEntry_increaseUseCount(fw, bundleId);
          bundle_t *bnd = framework_getBundleById(fw, bundleId);
-         celix_bundle_state_e bndState = celix_bundle_getState(bnd);
-         if (bndState == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
-             use(callbackHandle, bnd);
-             called = true;
+         if (bnd != NULL) {
+             celix_bundle_state_e bndState = celix_bundle_getState(bnd);
+             if (onlyActive && (bndState == OSGI_FRAMEWORK_BUNDLE_ACTIVE || bndState == OSGI_FRAMEWORK_BUNDLE_STARTING)) {
+                 use(callbackHandle, bnd);
+             } else if (!onlyActive) {
+                 use(callbackHandle, bnd);
+             }
+         } else {
+             framework_logIfError(fw->logger, CELIX_FRAMEWORK_EXCEPTION, NULL, "Bundle with id %li is not installed", bundleId);
          }
-         //TODO unlock
+         fw_bundleEntry_decreaseUseCount(fw, bundleId);
      }
-     return called;
++    //return called;
  }
  
  service_registration_t* celix_framework_registerServiceFactory(framework_t *fw , const celix_bundle_t *bnd, const char* serviceName, celix_service_factory_t *factory, celix_properties_t *properties) {
      const char *error = NULL;
      celix_status_t status = CELIX_SUCCESS;
      service_registration_t *reg = NULL;
+ 
+     long bndId = celix_bundle_getId(bnd);
+     fw_bundleEntry_increaseUseCount(fw, bndId);
+ 
      if (serviceName != NULL && factory != NULL) {
-         status = framework_acquireBundleLock(fw, (celix_bundle_t*)bnd, OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE);
          status = CELIX_DO_IF(status, celix_serviceRegistry_registerServiceFactory(fw->registry, bnd, serviceName, factory, properties, &reg));
-         if (!framework_releaseBundleLock(fw, (celix_bundle_t*)bnd)) {
-             status = CELIX_ILLEGAL_STATE;
-             error = "Could not release bundle lock";
-         }
      }
-     
+ 
+     fw_bundleEntry_decreaseUseCount(fw, bndId);
+ 
      framework_logIfError(fw->logger, status, error, "Cannot register service factory: %s", serviceName);
 -
 +    
      return reg;
  }
  
diff --cc libs/framework/src/framework.c.orig
index 5ff7c46,de14161..ebdb89d
--- a/libs/framework/src/framework.c.orig
+++ b/libs/framework/src/framework.c.orig
@@@ -107,18 -200,9 +200,21 @@@ celix_status_t fw_refreshHelper_refresh
  celix_status_t fw_refreshHelper_restart(struct fw_refreshHelper * refreshHelper);
  celix_status_t fw_refreshHelper_stop(struct fw_refreshHelper * refreshHelper);
  
++<<<<<<< HEAD
 +struct fw_serviceListener {
 +    bundle_pt bundle;
 +    service_listener_pt listener;
 +    filter_pt filter;
 +    array_list_pt retainedReferences;
 +};
 +
 +typedef struct fw_serviceListener * fw_service_listener_pt;
 +
++=======
++>>>>>>> develop
  struct fw_bundleListener {
 -	bundle_pt bundle;
 -	bundle_listener_pt listener;
 +    bundle_pt bundle;
 +    bundle_listener_pt listener;
  };
  
  typedef struct fw_bundleListener * fw_bundle_listener_pt;
@@@ -212,26 -364,21 +376,31 @@@ celix_status_t framework_create(framewo
          celix_thread_mutexattr_t attr;
          celixThreadMutexAttr_create(&attr);
          celixThreadMutexAttr_settype(&attr, CELIX_THREAD_MUTEX_RECURSIVE);
++<<<<<<< HEAD
 +        
 +        status = CELIX_DO_IF(status, celixThreadCondition_init(&(*framework)->condition, NULL));
 +        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->mutex, NULL));
 +        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->installedBundleMapLock, NULL));
 +        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->bundleLock, NULL));
 +        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->installRequestLock, NULL));
 +        status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->dispatcherLock, NULL));
++=======
+ 
+         status = CELIX_DO_IF(status, celixThreadCondition_init(&(*framework)->shutdown.cond, NULL));
+         status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->shutdown.mutex, NULL));
+         status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->dispatcher.mutex, NULL));  //TODO refactor to use use count with condition (see serviceListeners)
++>>>>>>> develop
          status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->serviceListenersLock, &attr));
-         status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->frameworkListenersLock, &attr));
-         status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->bundleListenerLock, NULL));
-         status = CELIX_DO_IF(status, celixThreadCondition_init(&(*framework)->dispatcher, NULL));
+         status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->frameworkListenersLock, &attr));  //TODO refactor to use use count with condition (see serviceListeners)
+         status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->bundleListenerLock, NULL));  //TODO refactor to use use count with condition (see serviceListeners)
+         status = CELIX_DO_IF(status, celixThreadMutex_create(&(*framework)->installedBundles.mutex, NULL));  //TODO refactor to use use count with condition (see serviceListeners)
+         status = CELIX_DO_IF(status, celixThreadCondition_init(&(*framework)->dispatcher.cond, NULL));
          if (status == CELIX_SUCCESS) {
              (*framework)->bundle = NULL;
-             (*framework)->installedBundleMap = NULL;
              (*framework)->registry = NULL;
-             (*framework)->interrupted = false;
-             (*framework)->shutdown = false;
-             (*framework)->globalLockWaitersList = NULL;
-             (*framework)->globalLockCount = 0;
-             (*framework)->globalLockThread = celix_thread_default;
+             (*framework)->shutdown.done = false;
+             (*framework)->shutdown.initialized = false;
+             (*framework)->dispatcher.active = true;
              (*framework)->nextBundleId = 1L; //system bundle is 0
              (*framework)->cache = NULL;
              (*framework)->installRequestMap = hashMap_create(utils_stringHash, utils_stringHash, utils_stringEquals, utils_stringEquals);
@@@ -238,13 -386,13 +408,13 @@@
              (*framework)->serviceListeners = NULL;
              (*framework)->bundleListeners = NULL;
              (*framework)->frameworkListeners = NULL;
-             (*framework)->requests = NULL;
+             (*framework)->dispatcher.requests = NULL;
              (*framework)->configurationMap = config;
              (*framework)->logger = logger;
 -
 -
 +            
 +            
              status = CELIX_DO_IF(status, bundle_create(&(*framework)->bundle));
-             status = CELIX_DO_IF(status, arrayList_create(&(*framework)->globalLockWaitersList));
+             status = CELIX_DO_IF(status, bundle_getBundleId((*framework)->bundle, &(*framework)->bundleId));
              status = CELIX_DO_IF(status, bundle_setFramework((*framework)->bundle, (*framework)));
              if (status == CELIX_SUCCESS) {
                  //
@@@ -266,56 -415,70 +437,118 @@@
  
  celix_status_t framework_destroy(framework_pt framework) {
      celix_status_t status = CELIX_SUCCESS;
++<<<<<<< HEAD
 +    celixThreadMutex_lock(&framework->installedBundleMapLock);
 +    
 +    if (framework->installedBundleMap != NULL) {
 +        hash_map_iterator_pt iterator = hashMapIterator_create(framework->installedBundleMap);
 +        while (hashMapIterator_hasNext(iterator)) {
 +            hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
 +            bundle_pt bundle = (bundle_pt) hashMapEntry_getValue(entry);
 +            char * key = hashMapEntry_getKey(entry);
 +            bundle_archive_pt archive = NULL;
 +            
 +            bool systemBundle = false;
 +            bundle_isSystemBundle(bundle, &systemBundle);
 +            if (systemBundle) {
 +                bundle_context_t *context = NULL;
 +                bundle_getContext(framework->bundle, &context);
 +                bundleContext_destroy(context);
 +            }
 +            
 +            if (bundle_getArchive(bundle, &archive) == CELIX_SUCCESS) {
 +                if (!systemBundle) {
 +                    bundle_revision_pt revision = NULL;
 +                    array_list_pt handles = NULL;
 +                    status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
 +                    status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
 +                    if (handles != NULL) {
 +                        for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
 +                            void *handle = arrayList_get(handles, i);
 +                            fw_closeLibrary(handle);
 +                        }
 +                    }
 +                }
 +                
 +                bundleArchive_destroy(archive);
++=======
+ 
+     //Note the shutdown thread can not be joined on the framework_shutdown (which is normally more logical),
+     //because a shutdown can be initiated from a bundle.
+     //A bundle cannot be stopped when it is waiting for a framework shutdown -> hence a shutdown thread which
+     //has not been joined yet.
+     celixThread_join(framework->shutdown.thread, NULL);
+ 
+ 
+     celixThreadMutex_lock(&framework->installedBundles.mutex);
+     for (int i = 0; i < celix_arrayList_size(framework->installedBundles.entries); ++i) {
+         celix_framework_bundle_entry_t *entry = celix_arrayList_get(framework->installedBundles.entries, i);
+         celixThreadMutex_lock(&entry->useMutex);
+         size_t count = entry->useCount;
+         celixThreadMutex_unlock(&entry->useMutex);
+         bundle_t *bnd = entry->bnd;
+         if (count > 0) {
+             fw_log(framework->logger, OSGI_FRAMEWORK_LOG_WARNING, "Cannot destroy framework (yet), a bundle use count is not 0 (%ui)", count);
+         }
+         fw_bundleEntry_destroy(entry, true);
+ 
+         bool systemBundle = false;
+         bundle_isSystemBundle(bnd, &systemBundle);
+         if (systemBundle) {
+             bundle_context_t *context = NULL;
+             bundle_getContext(framework->bundle, &context);
+             bundleContext_destroy(context);
+         }
+ 
+         bundle_archive_t *archive = NULL;
+         if (bundle_getArchive(bnd, &archive) == CELIX_SUCCESS) {
+             if (!systemBundle) {
+                 bundle_revision_pt revision = NULL;
+                 array_list_pt handles = NULL;
+                 status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
+                 status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
+                 if (handles != NULL) {
+                     for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
+                         void *handle = arrayList_get(handles, i);
+                         fw_closeLibrary(handle);
+                     }
+                 }
++>>>>>>> develop
              }
-             bundle_destroy(bundle);
-             hashMapIterator_remove(iterator);
-             free(key);
+ 
+             bundleArchive_destroy(archive);
          }
-         hashMapIterator_destroy(iterator);
+         bundle_destroy(bnd);
+ 
      }
++<<<<<<< HEAD
 +    
 +    celixThreadMutex_unlock(&framework->installedBundleMapLock);
 +    
 +    hashMap_destroy(framework->installRequestMap, false, false);
 +    
 +    serviceRegistry_destroy(framework->registry);
 +    
 +    arrayList_destroy(framework->globalLockWaitersList);
 +    
++=======
+     celix_arrayList_destroy(framework->installedBundles.entries);
+     celixThreadMutex_destroy(&framework->installedBundles.mutex);
+ 
+ 
+ 
+ 	hashMap_destroy(framework->installRequestMap, false, false);
+ 
+ 	serviceRegistry_destroy(framework->registry);
+ 
++>>>>>>> develop
      if (framework->serviceListeners != NULL) {
+         int size = celix_arrayList_size(framework->serviceListeners);
+         for (int i = 0; i < size; ++i) {
+             celix_fw_service_listener_entry_t *entry = celix_arrayList_get(framework->serviceListeners, i);
+             listener_release(entry);
+             listener_waitAndDestroy(framework, entry);
+         }
          arrayList_destroy(framework->serviceListeners);
      }
      if (framework->bundleListeners) {
@@@ -324,32 -487,27 +557,56 @@@
      if (framework->frameworkListeners) {
          arrayList_destroy(framework->frameworkListeners);
      }
++<<<<<<< HEAD
 +    
 +    if(framework->requests){
 +        int i;
 +        for (i = 0; i < arrayList_size(framework->requests); i++) {
 +            request_pt request = arrayList_get(framework->requests, i);
 +            free(request);
 +        }
 +        arrayList_destroy(framework->requests);
 +    }
 +    if(framework->installedBundleMap!=NULL){
 +        hashMap_destroy(framework->installedBundleMap, true, false);
 +    }
 +    
 +    bundleCache_destroy(&framework->cache);
 +    
 +    celixThreadCondition_destroy(&framework->dispatcher);
 +    celixThreadMutex_destroy(&framework->serviceListenersLock);
 +    celixThreadMutex_destroy(&framework->frameworkListenersLock);
 +    celixThreadMutex_destroy(&framework->bundleListenerLock);
 +    celixThreadMutex_destroy(&framework->dispatcherLock);
 +    celixThreadMutex_destroy(&framework->installRequestLock);
 +    celixThreadMutex_destroy(&framework->bundleLock);
 +    celixThreadMutex_destroy(&framework->installedBundleMapLock);
 +    celixThreadMutex_destroy(&framework->mutex);
 +    celixThreadCondition_destroy(&framework->condition);
 +    
++=======
+ 
+ 	if(framework->dispatcher.requests){
+ 	    int i;
+ 	    for (i = 0; i < arrayList_size(framework->dispatcher.requests); i++) {
+ 	        request_pt request = arrayList_get(framework->dispatcher.requests, i);
+ 	        free(request->bundleSymbolicName);
+ 	        free(request);
+ 	    }
+ 	    arrayList_destroy(framework->dispatcher.requests);
+ 	}
+ 
+ 	bundleCache_destroy(&framework->cache);
+ 
+ 	celixThreadCondition_destroy(&framework->dispatcher.cond);
+     celixThreadMutex_destroy(&framework->serviceListenersLock);
+     celixThreadMutex_destroy(&framework->frameworkListenersLock);
+ 	celixThreadMutex_destroy(&framework->bundleListenerLock);
+ 	celixThreadMutex_destroy(&framework->dispatcher.mutex);
+ 	celixThreadMutex_destroy(&framework->shutdown.mutex);
+ 	celixThreadCondition_destroy(&framework->shutdown.cond);
+ 
++>>>>>>> develop
      logger = hashMap_get(framework->configurationMap, "logger");
      if (logger == NULL) {
          free(framework->logger);
@@@ -363,50 -521,46 +620,93 @@@
  }
  
  celix_status_t fw_init(framework_pt framework) {
++<<<<<<< HEAD
 +    bundle_state_e state;
 +    const char *location = NULL;
 +    module_pt module = NULL;
 +    linked_list_pt wires = NULL;
 +    array_list_pt archives = NULL;
 +    bundle_archive_pt archive = NULL;
 +    
 +    celix_status_t status = CELIX_SUCCESS;
 +    status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
 +    status = CELIX_DO_IF(status, arrayList_create(&framework->serviceListeners));
 +    status = CELIX_DO_IF(status, arrayList_create(&framework->bundleListeners));
 +    status = CELIX_DO_IF(status, arrayList_create(&framework->frameworkListeners));
 +    status = CELIX_DO_IF(status, arrayList_create(&framework->requests));
 +    status = CELIX_DO_IF(status, celixThread_create(&framework->dispatcherThread, NULL, fw_eventDispatcher, framework));
 +    status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
 +    if (status == CELIX_SUCCESS) {
 +        if ((state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) || (state == OSGI_FRAMEWORK_BUNDLE_RESOLVED)) {
 +            bundle_state_e state;
 +            status = CELIX_DO_IF(status, bundleCache_create(framework->configurationMap,&framework->cache));
 +            status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
 +            if (status == CELIX_SUCCESS) {
 +                if (state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) {
 +                    const char *clean = properties_get(framework->configurationMap, OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN);
 +                    if (clean != NULL && (strcmp(clean, OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT) == 0)) {
 +                        bundleCache_delete(framework->cache);
 +                    }
 +                }
 +            }
 +        }
 +    }
 +    
 +    if (status == CELIX_SUCCESS) {
 +        /*create and store framework uuid*/
 +        char uuid[37];
 +        
 +        uuid_t uid;
 +        uuid_generate(uid);
 +        uuid_unparse(uid, uuid);
 +        
 +        properties_set(framework->configurationMap, (char*) OSGI_FRAMEWORK_FRAMEWORK_UUID, uuid);
 +        
 +        framework->installedBundleMap = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL);
 +    }
 +    
++=======
+ 	bundle_state_e state;
+ 	const char *location = NULL;
+ 	module_pt module = NULL;
+ 	linked_list_pt wires = NULL;
+ 	array_list_pt archives = NULL;
+ 	bundle_archive_pt archive = NULL;
+ 
+     /*create and store framework uuid*/
+     char uuid[37];
+ 
+     uuid_t uid;
+     uuid_generate(uid);
+     uuid_unparse(uid, uuid);
+ 
+     properties_set(framework->configurationMap, (char*) OSGI_FRAMEWORK_FRAMEWORK_UUID, uuid);
+ 
+ 	celix_status_t status = CELIX_SUCCESS;
+ 	status = CELIX_DO_IF(status, arrayList_create(&framework->serviceListeners)); //entry is celix_fw_service_listener_entry_t
+ 	status = CELIX_DO_IF(status, arrayList_create(&framework->bundleListeners));
+ 	status = CELIX_DO_IF(status, arrayList_create(&framework->frameworkListeners));
+ 	status = CELIX_DO_IF(status, arrayList_create(&framework->dispatcher.requests));
+ 	status = CELIX_DO_IF(status, celixThread_create(&framework->dispatcher.thread, NULL, fw_eventDispatcher, framework));
+ 	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
+ 	if (status == CELIX_SUCCESS) {
+ 	    if ((state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) || (state == OSGI_FRAMEWORK_BUNDLE_RESOLVED)) {
+ 	        bundle_state_e state;
+ 	        status = CELIX_DO_IF(status, bundleCache_create(uuid, framework->configurationMap,&framework->cache));
+ 	        status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
+ 	        if (status == CELIX_SUCCESS) {
+ 	            if (state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) {
+ 	                const char *clean = properties_get(framework->configurationMap, OSGI_FRAMEWORK_FRAMEWORK_STORAGE_CLEAN_NAME);
+ 	                bool cleanCache = clean == NULL ? true : strcmp(clean, "false") != 0;
+ 	                if (cleanCache) {
+ 	                    bundleCache_delete(framework->cache);
+ 	                }
+ 	            }
+             }
+         }
+ 	}
+ 
++>>>>>>> develop
      status = CELIX_DO_IF(status, bundle_getArchive(framework->bundle, &archive));
      status = CELIX_DO_IF(status, bundleArchive_getLocation(archive, &location));
      if (status == CELIX_SUCCESS) {
@@@ -445,11 -604,10 +750,15 @@@
          }
          arrayList_destroy(archives);
      }
 -
 +    
      status = CELIX_DO_IF(status, serviceRegistry_create(framework, fw_serviceChanged, &framework->registry));
      status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_STARTING));
++<<<<<<< HEAD
 +    status = CELIX_DO_IF(status, celixThreadCondition_init(&framework->shutdownGate, NULL));
 +    
++=======
+ 
++>>>>>>> develop
      bundle_context_t *context = NULL;
      status = CELIX_DO_IF(status, bundleContext_create(framework, framework->logger, framework->bundle, &context));
      status = CELIX_DO_IF(status, bundle_setContext(framework->bundle, context));
@@@ -490,52 -648,47 +799,84 @@@
              status = CELIX_ENOMEM;
          }
      }
 -
 +    
      if (status != CELIX_SUCCESS) {
 -       fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not init framework");
 +        fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not init framework");
      }
++<<<<<<< HEAD
 +    
 +    framework_releaseBundleLock(framework, framework->bundle);
 +    
 +    return status;
 +}
 +
 +celix_status_t framework_start(framework_pt framework) {
 +    celix_status_t status = CELIX_SUCCESS;
 +    bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
 +    
 +    status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
 +    status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
 +    if (status == CELIX_SUCCESS) {
 +        if ((state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) || (state == OSGI_FRAMEWORK_BUNDLE_RESOLVED)) {
 +            status = CELIX_DO_IF(status, fw_init(framework));
 +        }
++=======
+ 
+ 	return status;
+ }
+ 
+ celix_status_t framework_start(framework_pt framework) {
+ 	celix_status_t status = CELIX_SUCCESS;
+ 	bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
+ 
+ 	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
+ 	if (status == CELIX_SUCCESS) {
+ 	    if ((state == OSGI_FRAMEWORK_BUNDLE_INSTALLED) || (state == OSGI_FRAMEWORK_BUNDLE_RESOLVED)) {
+ 	        status = CELIX_DO_IF(status, fw_init(framework));
+         }
+ 	}
+ 
+ 	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
+ 	if (status == CELIX_SUCCESS) {
+ 	    if (state == OSGI_FRAMEWORK_BUNDLE_STARTING) {
+ 	        status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_ACTIVE));
+ 	    }
+ 	}
+ 
+ 	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STARTED, framework->bundle));
+ 	status = CELIX_DO_IF(status, fw_fireFrameworkEvent(framework, OSGI_FRAMEWORK_EVENT_STARTED, framework->bundle, framework->bundleId));
+ 
+ 	if (status != CELIX_SUCCESS) {
+        status = CELIX_BUNDLE_EXCEPTION;
+        fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start framework");
+        fw_fireFrameworkEvent(framework, OSGI_FRAMEWORK_EVENT_ERROR, framework->bundle, status);
++>>>>>>> develop
      }
 -
 +    
 +    status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
 +    if (status == CELIX_SUCCESS) {
 +        if (state == OSGI_FRAMEWORK_BUNDLE_STARTING) {
 +            status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, framework->bundle, OSGI_FRAMEWORK_BUNDLE_ACTIVE));
 +        }
 +        
 +        framework_releaseBundleLock(framework, framework->bundle);
 +    }
 +    
 +    status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STARTED, framework->bundle));
 +    status = CELIX_DO_IF(status, fw_fireFrameworkEvent(framework, OSGI_FRAMEWORK_EVENT_STARTED, framework->bundle, 0));
 +    
 +    if (status != CELIX_SUCCESS) {
 +        status = CELIX_BUNDLE_EXCEPTION;
 +        fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start framework");
 +        fw_fireFrameworkEvent(framework, OSGI_FRAMEWORK_EVENT_ERROR, framework->bundle, status);
 +    }
 +    
      bundle_context_t *fwCtx = framework_getContext(framework);
 -	if (fwCtx != NULL) {
 +    if (fwCtx != NULL) {
          framework_autoStartConfiguredBundles(fwCtx);
      }
 -
 -	return status;
 +    
 +    return status;
  }
  
  static void framework_autoStartConfiguredBundles(bundle_context_t *fwCtx) {
@@@ -594,99 -747,143 +935,204 @@@ static void framework_autoStartConfigur
  
  
  celix_status_t framework_stop(framework_pt framework) {
 -	return fw_stopBundle(framework, framework->bundle, true);
 +    return fw_stopBundle(framework, framework->bundle, true);
  }
  
++<<<<<<< HEAD
 +celix_status_t fw_getProperty(framework_pt framework, const char* name, const char* defaultValue, const char** value) {
 +    celix_status_t status = CELIX_SUCCESS;
 +    
 +    if (framework == NULL || name == NULL) {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +    } else {
 +        if (framework->configurationMap != NULL) {
 +            *value = properties_get(framework->configurationMap, name);
 +        }
 +        if (*value == NULL) {
 +            *value = getenv(name);
 +        }
 +        if (*value == NULL) {
 +            *value = defaultValue;
 +        }
 +    }
 +    
 +    return status;
++=======
+ celix_status_t fw_getProperty(framework_pt framework, const char* name, const char* defaultValue, const char** out) {
+ 	celix_status_t status = CELIX_SUCCESS;
+ 
+ 
+ 	const char *result = NULL;
+ 
+ 	if (framework == NULL || name == NULL) {
+ 		status = CELIX_ILLEGAL_ARGUMENT;
+ 	} else {
+ 		result = getenv(name); //NOTE that an env environment overrides the config.properties values
+ 		if (result == NULL && framework->configurationMap != NULL) {
+ 		    result = properties_get(framework->configurationMap, name);
+ 		}
+                 if (result == NULL) {
+                     result = defaultValue;
+                 }
+ 	}
+ 
+ 	if (out != NULL) {
+ 		*out = result;
+ 	}
+ 
+ 	return status;
++>>>>>>> develop
  }
  
  celix_status_t fw_installBundle(framework_pt framework, bundle_pt * bundle, const char * location, const char *inputFile) {
 -	return fw_installBundle2(framework, bundle, -1, location, inputFile, NULL);
 +    return fw_installBundle2(framework, bundle, -1, location, inputFile, NULL);
  }
  
- celix_status_t fw_installBundle2(framework_pt framework, bundle_pt * bundle, long id, const char * location, const char *inputFile, bundle_archive_pt archive) {
+ static char* resolveBundleLocation(celix_framework_t *fw, const char *bndLoc, const char *p) {
+     char *result = NULL;
+     if (strnlen(bndLoc, 1) > 0) {
+         if (bndLoc[0] == '/') {
+             //absolute path, just use that
+             asprintf(&result, "%s", bndLoc);
+         } else if (access(bndLoc, F_OK) != -1) {
+             //current relative path points to an existing file, so use that.
+             result = strndup(bndLoc, 1024*1024);
+         } else {
+             //relative path -> resolve using BUNDLES_PATH
+             char *paths = strndup(p, 1024 * 1024);
+             const char *sep = ";";
+             char *savePtr = NULL;
+ 
+             for (char *path = strtok_r(paths, sep, &savePtr); path != NULL; path = strtok_r(NULL, sep, &savePtr)){
+                 char *absPath = NULL;
+                 asprintf(&absPath, "%s/%s", path, bndLoc);
+                 if (access(absPath, F_OK) != -1 ) {
+                     result = absPath;
+                     break;
+                 } else {
+                     free(absPath);
+                 }
+             }
+             free(paths);
+         }
+     }
+     return result;
+ }
+ 
+ celix_status_t fw_installBundle2(framework_pt framework, bundle_pt * bundle, long id, const char *bndLoc, const char *inputFile, bundle_archive_pt archive) {
      celix_status_t status = CELIX_SUCCESS;
++<<<<<<< HEAD
 +    //    bundle_archive_pt bundle_archive = NULL;
 +    bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
 +    bool locked;
 +    
 +    status = CELIX_DO_IF(status, framework_acquireInstallLock(framework, location));
 +    status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
 +    if (status == CELIX_SUCCESS) {
++=======
+     bundle_state_e state = OSGI_FRAMEWORK_BUNDLE_UNKNOWN;
+ 
+     const char *paths = NULL;
+     fw_getProperty(framework, CELIX_BUNDLES_PATH_NAME, CELIX_BUNDLES_PATH_DEFAULT, &paths);
+     char *location = resolveBundleLocation(framework, bndLoc, paths);
+     if (location == NULL) {
+         fw_log(framework->logger, OSGI_FRAMEWORK_LOG_WARNING, "Cannot find bundle %s. Using %s=%s", bndLoc, CELIX_BUNDLES_PATH_NAME, paths);
+         free(location);
+         return CELIX_FILE_IO_EXCEPTION;
+     }
+ 
+     //increase use count of framework bundle to prevent a stop. TODO is concurrent installing of bundles supported? -> else need another lock
+     fw_bundleEntry_increaseUseCount(framework, framework->bundleId);
+ 
+   	status = CELIX_DO_IF(status, bundle_getState(framework->bundle, &state));
+   	if (status == CELIX_SUCCESS) {
++>>>>>>> develop
          if (state == OSGI_FRAMEWORK_BUNDLE_STOPPING || state == OSGI_FRAMEWORK_BUNDLE_UNINSTALLED) {
              fw_log(framework->logger, OSGI_FRAMEWORK_LOG_INFO,  "The framework is being shutdown");
-             status = CELIX_DO_IF(status, framework_releaseInstallLock(framework, location));
              status = CELIX_FRAMEWORK_SHUTDOWN;
          }
 -  	}
 -
 +    }
 +    
      if (status == CELIX_SUCCESS) {
          *bundle = framework_getBundle(framework, location);
          if (*bundle != NULL) {
-             framework_releaseInstallLock(framework, location);
+             fw_bundleEntry_decreaseUseCount(framework, framework->bundleId);
+             free(location);
              return CELIX_SUCCESS;
          }
 -
 +        
          if (archive == NULL) {
              id = framework_getNextBundleId(framework);
 -
 +            
              status = CELIX_DO_IF(status, bundleCache_createArchive(framework->cache, id, location, inputFile, &archive));
 -
 +            
              if (status != CELIX_SUCCESS) {
 -            	bundleArchive_destroy(archive);
 +                bundleArchive_destroy(archive);
              }
          } else {
              // purge revision
              // multiple revisions not yet implemented
          }
 -
 +        
          if (status == CELIX_SUCCESS) {
++<<<<<<< HEAD
 +            locked = framework_acquireGlobalLock(framework);
 +            if (!locked) {
 +                status = CELIX_BUNDLE_EXCEPTION;
 +            } else {
 +                status = CELIX_DO_IF(status, bundle_createFromArchive(bundle, framework, archive));
 +                
 +                framework_releaseGlobalLock(framework);
 +                if (status == CELIX_SUCCESS) {
 +                    celixThreadMutex_lock(&framework->installedBundleMapLock);
 +                    hashMap_put(framework->installedBundleMap, strdup(location), *bundle);
 +                    celixThreadMutex_unlock(&framework->installedBundleMapLock);
 +                    
 +                } else {
 +                    status = CELIX_BUNDLE_EXCEPTION;
 +                    status = CELIX_DO_IF(status, bundleArchive_closeAndDelete(archive));
 +                }
 +            }
 +        }
 +    }
 +    
 +    framework_releaseInstallLock(framework, location);
 +    
++=======
+             status = bundle_createFromArchive(bundle, framework, archive);
+         }
+ 
+         if (status == CELIX_SUCCESS) {
+             long bndId = -1L;
+             bundle_getBundleId(*bundle, &bndId);
+             celix_framework_bundle_entry_t *entry = fw_bundleEntry_create(*bundle);
+             celixThreadMutex_lock(&framework->installedBundles.mutex);
+             celix_arrayList_add(framework->installedBundles.entries, entry);
+             celixThreadMutex_unlock(&framework->installedBundles.mutex);
+ 
+         } else {
+             status = CELIX_BUNDLE_EXCEPTION;
+             status = CELIX_DO_IF(status, bundleArchive_closeAndDelete(archive));
+         }
+     }
+ 
+     fw_bundleEntry_decreaseUseCount(framework, framework->bundleId);
+ 
++>>>>>>> develop
      if (status != CELIX_SUCCESS) {
 -    	fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not install bundle");
 +        fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not install bundle");
      } else {
          status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_INSTALLED, *bundle));
      }
++<<<<<<< HEAD
 +    
 +    return status;
++=======
+ 
+     free(location);
+ 
+   	return status;
++>>>>>>> develop
  }
  
  celix_status_t framework_getBundleEntry(framework_pt framework, bundle_pt bundle, const char* name, char** entry) {
@@@ -828,92 -1026,86 +1275,161 @@@ celix_status_t fw_startBundle(framework
                          status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STARTED, bundle));
                      }
                  }
 +                
 +                break;
 +        }
++<<<<<<< HEAD
 +    }
 +    
 +    framework_releaseBundleLock(framework, bundle);
 +    
 +    if (status != CELIX_SUCCESS) {
 +        module_pt module = NULL;
 +        const char *symbolicName = NULL;
 +        long id = 0;
 +        bundle_getCurrentModule(bundle, &module);
 +        module_getSymbolicName(module, &symbolicName);
 +        bundle_getBundleId(bundle, &id);
 +        if (error != NULL) {
 +            fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start bundle: %s [%ld]; cause: %s", symbolicName, id, error);
 +        } else {
 +            fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start bundle: %s [%ld]", symbolicName, id);
 +        }
 +        if(activator!=NULL){
 +            free(activator);
 +        }
 +    }
 +    
 +    return status;
 +}
  
 -            break;
 +celix_status_t framework_updateBundle(framework_pt framework, bundle_pt bundle, const char *inputFile) {
 +    celix_status_t status = CELIX_SUCCESS;
 +    bundle_state_e oldState;
 +    const char *location;
 +    bundle_archive_pt archive = NULL;
 +    char *error = NULL;
 +    
 +    status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
 +    status = CELIX_DO_IF(status, bundle_getState(bundle, &oldState));
 +    if (status == CELIX_SUCCESS) {
 +        if (oldState == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
 +            fw_stopBundle(framework, bundle, false);
 +        }
 +    }
 +    status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
 +    status = CELIX_DO_IF(status, bundleArchive_getLocation(archive, &location));
 +    
 +    if (status == CELIX_SUCCESS) {
 +        bool locked = framework_acquireGlobalLock(framework);
 +        if (!locked) {
 +            status = CELIX_BUNDLE_EXCEPTION;
 +            error = "Unable to acquire the global lock to update the bundle";
          }
 +    }
 +    
 +    status = CELIX_DO_IF(status, bundle_revise(bundle, location, inputFile));
 +    status = CELIX_DO_IF(status, framework_releaseGlobalLock(framework));
 +    
 +    status = CELIX_DO_IF(status, bundleArchive_setLastModified(archive, time(NULL)));
 +    status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED));
 +    
 +    bundle_revision_pt revision = NULL;
 +    array_list_pt handles = NULL;
 +    status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
++=======
+ 	}
+ 
+     fw_bundleEntry_decreaseUseCount(framework, bndId);
+ 
+ 	if (status != CELIX_SUCCESS) {
+ 	    module_pt module = NULL;
+ 	    const char *symbolicName = NULL;
+ 	    long id = 0;
+ 	    bundle_getCurrentModule(bundle, &module);
+ 	    module_getSymbolicName(module, &symbolicName);
+ 	    bundle_getBundleId(bundle, &id);
+ 	    if (error != NULL) {
+ 	        fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start bundle: %s [%ld]; cause: %s", symbolicName, id, error);
+ 	    } else {
+ 	        fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start bundle: %s [%ld]", symbolicName, id);
+ 	    }
+ 	    if(activator!=NULL){
+ 	    	free(activator);
+ 	    }
+ 	}
+ 
+ 	return status;
+ }
+ 
+ celix_status_t framework_updateBundle(framework_pt framework, bundle_pt bundle, const char *inputFile) {
+ 	celix_status_t status = CELIX_SUCCESS;
+ 	bundle_state_e oldState;
+ 	const char *location;
+ 	bundle_archive_pt archive = NULL;
+ 	char *error = NULL;
+ 
+     long bndId = celix_bundle_getId(bundle);
+     fw_bundleEntry_increaseUseCount(framework, bndId);
+ 
+ 	status = CELIX_DO_IF(status, bundle_getState(bundle, &oldState));
+ 	if (status == CELIX_SUCCESS) {
+         if (oldState == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
+             fw_stopBundle(framework, bundle, false);
+         }
+ 	}
+ 	status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
+ 	status = CELIX_DO_IF(status, bundleArchive_getLocation(archive, &location));
+ 
+ 	status = CELIX_DO_IF(status, bundle_revise(bundle, location, inputFile));
+ 
+ 	status = CELIX_DO_IF(status, bundleArchive_setLastModified(archive, time(NULL)));
+ 	status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED));
+ 
+ 	bundle_revision_pt revision = NULL;
+ 	array_list_pt handles = NULL;
+ 	status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
++>>>>>>> develop
      status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
      if (handles != NULL) {
          int i;
 -	    for (i = arrayList_size(handles) - 1; i >= 0; i--) {
 -	        void* handle = arrayList_get(handles, i);
 -	        fw_closeLibrary(handle);
 -	    }
 +        for (i = arrayList_size(handles) - 1; i >= 0; i--) {
 +            void* handle = arrayList_get(handles, i);
 +            fw_closeLibrary(handle);
 +        }
      }
 -
 -
 -	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle));
 -	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UPDATED, bundle));
 -
 +    
 +    
 +    status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle));
 +    status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UPDATED, bundle));
 +    
      // Refresh packages?
++<<<<<<< HEAD
 +    
 +    if (status == CELIX_SUCCESS) {
 +        if (oldState == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
 +            status = CELIX_DO_IF(status, fw_startBundle(framework, bundle, 1));
 +        }
 +    }
 +    
 +    framework_releaseBundleLock(framework, bundle);
 +    
 +    if (status != CELIX_SUCCESS) {
 +        module_pt module = NULL;
++=======
+ 
+ 	if (status == CELIX_SUCCESS) {
+ 	    if (oldState == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
+ 	        status = CELIX_DO_IF(status, fw_startBundle(framework, bundle, 1));
+ 	    }
+ 	}
+ 
+ 
+     fw_bundleEntry_decreaseUseCount(framework, bndId);
+ 
+ 	if (status != CELIX_SUCCESS) {
+ 	    module_pt module = NULL;
++>>>>>>> develop
          const char *symbolicName = NULL;
          long id = 0;
          bundle_getCurrentModule(bundle, &module);
@@@ -935,18 -1127,19 +1451,27 @@@ celix_status_t fw_stopBundle(framework_
      celix_bundle_activator_t *activator = NULL;
      bundle_context_t *context = NULL;
      bool wasActive = false;
-     long id = 0;
      char *error = NULL;
++<<<<<<< HEAD
 +    
 +    status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
 +    
 +    if (record) {
 +        status = CELIX_DO_IF(status, bundle_setPersistentStateInactive(bundle));
++=======
+ 
+     long bndId = celix_bundle_getId(bundle);
+     fw_bundleEntry_increaseUseCount(framework, bndId);
+ 
+ 
+ 	if (record) {
+ 	    status = CELIX_DO_IF(status, bundle_setPersistentStateInactive(bundle));
++>>>>>>> develop
      }
 -
 -	status = CELIX_DO_IF(status, bundle_getState(bundle, &state));
 -	if (status == CELIX_SUCCESS) {
 -	    switch (state) {
 +    
 +    status = CELIX_DO_IF(status, bundle_getState(bundle, &state));
 +    if (status == CELIX_SUCCESS) {
 +        switch (state) {
              case OSGI_FRAMEWORK_BUNDLE_UNKNOWN:
                  status = CELIX_ILLEGAL_STATE;
                  error = "state is unknown";
@@@ -970,33 -1163,33 +1495,54 @@@
                  wasActive = true;
                  break;
          }
++<<<<<<< HEAD
 +    }
 +    
 +    
 +    status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_STOPPING));
 +    status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPING, bundle));
 +    status = CELIX_DO_IF(status, bundle_getBundleId(bundle, &id));
 +    if (status == CELIX_SUCCESS) {
 +        if (wasActive || (id == 0)) {
 +            activator = bundle_getActivator(bundle);
 +            
 +            status = CELIX_DO_IF(status, bundle_getContext(bundle, &context));
 +            if (status == CELIX_SUCCESS) {
++=======
+ 	}
+ 
+ 
+ 	status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_STOPPING));
+ 	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPING, bundle));
+ 	if (status == CELIX_SUCCESS) {
+ 	    if (wasActive || (bndId == 0)) {
+ 	        activator = bundle_getActivator(bundle);
+ 
+ 	        status = CELIX_DO_IF(status, bundle_getContext(bundle, &context));
+ 	        if (status == CELIX_SUCCESS) {
++>>>>>>> develop
                  if (activator->stop != NULL) {
                      status = CELIX_DO_IF(status, activator->stop(activator->userData, context));
                      if (status == CELIX_SUCCESS) {
-                         dm_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(context);
-                         dependencyManager_removeAllComponents(mng);
+                         celix_dependency_manager_t *mng = celix_bundleContext_getDependencyManager(context);
+                         celix_dependencyManager_removeAllComponents(mng);
                      }
                  }
 -	        }
 +            }
              if (status == CELIX_SUCCESS) {
                  if (activator->destroy != NULL) {
                      status = CELIX_DO_IF(status, activator->destroy(activator->userData, context));
                  }
++<<<<<<< HEAD
 +            }
 +            
 +            if (id != 0) {
++=======
+ 	        }
+ 
+             if (bndId > 0) {
+ 	            celix_serviceTracker_syncForContext(bundle->context);
++>>>>>>> develop
                  status = CELIX_DO_IF(status, serviceRegistry_clearServiceRegistrations(framework->registry, bundle));
                  if (status == CELIX_SUCCESS) {
                      module_pt module = NULL;
@@@ -1014,21 -1207,23 +1560,38 @@@
                      status = CELIX_DO_IF(status, bundleContext_destroy(context));
                      status = CELIX_DO_IF(status, bundle_setContext(bundle, NULL));
                  }
 -
 +                
                  status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_RESOLVED));
              }
++<<<<<<< HEAD
 +        }
 +        
 +        if (activator != NULL) {
 +            bundle_setActivator(bundle, NULL);
 +            free(activator);
 +        }
 +    }
 +    
 +    framework_releaseBundleLock(framework, bundle);
 +    
 +    if (status != CELIX_SUCCESS) {
 +        module_pt module = NULL;
++=======
+ 	    }
+ 
+ 	    if (activator != NULL) {
+ 	        bundle_setActivator(bundle, NULL);
+ 	        free(activator);
+ 	    }
+ 	}
+ 
+ 
+     fw_bundleEntry_decreaseUseCount(framework, bndId);
+ 
+ 
+ 	if (status != CELIX_SUCCESS) {
+ 	    module_pt module = NULL;
++>>>>>>> develop
          const char *symbolicName = NULL;
          long id = 0;
          bundle_getCurrentModule(bundle, &module);
@@@ -1039,206 -1234,175 +1602,360 @@@
          } else {
              fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Cannot stop bundle: %s [%ld]", symbolicName, id);
          }
 - 	} else {
 +    } else {
          fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPED, bundle);
++<<<<<<< HEAD
 +    }
 +    
 +    return status;
 +}
 +
 +celix_status_t fw_uninstallBundle(framework_pt framework, bundle_pt bundle) {
 +    celix_status_t status = CELIX_SUCCESS;
 +    bool locked;
 +    bundle_archive_pt archive = NULL;
 +    const char * location = NULL;
 +    bundle_pt target = NULL;
 +    char *error = NULL;
 +    
 +    status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE|OSGI_FRAMEWORK_BUNDLE_STOPPING));
 +    status = CELIX_DO_IF(status, fw_stopBundle(framework, bundle, true));
 +    if (status == CELIX_SUCCESS) {
 +        locked = framework_acquireGlobalLock(framework);
 +        if (!locked) {
 +            status = CELIX_ILLEGAL_STATE;
 +            error = "Unable to acquire the global lock to uninstall the bundle";
 +        }
 +    }
 +    
 +    status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
 +    status = CELIX_DO_IF(status, bundleArchive_getLocation(archive, &location));
 +    if (status == CELIX_SUCCESS) {
 +        
 +        celixThreadMutex_lock(&framework->installedBundleMapLock);
 +        
 +        hash_map_entry_pt entry = hashMap_getEntry(framework->installedBundleMap, location);
 +        char* entryLocation = hashMapEntry_getKey(entry);
 +        
 +        target = (bundle_pt) hashMap_remove(framework->installedBundleMap, location);
 +        
 +        free(entryLocation);
 +        if (target != NULL) {
 +            status = CELIX_DO_IF(status, bundle_setPersistentStateUninstalled(target));
 +            // fw_rememberUninstalledBundle(framework, target);
 +        }
 +        celixThreadMutex_unlock(&framework->installedBundleMapLock);
 +        
 +    }
 +    
 +    framework_releaseGlobalLock(framework);
 +    
 +    if (status == CELIX_SUCCESS) {
 +        if (target == NULL) {
 +            fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Could not remove bundle from installed map");
 +        }
 +    }
 +    
 +    status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED));
 +    
 +    // TODO Unload all libraries for transition to unresolved
 +    bundle_revision_pt revision = NULL;
 +    array_list_pt handles = NULL;
 +    status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
 +    status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
 +    if(handles != NULL){
 +        for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
 +            void *handle = arrayList_get(handles, i);
 +            fw_closeLibrary(handle);
 +        }
 +    }
 +    
++=======
+  	}
+ 
+  	celix_serviceTracker_syncForFramework(framework);
+ 
+ 	return status;
+ }
+ 
+ celix_status_t fw_uninstallBundle(framework_pt framework, bundle_pt bundle) {
+     celix_status_t status;
+ 
+     celix_framework_bundle_entry_t *entry = NULL;
+     long bndId = -1L;
+     status = bundle_getBundleId(bundle, &bndId);
+     if (status == CELIX_SUCCESS) {
+         celixThreadMutex_lock(&framework->installedBundles.mutex);
+         int size = celix_arrayList_size(framework->installedBundles.entries);
+         for (int i = 0; i < size; ++i) {
+             celix_framework_bundle_entry_t *visit = celix_arrayList_get(framework->installedBundles.entries, i);
+             if (visit != NULL && visit->bndId == bndId) {
+                 entry = visit;
+                 break;
+             }
+         }
+         celixThreadMutex_unlock(&framework->installedBundles.mutex);
+         status = entry != NULL ? CELIX_SUCCESS : CELIX_ILLEGAL_ARGUMENT;
+     }
+ 
+     if (entry != NULL) {
+         //NOTE wait outside installedBundles.mutex
+         fw_bundleEntry_destroy(entry, true); //wait till use count is 0 -> e.g. not used
+     }
+ 
+     status = CELIX_DO_IF(status, fw_stopBundle(framework, bundle, true));
+ 
+     // TODO Unload all libraries for transition to unresolved
+     bundle_archive_t *archive = NULL;
+     bundle_revision_t *revision = NULL;
+ 	array_list_pt handles = NULL;
+ 	status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
+     status = CELIX_DO_IF(status, bundleArchive_setPersistentState(archive, OSGI_FRAMEWORK_BUNDLE_UNINSTALLED)); //set state to uninstalled, so that next framework start will not start bundle.
+ 	status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
+ 	status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
+ 	if(handles != NULL){
+ 		for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
+ 			void *handle = arrayList_get(handles, i);
+ 			fw_closeLibrary(handle);
+ 		}
+ 	}
+ 
++>>>>>>> develop
      status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle));
 -
 +    
      status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_UNINSTALLED));
      status = CELIX_DO_IF(status, bundleArchive_setLastModified(archive, time(NULL)));
++<<<<<<< HEAD
 +    
 +    framework_releaseBundleLock(framework, bundle);
 +    
++=======
+ 
++>>>>>>> develop
      status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNINSTALLED, bundle));
 -
 +    
      if (status == CELIX_SUCCESS) {
++<<<<<<< HEAD
 +        locked = framework_acquireGlobalLock(framework);
 +        if (locked) {
 +            bundle_pt bundles[] = { bundle };
 +            celix_status_t refreshStatus = fw_refreshBundles(framework, bundles, 1);
 +            if (refreshStatus != CELIX_SUCCESS) {
 +                printf("Could not refresh bundle");
 +            } else {
 +                bundleArchive_destroy(archive);
 +                status = CELIX_DO_IF(status, bundle_destroy(bundle));
 +            }
 +            
 +            status = CELIX_DO_IF(status, framework_releaseGlobalLock(framework));
++=======
+         bundle_pt bundles[] = { bundle };
+         celix_status_t refreshStatus = fw_refreshBundles(framework, bundles, 1);
+         if (refreshStatus != CELIX_SUCCESS) {
+             printf("Could not refresh bundle");
+         } else {
+             bundleArchive_destroy(archive);
+             status = CELIX_DO_IF(status, bundle_destroy(bundle));
++>>>>>>> develop
          }
      }
 -
 -
 +    
 +    
      if (status != CELIX_SUCCESS) {
++<<<<<<< HEAD
 +        //        module_pt module = NULL;
 +        //        char *symbolicName = NULL;
 +        //        long id = 0;
 +        //        bundle_getCurrentModule(bundle, &module);
 +        //        module_getSymbolicName(module, &symbolicName);
 +        //        bundle_getBundleId(bundle, &id);
 +        
 +        framework_logIfError(framework->logger, status, error, "Cannot uninstall bundle");
++=======
+ //        module_pt module = NULL;
+ //        char *symbolicName = NULL;
+ //        long id = 0;
+ //        bundle_getCurrentModule(bundle, &module);
+ //        module_getSymbolicName(module, &symbolicName);
+ //        bundle_getBundleId(bundle, &id);
+ 
+         framework_logIfError(framework->logger, status, "", "Cannot uninstall bundle");
++>>>>>>> develop
      }
 -
 +    
      return status;
  }
  
  celix_status_t fw_refreshBundles(framework_pt framework, bundle_pt bundles[], int size) {
      celix_status_t status = CELIX_SUCCESS;
++<<<<<<< HEAD
 +    
 +    bool locked = framework_acquireGlobalLock(framework);
 +    if (!locked) {
 +        framework_releaseGlobalLock(framework);
 +        status = CELIX_ILLEGAL_STATE;
 +    } else {
 +        hash_map_values_pt values;
 +        bundle_pt *newTargets;
 +        unsigned int nrofvalues;
 +        bool restart = false;
 +        hash_map_pt map = hashMap_create(NULL, NULL, NULL, NULL);
 +        int targetIdx = 0;
 +        for (targetIdx = 0; targetIdx < size; targetIdx++) {
 +            bundle_pt bundle = bundles[targetIdx];
 +            hashMap_put(map, bundle, bundle);
 +            fw_populateDependentGraph(framework, bundle, &map);
 +        }
 +        values = hashMapValues_create(map);
 +        hashMapValues_toArray(values, (void ***) &newTargets, &nrofvalues);
 +        hashMapValues_destroy(values);
 +        
 +        hashMap_destroy(map, false, false);
 +        
 +        if (newTargets != NULL) {
 +            int i = 0;
 +            struct fw_refreshHelper * helpers;
 +            for (i = 0; i < nrofvalues && !restart; i++) {
 +                bundle_pt bundle = (bundle_pt) newTargets[i];
 +                if (framework->bundle == bundle) {
 +                    restart = true;
 +                }
 +            }
 +            
 +            helpers = (struct fw_refreshHelper * )malloc(nrofvalues * sizeof(struct fw_refreshHelper));
 +            for (i = 0; i < nrofvalues && !restart; i++) {
 +                bundle_pt bundle = (bundle_pt) newTargets[i];
 +                helpers[i].framework = framework;
 +                helpers[i].bundle = bundle;
 +                helpers[i].oldState = OSGI_FRAMEWORK_BUNDLE_INSTALLED;
 +            }
 +            
 +            for (i = 0; i < nrofvalues; i++) {
 +                struct fw_refreshHelper helper = helpers[i];
 +                fw_refreshHelper_stop(&helper);
 +                fw_refreshHelper_refreshOrRemove(&helper);
 +            }
 +            
 +            for (i = 0; i < nrofvalues; i++) {
 +                struct fw_refreshHelper helper = helpers[i];
 +                fw_refreshHelper_restart(&helper);
 +            }
 +            
 +            if (restart) {
 +                bundle_update(framework->bundle, NULL);
 +            }
 +            free(helpers);
 +            free(newTargets);
 +        }
 +        
 +        framework_releaseGlobalLock(framework);
++=======
+ 
+     hash_map_values_pt values;
+     bundle_pt *newTargets;
+     unsigned int nrofvalues;
+     bool restart = false;
+     hash_map_pt map = hashMap_create(NULL, NULL, NULL, NULL);
+     int targetIdx = 0;
+     for (targetIdx = 0; targetIdx < size; targetIdx++) {
+         bundle_pt bundle = bundles[targetIdx];
+         hashMap_put(map, bundle, bundle);
+         fw_populateDependentGraph(framework, bundle, &map);
+     }
+     values = hashMapValues_create(map);
+     hashMapValues_toArray(values, (void ***) &newTargets, &nrofvalues);
+     hashMapValues_destroy(values);
+ 
+     hashMap_destroy(map, false, false);
+ 
+     if (newTargets != NULL) {
+         int i = 0;
+         struct fw_refreshHelper * helpers;
+         for (i = 0; i < nrofvalues && !restart; i++) {
+             bundle_pt bundle = (bundle_pt) newTargets[i];
+             if (framework->bundle == bundle) {
+                 restart = true;
+             }
+         }
+ 
+         helpers = (struct fw_refreshHelper * )malloc(nrofvalues * sizeof(struct fw_refreshHelper));
+         for (i = 0; i < nrofvalues && !restart; i++) {
+             bundle_pt bundle = (bundle_pt) newTargets[i];
+             helpers[i].framework = framework;
+             helpers[i].bundle = bundle;
+             helpers[i].oldState = OSGI_FRAMEWORK_BUNDLE_INSTALLED;
+         }
+ 
+         for (i = 0; i < nrofvalues; i++) {
+             struct fw_refreshHelper helper = helpers[i];
+             fw_refreshHelper_stop(&helper);
+             fw_refreshHelper_refreshOrRemove(&helper);
+         }
+ 
+         for (i = 0; i < nrofvalues; i++) {
+             struct fw_refreshHelper helper = helpers[i];
+             fw_refreshHelper_restart(&helper);
+         }
+ 
+         if (restart) {
+             bundle_update(framework->bundle, NULL);
+         }
+         free(helpers);
+         free(newTargets);
++>>>>>>> develop
      }
 -
 +    
      framework_logIfError(framework->logger, status, NULL, "Cannot refresh bundles");
 -
 +    
      return status;
  }
  
  celix_status_t fw_refreshBundle(framework_pt framework, bundle_pt bundle) {
      celix_status_t status = CELIX_SUCCESS;
      bundle_state_e state;
++<<<<<<< HEAD
 +    
 +    status = framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED | OSGI_FRAMEWORK_BUNDLE_RESOLVED);
 +    if (status != CELIX_SUCCESS) {
 +        printf("Cannot refresh bundle");
 +        framework_releaseBundleLock(framework, bundle);
 +    } else {
 +        bool fire;
 +        bundle_getState(bundle, &state);
 +        fire = (state != OSGI_FRAMEWORK_BUNDLE_INSTALLED);
 +        bundle_refresh(bundle);
 +        
 +        if (fire) {
 +            framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED);
 +            fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle);
 +        }
 +        
 +        framework_releaseBundleLock(framework, bundle);
 +    }
 +    
++=======
+ 
+     long bndId = celix_bundle_getId(bundle);
+     fw_bundleEntry_increaseUseCount(framework, bndId);
+ 
+ 
+ 
+     bool fire;
+     bundle_getState(bundle, &state);
+     fire = (state != OSGI_FRAMEWORK_BUNDLE_INSTALLED);
+     bundle_refresh(bundle);
+ 
+     if (fire) {
+         framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED);
+         fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle);
+     }
+ 
+ 
+     fw_bundleEntry_decreaseUseCount(framework, bndId);
+ 
++>>>>>>> develop
      framework_logIfError(framework->logger, status, NULL, "Cannot refresh bundle");
 -
 +    
      return status;
  }
  
@@@ -1329,37 -1493,35 +2046,55 @@@ celix_status_t fw_populateDependentGrap
  }
  
  celix_status_t fw_registerService(framework_pt framework, service_registration_pt *registration, bundle_pt bundle, const char* serviceName, const void* svcObj, properties_pt properties) {
++<<<<<<< HEAD
 +    celix_status_t status = CELIX_SUCCESS;
 +    char *error = NULL;
 +    if (serviceName == NULL || svcObj == NULL) {
 +        status = CELIX_ILLEGAL_ARGUMENT;
 +        error = "ServiceName and SvcObj cannot be null";
 +    }
 +    
 +    status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
 +    status = CELIX_DO_IF(status, serviceRegistry_registerService(framework->registry, bundle, serviceName, svcObj, properties, registration));
 +    bool res = framework_releaseBundleLock(framework, bundle);
 +    if (!res) {
 +        status = CELIX_ILLEGAL_STATE;
 +        error = "Could not release bundle lock";
 +    }
 +    
 +    if (status == CELIX_SUCCESS) {
 +        // If this is a listener hook, invoke the callback with all current listeners
++=======
+ 	celix_status_t status = CELIX_SUCCESS;
+ 	char *error = NULL;
+ 	if (serviceName == NULL || svcObj == NULL) {
+ 	    status = CELIX_ILLEGAL_ARGUMENT;
+ 	    error = "ServiceName and SvcObj cannot be null";
+ 	}
+ 
+ 	long bndId = celix_bundle_getId(bundle);
+     fw_bundleEntry_increaseUseCount(framework, bndId);
+ 
+ 
+ 	status = CELIX_DO_IF(status, serviceRegistry_registerService(framework->registry, bundle, serviceName, svcObj, properties, registration));
+ 
+ 	if (status == CELIX_SUCCESS) {
+ 	    // If this is a listener hook, invoke the callback with all current listeners
++>>>>>>> develop
          if (strcmp(serviceName, OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME) == 0) {
              unsigned int i;
              array_list_pt infos = NULL;
              service_reference_pt ref = NULL;
              listener_hook_service_pt hook = NULL;
 -
 +            
              status = CELIX_DO_IF(status, arrayList_create(&infos));
 -
 +            
              if (status == CELIX_SUCCESS) {
                  celix_status_t subs = CELIX_SUCCESS;
 -
 +                
                  celixThreadMutex_lock(&framework->serviceListenersLock);
                  for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
-                     fw_service_listener_pt listener =(fw_service_listener_pt) arrayList_get(framework->serviceListeners, i);
+                     celix_fw_service_listener_entry_t *listener = arrayList_get(framework->serviceListeners, i);
                      bundle_context_t *context = NULL;
                      listener_hook_info_pt info = NULL;
                      bundle_context_pt lContext = NULL;
@@@ -1404,13 -1566,17 +2139,22 @@@
                      free(info);
                  }
                  arrayList_destroy(infos);
 -             }
 +            }
          }
++<<<<<<< HEAD
 +    }
 +    
++=======
+ 	}
+ 
+ 
+     fw_bundleEntry_decreaseUseCount(framework, bndId);
+ 
+ 
++>>>>>>> develop
      framework_logIfError(framework->logger, status, error, "Cannot register service: %s", serviceName);
 -
 -	return status;
 +    
 +    return status;
  }
  
  celix_status_t fw_registerServiceFactory(framework_pt framework, service_registration_pt *registration, bundle_pt bundle, const char* serviceName, service_factory_pt factory, properties_pt properties) {
@@@ -1420,16 -1586,18 +2164,29 @@@
          status = CELIX_ILLEGAL_ARGUMENT;
          error = "Service name and factory cannot be null";
      }
++<<<<<<< HEAD
 +    
 +    status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
 +    status = CELIX_DO_IF(status, serviceRegistry_registerServiceFactory(framework->registry, bundle, serviceName, factory, properties, registration));
 +    if (!framework_releaseBundleLock(framework, bundle)) {
 +        status = CELIX_ILLEGAL_STATE;
 +        error = "Could not release bundle lock";
 +    }
 +    
++=======
+ 
+     long bndId = celix_bundle_getId(bundle);
+     fw_bundleEntry_increaseUseCount(framework, bndId);
+ 
+ 
+ 	status = CELIX_DO_IF(status, serviceRegistry_registerServiceFactory(framework->registry, bundle, serviceName, factory, properties, registration));
+ 
+ 
+     fw_bundleEntry_decreaseUseCount(framework, bndId);
+ 
++>>>>>>> develop
      framework_logIfError(framework->logger, status, error, "Cannot register service factory: %s", serviceName);
 -
 +    
      return CELIX_SUCCESS;
  }
  
@@@ -1491,64 -1659,62 +2248,120 @@@ celix_status_t fw_getBundleServicesInUs
  }
  
  celix_status_t framework_ungetService(framework_pt framework, bundle_pt bundle, service_reference_pt reference, bool *result) {
 -	return serviceRegistry_ungetService(framework->registry, bundle, reference, result);
 +    return serviceRegistry_ungetService(framework->registry, bundle, reference, result);
  }
  
++<<<<<<< HEAD
 +void fw_addServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener, const char* sfilter) {
 +    array_list_pt listenerHooks = NULL;
 +    unsigned int i;
 +    
 +    fw_service_listener_pt fwListener = (fw_service_listener_pt) calloc(1, sizeof(*fwListener));
 +    bundle_context_t *context = NULL;
 +    
 +    fwListener->bundle = bundle;
 +    arrayList_create(&fwListener->retainedReferences);
 +    if (sfilter != NULL) {
 +        filter_pt filter = filter_create(sfilter);
 +        fwListener->filter = filter;
 +    } else {
 +        fwListener->filter = NULL;
 +    }
 +    fwListener->listener = listener;
 +    
++=======
+ void fw_addServiceListener(framework_pt framework, bundle_pt bundle, celix_service_listener_t *listener, const char* sfilter) {
+ 	array_list_pt listenerHooks = NULL;
+ 	unsigned int i;
+ 
+     celix_fw_service_listener_entry_t *fwListener = listener_create(bundle, sfilter, listener);
+ 
+ 	bundle_context_t *context = NULL;
+ 
++>>>>>>> develop
      celixThreadMutex_lock(&framework->serviceListenersLock);
 -	arrayList_add(framework->serviceListeners, fwListener);
 +    arrayList_add(framework->serviceListeners, fwListener);
      celixThreadMutex_unlock(&framework->serviceListenersLock);
++<<<<<<< HEAD
 +    
 +    serviceRegistry_getListenerHooks(framework->registry, framework->bundle, &listenerHooks);
 +    
 +    struct listener_hook_info info;
 +    
 +    bundle_getContext(bundle, &context);
 +    info.context = context;
 +    info.removed = false;
 +    info.filter = sfilter;
 +    
 +    for (i = 0; i < arrayList_size(listenerHooks); i++) {
 +        service_reference_pt ref = (service_reference_pt) arrayList_get(listenerHooks, i);
 +        listener_hook_service_pt hook = NULL;
 +        array_list_pt infos = NULL;
 +        bool ungetResult = false;
 +        
 +        fw_getService(framework, framework->bundle, ref, (const void **) &hook);
 +        
 +        arrayList_create(&infos);
 +        arrayList_add(infos, &info);
 +        hook->added(hook->handle, infos);
 +        serviceRegistry_ungetService(framework->registry, framework->bundle, ref, &ungetResult);
 +        serviceRegistry_ungetServiceReference(framework->registry, framework->bundle, ref);
 +        arrayList_destroy(infos);
 +    }
 +    
 +    arrayList_destroy(listenerHooks);
 +}
 +
 +void fw_removeServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener) {
 +    fw_service_listener_pt match = NULL;
 +    
 +    bundle_context_t *context;
 +    bundle_getContext(bundle, &context);
 +    
++=======
+ 
+     //TODO lock listeners hooks?
+ 	celix_status_t  status = serviceRegistry_getListenerHooks(framework->registry, framework->bundle, &listenerHooks);
+ 
+ 	if (status == CELIX_SUCCESS) {
+         struct listener_hook_info info;
+ 
+         bundle_getContext(bundle, &context);
+         info.context = context;
+         info.removed = false;
+         info.filter = sfilter;
+ 
+         for (i = 0; i < arrayList_size(listenerHooks); i++) {
+             service_reference_pt ref = (service_reference_pt) arrayList_get(listenerHooks, i);
+             listener_hook_service_pt hook = NULL;
+             array_list_pt infos = NULL;
+             bool ungetResult = false;
+ 
+             status = fw_getService(framework, framework->bundle, ref, (const void **) &hook);
+ 
+             if (status == CELIX_SUCCESS && hook != NULL) {
+                 arrayList_create(&infos);
+                 arrayList_add(infos, &info);
+                 hook->added(hook->handle, infos);
+                 serviceRegistry_ungetService(framework->registry, framework->bundle, ref, &ungetResult);
+                 serviceRegistry_ungetServiceReference(framework->registry, framework->bundle, ref);
+                 arrayList_destroy(infos);
+             } else {
+                 fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not retrieve hook service.");
+             }
+         }
+ 
+         arrayList_destroy(listenerHooks);
+     }
+ }
+ 
+ void fw_removeServiceListener(framework_pt framework, bundle_pt bundle, celix_service_listener_t *listener) {
+     celix_fw_service_listener_entry_t *match = NULL;
+ 
+     bundle_context_t *context;
+     bundle_getContext(bundle, &context);
+ 
++>>>>>>> develop
      int i;
      celixThreadMutex_lock(&framework->serviceListenersLock);
      for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
@@@ -1580,71 -1746,60 +2393,113 @@@
              listener_hook_service_pt hook = NULL;
              array_list_pt infos = NULL;
              bool ungetResult;
 -
 +            
              fw_getService(framework, framework->bundle, ref, (const void **) &hook);
++<<<<<<< HEAD
 +            
 +            arrayList_create(&infos);
 +            arrayList_add(infos, &info);
 +            hook->removed(hook->handle, infos);
 +            serviceRegistry_ungetService(framework->registry, framework->bundle, ref, &ungetResult);
 +            serviceRegistry_ungetServiceReference(framework->registry, framework->bundle, ref);
 +            arrayList_destroy(infos);
++=======
+ 
+             if (hook != NULL) {
+                 arrayList_create(&infos);
+                 arrayList_add(infos, &info);
+                 hook->removed(hook->handle, infos);
+                 serviceRegistry_ungetService(framework->registry, framework->bundle, ref, &ungetResult);
+                 serviceRegistry_ungetServiceReference(framework->registry, framework->bundle, ref);
+                 arrayList_destroy(infos);
+             }
++>>>>>>> develop
          }
          arrayList_destroy(listenerHooks);
      }
 -
 +    
      if (match != NULL) {
++<<<<<<< HEAD
 +        //unregistering retained service references. For these refs a unregister event will not be triggered.
 +        int rSize = arrayList_size(match->retainedReferences);
 +        for (i = 0; i < rSize; i += 1) {
 +            service_reference_pt ref = arrayList_get(match->retainedReferences, i);
 +            if (ref != NULL) {
 +                serviceRegistry_ungetServiceReference(framework->registry, match->bundle, ref); // decrease retain counter
 +            }
 +        }
 +        
 +        match->bundle = NULL;
 +        filter_destroy(match->filter);
 +        arrayList_destroy(match->retainedReferences);
 +        match->filter = NULL;
 +        match->listener = NULL;
 +        free(match);
++=======
+         listener_release(match);
+         listener_waitAndDestroy(framework, match);
++>>>>>>> develop
      }
  }
  
  celix_status_t fw_addBundleListener(framework_pt framework, bundle_pt bundle, bundle_listener_pt listener) {
      celix_status_t status = CELIX_SUCCESS;
      fw_bundle_listener_pt bundleListener = NULL;
++<<<<<<< HEAD
 +    
++=======
+ 
++>>>>>>> develop
      bundleListener = (fw_bundle_listener_pt) malloc(sizeof(*bundleListener));
      if (!bundleListener) {
          status = CELIX_ENOMEM;
      } else {
          bundleListener->listener = listener;
          bundleListener->bundle = bundle;
++<<<<<<< HEAD
 +        
++=======
+ 
++>>>>>>> develop
          if (celixThreadMutex_lock(&framework->bundleListenerLock) != CELIX_SUCCESS) {
              status = CELIX_FRAMEWORK_EXCEPTION;
          } else {
              arrayList_add(framework->bundleListeners, bundleListener);
++<<<<<<< HEAD
 +            
++=======
+ 
++>>>>>>> develop
              if (celixThreadMutex_unlock(&framework->bundleListenerLock)) {
                  status = CELIX_FRAMEWORK_EXCEPTION;
              }
          }
      }
++<<<<<<< HEAD
 +    
 +    framework_logIfError(framework->logger, status, NULL, "Failed to add bundle listener");
 +    
++=======
+ 
+     framework_logIfError(framework->logger, status, NULL, "Failed to add bundle listener");
+ 
++>>>>>>> develop
      return status;
  }
  
  celix_status_t fw_removeBundleListener(framework_pt framework, bundle_pt bundle, bundle_listener_pt listener) {
      celix_status_t status = CELIX_SUCCESS;
++<<<<<<< HEAD
 +    
 +    unsigned int i;
 +    fw_bundle_listener_pt bundleListener;
 +    
++=======
+ 
+     unsigned int i;
+     fw_bundle_listener_pt bundleListener;
+ 
++>>>>>>> develop
      if (celixThreadMutex_lock(&framework->bundleListenerLock) != CELIX_SUCCESS) {
          status = CELIX_FRAMEWORK_EXCEPTION;
      }
@@@ -1653,7 -1808,7 +2508,11 @@@
              bundleListener = (fw_bundle_listener_pt) arrayList_get(framework->bundleListeners, i);
              if (bundleListener->listener == listener && bundleListener->bundle == bundle) {
                  arrayList_remove(framework->bundleListeners, i);
++<<<<<<< HEAD
 +                
++=======
+ 
++>>>>>>> develop
                  bundleListener->bundle = NULL;
                  bundleListener->listener = NULL;
                  free(bundleListener);
@@@ -1663,131 -1818,140 +2522,253 @@@
              status = CELIX_FRAMEWORK_EXCEPTION;
          }
      }
++<<<<<<< HEAD
 +    
 +    framework_logIfError(framework->logger, status, NULL, "Failed to remove bundle listener");
 +    
++=======
+ 
+     framework_logIfError(framework->logger, status, NULL, "Failed to remove bundle listener");
+ 
++>>>>>>> develop
      return status;
  }
  
  celix_status_t fw_addFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener) {
      celix_status_t status = CELIX_SUCCESS;
      fw_framework_listener_pt frameworkListener = NULL;
++<<<<<<< HEAD
 +    
++=======
+ 
++>>>>>>> develop
      frameworkListener = (fw_framework_listener_pt) malloc(sizeof(*frameworkListener));
      if (!frameworkListener) {
          status = CELIX_ENOMEM;
      } else {
          frameworkListener->listener = listener;
          frameworkListener->bundle = bundle;
++<<<<<<< HEAD
 +        
++=======
+ 
++>>>>>>> develop
          celixThreadMutex_lock(&framework->frameworkListenersLock);
          arrayList_add(framework->frameworkListeners, frameworkListener);
          celixThreadMutex_unlock(&framework->frameworkListenersLock);
      }
++<<<<<<< HEAD
 +    
 +    framework_logIfError(framework->logger, status, NULL, "Failed to add framework listener");
 +    
++=======
+ 
+     framework_logIfError(framework->logger, status, NULL, "Failed to add framework listener");
+ 
++>>>>>>> develop
      return status;
  }
  
  celix_status_t fw_removeFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener) {
      celix_status_t status = CELIX_SUCCESS;
++<<<<<<< HEAD
 +    
 +    unsigned int i;
 +    fw_framework_listener_pt frameworkListener;
 +    
++=======
+ 
+     unsigned int i;
+     fw_framework_listener_pt frameworkListener;
+ 
++>>>>>>> develop
      celixThreadMutex_lock(&framework->frameworkListenersLock);
      for (i = 0; i < arrayList_size(framework->frameworkListeners); i++) {
          frameworkListener = (fw_framework_listener_pt) arrayList_get(framework->frameworkListeners, i);
          if (frameworkListener->listener == listener && frameworkListener->bundle == bundle) {
              arrayList_remove(framework->frameworkListeners, i);
++<<<<<<< HEAD
 +            
++=======
+ 
++>>>>>>> develop
              frameworkListener->bundle = NULL;
              frameworkListener->listener = NULL;
              free(frameworkListener);
          }
      }
      celixThreadMutex_unlock(&framework->frameworkListenersLock);
++<<<<<<< HEAD
 +    
 +    framework_logIfError(framework->logger, status, NULL, "Failed to remove framework listener");
 +    
++=======
+ 
+     framework_logIfError(framework->logger, status, NULL, "Failed to remove framework listener");
+ 
++>>>>>>> develop
      return status;
  }
  
- void fw_serviceChanged(framework_pt framework, service_event_type_e eventType, service_registration_pt registration, properties_pt oldprops) {
+ void fw_serviceChanged(framework_pt framework, celix_service_event_type_t eventType, service_registration_pt registration, properties_pt oldprops) {
      unsigned int i;
++<<<<<<< HEAD
 +    fw_service_listener_pt element;
 +    
 +    celixThreadMutex_lock(&framework->serviceListenersLock);
 +    if (arrayList_size(framework->serviceListeners) > 0) {
 +        for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
 +            int matched = 0;
 +            properties_pt props = NULL;
 +            bool matchResult = false;
 +            
 +            element = (fw_service_listener_pt) arrayList_get(framework->serviceListeners, i);
 +            serviceRegistration_getProperties(registration, &props);
 +            if (element->filter != NULL) {
 +                filter_match(element->filter, props, &matchResult);
 +            }
 +            matched = (element->filter == NULL) || matchResult;
 +            if (matched) {
 +                service_reference_pt reference = NULL;
 +                service_event_pt event;
 +                
 +                event = (service_event_pt) malloc(sizeof (*event));
 +                
 +                serviceRegistry_getServiceReference(framework->registry, element->bundle, registration, &reference);
 +                
 +                //NOTE: that you are never sure that the UNREGISTERED event will by handle by an service_listener. listener could be gone
 +                //Every reference retained is therefore stored and called when a service listener is removed from the framework.
 +                if (eventType == OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED) {
 +                    serviceRegistry_retainServiceReference(framework->registry, element->bundle, reference);
 +                    arrayList_add(element->retainedReferences, reference); //TODO improve by using set (or hashmap) instead of list
 +                }
 +                
 +                event->type = eventType;
 +                event->reference = reference;
 +                
 +                element->listener->serviceChanged(element->listener, event);
 +                
 +                serviceRegistry_ungetServiceReference(framework->registry, element->bundle, reference);
 +                
 +                if (eventType == OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING) {
 +                    //if service listener was active when service was registered, release the retained reference
 +                    if (arrayList_removeElement(element->retainedReferences, reference)) {
 +                        serviceRegistry_ungetServiceReference(framework->registry, element->bundle, reference); // decrease retain counter
 +                    }
 +                }
 +                
 +                free(event);
 +                
 +            } else if (eventType == OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED) {
 +                bool matchResult = false;
 +                int matched = 0;
 +                if (element->filter != NULL) {
 +                    filter_match(element->filter, oldprops, &matchResult);
 +                }
 +                matched = (element->filter == NULL) || matchResult;
 +                if (matched) {
 +                    service_reference_pt reference = NULL;
 +                    service_event_pt endmatch = (service_event_pt) malloc(sizeof (*endmatch));
 +                    
 +                    serviceRegistry_getServiceReference(framework->registry, element->bundle, registration, &reference);
 +                    
 +                    endmatch->reference = reference;
 +                    endmatch->type = OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED_ENDMATCH;
 +                    element->listener->serviceChanged(element->listener, endmatch);
 +                    
 +                    serviceRegistry_ungetServiceReference(framework->registry, element->bundle, reference);
 +                    free(endmatch);
 +                    
 +                }
 +            }
++=======
+     celix_fw_service_listener_entry_t *entry;
+ 
+     celix_array_list_t* retainedEntries = celix_arrayList_create();
+     celix_array_list_t* matchedEntries = celix_arrayList_create();
+ 
+     celixThreadMutex_lock(&framework->serviceListenersLock);
+     for (i = 0; i < celix_arrayList_size(framework->serviceListeners); i++) {
+         entry = (celix_fw_service_listener_entry_t *) celix_arrayList_get(framework->serviceListeners, i);
+         celix_arrayList_add(retainedEntries, entry);
+         listener_retain(entry); //ensure that use count > 0, so that the listener cannot be destroyed until all pending event are handled.
+     }
+     celixThreadMutex_unlock(&framework->serviceListenersLock);
+ 
+     for (i = 0; i < celix_arrayList_size(retainedEntries); ++i) {
+         entry = (celix_fw_service_listener_entry_t *) celix_arrayList_get(retainedEntries, i);
+         int matched = 0;
+         properties_pt props = NULL;
+         bool matchResult = false;
+         serviceRegistration_getProperties(registration, &props);
+         if (entry->filter != NULL) {
+             filter_match(entry->filter, props, &matchResult);
+         }
+         matched = (entry->filter == NULL) || matchResult;
+         if (matched) {
+             celix_arrayList_add(matchedEntries, entry);
+         } else {
+             listener_release(entry); //Not a match -> release entry
+         }
+     }
+     celix_arrayList_destroy(retainedEntries);
+ 
+     /*
+      * TODO FIXME, A deadlock can happen when (e.g.) a service is deregistered, triggering this fw_serviceChanged and
+      * one of the matching service listener callback tries to remove an other matched service listener.
+      * The remove service listener will call the listener_waitForDestroy and the fw_serviceChanged part keeps the
+      * usageCount on > 0.
+      *
+      * Not sure how to prevent/handle this.
+      */
+     for (i = 0; i < celix_arrayList_size(matchedEntries); ++i) {
+         entry = (celix_fw_service_listener_entry_t *) celix_arrayList_get(matchedEntries, i);
+ 
+         service_reference_pt reference = NULL;
+         celix_service_event_t event;
+ 
+         serviceRegistry_getServiceReference(framework->registry, entry->bundle, registration, &reference);
+ 
+         //NOTE: that you are never sure that the UNREGISTERED event will by handle by an service_listener. listener could be gone
+         //Every reference retained is therefore stored and called when a service listener is removed from the framework.
+         if (eventType == OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED) {
+             serviceRegistry_retainServiceReference(framework->registry, entry->bundle, reference);
+             celixThreadMutex_lock(&entry->mutex);
+             arrayList_add(entry->retainedReferences, reference); //TODO improve by using set (or hashmap) instead of list
+             celixThreadMutex_unlock(&entry->mutex);
+         }
+ 
+         event.type = eventType;
+         event.reference = reference;
+ 
+         entry->listener->serviceChanged(entry->listener, &event);
+ 
+         serviceRegistry_ungetServiceReference(framework->registry, entry->bundle, reference);
+ 
+         if (eventType == OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING) {
+             //if service listener was active when service was registered, release the retained reference
+             celixThreadMutex_lock(&entry->mutex);
+             bool removed = arrayList_removeElement(entry->retainedReferences, reference);
+             celixThreadMutex_unlock(&entry->mutex);
+             if (removed) {
+                 serviceRegistry_ungetServiceReference(framework->registry, entry->bundle,
+                                                       reference); // decrease retain counter
+             }
+ 
+         }
+ 
+         if (eventType == OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED) {
+             entry->listener->serviceChanged(entry->listener, &event);
++>>>>>>> develop
          }
+         listener_release(entry); //decrease usage, so that the listener can be destroyed (if use count is now 0)
      }
++<<<<<<< HEAD
 +    celixThreadMutex_unlock(&framework->serviceListenersLock);
 +    
++=======
+     celix_arrayList_destroy(matchedEntries);
++>>>>>>> develop
  }
  
  //celix_status_t fw_isServiceAssignable(framework_pt fw, bundle_pt requester, service_reference_pt reference, bool *assignable) {
@@@ -1820,60 -1984,60 +2801,117 @@@ celix_status_t framework_markResolvedMo
              importer_wires_pt iw = linkedListIterator_previous(iterator);
              // hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
              module_pt module = iw->importer;
++<<<<<<< HEAD
 +            
 +            //			bundle_pt bundle = module_getBundle(module);
 +            //			bundle_archive_pt archive = NULL;
 +            //			bundle_getArchive(bundle, &archive);
 +            //			bundle_revision_pt revision = NULL;
 +            //			bundleArchive_getCurrentRevision(archive, &revision);
 +            //			char *root = NULL;
 +            //			bundleRevision_getRoot(revision, &root);
 +            //			manifest_pt manifest = NULL;
 +            //			bundleRevision_getManifest(revision, &manifest);
 +            //
 +            //			char *private = manifest_getValue(manifest, OSGI_FRAMEWORK_PRIVATE_LIBRARY);
 +            //			char *export = manifest_getValue(manifest, OSGI_FRAMEWORK_EXPORT_LIBRARY);
 +            //
 +            //			printf("Root %s\n", root);
 +            
 +            // for each library update the reference to the wires, if there are any
 +            
 +            linked_list_pt wires = iw->wires;
 +            
 +            //			linked_list_iterator_pt wit = linkedListIterator_create(wires, 0);
 +            //			while (linkedListIterator_hasNext(wit)) {
 +            //			    wire_pt wire = linkedListIterator_next(wit);
 +            //			    module_pt importer = NULL;
 +            //			    requirement_pt requirement = NULL;
 +            //			    module_pt exporter = NULL;
 +            //                capability_pt capability = NULL;
 +            //			    wire_getImporter(wire, &importer);
 +            //			    wire_getRequirement(wire, &requirement);
 +            //
 +            //			    wire_getExporter(wire, &exporter);
 +            //			    wire_getCapability(wire, &capability);
 +            //
 +            //			    char *importerName = NULL;
 +            //			    module_getSymbolicName(importer, &importerName);
 +            //
 +            //			    char *exporterName = NULL;
 +            //                module_getSymbolicName(exporter, &exporterName);
 +            //
 +            //                version_pt version = NULL;
 +            //                char *name = NULL;
 +            //                capability_getServiceName(capability, &name);
 +            //                capability_getVersion(capability, &version);
 +            //                char *versionString = NULL;
 +            //                version_toString(version, framework->mp, &versionString);
 +            //
 +            //                printf("Module %s imports library %s:%s from %s\n", importerName, name, versionString, exporterName);
 +            //			}
 +            
 +            module_setWires(module, wires);
 +            
 +            module_setResolved(module);
 +            resolver_moduleResolved(module);
 +            
++=======
+ 
+ //			bundle_pt bundle = module_getBundle(module);
+ //			bundle_archive_pt archive = NULL;
+ //			bundle_getArchive(bundle, &archive);
+ //			bundle_revision_pt revision = NULL;
+ //			bundleArchive_getCurrentRevision(archive, &revision);
+ //			char *root = NULL;
+ //			bundleRevision_getRoot(revision, &root);
+ //			manifest_pt manifest = NULL;
+ //			bundleRevision_getManifest(revision, &manifest);
+ //
+ //			char *private = manifest_getValue(manifest, OSGI_FRAMEWORK_PRIVATE_LIBRARY);
+ //			char *export = manifest_getValue(manifest, OSGI_FRAMEWORK_EXPORT_LIBRARY);
+ //
+ //			printf("Root %s\n", root);
+ 
+             // for each library update the reference to the wires, if there are any
+ 
+             linked_list_pt wires = iw->wires;
+ 
+ //			linked_list_iterator_pt wit = linkedListIterator_create(wires, 0);
+ //			while (linkedListIterator_hasNext(wit)) {
+ //			    wire_pt wire = linkedListIterator_next(wit);
+ //			    module_pt importer = NULL;
+ //			    requirement_pt requirement = NULL;
+ //			    module_pt exporter = NULL;
+ //                capability_pt capability = NULL;
+ //			    wire_getImporter(wire, &importer);
+ //			    wire_getRequirement(wire, &requirement);
+ //
+ //			    wire_getExporter(wire, &exporter);
+ //			    wire_getCapability(wire, &capability);
+ //
+ //			    char *importerName = NULL;
+ //			    module_getSymbolicName(importer, &importerName);
+ //
+ //			    char *exporterName = NULL;
+ //                module_getSymbolicName(exporter, &exporterName);
+ //
+ //                version_pt version = NULL;
+ //                char *name = NULL;
+ //                capability_getServiceName(capability, &name);
+ //                capability_getVersion(capability, &version);
+ //                char *versionString = NULL;
+ //                version_toString(version, framework->mp, &versionString);
+ //
+ //                printf("Module %s imports library %s:%s from %s\n", importerName, name, versionString, exporterName);
+ //			}
+ 
+             module_setWires(module, wires);
+ 
+             module_setResolved(module);
+             resolver_moduleResolved(module);
+ 
++>>>>>>> develop
              const char *mname = NULL;
              module_getSymbolicName(module, &mname);
              framework_markBundleResolved(framework, module);
@@@ -1891,9 -2055,12 +2929,18 @@@ celix_status_t framework_markBundleReso
      bundle_pt bundle = module_getBundle(module);
      bundle_state_e state;
      char *error = NULL;
++<<<<<<< HEAD
 +    
 +    if (bundle != NULL) {
 +        framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_ACTIVE);
++=======
+ 
+     if (bundle != NULL) {
+ 
+         long bndId = celix_bundle_getId(bundle);
+         fw_bundleEntry_increaseUseCount(framework, bndId);
+ 
++>>>>>>> develop
          bundle_getState(bundle, &state);
          if (state != OSGI_FRAMEWORK_BUNDLE_INSTALLED) {
              printf("Trying to resolve a resolved bundle");
@@@ -1905,11 -2072,11 +2952,19 @@@
              if (!isSystemBundle) {
                  status = CELIX_DO_IF(status, framework_loadBundleLibraries(framework, bundle));
              }
++<<<<<<< HEAD
 +            
 +            status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_RESOLVED));
 +            status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_RESOLVED, bundle));
 +        }
 +        
++=======
+ 
+             status = CELIX_DO_IF(status, framework_setBundleStateAndNotify(framework, bundle, OSGI_FRAMEWORK_BUNDLE_RESOLVED));
+             status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_RESOLVED, bundle));
+         }
+ 
++>>>>>>> develop
          if (status != CELIX_SUCCESS) {
              module_pt module = NULL;
              const char *symbolicName = NULL;
@@@ -1922,368 -2089,158 +2977,510 @@@
                  fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Could not start bundle: %s [%ld]", symbolicName, id);
              }
          }
++<<<<<<< HEAD
 +        
 +        framework_releaseBundleLock(framework, bundle);
 +    }
 +    
++=======
+ 
+ 
+         fw_bundleEntry_decreaseUseCount(framework, bndId);
+     }
+ 
++>>>>>>> develop
      return CELIX_SUCCESS;
  }
  
  array_list_pt framework_getBundles(framework_pt framework) {
++<<<<<<< HEAD
 +    array_list_pt bundles = NULL;
 +    hash_map_iterator_pt iterator;
 +    arrayList_create(&bundles);
 +    
 +    celixThreadMutex_lock(&framework->installedBundleMapLock);
 +    
 +    iterator = hashMapIterator_create(framework->installedBundleMap);
 +    while (hashMapIterator_hasNext(iterator)) {
 +        bundle_pt bundle = (bundle_pt) hashMapIterator_nextValue(iterator);
 +        arrayList_add(bundles, bundle);
 +    }
 +    hashMapIterator_destroy(iterator);
 +    
 +    celixThreadMutex_unlock(&framework->installedBundleMapLock);
 +    
++=======
+     //FIXME Note that this does not increase the use count of the bundle, which can lead to race conditions.
+     //promote to use the celix_bundleContext_useBundle(s) functions and deprecated this one
+     array_list_pt bundles = NULL;
+     arrayList_create(&bundles);
+ 
+     celixThreadMutex_lock(&framework->installedBundles.mutex);
+     int size = celix_arrayList_size(framework->installedBundles.entries);
+     for (int i = 0; i < size; ++i) {
+         celix_framework_bundle_entry_t *entry = celix_arrayList_get(framework->installedBundles.entries, i);
+         celix_arrayList_add(bundles, entry->bnd);
+     }
+     celixThreadMutex_unlock(&framework->installedBundles.mutex);
+ 
++>>>>>>> develop
      return bundles;
  }
  
  bundle_pt framework_getBundle(framework_pt framework, const char* location) {
++<<<<<<< HEAD
 +    celixThreadMutex_lock(&framework->installedBundleMapLock);
 +    bundle_pt bundle = (bundle_pt) hashMap_get(framework->installedBundleMap, location);
 +    celixThreadMutex_unlock(&framework->installedBundleMapLock);
 +    return bundle;
 +}
 +
 +bundle_pt framework_getBundleById(framework_pt framework, long id) {
 +    celixThreadMutex_lock(&framework->installedBundleMapLock);
 +    hash_map_iterator_pt iter = hashMapIterator_create(framework->installedBundleMap);
 +    bundle_pt bundle = NULL;
 +    while (hashMapIterator_hasNext(iter)) {
 +        bundle_pt b = (bundle_pt) hashMapIterator_nextValue(iter);
 +        bundle_archive_pt archive = NULL;
 +        long bid;
 +        bundle_getArchive(b, &archive);
 +        bundleArchive_getId(archive, &bid);
 +        if (bid == id) {
 +            bundle = b;
 +            break;
 +        }
 +    }
 +    hashMapIterator_destroy(iter);
 +    celixThreadMutex_unlock(&framework->installedBundleMapLock);
 +    
 +    return bundle;
 +}
 +
 +celix_status_t framework_acquireInstallLock(framework_pt framework, const char * location) {
 +    celixThreadMutex_lock(&framework->installRequestLock);
 +    
 +    while (hashMap_get(framework->installRequestMap, location) != NULL) {
 +        celixThreadCondition_wait(&framework->condition, &framework->installRequestLock);
 +    }
 +    hashMap_put(framework->installRequestMap, (char*)location, (char*)location);
 +    
 +    celixThreadMutex_unlock(&framework->installRequestLock);
 +    
 +    return CELIX_SUCCESS;
 +}
 +
 +celix_status_t framework_releaseInstallLock(framework_pt framework, const char* location) {
 +    celixThreadMutex_lock(&framework->installRequestLock);
 +    
 +    hashMap_remove(framework->installRequestMap, location);
 +    celixThreadCondition_broadcast(&framework->condition);
 +    
 +    celixThreadMutex_unlock(&framework->installRequestLock);
 +    
 +    return CELIX_SUCCESS;
++=======
+     //FIXME Note that this does not increase the use count of the bundle, which can lead to race conditions.
+     //promote to use the celix_bundleContext_useBundle(s) functions and deprecated this one
+     bundle_t *bnd = NULL;
+ 
+     celixThreadMutex_lock(&framework->installedBundles.mutex);
+     int size = celix_arrayList_size(framework->installedBundles.entries);
+     for (int i = 0; i < size; ++i) {
+         celix_framework_bundle_entry_t *entry = celix_arrayList_get(framework->installedBundles.entries, i);
+         const char *loc = NULL;
+         bundle_getBundleLocation(entry->bnd, &loc);
+         if (loc != NULL && location != NULL && strncmp(loc, location, strlen(loc)) == 0) {
+             bnd = entry->bnd;
+             break;
+         }
+     }
+     celixThreadMutex_unlock(&framework->installedBundles.mutex);
+ 
+ 
+     return bnd;
+ }
+ 
+ bundle_pt framework_getBundleById(framework_pt framework, long id) {
+     bundle_t *bnd = NULL;
+ 
+     celixThreadMutex_lock(&framework->installedBundles.mutex);
+     int size = celix_arrayList_size(framework->installedBundles.entries);
+     for (int i = 0; i < size; ++i) {
+         celix_framework_bundle_entry_t *entry = celix_arrayList_get(framework->installedBundles.entries, i);
+         if (entry != NULL && entry->bndId == id) {
+             bnd = entry->bnd;
+             break;
+         }
+     }
+     celixThreadMutex_unlock(&framework->installedBundles.mutex);
+ 
+     return bnd;
++>>>>>>> develop
  }
  
  celix_status_t framework_setBundleStateAndNotify(framework_pt framework, bundle_pt bundle, int state) {
      int ret = CELIX_SUCCESS;
++<<<<<<< HEAD
 +    
 +    int err = celixThreadMutex_lock(&framework->bundleLock);
 +    if (err != 0) {
 +        fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to lock");
 +        return CELIX_BUNDLE_EXCEPTION;
 +    }
 +    
 +    bundle_setState(bundle, state);
 +    err = celixThreadCondition_broadcast(&framework->condition);
 +    if (err != 0) {
 +        fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to broadcast");
 +        ret = CELIX_BUNDLE_EXCEPTION;
 +    }
 +    
 +    err = celixThreadMutex_unlock(&framework->bundleLock);
 +    if (err != 0) {
 +        fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to unlock");
 +        return CELIX_BUNDLE_EXCEPTION;
 +    }
 +    return ret;
 +}
 +
 +celix_status_t framework_acquireBundleLock(framework_pt framework, bundle_pt bundle, int desiredStates) {
 +    celix_status_t status = CELIX_SUCCESS;
 +    
 +    bool locked;
 +    celix_thread_t lockingThread = celix_thread_default;
 +    
 +    int err = celixThreadMutex_lock(&framework->bundleLock);
 +    if (err != CELIX_SUCCESS) {
 +        fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to lock");
 +        status = CELIX_BUNDLE_EXCEPTION;
 +    } else {
 +        bool lockable = false;
 +        bool isSelf = false;
 +        
 +        bundle_isLockable(bundle, &lockable);
 +        thread_equalsSelf(framework->globalLockThread, &isSelf);
 +        
 +        while (!lockable
 +               || (( celixThread_initalized(framework->globalLockThread) == true)
 +                   && !isSelf))
 +        {
 +            bundle_state_e state;
 +            bundle_getState(bundle, &state);
 +            if ((desiredStates & state) == 0) {
 +                status = CELIX_ILLEGAL_STATE;
 +                break;
 +            }
 +            
 +            bundle_getLockingThread(bundle, &lockingThread);
 +            if (isSelf && (celixThread_initalized(lockingThread) == true)
 +                && arrayList_contains(framework->globalLockWaitersList, &lockingThread)) {
 +                framework->interrupted = true;
 +                //				celixThreadCondition_signal_thread_np(&framework->condition, bundle_getLockingThread(bundle));
 +                celixThreadCondition_signal(&framework->condition);
 +            }
 +            
 +            celixThreadCondition_wait(&framework->condition, &framework->bundleLock);
 +            
 +            status = bundle_isLockable(bundle, &lockable);
 +            if (status != CELIX_SUCCESS) {
 +                break;
 +            }
 +        }
 +        
 +        if (status == CELIX_SUCCESS) {
 +            bundle_state_e state;
 +            bundle_getState(bundle, &state);
 +            if ((desiredStates & state) == 0) {
 +                status = CELIX_ILLEGAL_STATE;
 +            } else {
 +                if (bundle_lock(bundle, &locked)) {
 +                    if (!locked) {
 +                        status = CELIX_ILLEGAL_STATE;
 +                    }
 +                }
 +            }
 +        }
 +        celixThreadMutex_unlock(&framework->bundleLock);
 +    }
 +    
 +    framework_logIfError(framework->logger, status, NULL, "Failed to get bundle lock");
 +    
 +    return status;
 +}
 +
 +bool framework_releaseBundleLock(framework_pt framework, bundle_pt bundle) {
 +    bool unlocked;
 +    celix_thread_t lockingThread = celix_thread_default;
 +    
 +    celixThreadMutex_lock(&framework->bundleLock);
 +    
 +    bundle_unlock(bundle, &unlocked);
 +    if (!unlocked) {
 +        celixThreadMutex_unlock(&framework->bundleLock);
 +        return false;
 +    }
 +    bundle_getLockingThread(bundle, &lockingThread);
 +    if (celixThread_initalized(lockingThread) == false) {
 +        celixThreadCondition_broadcast(&framework->condition);
 +    }
 +    
 +    celixThreadMutex_unlock(&framework->bundleLock);
 +    
 +    return true;
 +}
 +
 +bool framework_acquireGlobalLock(framework_pt framework) {
 +    bool interrupted = false;
 +    bool isSelf = false;
 +    
 +    celixThreadMutex_lock(&framework->bundleLock);
 +    
 +    thread_equalsSelf(framework->globalLockThread, &isSelf);
 +    
 +    while (!interrupted
 +           && (celixThread_initalized(framework->globalLockThread) == true)
 +           && (!isSelf)) {
 +        celix_thread_t currentThread = celixThread_self();
 +        arrayList_add(framework->globalLockWaitersList, &currentThread);
 +        celixThreadCondition_broadcast(&framework->condition);
 +        
 +        celixThreadCondition_wait(&framework->condition, &framework->bundleLock);
 +        if (framework->interrupted) {
 +            interrupted = true;
 +            framework->interrupted = false;
 +        }
 +        
 +        arrayList_removeElement(framework->globalLockWaitersList, &currentThread);
 +    }
 +    
 +    if (!interrupted) {
 +        framework->globalLockCount++;
 +        framework->globalLockThread = celixThread_self();
 +    }
 +    
 +    celixThreadMutex_unlock(&framework->bundleLock);
 +    
 +    return !interrupted;
 +}
 +
 +celix_status_t framework_releaseGlobalLock(framework_pt framework) {
 +    int status = CELIX_SUCCESS;
 +    if (celixThreadMutex_lock(&framework->bundleLock) != 0) {
 +        fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error locking framework bundle lock");
 +        return CELIX_FRAMEWORK_EXCEPTION;
 +    }
 +    
 +    if (celixThread_equals(framework->globalLockThread, celixThread_self())) {
 +        framework->globalLockCount--;
 +        if (framework->globalLockCount == 0) {
 +            framework->globalLockThread = celix_thread_default;
 +            if (celixThreadCondition_broadcast(&framework->condition) != 0) {
 +                fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Failed to broadcast global lock release.");
 +                status = CELIX_FRAMEWORK_EXCEPTION;
 +                // still need to unlock before returning
 +            }
 +        }
 +    } else {
 +        printf("The current thread does not own the global lock");
 +    }
 +    
 +    if (celixThreadMutex_unlock(&framework->bundleLock) != 0) {
 +        fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking framework bundle lock");
 +        return CELIX_FRAMEWORK_EXCEPTION;
 +    }
 +    
 +    framework_logIfError(framework->logger, status, NULL, "Failed to release global lock");
 +    
 +    return status;
 +}
 +
 +celix_status_t framework_waitForStop(framework_pt framework) {
 +    if (celixThreadMutex_lock(&framework->mutex) != 0) {
 +        fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error locking the framework, shutdown gate not set.");
 +        return CELIX_FRAMEWORK_EXCEPTION;
 +    }
 +    while (!framework->shutdown) {
 +        celix_status_t status = celixThreadCondition_wait(&framework->shutdownGate, &framework->mutex);
 +        if (status != 0) {
 +            fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error waiting for shutdown gate.");
 +            return CELIX_FRAMEWORK_EXCEPTION;
 +        }
 +    }
 +    if (celixThreadMutex_unlock(&framework->mutex) != 0) {
 +        fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error unlocking the framework.");
 +        return CELIX_FRAMEWORK_EXCEPTION;
 +    }
 +    
 +    celixThread_join(framework->shutdownThread, NULL);
 +    
 +    fw_log(framework->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Successful shutdown");
 +    return CELIX_SUCCESS;
 +}
 +
 +static void *framework_shutdown(void *framework) {
 +    framework_pt fw = (framework_pt) framework;
 +    int err;
 +    
 +    fw_log(fw->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Shutdown");
 +    celixThreadMutex_lock(&fw->installedBundleMapLock);
 +    
 +    hash_map_iterator_pt iter = hashMapIterator_create(fw->installedBundleMap);
 +    bundle_pt bundle = NULL;
 +    while ((bundle = hashMapIterator_nextValue(iter)) != NULL) {
++=======
+     bundle_setState(bundle, state);
+     return ret;
+ }
+ 
+ celix_status_t framework_waitForStop(framework_pt framework) {
+     celixThreadMutex_lock(&framework->shutdown.mutex);
+     while (!framework->shutdown.done) {
+         celixThreadCondition_wait(&framework->shutdown.cond, &framework->shutdown.mutex);
+     }
+     celixThreadMutex_unlock(&framework->shutdown.mutex);
+ 
+     fw_log(framework->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Successful shutdown");
+     return CELIX_SUCCESS;
+ }
+ 
+ static void* framework_shutdown(void *framework) {
+     framework_pt fw = (framework_pt) framework;
+ 
+     fw_log(fw->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Shutdown");
+ 
+     //celix_framework_bundle_entry_t *fwEntry = NULL;
+     celix_array_list_t *stopEntries = celix_arrayList_create();
+     celix_framework_bundle_entry_t *fwEntry = NULL;
+     celixThreadMutex_lock(&fw->installedBundles.mutex);
+     int size = celix_arrayList_size(fw->installedBundles.entries);
+     for (int i = 0; i < size; ++i) {
+         celix_framework_bundle_entry_t *entry = celix_arrayList_get(fw->installedBundles.entries, i);
+         if (entry->bndId != 0) { //i.e. not framework bundle
+             celix_arrayList_add(stopEntries, entry);
+         } else {
+             fwEntry = entry;
+         }
+     }
+ //	celix_arrayList_clear(fw->installedBundles.entries);
+     celixThreadMutex_unlock(&fw->installedBundles.mutex);
+ 
+ 
+     size = celix_arrayList_size(stopEntries);
+     for (int i = size-1; i >= 0; --i) { //note loop in reverse order -> stop later installed bundle first
+         celix_framework_bundle_entry_t *entry = celix_arrayList_get(stopEntries, i);
+ 
+         //wait until entry use counts is 0
+         bundle_t *bnd = entry->bnd;
+         fw_bundleEntry_waitTillNotUsed(entry);
+ 
++>>>>>>> develop
          bundle_state_e state;
-         bundle_getState(bundle, &state);
+         bundle_getState(bnd, &state);
          if (state == OSGI_FRAMEWORK_BUNDLE_ACTIVE || state == OSGI_FRAMEWORK_BUNDLE_STARTING) {
-             celixThreadMutex_unlock(&fw->installedBundleMapLock);
-             fw_stopBundle(fw, bundle, 0);
-             celixThreadMutex_lock(&fw->installedBundleMapLock);
-             hashMapIterator_destroy(iter);
-             iter = hashMapIterator_create(fw->installedBundleMap);
+             fw_stopBundle(fw, bnd, 0);
          }
++<<<<<<< HEAD
 +    }
 +    hashMapIterator_destroy(iter);
 +    
 +    iter = hashMapIterator_create(fw->installedBundleMap);
 +    bundle = NULL;
 +    while ((bundle = hashMapIterator_nextValue(iter)) != NULL) {
 +        bundle_close(bundle);
 +    }
 +    hashMapIterator_destroy(iter);
 +    celixThreadMutex_unlock(&fw->installedBundleMapLock);
 +    
 +    err = celixThreadMutex_lock(&fw->mutex);
 +    if (err != 0) {
 +        fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error locking the framework, cannot exit clean.");
 +        celixThread_exit(NULL);
 +        return NULL;
 +    }
 +    
 +    if (celixThreadMutex_lock(&fw->dispatcherLock) != CELIX_SUCCESS) {
 +        fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error locking the dispatcherThread.");
 +    }
 +    else {
 +        fw->shutdown = true;
 +        
 +        if (celixThreadCondition_broadcast(&fw->dispatcher)) {
 +            fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error broadcasting .");
 +        }
 +        
 +        if (celixThreadMutex_unlock(&fw->dispatcherLock)) {
 +            fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR, "Error unlocking the dispatcherThread.");
 +        }
 +        
 +        celixThread_join(fw->dispatcherThread, NULL);
 +    }
 +    
 +    
 +    err = celixThreadCondition_broadcast(&fw->shutdownGate);
 +    if (err != 0) {
 +        fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error waking the shutdown gate, cannot exit clean.");
 +        err = celixThreadMutex_unlock(&fw->mutex);
 +        if (err != 0) {
 +            fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking the framework, cannot exit clean.");
 +        }
 +        
 +        celixThread_exit(NULL);
 +        return NULL;
 +    }
 +    err = celixThreadMutex_unlock(&fw->mutex);
 +    if (err != 0) {
 +        //		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking the framework, cannot exit clean.");
 +    }
 +    
 +    //	fw_log(fw->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Shutdown done\n");
 +    celixThread_exit((void *) CELIX_SUCCESS);
 +    
++=======
+         bundle_close(bnd);
+     }
+     celix_arrayList_destroy(stopEntries);
+ 
+ 
+     // 'stop' framework bundle
+     if (fwEntry != NULL) {
+         bundle_t *bnd = fwEntry->bnd;
+         fw_bundleEntry_waitTillNotUsed(fwEntry);
+ 
+         bundle_state_e state;
+         bundle_getState(bnd, &state);
+         if (state == OSGI_FRAMEWORK_BUNDLE_ACTIVE || state == OSGI_FRAMEWORK_BUNDLE_STARTING) {
+             fw_stopBundle(fw, bnd, 0);
+         }
+         bundle_close(bnd);
+     }
+ 
+     celixThreadMutex_lock(&fw->shutdown.mutex);
+     fw->shutdown.done = true;
+     celixThreadCondition_broadcast(&fw->shutdown.cond);
+     celixThreadMutex_unlock(&fw->shutdown.mutex);
+ 
+     celixThread_exit(NULL);
++>>>>>>> develop
      return NULL;
  }
  
  celix_status_t framework_getFrameworkBundle(framework_pt framework, bundle_pt *bundle) {
      celix_status_t status = CELIX_SUCCESS;
++<<<<<<< HEAD
 +    
++=======
+ 
++>>>>>>> develop
      if (framework != NULL && *bundle == NULL) {
          *bundle = framework->bundle;
      } else {
          status = CELIX_ILLEGAL_ARGUMENT;
      }
++<<<<<<< HEAD
 +    
++=======
+ 
++>>>>>>> develop
      return status;
  }
  
@@@ -2297,7 -2254,7 +3494,11 @@@ bundle_context_t* framework_getContext(
  
  celix_status_t fw_fireBundleEvent(framework_pt framework, bundle_event_type_e eventType, bundle_pt bundle) {
      celix_status_t status = CELIX_SUCCESS;
++<<<<<<< HEAD
 +    
++=======
+ 
++>>>>>>> develop
      if ((eventType != OSGI_FRAMEWORK_BUNDLE_EVENT_STARTING)
          && (eventType != OSGI_FRAMEWORK_BUNDLE_EVENT_STOPPING)
          && (eventType != OSGI_FRAMEWORK_BUNDLE_EVENT_LAZY_ACTIVATION)) {
@@@ -2338,28 -2295,23 +3539,45 @@@
                      }
                  }
              }
++<<<<<<< HEAD
 +            
 +            if (celixThreadMutex_lock(&framework->dispatcherLock) != CELIX_SUCCESS) {
 +                status = CELIX_FRAMEWORK_EXCEPTION;
 +            } else {
 +                arrayList_add(framework->requests, request);
 +                celix_status_t bcast_status = celixThreadCondition_broadcast(&framework->dispatcher);
 +                celix_status_t unlock_status = celixThreadMutex_unlock(&framework->dispatcherLock);
 +                if (bcast_status!=0 || unlock_status!=0) {
 +                    status = CELIX_FRAMEWORK_EXCEPTION;
 +                }
 +            }
++=======
+ 
+             celixThreadMutex_lock(&framework->dispatcher.mutex);
+             arrayList_add(framework->dispatcher.requests, request);
+             celixThreadCondition_broadcast(&framework->dispatcher.cond);
+             celixThreadMutex_unlock(&framework->dispatcher.mutex);
+ 
++>>>>>>> develop
          }
      }
 -
 +    
      framework_logIfError(framework->logger, status, NULL, "Failed to fire bundle event");
++<<<<<<< HEAD
 +    
++=======
+ 
++>>>>>>> develop
      return status;
  }
  
  celix_status_t fw_fireFrameworkEvent(framework_pt framework, framework_event_type_e eventType, bundle_pt bundle, celix_status_t errorCode) {
      celix_status_t status = CELIX_SUCCESS;
++<<<<<<< HEAD
 +    
++=======
+ 
++>>>>>>> develop
      request_pt request = (request_pt) malloc(sizeof(*request));
      if (!request) {
          status = CELIX_ENOMEM;
@@@ -2404,113 -2356,89 +3622,195 @@@
              celix_strerror(errorCode, message, 256);
              request->error = message;
          }
++<<<<<<< HEAD
 +        
 +        if (celixThreadMutex_lock(&framework->dispatcherLock) != CELIX_SUCCESS) {
 +            status = CELIX_FRAMEWORK_EXCEPTION;
 +        } else {
 +            arrayList_add(framework->requests, request);
 +            celix_status_t bcast_status = celixThreadCondition_broadcast(&framework->dispatcher);
 +            celix_status_t unlock_status = celixThreadMutex_unlock(&framework->dispatcherLock);
 +            if (bcast_status!=0 || unlock_status!=0) {
 +                status = CELIX_FRAMEWORK_EXCEPTION;
 +            }
 +        }
 +    }
 +    
 +    framework_logIfError(framework->logger, status, NULL, "Failed to fire framework event");
 +    
++=======
+ 
+         celixThreadMutex_lock(&framework->dispatcher.mutex);
+         arrayList_add(framework->dispatcher.requests, request);
+         celixThreadCondition_broadcast(&framework->dispatcher.cond);
+         celixThreadMutex_unlock(&framework->dispatcher.mutex);
+     }
+ 
+     framework_logIfError(framework->logger, status, NULL, "Failed to fire framework event");
+ 
++>>>>>>> develop
      return status;
  }
  
  static void *fw_eventDispatcher(void *fw) {
      framework_pt framework = (framework_pt) fw;
++<<<<<<< HEAD
 +    
 +    while (true) {
 +        int size;
 +        celix_status_t status;
 +        
 +        if (celixThreadMutex_lock(&framework->dispatcherLock) != 0) {
 +            fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error locking the dispatcher");
 +            celixThread_exit(NULL);
 +            return NULL;
 +        }
 +        
 +        size = arrayList_size(framework->requests);
 +        while (size == 0 && !framework->shutdown) {
 +            celixThreadCondition_wait(&framework->dispatcher, &framework->dispatcherLock);
 +            // Ignore status and just keep waiting
 +            size = arrayList_size(framework->requests);
 +        }
 +        
 +        if (size == 0 && framework->shutdown) {
 +            celixThreadMutex_unlock(&framework->dispatcherLock);
 +            celixThread_exit(NULL);
 +            return NULL;
 +        }
 +        
 +        request_pt request = (request_pt) arrayList_remove(framework->requests, 0);
 +        
 +        if ((status = celixThreadMutex_unlock(&framework->dispatcherLock)) != 0) {
 +            fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error unlocking the dispatcher.");
 +            celixThread_exit(NULL);
 +            return NULL;
 +        }
 +        
 +        if (celixThreadMutex_lock(&framework->bundleListenerLock) != CELIX_SUCCESS) {
 +            status = CELIX_FRAMEWORK_EXCEPTION;
 +        } else if (celixThreadMutex_lock(&framework->bundleLock) != CELIX_SUCCESS) {
 +            celixThreadMutex_unlock(&framework->bundleListenerLock);
 +            status = CELIX_FRAMEWORK_EXCEPTION;
 +        } else {
 +            int i;
++=======
+ 
+     celixThreadMutex_lock(&framework->dispatcher.mutex);
+     bool active = framework->dispatcher.active;
+     celixThreadMutex_unlock(&framework->dispatcher.mutex);
+ 
+     celix_array_list_t *localRequests = celix_arrayList_create();
+ 
+     while (active) {
+         celixThreadMutex_lock(&framework->dispatcher.mutex);
+         if (celix_arrayList_size(framework->dispatcher.requests) == 0) {
+             celixThreadCondition_wait(&framework->dispatcher.cond, &framework->dispatcher.mutex);
+         }
+         for (int i = 0; i < celix_arrayList_size(framework->dispatcher.requests); ++i) {
+             void *r = celix_arrayList_get(framework->dispatcher.requests, i);
+             celix_arrayList_add(localRequests, r);
+         }
+         celix_arrayList_clear(framework->dispatcher.requests);
+         celixThreadMutex_unlock(&framework->dispatcher.mutex);
+ 
+         //FIXME strange locking  of bundleListenerLock and frameworkListenerLock inside a loop.
+         //Seems like a request depends on bundle listeners or framework listeners -> this should be protected with
+         //a use count!!
+         for (int i = 0; i < celix_arrayList_size(localRequests); ++i) {
+             request_pt request = celix_arrayList_get(localRequests, i);
++>>>>>>> develop
              int size = arrayList_size(request->listeners);
-             for (i = 0; i < size; i++) {
+             for (int k = 0; k < size; k++) {
                  if (request->type == BUNDLE_EVENT_TYPE) {
++<<<<<<< HEAD
 +                    fw_bundle_listener_pt listener = (fw_bundle_listener_pt) arrayList_get(request->listeners, i);
 +                    bundle_event_pt event = (bundle_event_pt) calloc(1, sizeof(*event));
 +                    event->bundleId = request->bundleId;
 +                    event->bundleSymbolicName = strdup(request->bundleSymbolicName);
 +                    event->type = request->eventType;
 +                    
 +                    fw_invokeBundleListener(framework, listener->listener, event, listener->bundle);
 +                    
 +                    free(event->bundleSymbolicName);
 +                    free(event);
 +                } else if (request->type == FRAMEWORK_EVENT_TYPE) {
 +                    celixThreadMutex_lock(&framework->frameworkListenersLock);
 +                    fw_framework_listener_pt listener = (fw_framework_listener_pt) arrayList_get(request->listeners, i);
 +                    framework_event_pt event = (framework_event_pt) calloc(1, sizeof(*event));
 +                    event->bundleId = request->bundleId;
 +                    event->bundleSymbolicName = strdup(request->bundleSymbolicName);
 +                    event->type = request->eventType;
 +                    event->error = request->error;
 +                    event->errorCode = request->errorCode;
 +                    
 +                    fw_invokeFrameworkListener(framework, listener->listener, event, listener->bundle);
++=======
+                     celixThreadMutex_lock(&framework->bundleListenerLock);
+                     fw_bundle_listener_pt listener = (fw_bundle_listener_pt) arrayList_get(request->listeners, k);
+                     bundle_event_t event;
+                     memset(&event, 0, sizeof(event));
+                     event.bundleId = request->bundleId;
+                     event.bundleSymbolicName = request->bundleSymbolicName;
+                     event.type = request->eventType;
+ 
+                     fw_invokeBundleListener(framework, listener->listener, &event, listener->bundle);
+                     celixThreadMutex_unlock(&framework->bundleListenerLock);
+                 } else if (request->type == FRAMEWORK_EVENT_TYPE) {
+                     celixThreadMutex_lock(&framework->frameworkListenersLock);
+                     fw_framework_listener_pt listener = (fw_framework_listener_pt) arrayList_get(request->listeners, k);
+                     framework_event_t event;
+                     memset(&event, 0, sizeof(event));
+                     event.bundleId = request->bundleId;
+                     event.bundleSymbolicName = request->bundleSymbolicName;
+                     event.type = request->eventType;
+                     event.error = request->error;
+                     event.errorCode = request->errorCode;
+ 
+                     fw_invokeFrameworkListener(framework, listener->listener, &event, listener->bundle);
++>>>>>>> develop
                      celixThreadMutex_unlock(&framework->frameworkListenersLock);
-                     free(event->bundleSymbolicName);
-                     free(event);
                  }
              }
++<<<<<<< HEAD
 +            
 +            if (celixThreadMutex_unlock(&framework->bundleLock)) {
 +                status = CELIX_FRAMEWORK_EXCEPTION;
 +            }
 +            
 +            if (celixThreadMutex_unlock(&framework->bundleListenerLock)) {
 +                status = CELIX_FRAMEWORK_EXCEPTION;
 +            }
 +            
++=======
++>>>>>>> develop
              free(request->bundleSymbolicName);
+             //NOTE next 2 free calls not needed? why it is a char* not a const char*
+             //free(request->filter);
+             //free(request->error);
              free(request);
          }
++<<<<<<< HEAD
 +        
 +    }
 +    
 +    celixThread_exit(NULL);
 +    
 +    return NULL;
 +    
++=======
+         celix_arrayList_clear(localRequests);
+ 
+         celixThreadMutex_lock(&framework->dispatcher.mutex);
+         active = framework->dispatcher.active;
+         celixThreadMutex_unlock(&framework->dispatcher.mutex);
+     }
+ 
+     celix_arrayList_destroy(localRequests);
+     celixThread_exit(NULL);
+     return NULL;
+ 
++>>>>>>> develop
  }
  
  celix_status_t fw_invokeBundleListener(framework_pt framework, bundle_listener_pt listener, bundle_event_pt event, bundle_pt bundle) {
@@@ -2518,10 -2446,10 +3818,17 @@@
      bundle_state_e state;
      celix_status_t ret = bundle_getState(bundle, &state);
      if (state == OSGI_FRAMEWORK_BUNDLE_STARTING || state == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
++<<<<<<< HEAD
 +        
 +        listener->bundleChanged(listener, event);
 +    }
 +    
++=======
+ 
+         listener->bundleChanged(listener, event);
+     }
+ 
++>>>>>>> develop
      return ret;
  }
  
@@@ -2531,7 -2459,7 +3838,11 @@@ celix_status_t fw_invokeFrameworkListen
      if (state == OSGI_FRAMEWORK_BUNDLE_STARTING || state == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
          listener->frameworkEvent(listener, event);
      }
++<<<<<<< HEAD
 +    
++=======
+ 
++>>>>>>> develop
      return ret;
  }
  
@@@ -2543,20 -2471,31 +3854,47 @@@ static celix_status_t frameworkActivato
  static celix_status_t frameworkActivator_stop(void * userData, bundle_context_t *context) {
      celix_status_t status = CELIX_SUCCESS;
      framework_pt framework;
++<<<<<<< HEAD
 +    
 +    if (bundleContext_getFramework(context, &framework) == CELIX_SUCCESS) {
 +        
 +        fw_log(framework->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Start shutdownthread");
 +        if (celixThread_create(&framework->shutdownThread, NULL, &framework_shutdown, framework) != CELIX_SUCCESS) {
 +            fw_log(framework->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Could not create shutdown thread, normal exit not possible.");
 +            status = CELIX_FRAMEWORK_EXCEPTION;
++=======
+ 
+     if (bundleContext_getFramework(context, &framework) == CELIX_SUCCESS) {
+ 
+         fw_log(framework->logger, OSGI_FRAMEWORK_LOG_DEBUG, "FRAMEWORK: Start shutdownthread");
+ 
+         celixThreadMutex_lock(&framework->shutdown.mutex);
+         bool alreadyIntialized = framework->shutdown.initialized;
+         framework->shutdown.initialized = true;
+         celixThreadMutex_unlock(&framework->shutdown.mutex);
+ 
+         if (!alreadyIntialized) {
+             celixThreadMutex_lock(&framework->dispatcher.mutex);
+             framework->dispatcher.active = false;
+             celixThreadCondition_broadcast(&framework->dispatcher.cond);
+             celixThreadMutex_unlock(&framework->dispatcher.mutex);
+             celixThread_join(framework->dispatcher.thread, NULL);
+ 
+             celixThread_create(&framework->shutdown.thread, NULL, &framework_shutdown, framework);
++>>>>>>> develop
          }
      } else {
          status = CELIX_FRAMEWORK_EXCEPTION;
      }
++<<<<<<< HEAD
 +    
 +    framework_logIfError(framework->logger, status, NULL, "Failed to stop framework activator");
 +    
++=======
+ 
+     framework_logIfError(framework->logger, status, NULL, "Failed to stop framework activator");
+ 
++>>>>>>> develop
      return status;
  }
  
@@@ -2660,18 -2599,18 +3998,31 @@@ static celix_status_t framework_loadLib
  static celix_status_t framework_loadLibrary(framework_pt framework, const char *library, bundle_archive_pt archive, void **handle) {
      celix_status_t status = CELIX_SUCCESS;
      char *error = NULL;
++<<<<<<< HEAD
 +    
++=======
+ 
++>>>>>>> develop
  #ifdef __linux__
      char * library_prefix = "lib";
      char * library_extension = ".so";
  #elif __APPLE__
      char * library_prefix = "lib";
++<<<<<<< HEAD
 +    char * library_extension = ".dylib";
 +#elif WIN32
 +    char * library_prefix = "";
 +    char * library_extension = ".dll";
 +#endif
 +    
++=======
+         char * library_extension = ".dylib";
+     #elif WIN32
+         char * library_prefix = "";
+         char * library_extension = ".dll";
+ #endif
+ 
++>>>>>>> develop
      char libraryPath[256];
      long refreshCount = 0;
      const char *archiveRoot = NULL;
@@@ -2700,10 -2639,10 +4051,17 @@@
          } else {
              bundle_revision_pt revision = NULL;
              array_list_pt handles = NULL;
++<<<<<<< HEAD
 +            
 +            status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
 +            status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
 +            
++=======
+ 
+             status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
+             status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
+ 
++>>>>>>> develop
              if(handles != NULL){
                  arrayList_add(handles, *handle);
              }
@@@ -2727,58 -2666,66 +4085,91 @@@
   **********************************************************************************************************************/
  
  
- void celix_framework_useBundles(framework_t *fw, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd)) {
-     celixThreadMutex_lock(&fw->installedBundleMapLock);
-     int size = hashMap_size(fw->installedBundleMap);
-     long bundleIds[size];
-     int i = 0;
-     hash_map_iterator_t iter = hashMapIterator_construct(fw->installedBundleMap);
-     while (hashMapIterator_hasNext(&iter)) {
-         bundle_t *bnd = (bundle_t *) hashMapIterator_nextValue(&iter);
-         long bndId = celix_bundle_getId(bnd);
-         if (bndId >= 0) {
+ void celix_framework_useBundles(framework_t *fw, bool includeFrameworkBundle, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd)) {
+     celix_array_list_t *bundleIds = celix_arrayList_create();
+ 
+     celixThreadMutex_lock(&fw->installedBundles.mutex);
+     int size = celix_arrayList_size(fw->installedBundles.entries);
+     for (int i = 0; i < size; ++i) {
+         celix_framework_bundle_entry_t *entry = celix_arrayList_get(fw->installedBundles.entries, i);
+         if (entry->bndId > 0 || includeFrameworkBundle) {
              //NOTE bundle state is checked in celix_framework_useBundles
-             bundleIds[i++] =bndId;
+             celix_arrayList_addLong(bundleIds, entry->bndId);
          }
      }
++<<<<<<< HEAD
 +    celixThreadMutex_unlock(&fw->installedBundleMapLock);
 +    
 +    size = i;
 +    for (i = 0; i < size; ++i) {
 +        celix_framework_useBundle(fw, bundleIds[i], callbackHandle, use);
++=======
+     celixThreadMutex_unlock(&fw->installedBundles.mutex);
+ 
+     //note that stored bundle ids can now already be invalid (race cond),
+     //but the celix_framework_useBundle function should be able to handle this safely.
+ 
+     size = celix_arrayList_size(bundleIds);
+     for (int i = 0; i < size; ++i) {
+         long bndId = celix_arrayList_getLong(bundleIds, i);
+         celix_framework_useBundle(fw, true, bndId, callbackHandle, use);
++>>>>>>> develop
      }
+ 
+     celix_arrayList_destroy(bundleIds);
  }
  
++<<<<<<< HEAD
 +bool celix_framework_useBundle(framework_t *fw, long bundleId, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd)) {
 +    bool called = false;
++=======
+ void celix_framework_useBundle(framework_t *fw, bool onlyActive, long bundleId, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd)) {
++>>>>>>> develop
      if (bundleId >= 0) {
-         //TODO get bundle lock without throwing errors framework_acquireBundleLock() -> a more simple lock ??
+         fw_bundleEntry_increaseUseCount(fw, bundleId);
          bundle_t *bnd = framework_getBundleById(fw, bundleId);
++<<<<<<< HEAD
 +        celix_bundle_state_e bndState = celix_bundle_getState(bnd);
 +        if (bndState == OSGI_FRAMEWORK_BUNDLE_ACTIVE) {
 +            use(callbackHandle, bnd);
 +            called = true;
++=======
+         if (bnd != NULL) {
+             celix_bundle_state_e bndState = celix_bundle_getState(bnd);
+             if (onlyActive && (bndState == OSGI_FRAMEWORK_BUNDLE_ACTIVE || bndState == OSGI_FRAMEWORK_BUNDLE_STARTING)) {
+                 use(callbackHandle, bnd);
+             } else if (!onlyActive) {
+                 use(callbackHandle, bnd);
+             }
+         } else {
+             framework_logIfError(fw->logger, CELIX_FRAMEWORK_EXCEPTION, NULL, "Bundle with id %li is not installed", bundleId);
++>>>>>>> develop
          }
-         //TODO unlock
+         fw_bundleEntry_decreaseUseCount(fw, bundleId);
      }
 +    return called;
  }
  
  service_registration_t* celix_framework_registerServiceFactory(framework_t *fw , const celix_bundle_t *bnd, const char* serviceName, celix_service_factory_t *factory, celix_properties_t *properties) {
      const char *error = NULL;
      celix_status_t status = CELIX_SUCCESS;
      service_registration_t *reg = NULL;
+ 
+     long bndId = celix_bundle_getId(bnd);
+     fw_bundleEntry_increaseUseCount(fw, bndId);
+ 
      if (serviceName != NULL && factory != NULL) {
-         status = framework_acquireBundleLock(fw, (celix_bundle_t*)bnd, OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE);
          status = CELIX_DO_IF(status, celix_serviceRegistry_registerServiceFactory(fw->registry, bnd, serviceName, factory, properties, &reg));
-         if (!framework_releaseBundleLock(fw, (celix_bundle_t*)bnd)) {
-             status = CELIX_ILLEGAL_STATE;
-             error = "Could not release bundle lock";
-         }
      }
++<<<<<<< HEAD
 +    
++=======
+ 
+     fw_bundleEntry_decreaseUseCount(fw, bndId);
+ 
++>>>>>>> develop
      framework_logIfError(fw->logger, status, error, "Cannot register service factory: %s", serviceName);
 -
 +    
      return reg;
  }
  
diff --cc libs/framework/src/framework_private.h.orig
index fc7b0cf,0000000..c88466a
mode 100644,000000..100644
--- a/libs/framework/src/framework_private.h.orig
+++ b/libs/framework/src/framework_private.h.orig
@@@ -1,156 -1,0 +1,177 @@@
 +/**
 + *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.
 + */
++<<<<<<< HEAD
 +
++=======
++>>>>>>> develop
 +
 +#ifndef FRAMEWORK_PRIVATE_H_
 +#define FRAMEWORK_PRIVATE_H_
 +
 +#include "celix_framework.h"
 +#include "framework.h"
 +
 +#include "manifest.h"
 +#include "wire.h"
 +#include "hash_map.h"
 +#include "array_list.h"
 +#include "celix_errno.h"
 +#include "service_factory.h"
 +#include "bundle_archive.h"
- #include "service_listener.h"
++#include "celix_service_listener.h"
 +#include "bundle_listener.h"
 +#include "framework_listener.h"
 +#include "service_registration.h"
 +#include "bundle_context.h"
 +#include "bundle_cache.h"
 +#include "celix_log.h"
 +
 +#include "celix_threads.h"
++#include "service_registry.h"
 +
++<<<<<<< HEAD
 +struct framework {
 +    char uuid[37];
 +
 +    struct bundle * bundle;
 +    hash_map_pt installedBundleMap;
++=======
++struct celix_framework {
++#ifdef WITH_APR
++    apr_pool_t *pool;
++#endif
++    celix_bundle_t *bundle;
++    long bundleId; //the bundle id of the framework (normally 0)
++>>>>>>> develop
 +    hash_map_pt installRequestMap;
 +
 +    celix_thread_mutex_t serviceListenersLock;
 +    array_list_pt serviceListeners;
 +
 +    array_list_pt frameworkListeners;
 +    celix_thread_mutex_t frameworkListenersLock;
 +
 +    array_list_pt bundleListeners;
 +    celix_thread_mutex_t bundleListenerLock;
 +
 +    long nextBundleId;
 +    celix_service_registry_t *registry;
 +    bundle_cache_pt cache;
 +
-     celix_thread_cond_t shutdownGate;
-     celix_thread_cond_t condition;
++    struct {
++        celix_thread_mutex_t mutex;
++        celix_thread_cond_t cond;
++        bool done; //true is shutdown is done
++        bool initialized; //true is a shutdown is initialized
++        celix_thread_t thread;
++    } shutdown;
 +
-     celix_thread_mutex_t installedBundleMapLock;
-     celix_thread_mutex_t installRequestLock;
-     celix_thread_mutex_t mutex;
-     celix_thread_mutex_t bundleLock;
++    struct {
++        celix_array_list_t *entries; //value = celix_framework_bundle_entry_t*. Note ordered by installed bundle time
++                                     //i.e. later installed bundle are last
++        celix_thread_mutex_t mutex;
++    } installedBundles;
 +
-     celix_thread_t globalLockThread;
-     array_list_pt globalLockWaitersList;
-     int globalLockCount;
- 
-     bool interrupted;
-     bool shutdown;
 +
 +    properties_pt configurationMap;
 +
-     array_list_pt requests;
-     celix_thread_cond_t dispatcher;
-     celix_thread_mutex_t dispatcherLock;
-     celix_thread_t dispatcherThread;
-     celix_thread_t shutdownThread;
++
++    struct {
++        celix_thread_cond_t cond;
++        celix_thread_t thread;
++        celix_thread_mutex_t mutex; //protect active and requests
++        bool active;
++        celix_array_list_t *requests;
++    } dispatcher;
 +
 +    framework_logger_pt logger;
 +};
 +
 +FRAMEWORK_EXPORT celix_status_t fw_getProperty(framework_pt framework, const char* name, const char* defaultValue, const char** value);
 +
 +FRAMEWORK_EXPORT celix_status_t fw_installBundle(framework_pt framework, bundle_pt * bundle, const char * location, const char *inputFile);
 +FRAMEWORK_EXPORT celix_status_t fw_uninstallBundle(framework_pt framework, bundle_pt bundle);
 +
 +FRAMEWORK_EXPORT celix_status_t framework_getBundleEntry(framework_pt framework, bundle_pt bundle, const char* name, char** entry);
 +
 +FRAMEWORK_EXPORT celix_status_t fw_startBundle(framework_pt framework, bundle_pt bundle, int options);
 +FRAMEWORK_EXPORT celix_status_t framework_updateBundle(framework_pt framework, bundle_pt bundle, const char* inputFile);
 +FRAMEWORK_EXPORT celix_status_t fw_stopBundle(framework_pt framework, bundle_pt bundle, bool record);
 +
 +FRAMEWORK_EXPORT celix_status_t fw_registerService(framework_pt framework, service_registration_pt * registration, bundle_pt bundle, const char* serviceName, const void* svcObj, properties_pt properties);
 +FRAMEWORK_EXPORT celix_status_t fw_registerServiceFactory(framework_pt framework, service_registration_pt * registration, bundle_pt bundle, const char* serviceName, service_factory_pt factory, properties_pt properties);
 +FRAMEWORK_EXPORT void fw_unregisterService(service_registration_pt registration);
 +
 +FRAMEWORK_EXPORT celix_status_t fw_getServiceReferences(framework_pt framework, array_list_pt *references, bundle_pt bundle, const char* serviceName, const char* filter);
 +FRAMEWORK_EXPORT celix_status_t framework_ungetServiceReference(framework_pt framework, bundle_pt bundle, service_reference_pt reference);
 +FRAMEWORK_EXPORT celix_status_t fw_getService(framework_pt framework, bundle_pt bundle, service_reference_pt reference, const void** service);
 +FRAMEWORK_EXPORT celix_status_t framework_ungetService(framework_pt framework, bundle_pt bundle, service_reference_pt reference, bool *result);
 +FRAMEWORK_EXPORT celix_status_t fw_getBundleRegisteredServices(framework_pt framework, bundle_pt bundle, array_list_pt *services);
 +FRAMEWORK_EXPORT celix_status_t fw_getBundleServicesInUse(framework_pt framework, bundle_pt bundle, array_list_pt *services);
 +
- FRAMEWORK_EXPORT void fw_addServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener, const char* filter);
- FRAMEWORK_EXPORT void fw_removeServiceListener(framework_pt framework, bundle_pt bundle, service_listener_pt listener);
++FRAMEWORK_EXPORT void fw_addServiceListener(framework_pt framework, bundle_pt bundle, celix_service_listener_t *listener, const char* filter);
++FRAMEWORK_EXPORT void fw_removeServiceListener(framework_pt framework, bundle_pt bundle, celix_service_listener_t *listener);
 +
 +FRAMEWORK_EXPORT celix_status_t fw_addBundleListener(framework_pt framework, bundle_pt bundle, bundle_listener_pt listener);
 +FRAMEWORK_EXPORT celix_status_t fw_removeBundleListener(framework_pt framework, bundle_pt bundle, bundle_listener_pt listener);
 +
 +FRAMEWORK_EXPORT celix_status_t fw_addFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener);
 +FRAMEWORK_EXPORT celix_status_t fw_removeFrameworkListener(framework_pt framework, bundle_pt bundle, framework_listener_pt listener);
 +
- FRAMEWORK_EXPORT void fw_serviceChanged(framework_pt framework, service_event_type_e eventType, service_registration_pt registration, properties_pt oldprops);
++FRAMEWORK_EXPORT void fw_serviceChanged(framework_pt framework, celix_service_event_type_t eventType, service_registration_pt registration, properties_pt oldprops);
 +
 +FRAMEWORK_EXPORT celix_status_t fw_isServiceAssignable(framework_pt fw, bundle_pt requester, service_reference_pt reference, bool* assignable);
 +
 +//bundle_archive_t fw_createArchive(long id, char * location);
 +//void revise(bundle_archive_t archive, char * location);
 +FRAMEWORK_EXPORT celix_status_t getManifest(bundle_archive_pt archive, manifest_pt *manifest);
 +
 +FRAMEWORK_EXPORT bundle_pt findBundle(bundle_context_pt context);
 +FRAMEWORK_EXPORT service_registration_pt findRegistration(service_reference_pt reference);
 +
 +FRAMEWORK_EXPORT service_reference_pt listToArray(array_list_pt list);
 +FRAMEWORK_EXPORT celix_status_t framework_markResolvedModules(framework_pt framework, linked_list_pt wires);
 +
 +FRAMEWORK_EXPORT array_list_pt framework_getBundles(framework_pt framework);
 +FRAMEWORK_EXPORT bundle_pt framework_getBundle(framework_pt framework, const char* location);
 +FRAMEWORK_EXPORT bundle_pt framework_getBundleById(framework_pt framework, long id);
 +
 +
 +
 +
 +
 +
 +
 +
 +/**********************************************************************************************************************
 + **********************************************************************************************************************
 + * Updated API
 + **********************************************************************************************************************
 + **********************************************************************************************************************/
 +
++<<<<<<< HEAD
 +void celix_framework_useBundles(framework_t *fw, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd));
 +bool celix_framework_useBundle(framework_t *fw, long bundleId, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd));
++=======
++void celix_framework_useBundles(framework_t *fw, bool includeFrameworkBundle, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd));
++void celix_framework_useBundle(framework_t *fw, bool onlyActive, long bundleId, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd));
++>>>>>>> develop
 +service_registration_t* celix_framework_registerServiceFactory(framework_t *fw , const celix_bundle_t *bnd, const char* serviceName, celix_service_factory_t *factory, celix_properties_t *properties);
 +
 +#endif /* FRAMEWORK_PRIVATE_H_ */
diff --cc libs/framework/src/service_tracker.c.orig
index 0000000,0000000..2ae0088
new file mode 100644
--- /dev/null
+++ b/libs/framework/src/service_tracker.c.orig
@@@ -1,0 -1,0 +1,996 @@@
++/**
++ *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 <stdlib.h>
++#include <string.h>
++#include <stdio.h>
++#include <service_reference_private.h>
++#include <framework_private.h>
++#include <assert.h>
++
++#include "service_tracker_private.h"
++#include "bundle_context.h"
++#include "constants.h"
++#include "service_reference.h"
++#include "celix_log.h"
++#include "bundle_context_private.h"
++#include "celix_array_list.h"
++
++static celix_status_t serviceTracker_track(celix_service_tracker_instance_t *tracker, service_reference_pt reference, celix_service_event_t *event);
++static celix_status_t serviceTracker_untrack(celix_service_tracker_instance_t *tracker, service_reference_pt reference, celix_service_event_t *event);
++static void serviceTracker_untrackTracked(celix_service_tracker_instance_t *tracker, celix_tracked_entry_t *tracked);
++static celix_status_t serviceTracker_invokeAddingService(celix_service_tracker_instance_t *tracker, service_reference_pt ref, void **svcOut);
++static celix_status_t serviceTracker_invokeAddService(celix_service_tracker_instance_t *tracker, celix_tracked_entry_t *tracked);
++static celix_status_t serviceTracker_invokeModifiedService(celix_service_tracker_instance_t *tracker, celix_tracked_entry_t *tracked);
++static celix_status_t serviceTracker_invokeRemovingService(celix_service_tracker_instance_t *tracker, celix_tracked_entry_t *tracked);
++static void serviceTracker_checkAndInvokeSetService(void *handle, void *highestSvc, const properties_t *props, const bundle_t *bnd);
++static bool serviceTracker_useHighestRankingServiceInternal(celix_service_tracker_instance_t *instance,
++                                                            const char *serviceName /*sanity*/,
++                                                            void *callbackHandle,
++                                                            void (*use)(void *handle, void *svc),
++                                                            void (*useWithProperties)(void *handle, void *svc, const celix_properties_t *props),
++                                                            void (*useWithOwner)(void *handle, void *svc, const celix_properties_t *props, const celix_bundle_t *owner));
++
++static void serviceTracker_addInstanceFromShutdownList(celix_service_tracker_instance_t *instance);
++static void serviceTracker_remInstanceFromShutdownList(celix_service_tracker_instance_t *instance);
++
++static celix_thread_once_t g_once = CELIX_THREAD_ONCE_INIT;
++static celix_thread_mutex_t g_mutex;
++static celix_thread_cond_t g_cond;
++static celix_array_list_t *g_shutdownInstances = NULL; //value = celix_service_tracker_instance -> used for syncing with shutdown threads
++
++static void serviceTracker_once(void) {
++    celixThreadMutex_create(&g_mutex, NULL);
++    celixThreadCondition_init(&g_cond, NULL);
++}
++
++static inline celix_tracked_entry_t* tracked_create(service_reference_pt ref, void *svc, celix_properties_t *props, celix_bundle_t *bnd) {
++    celix_tracked_entry_t *tracked = calloc(1, sizeof(*tracked));
++    tracked->reference = ref;
++    tracked->service = svc;
++    tracked->properties = props;
++    tracked->serviceOwner = bnd;
++    tracked->serviceName = celix_properties_get(props, OSGI_FRAMEWORK_OBJECTCLASS, "Error");
++
++    tracked->useCount = 1;
++    celixThreadMutex_create(&tracked->mutex, NULL);
++    celixThreadCondition_init(&tracked->useCond, NULL);
++    return tracked;
++}
++
++static inline void tracked_retain(celix_tracked_entry_t *tracked) {
++    celixThreadMutex_lock(&tracked->mutex);
++    tracked->useCount += 1;
++    celixThreadMutex_unlock(&tracked->mutex);
++}
++
++static inline void tracked_release(celix_tracked_entry_t *tracked) {
++    celixThreadMutex_lock(&tracked->mutex);
++    assert(tracked->useCount > 0);
++    tracked->useCount -= 1;
++    if (tracked->useCount == 0) {
++        celixThreadCondition_broadcast(&tracked->useCond);
++    }
++    celixThreadMutex_unlock(&tracked->mutex);
++}
++
++static inline void tracked_waitAndDestroy(celix_tracked_entry_t *tracked) {
++    celixThreadMutex_lock(&tracked->mutex);
++    while (tracked->useCount != 0) {
++        celixThreadCondition_wait(&tracked->useCond, &tracked->mutex);
++    }
++    celixThreadMutex_unlock(&tracked->mutex);
++
++    //destroy
++    celixThreadMutex_destroy(&tracked->mutex);
++    celixThreadCondition_destroy(&tracked->useCond);
++    free(tracked);
++}
++
++celix_status_t serviceTracker_create(bundle_context_pt context, const char * service, service_tracker_customizer_pt customizer, service_tracker_pt *tracker) {
++	celix_status_t status = CELIX_SUCCESS;
++
++	if (service == NULL || *tracker != NULL) {
++		status = CELIX_ILLEGAL_ARGUMENT;
++	} else {
++		if (status == CELIX_SUCCESS) {
++			char filter[512];
++			snprintf(filter, sizeof(filter), "(%s=%s)", OSGI_FRAMEWORK_OBJECTCLASS, service);
++            serviceTracker_createWithFilter(context, filter, customizer, tracker);
++		}
++	}
++
++	framework_logIfError(logger, status, NULL, "Cannot create service tracker");
++
++	return status;
++}
++
++celix_status_t serviceTracker_createWithFilter(bundle_context_pt context, const char * filter, service_tracker_customizer_pt customizer, service_tracker_pt *tracker) {
++	celix_status_t status = CELIX_SUCCESS;
++	*tracker = (service_tracker_pt) calloc(1, sizeof(**tracker));
++	if (!*tracker) {
++		status = CELIX_ENOMEM;
++	} else {
++		(*tracker)->context = context;
++		(*tracker)->filter = strdup(filter);
++        (*tracker)->customizer = customizer;
++	}
++
++	framework_logIfError(logger, status, NULL, "Cannot create service tracker [filter=%s]", filter);
++
++	return status;
++}
++
++celix_status_t serviceTracker_destroy(service_tracker_pt tracker) {
++    if (tracker->customizer != NULL) {
++	    serviceTrackerCustomizer_destroy(tracker->customizer);
++	}
++
++	free(tracker->filter);
++	free(tracker);
++
++	return CELIX_SUCCESS;
++}
++
++celix_status_t serviceTracker_open(service_tracker_pt tracker) {
++    celix_service_listener_t *listener = NULL;
++    celix_service_tracker_instance_t *instance = NULL;
++    array_list_pt initial = NULL;
++    celix_status_t status = CELIX_SUCCESS;
++
++    celixThreadRwlock_writeLock(&tracker->instanceLock);
++    if (tracker->instance == NULL) {
++        instance = calloc(1, sizeof(*instance));
++        instance->context = tracker->context;
++
++        instance->closing = false;
++        instance->activeServiceChangeCalls = 0;
++        celixThreadMutex_create(&instance->closingLock, NULL);
++        celixThreadCondition_init(&instance->activeServiceChangeCallsCond, NULL);
++
++
++        celixThreadRwlock_create(&instance->lock, NULL);
++        instance->trackedServices = celix_arrayList_create();
++
++        celixThreadMutex_create(&instance->mutex, NULL);
++        instance->currentHighestServiceId = -1;
++
++        instance->listener.handle = instance;
++        instance->listener.serviceChanged = (void *) serviceTracker_serviceChanged;
++        listener = &instance->listener;
++
++        instance->callbackHandle = tracker->callbackHandle;
++        instance->filter = strdup(tracker->filter);
++        if (tracker->customizer != NULL) {
++            memcpy(&instance->customizer, tracker->customizer, sizeof(instance->customizer));
++        }
++        instance->add = tracker->add;
++        instance->addWithProperties = tracker->addWithProperties;
++        instance->addWithOwner = tracker->addWithOwner;
++        instance->set = tracker->set;
++        instance->setWithProperties = tracker->setWithProperties;
++        instance->setWithOwner = tracker->setWithOwner;
++        instance->remove = tracker->remove;
++        instance->removeWithProperties = tracker->removeWithProperties;
++        instance->removeWithOwner = tracker->removeWithOwner;
++
++        status = bundleContext_getServiceReferences(tracker->context, NULL, tracker->filter, &initial); //REF COUNT to 1
++
++        tracker->instance = instance;
++    } else {
++        //already open
++    }
++    celixThreadRwlock_unlock(&tracker->instanceLock);
++
++    //TODO add fw call which adds a service listener and return the then valid service references.
++    if (status == CELIX_SUCCESS && listener != NULL) { //register service listener
++        status = bundleContext_addServiceListener(tracker->context, listener, tracker->filter);
++    }
++    if (status == CELIX_SUCCESS && initial != NULL) {
++        service_reference_pt initial_reference;
++        unsigned int i;
++        for (i = 0; i < arrayList_size(initial); i++) {
++            initial_reference = (service_reference_pt) arrayList_get(initial, i);
++            serviceTracker_track(instance, initial_reference, NULL); //REF COUNT to 2
++            bundleContext_ungetServiceReference(tracker->context, initial_reference); //REF COUNT to 1
++        }
++        arrayList_destroy(initial);
++    }
++
++	if (status != CELIX_SUCCESS && listener != NULL){
++		free(listener);
++	}
++
++	framework_logIfError(logger, status, NULL, "Cannot open tracker");
++
++	return status;
++}
++
++static void* shutdownServiceTrackerInstanceHandler(void *data) {
++    celix_service_tracker_instance_t *instance = data;
++
++    fw_removeServiceListener(instance->context->framework, instance->context->bundle, &instance->listener);
++
++    celixThreadMutex_destroy(&instance->closingLock);
++    celixThreadCondition_destroy(&instance->activeServiceChangeCallsCond);
++    celixThreadMutex_destroy(&instance->mutex);
++    celixThreadRwlock_destroy(&instance->lock);
++    celix_arrayList_destroy(instance->trackedServices);
++    free(instance->filter);
++
++    serviceTracker_remInstanceFromShutdownList(instance);
++    free(instance);
++
++    return NULL;
++}
++
++celix_status_t serviceTracker_close(service_tracker_pt tracker) {
++	//put all tracked entries in tmp array list, so that the untrack (etc) calls are not blocked.
++    //set state to close to prevent service listener events
++
++    celixThreadRwlock_writeLock(&tracker->instanceLock);
++    celix_service_tracker_instance_t *instance = tracker->instance;
++    tracker->instance = NULL;
++    celixThreadRwlock_unlock(&tracker->instanceLock);
++
++    if (instance != NULL) {
++
++        //prevent service listener events
++        celixThreadMutex_lock(&instance->closingLock);
++        instance->closing = true;
++        celixThreadMutex_unlock(&instance->closingLock);
++
++        int i;
++        celixThreadRwlock_writeLock(&instance->lock);
++        size_t size = celix_arrayList_size(instance->trackedServices);
++        celix_tracked_entry_t *trackedEntries[size];
++        for (i = 0; i < arrayList_size(instance->trackedServices); i++) {
++            trackedEntries[i] = (celix_tracked_entry_t *) arrayList_get(instance->trackedServices, i);
++        }
++        arrayList_clear(instance->trackedServices);
++        celixThreadRwlock_unlock(&instance->lock);
++
++        //loop trough tracked entries an untrack
++        for (i = 0; i < size; i++) {
++            serviceTracker_untrackTracked(instance, trackedEntries[i]);
++        }
++
++        //sync til all pending serviceChanged event are handled.. (TODO again a possible deadlock??)
++        celixThreadMutex_lock(&instance->closingLock);
++        while(instance->activeServiceChangeCalls > 0) {
++            celixThreadCondition_wait(&instance->activeServiceChangeCallsCond, &instance->closingLock);
++        }
++        celixThreadMutex_unlock(&instance->closingLock);
++
++
++
++        //NOTE Separate thread is needed to prevent deadlock where closing is triggered from a serviceChange event and the
++        // untrack -> removeServiceListener will try to remove a service listener which is being invoked and is the
++        // actual thread calling the removeServiceListener.
++        //
++        // This can be detached -> because service listener events are ignored (closing=true) and so no callbacks
++        //are made back to the celix framework / tracker owner.
++        serviceTracker_addInstanceFromShutdownList(instance);
++        celix_thread_t localThread;
++        celixThread_create(&localThread, NULL, shutdownServiceTrackerInstanceHandler, instance);
++        celixThread_detach(localThread);
++    }
++
++	return CELIX_SUCCESS;
++}
++
++service_reference_pt serviceTracker_getServiceReference(service_tracker_pt tracker) {
++    //TODO deprecated warning -> not locked
++	celix_tracked_entry_t *tracked;
++    service_reference_pt result = NULL;
++	unsigned int i;
++
++	celixThreadRwlock_readLock(&tracker->instanceLock);
++	celix_service_tracker_instance_t *instance = tracker->instance;
++	if (instance != NULL) {
++        celixThreadRwlock_readLock(&instance->lock);
++        for (i = 0; i < arrayList_size(instance->trackedServices); ++i) {
++            tracked = (celix_tracked_entry_t *) arrayList_get(instance->trackedServices, i);
++            result = tracked->reference;
++            break;
++        }
++        celixThreadRwlock_unlock(&instance->lock);
++    }
++    celixThreadRwlock_unlock(&tracker->instanceLock);
++
++	return result;
++}
++
++array_list_pt serviceTracker_getServiceReferences(service_tracker_pt tracker) {
++    //TODO deprecated warning -> not locked
++    celix_tracked_entry_t *tracked;
++	unsigned int i;
++	array_list_pt references = NULL;
++	arrayList_create(&references);
++
++    celixThreadRwlock_readLock(&tracker->instanceLock);
++	celix_service_tracker_instance_t *instance = tracker->instance;
++	if (instance != NULL) {
++        celixThreadRwlock_readLock(&instance->lock);
++        for (i = 0; i < arrayList_size(instance->trackedServices); i++) {
++            tracked = (celix_tracked_entry_t*) arrayList_get(instance->trackedServices, i);
++            arrayList_add(references, tracked->reference);
++        }
++        celixThreadRwlock_unlock(&instance->lock);
++    }
++    celixThreadRwlock_unlock(&tracker->instanceLock);
++
++	return references;
++}
++
++void *serviceTracker_getService(service_tracker_pt tracker) {
++    //TODO deprecated warning -> not locked
++    celix_tracked_entry_t* tracked;
++    void *service = NULL;
++	unsigned int i;
++
++	celixThreadRwlock_readLock(&tracker->instanceLock);
++	celix_service_tracker_instance_t *instance = tracker->instance;
++	if (instance != NULL) {
++        celixThreadRwlock_readLock(&instance->lock);
++        for (i = 0; i < arrayList_size(instance->trackedServices); i++) {
++            tracked = (celix_tracked_entry_t*) arrayList_get(instance->trackedServices, i);
++            service = tracked->service;
++            break;
++        }
++        celixThreadRwlock_unlock(&instance->lock);
++    }
++    celixThreadRwlock_unlock(&tracker->instanceLock);
++
++    return service;
++}
++
++array_list_pt serviceTracker_getServices(service_tracker_pt tracker) {
++    //TODO deprecated warning -> not locked, also make locked variant
++    celix_tracked_entry_t *tracked;
++	unsigned int i;
++	array_list_pt references = NULL;
++	arrayList_create(&references);
++
++    celixThreadRwlock_readLock(&tracker->instanceLock);
++    celix_service_tracker_instance_t *instance = tracker->instance;
++    if (instance != NULL) {
++        celixThreadRwlock_readLock(&instance->lock);
++        for (i = 0; i < arrayList_size(instance->trackedServices); i++) {
++            tracked = (celix_tracked_entry_t *) arrayList_get(instance->trackedServices, i);
++            arrayList_add(references, tracked->service);
++        }
++        celixThreadRwlock_unlock(&instance->lock);
++    }
++    celixThreadRwlock_unlock(&tracker->instanceLock);
++
++    return references;
++}
++
++void *serviceTracker_getServiceByReference(service_tracker_pt tracker, service_reference_pt reference) {
++    //TODO deprecated warning -> not locked
++    celix_tracked_entry_t *tracked;
++    void *service = NULL;
++	unsigned int i;
++
++    celixThreadRwlock_readLock(&tracker->instanceLock);
++    celix_service_tracker_instance_t *instance = tracker->instance;
++    if (instance != NULL) {
++        celixThreadRwlock_readLock(&instance->lock);
++        for (i = 0; i < arrayList_size(instance->trackedServices); i++) {
++            bool equals = false;
++            tracked = (celix_tracked_entry_t *) arrayList_get(instance->trackedServices, i);
++            serviceReference_equals(reference, tracked->reference, &equals);
++            if (equals) {
++                service = tracked->service;
++                break;
++            }
++        }
++        celixThreadRwlock_unlock(&instance->lock);
++    }
++    celixThreadRwlock_unlock(&tracker->instanceLock);
++
++	return service;
++}
++
++void serviceTracker_serviceChanged(celix_service_listener_t *listener, celix_service_event_t *event) {
++	celix_service_tracker_instance_t *instance = listener->handle;
++
++    celixThreadMutex_lock(&instance->closingLock);
++    bool closing = instance->closing;
++    if (!closing) {
++        instance->activeServiceChangeCalls += 1;
++    }
++    celixThreadMutex_unlock(&instance->closingLock);
++
++    if (!closing) {
++        switch (event->type) {
++            case OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED:
++                serviceTracker_track(instance, event->reference, event);
++                break;
++            case OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED:
++                serviceTracker_track(instance, event->reference, event);
++                break;
++            case OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING:
++                serviceTracker_untrack(instance, event->reference, event);
++                break;
++            case OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED_ENDMATCH:
++                //TODO
++                break;
++        }
++        celixThreadMutex_lock(&instance->closingLock);
++        assert(instance->activeServiceChangeCalls > 0);
++        instance->activeServiceChangeCalls -= 1;
++        if (instance->activeServiceChangeCalls == 0) {
++            celixThreadCondition_broadcast(&instance->activeServiceChangeCallsCond);
++        }
++        celixThreadMutex_unlock(&instance->closingLock);
++    }
++}
++
++static celix_status_t serviceTracker_track(celix_service_tracker_instance_t *instance, service_reference_pt reference, celix_service_event_t *event) {
++	celix_status_t status = CELIX_SUCCESS;
++
++    celix_tracked_entry_t *found = NULL;
++    unsigned int i;
++    
++    bundleContext_retainServiceReference(instance->context, reference);
++
++    celixThreadRwlock_readLock(&instance->lock);
++    for (i = 0; i < arrayList_size(instance->trackedServices); i++) {
++        bool equals = false;
++        celix_tracked_entry_t *visit = (celix_tracked_entry_t*) arrayList_get(instance->trackedServices, i);
++        serviceReference_equals(reference, visit->reference, &equals);
++        if (equals) {
++            found = visit;
++            tracked_retain(found);
++            break;
++        }
++    }
++    celixThreadRwlock_unlock(&instance->lock);
++
++    if (found != NULL) {
++        status = serviceTracker_invokeModifiedService(instance, found);
++        tracked_retain(found);
++    } else if (status == CELIX_SUCCESS && found == NULL) {
++        //NEW entry
++        void *service = NULL;
++        status = serviceTracker_invokeAddingService(instance, reference, &service);
++        if (status == CELIX_SUCCESS && service != NULL) {
++            assert(reference != NULL);
++
++            service_registration_t *reg = NULL;
++            properties_t *props = NULL;
++            bundle_t *bnd = NULL;
++
++            serviceReference_getBundle(reference, &bnd);
++            serviceReference_getServiceRegistration(reference, &reg);
++            if (reg != NULL) {
++                serviceRegistration_getProperties(reg, &props);
++            }
++
++            celix_tracked_entry_t *tracked = tracked_create(reference, service, props, bnd);
++
++            celixThreadRwlock_writeLock(&instance->lock);
++            arrayList_add(instance->trackedServices, tracked);
++            celixThreadRwlock_unlock(&instance->lock);
++
++            serviceTracker_invokeAddService(instance, tracked);
++            serviceTracker_useHighestRankingServiceInternal(instance, tracked->serviceName, instance, NULL, NULL, serviceTracker_checkAndInvokeSetService);
++        }
++    }
++
++    framework_logIfError(logger, status, NULL, "Cannot track reference");
++
++    return status;
++}
++
++static void serviceTracker_checkAndInvokeSetService(void *handle, void *highestSvc, const celix_properties_t *props, const celix_bundle_t *bnd) {
++    celix_service_tracker_instance_t *instance = handle;
++    bool update = false;
++    long svcId = -1;
++    if (highestSvc == NULL) {
++        //no services available anymore -> unset == call with NULL
++        update = true;
++    } else {
++        svcId = celix_properties_getAsLong(props, OSGI_FRAMEWORK_SERVICE_ID, -1);
++    }
++    if (svcId > 0) {
++        celixThreadMutex_lock(&instance->mutex);
++        if (instance->currentHighestServiceId != svcId) {
++            instance->currentHighestServiceId = svcId;
++            update = true;
++            //update
++        }
++        celixThreadMutex_unlock(&instance->mutex);
++    }
++    if (update) {
++        void *h = instance->callbackHandle;
++        if (instance->set != NULL) {
++            instance->set(h, highestSvc);
++        }
++        if (instance->setWithProperties != NULL) {
++            instance->setWithProperties(h, highestSvc, props);
++        }
++        if (instance->setWithOwner != NULL) {
++            instance->setWithOwner(h, highestSvc, props, bnd);
++        }
++    }
++}
++
++static celix_status_t serviceTracker_invokeModifiedService(celix_service_tracker_instance_t *instance, celix_tracked_entry_t *tracked) {
++    celix_status_t status = CELIX_SUCCESS;
++
++    void *customizerHandle = NULL;
++    modified_callback_pt function = NULL;
++    serviceTrackerCustomizer_getHandle(&instance->customizer, &customizerHandle);
++    serviceTrackerCustomizer_getModifiedFunction(&instance->customizer, &function);
++    if (function != NULL) {
++        function(customizerHandle, tracked->reference, tracked->service);
++    }
++    
++    void *handle = instance->callbackHandle;
++    if (instance->modified != NULL) {
++        instance->modified(handle, tracked->service);
++    }
++    if (instance->modifiedWithProperties != NULL) {
++        instance->modifiedWithProperties(handle, tracked->service, tracked->properties);
++    }
++    if (instance->modifiedWithOwner != NULL) {
++        instance->modifiedWithOwner(handle, tracked->service, tracked->properties, tracked->serviceOwner);
++    }
++    return status;
++}
++
++
++static celix_status_t serviceTracker_invokeAddService(celix_service_tracker_instance_t *instance, celix_tracked_entry_t *tracked) {
++    celix_status_t status = CELIX_SUCCESS;
++
++    void *customizerHandle = NULL;
++    added_callback_pt function = NULL;
++
++    serviceTrackerCustomizer_getHandle(&instance->customizer, &customizerHandle);
++    serviceTrackerCustomizer_getAddedFunction(&instance->customizer, &function);
++    if (function != NULL) {
++        function(customizerHandle, tracked->reference, tracked->service);
++    }
++
++    void *handle = instance->callbackHandle;
++    if (instance->add != NULL) {
++        instance->add(handle, tracked->service);
++    }
++    if (instance->addWithProperties != NULL) {
++        instance->addWithProperties(handle, tracked->service, tracked->properties);
++    }
++    if (instance->addWithOwner != NULL) {
++        instance->addWithOwner(handle, tracked->service, tracked->properties, tracked->serviceOwner);
++    }
++    return status;
++}
++
++static celix_status_t serviceTracker_invokeAddingService(celix_service_tracker_instance_t *instance, service_reference_pt ref, void **svcOut) {
++	celix_status_t status = CELIX_SUCCESS;
++
++    void *handle = NULL;
++    adding_callback_pt function = NULL;
++
++    status = serviceTrackerCustomizer_getHandle(&instance->customizer, &handle);
++
++    if (status == CELIX_SUCCESS) {
++        status = serviceTrackerCustomizer_getAddingFunction(&instance->customizer, &function);
++    }
++
++    if (status == CELIX_SUCCESS && function != NULL) {
++        status = function(handle, ref, svcOut);
++    } else if (status == CELIX_SUCCESS) {
++        status = bundleContext_getService(instance->context, ref, svcOut);
++    }
++
++    framework_logIfError(logger, status, NULL, "Cannot handle addingService");
++
++    return status;
++}
++
++static celix_status_t serviceTracker_untrack(celix_service_tracker_instance_t* instance, service_reference_pt reference, celix_service_event_t *event) {
++    celix_status_t status = CELIX_SUCCESS;
++    celix_tracked_entry_t *remove = NULL;
++    unsigned int i;
++    unsigned int size;
++    const char *serviceName = NULL;
++
++    celixThreadRwlock_writeLock(&instance->lock);
++    size = arrayList_size(instance->trackedServices);
++    for (i = 0; i < size; i++) {
++        bool equals;
++        celix_tracked_entry_t *tracked = (celix_tracked_entry_t*) arrayList_get(instance->trackedServices, i);
++        serviceName = tracked->serviceName;
++        serviceReference_equals(reference, tracked->reference, &equals);
++        if (equals) {
++            remove = tracked;
++            //remove from trackedServices to prevent getting this service, but don't destroy yet, can be in use
++            arrayList_remove(instance->trackedServices, i);
++            break;
++        }
++    }
++    size = arrayList_size(instance->trackedServices); //updated size
++    celixThreadRwlock_unlock(&instance->lock);
++
++    if (size == 0) {
++        serviceTracker_checkAndInvokeSetService(instance, NULL, NULL, NULL);
++    } else {
++        serviceTracker_useHighestRankingServiceInternal(instance, serviceName, instance, NULL, NULL, serviceTracker_checkAndInvokeSetService);
++    }
++
++    serviceTracker_untrackTracked(instance, remove);
++
++    framework_logIfError(logger, status, NULL, "Cannot untrack reference");
++
++    return status;
++}
++
++static void serviceTracker_untrackTracked(celix_service_tracker_instance_t *instance, celix_tracked_entry_t *tracked) {
++    if (tracked != NULL) {
++        serviceTracker_invokeRemovingService(instance, tracked);
++        bundleContext_ungetServiceReference(instance->context, tracked->reference);
++        tracked_release(tracked);
++
++        //Wait till the useCount is 0, because the untrack should only return if the service is not used anymore.
++        tracked_waitAndDestroy(tracked);
++    }
++}
++
++static celix_status_t serviceTracker_invokeRemovingService(celix_service_tracker_instance_t *instance, celix_tracked_entry_t *tracked) {
++    celix_status_t status = CELIX_SUCCESS;
++    bool ungetSuccess = true;
++
++    void *customizerHandle = NULL;
++    removed_callback_pt function = NULL;
++
++    serviceTrackerCustomizer_getHandle(&instance->customizer, &customizerHandle);
++    serviceTrackerCustomizer_getRemovedFunction(&instance->customizer, &function);
++
++    if (function != NULL) {
++        status = function(customizerHandle, tracked->reference, tracked->service);
++    }
++
++    void *handle = instance->callbackHandle;
++    if (instance->remove != NULL) {
++        instance->remove(handle, tracked->service);
++    }
++    if (instance->addWithProperties != NULL) {
++        instance->removeWithProperties(handle, tracked->service, tracked->properties);
++    }
++    if (instance->removeWithOwner != NULL) {
++        instance->removeWithOwner(handle, tracked->service, tracked->properties, tracked->serviceOwner);
++    }
++
++    if (status == CELIX_SUCCESS) {
++        status = bundleContext_ungetService(instance->context, tracked->reference, &ungetSuccess);
++    }
++
++    if (!ungetSuccess) {
++        framework_log(logger, OSGI_FRAMEWORK_LOG_ERROR, __FUNCTION__, __BASE_FILE__, __LINE__, "Error ungetting service");
++        status = CELIX_BUNDLE_EXCEPTION;
++    }
++
++    return status;
++}
++
++
++
++/**********************************************************************************************************************
++ **********************************************************************************************************************
++ * Updated API
++ **********************************************************************************************************************
... 297 lines suppressed ...