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

pnoltes pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to refs/heads/develop by this push:
     new be87367  CELIX-426: Adds a CELIX_GEN_CXX_BUNDLE_ACTIVATOR marcro for 
creating C++ bundles without the need for the dependency_manager_cxx static lib
be87367 is described below

commit be8736741af53e0adc3fc139e9b160a9677e9b6c
Author: Pepijn Noltes <[email protected]>
AuthorDate: Fri Apr 26 00:08:41 2019 +0200

    CELIX-426: Adds a CELIX_GEN_CXX_BUNDLE_ACTIVATOR marcro for creating C++ 
bundles without the need for the dependency_manager_cxx static lib
---
 CMakeLists.txt                                     |   5 +-
 examples/celix-examples/CMakeLists.txt             |   2 +-
 .../dm_example_cxx/phase1/CMakeLists.txt           |  11 --
 .../dm_example_cxx/phase1/src/Phase1Activator.cc   |  31 ++---
 .../dm_example_cxx/phase1/src/Phase1Activator.h    |  12 +-
 .../dm_example_cxx/phase2/CMakeLists.txt           |  15 ---
 .../dm_example_cxx/phase2/src/Phase2Activator.h    |   8 +-
 .../dm_example_cxx/phase2/src/Phase2aActivator.cc  |  14 +--
 .../dm_example_cxx/phase2/src/Phase2bActivator.cc  |  14 +--
 .../dm_example_cxx/phase3/CMakeLists.txt           |  11 --
 .../dm_example_cxx/phase3/src/Phase3Activator.cc   |  12 +-
 .../dm_example_cxx/phase3/src/Phase3Activator.h    |   3 +-
 .../phase3/src/Phase3BaseActivator.cc              |   2 +-
 .../phase3/src/Phase3BaseActivator.h               |   7 +-
 .../dm_example_cxx/phase3_locking/CMakeLists.txt   |  10 --
 .../phase3_locking/src/Phase3LockingActivator.cc   |  14 +--
 .../phase3_locking/src/Phase3LockingActivator.h    |   7 +-
 .../service_hook_example/src/activator.c           | 137 ---------------------
 .../services_example_cxx/CMakeLists.txt            |  42 +++----
 .../services_example_cxx/bar/CMakeLists.txt        |  22 +---
 .../bar/{private => }/src/Bar.cc                   |   0
 .../bar/{private/include => src}/Bar.h             |   0
 .../bar/{private => }/src/BarActivator.cc          |  12 +-
 .../bar/{private/include => src}/BarActivator.h    |   8 +-
 .../services_example_cxx/baz/CMakeLists.txt        |  22 +---
 .../baz/{private => }/src/Baz.cc                   |   0
 .../baz/{private/include => src}/Baz.h             |   0
 .../baz/{private => }/src/BazActivator.cc          |  13 +-
 .../baz/{private/include => src}/BazActivator.h    |   8 +-
 .../services_example_cxx/foo/CMakeLists.txt        |  21 +---
 .../foo/{private => }/src/Foo.cc                   |   0
 .../foo/{private/include => src}/Foo.h             |   0
 .../foo/{private => }/src/FooActivator.cc          |  13 +-
 .../foo/{private/include => src}/FooActivator.h    |   8 +-
 .../CMakeLists.txt                                 |   9 +-
 .../track_tracker_example/src/activator.c          | 103 ++++++++++++++++
 libs/dependency_manager_cxx/CMakeLists.txt         |   1 +
 libs/dependency_manager_cxx/src/dm_activator.cc    |   3 +
 libs/framework/include/celix/dm/DmActivator.h      |   2 +-
 libs/framework/include/celix_bundle_activator.h    |  79 +++++++++++-
 libs/framework/src/framework.c                     |   3 +
 41 files changed, 299 insertions(+), 385 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ad165dc..64fcf33 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,11 +18,12 @@
 cmake_minimum_required (VERSION 3.2)
 cmake_policy(SET CMP0012 NEW)
 cmake_policy(SET CMP0042 NEW)
-cmake_policy(SET CMP0068 NEW)
+if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.9.0")
+    cmake_policy(SET CMP0068 NEW)
+endif()
 
 project (Celix C CXX)
 
-
 include(cmake/celix_project/CelixProject.cmake)
 include(cmake/cmake_celix/UseCelix.cmake)
 
diff --git a/examples/celix-examples/CMakeLists.txt 
b/examples/celix-examples/CMakeLists.txt
index 15a6361..af34f71 100644
--- a/examples/celix-examples/CMakeLists.txt
+++ b/examples/celix-examples/CMakeLists.txt
@@ -40,7 +40,7 @@ if (EXAMPLES)
         add_subdirectory(civetweb)
     endif()
     add_subdirectory(embedding)
-    add_subdirectory(service_hook_example)
+    add_subdirectory(track_tracker_example)
     add_subdirectory(log_service_example)
 
 endif(EXAMPLES)
diff --git a/examples/celix-examples/dm_example_cxx/phase1/CMakeLists.txt 
b/examples/celix-examples/dm_example_cxx/phase1/CMakeLists.txt
index 5007e77..e4a0268 100644
--- a/examples/celix-examples/dm_example_cxx/phase1/CMakeLists.txt
+++ b/examples/celix-examples/dm_example_cxx/phase1/CMakeLists.txt
@@ -24,14 +24,3 @@ add_celix_bundle(dm_example_cxx_phase1
 )
 target_include_directories(dm_example_cxx_phase1 PRIVATE src)
 target_link_libraries(dm_example_cxx_phase1 PRIVATE dm_example_cxx_api 
Celix::shell_api)
-
-IF(APPLE)
-    target_link_libraries(dm_example_cxx_phase1 PRIVATE  -Wl,-all_load 
Celix::dependency_manager_cxx_static)
-else()
-    if(ENABLE_ADDRESS_SANITIZER)
-        #With asan there can be undefined symbols
-        target_link_libraries(dm_example_cxx_phase1 PRIVATE 
-Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive)
-    else()
-        target_link_libraries(dm_example_cxx_phase1 PRIVATE -Wl,--no-undefined 
-Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive)
-    endif()
-endif()
diff --git 
a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc 
b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
index c4895e4..09781df 100644
--- a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
+++ b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.cc
@@ -20,6 +20,7 @@
 #include "Phase1Cmp.h"
 #include "Phase1Activator.h"
 #include "IPhase2.h"
+#include <celix_bundle_activator.h>
 
 using namespace celix::dm;
 
@@ -28,10 +29,6 @@ using namespace celix::dm;
  * For the C++ service the object itself is used
  */
 
-DmActivator* DmActivator::create(DependencyManager& mng) {
-    return new Phase1Activator(mng);
-}
-
 struct InvalidCServ {
     virtual ~InvalidCServ() = default;
     void* handle {nullptr}; //valid pod
@@ -40,7 +37,7 @@ struct InvalidCServ {
     virtual void baz(double __attribute__((unused)) arg) {} //not a valid pod
 };
 
-void Phase1Activator::init() {
+Phase1Activator::Phase1Activator(std::shared_ptr<celix::dm::DependencyManager> 
mng) {
     auto cmp = std::shared_ptr<Phase1Cmp>(new Phase1Cmp());
 
     Properties cmdProps;
@@ -86,14 +83,18 @@ void Phase1Activator::init() {
     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->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);
+
+
+}
 
-    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);
-}
\ No newline at end of file
+CELIX_GEN_CXX_BUNDLE_ACTIVATOR(Phase1Activator)
\ No newline at end of file
diff --git 
a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h 
b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h
index 76ba839..019a5a5 100644
--- a/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h
+++ b/examples/celix-examples/dm_example_cxx/phase1/src/Phase1Activator.h
@@ -28,17 +28,17 @@ struct DummyService {
     void *handle;
 };
 
-class Phase1Activator : public DmActivator {
+class Phase1Activator {
+public:
+    Phase1Activator(std::shared_ptr<celix::dm::DependencyManager> mng);
+    Phase1Activator(const Phase1Activator&) = delete;
+    Phase1Activator& operator=(const Phase1Activator&) = delete;
+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 --git a/examples/celix-examples/dm_example_cxx/phase2/CMakeLists.txt 
b/examples/celix-examples/dm_example_cxx/phase2/CMakeLists.txt
index f2b3813..345bd51 100644
--- a/examples/celix-examples/dm_example_cxx/phase2/CMakeLists.txt
+++ b/examples/celix-examples/dm_example_cxx/phase2/CMakeLists.txt
@@ -34,18 +34,3 @@ add_celix_bundle(dm_example_cxx_phase2b
         )
 target_include_directories(dm_example_cxx_phase2b PRIVATE src)
 target_link_libraries(dm_example_cxx_phase2b PRIVATE Celix::log_service_api 
dm_example_cxx_api)
-
-IF(APPLE)
-    target_link_libraries(dm_example_cxx_phase2a PRIVATE -Wl,-all_load 
Celix::dependency_manager_cxx_static)
-    target_link_libraries(dm_example_cxx_phase2b PRIVATE -Wl,-all_load 
Celix::dependency_manager_cxx_static)
-else()
-    if(ENABLE_ADDRESS_SANITIZER)
-        #With asan there can be undefined symbols
-        target_link_libraries(dm_example_cxx_phase2a PRIVATE 
-Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive)
-        target_link_libraries(dm_example_cxx_phase2b PRIVATE 
-Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive)
-    else()
-        target_link_libraries(dm_example_cxx_phase2a PRIVATE 
-Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive)
-        target_link_libraries(dm_example_cxx_phase2b PRIVATE 
-Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive)
-
-    endif()
-endif()
diff --git 
a/examples/celix-examples/dm_example_cxx/phase2/src/Phase2Activator.h 
b/examples/celix-examples/dm_example_cxx/phase2/src/Phase2Activator.h
index 069b2ae..d344fe7 100644
--- a/examples/celix-examples/dm_example_cxx/phase2/src/Phase2Activator.h
+++ b/examples/celix-examples/dm_example_cxx/phase2/src/Phase2Activator.h
@@ -20,15 +20,13 @@
 #ifndef CELIX_PHASE2AACTIVATOR_H
 #define CELIX_PHASE2AACTIVATOR_H
 
-#include "celix/dm/DmActivator.h"
+#include "celix/dm/DependencyManager.h"
 
 using namespace celix::dm;
 
-class Phase2Activator : public DmActivator {
+class Phase2Activator {
 public:
-    Phase2Activator(DependencyManager& mng) : DmActivator(mng) {}
-    virtual void init();
-    virtual void deinit();
+    Phase2Activator(std::shared_ptr<DependencyManager> mng);
 };
 
 #endif //CELIX_PHASE2AACTIVATOR_H
diff --git 
a/examples/celix-examples/dm_example_cxx/phase2/src/Phase2aActivator.cc 
b/examples/celix-examples/dm_example_cxx/phase2/src/Phase2aActivator.cc
index e33ae0e..e5f3c17 100644
--- a/examples/celix-examples/dm_example_cxx/phase2/src/Phase2aActivator.cc
+++ b/examples/celix-examples/dm_example_cxx/phase2/src/Phase2aActivator.cc
@@ -18,6 +18,7 @@
  */
 
 #include <IName.h>
+#include <celix_bundle_activator.h>
 #include "Phase2Cmp.h"
 #include "Phase2Activator.h"
 #include "log_service.h"
@@ -25,17 +26,12 @@
 using namespace celix::dm;
 
 
-DmActivator* DmActivator::create(DependencyManager& mng) {
-    return new Phase2Activator(mng);
-}
-
-
-void Phase2Activator::init() {
+Phase2Activator::Phase2Activator(std::shared_ptr<celix::dm::DependencyManager> 
mng) {
 
     Properties props {};
     props["name"] = "phase2a";
 
-    Component<Phase2Cmp>& cmp = mng.createComponent<Phase2Cmp>()
+    Component<Phase2Cmp>& cmp = mng->createComponent<Phase2Cmp>()
             .setInstance(Phase2Cmp())
             .addInterface<IPhase2>(IPHASE2_VERSION, props);
 
@@ -52,6 +48,4 @@ void Phase2Activator::init() {
             .setCallbacks(&Phase2Cmp::setLogService);
 }
 
-void Phase2Activator::deinit() {
-
-}
+CELIX_GEN_CXX_BUNDLE_ACTIVATOR(Phase2Activator)
\ No newline at end of file
diff --git 
a/examples/celix-examples/dm_example_cxx/phase2/src/Phase2bActivator.cc 
b/examples/celix-examples/dm_example_cxx/phase2/src/Phase2bActivator.cc
index 4fba8c0..1b472e2 100644
--- a/examples/celix-examples/dm_example_cxx/phase2/src/Phase2bActivator.cc
+++ b/examples/celix-examples/dm_example_cxx/phase2/src/Phase2bActivator.cc
@@ -20,20 +20,16 @@
 #include "Phase2Cmp.h"
 #include "Phase2Activator.h"
 #include "log_service.h"
+#include <celix_bundle_activator.h>
 
 using namespace celix::dm;
 
-
-DmActivator* DmActivator::create(DependencyManager& mng) {
-    return new Phase2Activator(mng);
-}
-
-void Phase2Activator::init() {
+Phase2Activator::Phase2Activator(std::shared_ptr<DependencyManager> mng) {
 
     Properties props {};
     props["name"] = "phase2b";
 
-    Component<Phase2Cmp>& cmp = mng.createComponent<Phase2Cmp>()
+    Component<Phase2Cmp>& cmp = mng->createComponent<Phase2Cmp>()
         .addInterface<IPhase2>(IPHASE2_VERSION, props);
 
     cmp.createServiceDependency<IPhase1>()
@@ -45,6 +41,4 @@ void Phase2Activator::init() {
             .setCallbacks(&Phase2Cmp::setLogService);
 }
 
-void Phase2Activator::deinit() {
-
-}
\ No newline at end of file
+CELIX_GEN_CXX_BUNDLE_ACTIVATOR(Phase2Activator)
\ No newline at end of file
diff --git a/examples/celix-examples/dm_example_cxx/phase3/CMakeLists.txt 
b/examples/celix-examples/dm_example_cxx/phase3/CMakeLists.txt
index c583f25..60dd73b 100644
--- a/examples/celix-examples/dm_example_cxx/phase3/CMakeLists.txt
+++ b/examples/celix-examples/dm_example_cxx/phase3/CMakeLists.txt
@@ -25,14 +25,3 @@ add_celix_bundle(dm_example_cxx_phase3
 )
 target_include_directories(dm_example_cxx_phase3 PRIVATE src)
 target_link_libraries(dm_example_cxx_phase3 PRIVATE dm_example_cxx_api pthread)
-
-IF(APPLE)
-    target_link_libraries(dm_example_cxx_phase3 PRIVATE -Wl,-all_load 
Celix::dependency_manager_cxx_static)
-else()
-    if(ENABLE_ADDRESS_SANITIZER)
-        #With asan there can be undefined symbols
-        target_link_libraries(dm_example_cxx_phase3 PRIVATE  
-Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive)
-    else()
-        target_link_libraries(dm_example_cxx_phase3 PRIVATE  
-Wl,--no-undefined -Wl,--whole-archive Celix::dependency_manager_cxx_static 
-Wl,--no-whole-archive)
-    endif()
-endif()
diff --git 
a/examples/celix-examples/dm_example_cxx/phase3/src/Phase3Activator.cc 
b/examples/celix-examples/dm_example_cxx/phase3/src/Phase3Activator.cc
index f5aa178..128d476 100644
--- a/examples/celix-examples/dm_example_cxx/phase3/src/Phase3Activator.cc
+++ b/examples/celix-examples/dm_example_cxx/phase3/src/Phase3Activator.cc
@@ -20,18 +20,16 @@
 
 #include "Phase3Cmp.h"
 #include "Phase3Activator.h"
+#include <celix_bundle_activator.h>
 
 using namespace celix::dm;
 
-
-DmActivator* DmActivator::create(DependencyManager& mng) {
-    return new Phase3Activator(mng);
-}
-
-void Phase3Activator::init() {
-    Phase3BaseActivator::init();
+Phase3Activator::Phase3Activator(std::shared_ptr<DependencyManager> mng) : 
Phase3BaseActivator{mng} {
     cmp.createServiceDependency<IPhase2>()
              .setRequired(false)
              .setFilter("(&(name=phase2a)(non-existing=*))")
              .setCallbacks(&Phase3Cmp::setPhase2a);
 }
+
+
+CELIX_GEN_CXX_BUNDLE_ACTIVATOR(Phase3Activator)
\ No newline at end of file
diff --git 
a/examples/celix-examples/dm_example_cxx/phase3/src/Phase3Activator.h 
b/examples/celix-examples/dm_example_cxx/phase3/src/Phase3Activator.h
index e02cd61..fbb8ad3 100644
--- a/examples/celix-examples/dm_example_cxx/phase3/src/Phase3Activator.h
+++ b/examples/celix-examples/dm_example_cxx/phase3/src/Phase3Activator.h
@@ -26,8 +26,7 @@ using namespace celix::dm;
 
 class Phase3Activator : public Phase3BaseActivator {
 public:
-    Phase3Activator(DependencyManager& mng) : Phase3BaseActivator(mng) {}
-    virtual void init();
+    Phase3Activator(std::shared_ptr<DependencyManager> mng);
 };
 
 #endif //CELIX_PHASE2AACTIVATOR_H
diff --git 
a/examples/celix-examples/dm_example_cxx/phase3/src/Phase3BaseActivator.cc 
b/examples/celix-examples/dm_example_cxx/phase3/src/Phase3BaseActivator.cc
index 37746dc..0562bf6 100644
--- a/examples/celix-examples/dm_example_cxx/phase3/src/Phase3BaseActivator.cc
+++ b/examples/celix-examples/dm_example_cxx/phase3/src/Phase3BaseActivator.cc
@@ -22,7 +22,7 @@
 
 using namespace celix::dm;
 
-void Phase3BaseActivator::init() {
+Phase3BaseActivator::Phase3BaseActivator(std::shared_ptr<DependencyManager> 
mng) : cmp(mng->createComponent<Phase3Cmp>()) {
     cmp.setCallbacks(nullptr, &Phase3Cmp::start, &Phase3Cmp::stop, nullptr);
 
     cmp.createServiceDependency<IPhase2>()
diff --git 
a/examples/celix-examples/dm_example_cxx/phase3/src/Phase3BaseActivator.h 
b/examples/celix-examples/dm_example_cxx/phase3/src/Phase3BaseActivator.h
index 0f3d813..2eb6097 100644
--- a/examples/celix-examples/dm_example_cxx/phase3/src/Phase3BaseActivator.h
+++ b/examples/celix-examples/dm_example_cxx/phase3/src/Phase3BaseActivator.h
@@ -20,14 +20,13 @@
 #ifndef CELIX_PHASE3BASEACTIVATOR_H
 #define CELIX_PHASE3BASEACTIVATOR_H
 
-#include "celix/dm/DmActivator.h"
+#include "celix/dm/DependencyManager.h"
 
 using namespace celix::dm;
 
-class Phase3BaseActivator : public DmActivator {
+class Phase3BaseActivator  {
 public:
-    Phase3BaseActivator(DependencyManager& mng) : DmActivator(mng), 
cmp(mng.createComponent<Phase3Cmp>()) {}
-    void init();
+    Phase3BaseActivator(std::shared_ptr<DependencyManager> mng);
 protected:
     celix::dm::Component<Phase3Cmp>& cmp;
 };
diff --git 
a/examples/celix-examples/dm_example_cxx/phase3_locking/CMakeLists.txt 
b/examples/celix-examples/dm_example_cxx/phase3_locking/CMakeLists.txt
index 7a6823a..aa62b70 100644
--- a/examples/celix-examples/dm_example_cxx/phase3_locking/CMakeLists.txt
+++ b/examples/celix-examples/dm_example_cxx/phase3_locking/CMakeLists.txt
@@ -26,13 +26,3 @@ add_celix_bundle(dm_example_cxx_phase3_locking
 target_include_directories(dm_example_cxx_phase3_locking PRIVATE src)
 target_link_libraries(dm_example_cxx_phase3_locking PRIVATE dm_example_cxx_api 
pthread)
 
-IF(APPLE)
-    target_link_libraries(dm_example_cxx_phase3_locking PRIVATE -Wl,-all_load 
Celix::dependency_manager_cxx_static)
-else()
-    if(ENABLE_ADDRESS_SANITIZER)
-        #With asan there can be undefined symbols
-        target_link_libraries(dm_example_cxx_phase3_locking PRIVATE 
-Wl,--whole-archive Celix::dependency_manager_cxx_static -Wl,--no-whole-archive)
-    else()
-        target_link_libraries(dm_example_cxx_phase3_locking PRIVATE 
-Wl,--no-undefined -Wl,--whole-archive Celix::dependency_manager_cxx_static 
-Wl,--no-whole-archive)
-    endif()
-endif()
diff --git 
a/examples/celix-examples/dm_example_cxx/phase3_locking/src/Phase3LockingActivator.cc
 
b/examples/celix-examples/dm_example_cxx/phase3_locking/src/Phase3LockingActivator.cc
index 29d178e..494fad7 100644
--- 
a/examples/celix-examples/dm_example_cxx/phase3_locking/src/Phase3LockingActivator.cc
+++ 
b/examples/celix-examples/dm_example_cxx/phase3_locking/src/Phase3LockingActivator.cc
@@ -22,21 +22,19 @@
 #include "Phase3LockingActivator.h"
 
 #include <memory>
+#include <celix_bundle_activator.h>
 
 using namespace celix::dm;
 
-
-DmActivator* DmActivator::create(DependencyManager& mng) {
-    return new Phase3LockingActivator(mng);
-}
-
-void Phase3LockingActivator::init() {
+Phase3LockingActivator::Phase3LockingActivator(std::shared_ptr<DependencyManager>
 mng) {
     auto inst = std::shared_ptr<Phase3LockingCmp> {new Phase3LockingCmp {}};
 
-    Component<Phase3LockingCmp>& cmp = 
mng.createComponent<Phase3LockingCmp>(inst)  //set inst using a shared ptr
+    Component<Phase3LockingCmp>& cmp = 
mng->createComponent<Phase3LockingCmp>(inst)  //set inst using a shared ptr
         .setCallbacks(nullptr, &Phase3LockingCmp::start, 
&Phase3LockingCmp::stop, nullptr);
 
     cmp.createServiceDependency<IPhase2>()
             .setStrategy(DependencyUpdateStrategy::locking)
             .setCallbacks(&Phase3LockingCmp::addPhase2, 
&Phase3LockingCmp::removePhase2);
-}
\ No newline at end of file
+}
+
+CELIX_GEN_CXX_BUNDLE_ACTIVATOR(Phase3LockingActivator)
\ No newline at end of file
diff --git 
a/examples/celix-examples/dm_example_cxx/phase3_locking/src/Phase3LockingActivator.h
 
b/examples/celix-examples/dm_example_cxx/phase3_locking/src/Phase3LockingActivator.h
index 78d1748..159fc4c 100644
--- 
a/examples/celix-examples/dm_example_cxx/phase3_locking/src/Phase3LockingActivator.h
+++ 
b/examples/celix-examples/dm_example_cxx/phase3_locking/src/Phase3LockingActivator.h
@@ -20,14 +20,13 @@
 #ifndef CELIX_PHASE3LOCKINGACTIVATOR_H
 #define CELIX_PHASE3LOCKINGACTIVATOR_H
 
-#include "celix/dm/DmActivator.h"
+#include <celix/dm/DependencyManager.h>
 
 using namespace celix::dm;
 
-class Phase3LockingActivator : public DmActivator {
+class Phase3LockingActivator {
 public:
-    Phase3LockingActivator(DependencyManager& mng) : DmActivator(mng) {}
-    virtual void init();
+    Phase3LockingActivator(std::shared_ptr<DependencyManager> mng);
 };
 
 #endif //CELIX_PHASE3LOCKINGAACTIVATOR_H
diff --git a/examples/celix-examples/service_hook_example/src/activator.c 
b/examples/celix-examples/service_hook_example/src/activator.c
deleted file mode 100644
index 8fe56f2..0000000
--- a/examples/celix-examples/service_hook_example/src/activator.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * activator.c
- *
- *  \date       Aug 20, 2010
- *  \author            <a href="mailto:[email protected]";>Apache Celix 
Project Team</a>
- *  \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-
-#include "bundle_activator.h"
-#include "service_tracker_customizer.h"
-#include "service_tracker.h"
-#include "bundle_context.h"
-#include "listener_hook_service.h"
-#include "service_registry.h"
-
-struct userData {
-    service_registration_pt hookReg;
-    service_tracker_pt trackerBefore;
-    service_tracker_pt trackerAfter;
-    listener_hook_service_pt hookService; 
-};
-
-
-celix_status_t tracker_added(void*hook, celix_array_list_t *listeners) {
-    for(unsigned int i = 0; i < arrayList_size(listeners); i++) {
-        listener_hook_info_pt info = arrayList_get(listeners, i);
-        printf("Added tracker for service %s\n", info->filter);
-    }
-
-    return CELIX_SUCCESS;
-}
-
-celix_status_t tracker_removed(void*hook, celix_array_list_t *listeners) {
-    for(unsigned int i = 0; i < arrayList_size(listeners); i++) {
-        listener_hook_info_pt info = arrayList_get(listeners, i);
-        printf("Removed tracker for service %s\n", info->filter);
-    }
-
-    return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_create(celix_bundle_context_t *context, void 
**userData) {
-       celix_status_t status = CELIX_SUCCESS;
-    *userData = malloc(sizeof(struct userData));
-    if (*userData != NULL) {
-       
-       } else {
-               status = CELIX_START_ERROR;
-       }
-       return status;
-}
-
-celix_status_t bundleActivator_start(void * handle, celix_bundle_context_t 
*context) {
-       printf("Starting hook example bundle\n");
-    struct userData *userData = (struct userData*)handle;   
-    
-    userData->trackerBefore = 0;
-    serviceTracker_create(context, "MY_SERVICE_BEFORE_REGISTERING_HOOK", NULL, 
&userData->trackerBefore);
-    serviceTracker_open(userData->trackerBefore);
-    
-    listener_hook_service_pt hookService = calloc(1, sizeof(*hookService));
-    hookService->handle = userData;
-    hookService->added = tracker_added;
-    hookService->removed = tracker_removed;
-
-    userData->hookService = hookService;
-    userData->hookReg = NULL;
-
-    printf("Registering hook service\n");
-    bundleContext_registerService(context, 
OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, hookService, NULL, 
&userData->hookReg);
-
-    printf("Unregistering hook service\n");
-    serviceRegistration_unregister(userData->hookReg);
-
-    printf("Re-Registering hook service\n");
-    userData->hookReg = NULL;
-    bundleContext_registerService(context, 
OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, hookService, NULL, 
&userData->hookReg);
-
-    userData->trackerAfter = 0;
-    serviceTracker_create(context, "MY_SERVICE_AFTER_REGISTERING_HOOK", NULL, 
&userData->trackerAfter);
-    serviceTracker_open(userData->trackerAfter);
-  
-    sleep(1);
-    printf("Closing tracker\n");
-    serviceTracker_close(userData->trackerAfter);
-    printf("Reopening tracker\n");
-    serviceTracker_open(userData->trackerAfter);
-    
-    sleep(1);
-    printf("Closing tracker\n");
-    serviceTracker_close(userData->trackerAfter);
-    printf("Reopening tracker\n");
-    serviceTracker_open(userData->trackerAfter);
-
-       return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_stop(void * handle, celix_bundle_context_t 
*context) {
-       printf("Stopping hook example bundle\n");
-    struct userData *userData = (struct userData*)handle;   
-
-    serviceTracker_close(userData->trackerAfter);
-    serviceTracker_close(userData->trackerBefore);
-    serviceTracker_destroy(userData->trackerAfter);
-    serviceTracker_destroy(userData->trackerBefore);
-
-    serviceRegistration_unregister(userData->hookReg);
-    free(userData->hookService);
-
-       return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * handle, celix_bundle_context_t 
*context) {
-    free(handle);
-       return CELIX_SUCCESS;
-}
diff --git a/examples/celix-examples/services_example_cxx/CMakeLists.txt 
b/examples/celix-examples/services_example_cxx/CMakeLists.txt
index ba13251..3bf458a 100644
--- a/examples/celix-examples/services_example_cxx/CMakeLists.txt
+++ b/examples/celix-examples/services_example_cxx/CMakeLists.txt
@@ -14,30 +14,24 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-if (BUILD_DEPENDENCY_MANAGER_CXX)
-    include_directories(
-            ${PROJECT_SOURCE_DIR}/dependency_manager/public/include
-            ${PROJECT_SOURCE_DIR}/dependency_manager_cxx/include
-            ${PROJECT_SOURCE_DIR}/utils/public/include
-            api
-    )
 
-    add_subdirectory(bar)
-    add_subdirectory(foo)
-    add_subdirectory(baz)
+add_library(services_example_cxx_api INTERFACE)
+target_include_directories(services_example_cxx_api INTERFACE api)
 
-    add_celix_container(services_example_cxx
-        GROUP services_example
-        COPY
-        BUNDLES
-            Celix::shell
-            Celix::shell_tui
-            dm_shell
-            bar_cxx
-            foo_cxx
-            baz_cxx
-        PROPERTIES
-            example=value
-    )
+add_subdirectory(bar)
+add_subdirectory(foo)
+add_subdirectory(baz)
+
+add_celix_container(services_example_cxx
+    GROUP services_example
+    COPY
+    BUNDLES
+        Celix::shell
+        Celix::shell_tui
+        bar_cxx
+        foo_cxx
+        baz_cxx
+    PROPERTIES
+        example=value
+)
 
-endif ()
diff --git a/examples/celix-examples/services_example_cxx/bar/CMakeLists.txt 
b/examples/celix-examples/services_example_cxx/bar/CMakeLists.txt
index c660ce6..4ac99a7 100644
--- a/examples/celix-examples/services_example_cxx/bar/CMakeLists.txt
+++ b/examples/celix-examples/services_example_cxx/bar/CMakeLists.txt
@@ -15,27 +15,11 @@
 # specific language governing permissions and limitations
 # under the License.
 
-include_directories(
-        private/include
-)
-
 add_celix_bundle(bar_cxx
     SYMBOLIC_NAME Bar
     VERSION 1.0.0
     SOURCES
-        private/src/Bar.cc
-        private/src/BarActivator.cc
+        src/Bar.cc
+        src/BarActivator.cc
 )
-
-target_compile_options(bar_cxx PUBLIC -Wall -Wextra -Weffc++ -Werror)
-
-IF(APPLE)
-    target_link_libraries(bar_cxx PRIVATE -Wl,-all_load  
dependency_manager_cxx_static)
-else()
-    if(ENABLE_ADDRESS_SANITIZER)
-        #With asan there can be undefined symbols
-        target_link_libraries(bar_cxx PRIVATE -Wl,--whole-archive  
dependency_manager_cxx_static -Wl,--no-whole-archive)
-    else()
-        target_link_libraries(bar_cxx PRIVATE -Wl,--no-undefined 
-Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive)
-    endif()
-endif()
\ No newline at end of file
+target_link_libraries(bar_cxx PRIVATE services_example_cxx_api)
diff --git 
a/examples/celix-examples/services_example_cxx/bar/private/src/Bar.cc 
b/examples/celix-examples/services_example_cxx/bar/src/Bar.cc
similarity index 100%
rename from examples/celix-examples/services_example_cxx/bar/private/src/Bar.cc
rename to examples/celix-examples/services_example_cxx/bar/src/Bar.cc
diff --git 
a/examples/celix-examples/services_example_cxx/bar/private/include/Bar.h 
b/examples/celix-examples/services_example_cxx/bar/src/Bar.h
similarity index 100%
rename from 
examples/celix-examples/services_example_cxx/bar/private/include/Bar.h
rename to examples/celix-examples/services_example_cxx/bar/src/Bar.h
diff --git 
a/examples/celix-examples/services_example_cxx/bar/private/src/BarActivator.cc 
b/examples/celix-examples/services_example_cxx/bar/src/BarActivator.cc
similarity index 82%
rename from 
examples/celix-examples/services_example_cxx/bar/private/src/BarActivator.cc
rename to examples/celix-examples/services_example_cxx/bar/src/BarActivator.cc
index e4b8bec..91b1a5d 100644
--- 
a/examples/celix-examples/services_example_cxx/bar/private/src/BarActivator.cc
+++ b/examples/celix-examples/services_example_cxx/bar/src/BarActivator.cc
@@ -19,14 +19,12 @@
 
 #include "Bar.h"
 #include "BarActivator.h"
+#include <celix_bundle_activator.h>
 
 using namespace celix::dm;
 
-DmActivator* DmActivator::create(DependencyManager& mng) {
-    return new BarActivator(mng);
-}
 
-void BarActivator::init() {
+BarActivator::BarActivator(std::shared_ptr<DependencyManager> mng) {
     auto bar = std::unique_ptr<Bar>{new Bar{}};
 
     Properties props;
@@ -41,8 +39,10 @@ void BarActivator::init() {
         return bar->cMethod(arg1, arg2, out);
     };
 
-    mng.createComponent(std::move(bar))  //using a pointer a instance. Also 
supported is lazy initialization (default constructor needed) or a rvalue 
reference (move)
+    mng->createComponent(std::move(bar))  //using a pointer a instance. Also 
supported is lazy initialization (default constructor needed) or a rvalue 
reference (move)
         .addInterface<IAnotherExample>(IANOTHER_EXAMPLE_VERSION, props)
         .addCInterface(&this->cExample, EXAMPLE_NAME, EXAMPLE_VERSION, cProps)
         .setCallbacks(&Bar::init, &Bar::start, &Bar::stop, &Bar::deinit);
-}
\ No newline at end of file
+}
+
+CELIX_GEN_CXX_BUNDLE_ACTIVATOR(BarActivator)
\ No newline at end of file
diff --git 
a/examples/celix-examples/services_example_cxx/bar/private/include/BarActivator.h
 b/examples/celix-examples/services_example_cxx/bar/src/BarActivator.h
similarity index 85%
rename from 
examples/celix-examples/services_example_cxx/bar/private/include/BarActivator.h
rename to examples/celix-examples/services_example_cxx/bar/src/BarActivator.h
index 0c635a8..58e1bb8 100644
--- 
a/examples/celix-examples/services_example_cxx/bar/private/include/BarActivator.h
+++ b/examples/celix-examples/services_example_cxx/bar/src/BarActivator.h
@@ -20,17 +20,17 @@
 #ifndef BAR_ACTIVATOR_H
 #define BAR_ACTIVATOR_H
 
-#include "celix/dm/DmActivator.h"
+#include "celix/dm/DependencyManager.h"
 #include "example.h"
 
 using namespace celix::dm;
 
-class BarActivator : public DmActivator {
+class BarActivator  {
 private:
     example_t cExample {nullptr, nullptr};
 public:
-    BarActivator(DependencyManager& mng) : DmActivator(mng) {}
-    virtual void init() override;
+    BarActivator(std::shared_ptr<DependencyManager> mng);
+
 };
 
 #endif //BAR_ACTIVATOR_H
diff --git a/examples/celix-examples/services_example_cxx/baz/CMakeLists.txt 
b/examples/celix-examples/services_example_cxx/baz/CMakeLists.txt
index ce5bfd0..c0d1924 100644
--- a/examples/celix-examples/services_example_cxx/baz/CMakeLists.txt
+++ b/examples/celix-examples/services_example_cxx/baz/CMakeLists.txt
@@ -15,27 +15,11 @@
 # specific language governing permissions and limitations
 # under the License.
 
-include_directories(
-        private/include
-)
-
 add_celix_bundle(baz_cxx
     SYMBOLIC_NAME Baz
     VERSION 1.0.0
     SOURCES
-        private/src/Baz.cc
-        private/src/BazActivator.cc
+        src/Baz.cc
+        src/BazActivator.cc
 )
-
-target_compile_options(baz_cxx PUBLIC -Wall -Wextra -Weffc++ -Werror)
-
-IF(APPLE)
-    target_link_libraries(baz_cxx PRIVATE  -Wl,-all_load  
dependency_manager_cxx_static)
-else()
-    if(ENABLE_ADDRESS_SANITIZER)
-        #With asan there can be undefined symbols
-        target_link_libraries(baz_cxx PRIVATE -Wl,--whole-archive  
dependency_manager_cxx_static -Wl,--no-whole-archive)
-    else()
-        target_link_libraries(baz_cxx PRIVATE -Wl,--no-undefined 
-Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive)
-    endif()
-endif()
+target_link_libraries(baz_cxx PRIVATE services_example_cxx_api)
diff --git 
a/examples/celix-examples/services_example_cxx/baz/private/src/Baz.cc 
b/examples/celix-examples/services_example_cxx/baz/src/Baz.cc
similarity index 100%
rename from examples/celix-examples/services_example_cxx/baz/private/src/Baz.cc
rename to examples/celix-examples/services_example_cxx/baz/src/Baz.cc
diff --git 
a/examples/celix-examples/services_example_cxx/baz/private/include/Baz.h 
b/examples/celix-examples/services_example_cxx/baz/src/Baz.h
similarity index 100%
rename from 
examples/celix-examples/services_example_cxx/baz/private/include/Baz.h
rename to examples/celix-examples/services_example_cxx/baz/src/Baz.h
diff --git 
a/examples/celix-examples/services_example_cxx/baz/private/src/BazActivator.cc 
b/examples/celix-examples/services_example_cxx/baz/src/BazActivator.cc
similarity index 88%
rename from 
examples/celix-examples/services_example_cxx/baz/private/src/BazActivator.cc
rename to examples/celix-examples/services_example_cxx/baz/src/BazActivator.cc
index 3f17b5a..2bd28a3 100644
--- 
a/examples/celix-examples/services_example_cxx/baz/private/src/BazActivator.cc
+++ b/examples/celix-examples/services_example_cxx/baz/src/BazActivator.cc
@@ -19,16 +19,13 @@
 
 #include "Baz.h"
 #include "BazActivator.h"
+#include <celix_bundle_activator.h>
 
 using namespace celix::dm;
 
-DmActivator* DmActivator::create(DependencyManager& mng) {
-    return new BazActivator(mng);
-}
-
-void BazActivator::init() {
+BazActivator::BazActivator(std::shared_ptr<DependencyManager> mng) {
 
-    Component<Baz>& cmp = mng.createComponent<Baz>()
+    Component<Baz>& cmp = mng->createComponent<Baz>()
         .setCallbacks(nullptr, &Baz::start, &Baz::stop, nullptr);
 
     cmp.createServiceDependency<IAnotherExample>()
@@ -42,4 +39,6 @@ void BazActivator::init() {
             .setStrategy(DependencyUpdateStrategy::locking)
             .setVersionRange(EXAMPLE_CONSUMER_RANGE)
             .setCallbacks(&Baz::addExample, &Baz::removeExample);
-}
\ No newline at end of file
+}
+
+CELIX_GEN_CXX_BUNDLE_ACTIVATOR(BazActivator)
\ No newline at end of file
diff --git 
a/examples/celix-examples/services_example_cxx/baz/private/include/BazActivator.h
 b/examples/celix-examples/services_example_cxx/baz/src/BazActivator.h
similarity index 83%
rename from 
examples/celix-examples/services_example_cxx/baz/private/include/BazActivator.h
rename to examples/celix-examples/services_example_cxx/baz/src/BazActivator.h
index fe24918..445002d 100644
--- 
a/examples/celix-examples/services_example_cxx/baz/private/include/BazActivator.h
+++ b/examples/celix-examples/services_example_cxx/baz/src/BazActivator.h
@@ -20,15 +20,13 @@
 #ifndef BAZ_ACTIVATOR_H
 #define BAZ_ACTIVATOR_H
 
-#include "celix/dm/DmActivator.h"
+#include "celix/dm/DependencyManager.h"
 
 using namespace celix::dm;
 
-class BazActivator : public DmActivator {
-private:
+class BazActivator  {
 public:
-    BazActivator(DependencyManager& mng) : DmActivator(mng) {}
-    virtual void init() override;
+    BazActivator(std::shared_ptr<DependencyManager> mng);
 };
 
 #endif //BAZ_ACTIVATOR_H
diff --git a/examples/celix-examples/services_example_cxx/foo/CMakeLists.txt 
b/examples/celix-examples/services_example_cxx/foo/CMakeLists.txt
index ba2aa55..b904863 100644
--- a/examples/celix-examples/services_example_cxx/foo/CMakeLists.txt
+++ b/examples/celix-examples/services_example_cxx/foo/CMakeLists.txt
@@ -15,27 +15,12 @@
 # specific language governing permissions and limitations
 # under the License.
 
-include_directories(
-        private/include
-)
-
 add_celix_bundle(foo_cxx
     SYMBOLIC_NAME Foo
     VERSION 1.0.0
     SOURCES
-        private/src/Foo.cc
-        private/src/FooActivator.cc
+        src/Foo.cc
+        src/FooActivator.cc
 )
+target_link_libraries(foo_cxx PRIVATE services_example_cxx_api)
 
-target_compile_options(foo_cxx PUBLIC -Wall -Wextra -Weffc++ -Werror)
-
-IF(APPLE)
-    target_link_libraries(foo_cxx PRIVATE -Wl,-all_load  
dependency_manager_cxx_static)
-else()
-    if(ENABLE_ADDRESS_SANITIZER)
-        #With asan there can be undefined symbols
-        target_link_libraries(foo_cxx PRIVATE -Wl,--whole-archive  
dependency_manager_cxx_static -Wl,--no-whole-archive)
-    else()
-        target_link_libraries(foo_cxx PRIVATE -Wl,--no-undefined 
-Wl,--whole-archive  dependency_manager_cxx_static -Wl,--no-whole-archive)
-    endif()
-endif()
diff --git 
a/examples/celix-examples/services_example_cxx/foo/private/src/Foo.cc 
b/examples/celix-examples/services_example_cxx/foo/src/Foo.cc
similarity index 100%
rename from examples/celix-examples/services_example_cxx/foo/private/src/Foo.cc
rename to examples/celix-examples/services_example_cxx/foo/src/Foo.cc
diff --git 
a/examples/celix-examples/services_example_cxx/foo/private/include/Foo.h 
b/examples/celix-examples/services_example_cxx/foo/src/Foo.h
similarity index 100%
rename from 
examples/celix-examples/services_example_cxx/foo/private/include/Foo.h
rename to examples/celix-examples/services_example_cxx/foo/src/Foo.h
diff --git 
a/examples/celix-examples/services_example_cxx/foo/private/src/FooActivator.cc 
b/examples/celix-examples/services_example_cxx/foo/src/FooActivator.cc
similarity index 86%
rename from 
examples/celix-examples/services_example_cxx/foo/private/src/FooActivator.cc
rename to examples/celix-examples/services_example_cxx/foo/src/FooActivator.cc
index fba10ce..03ddd4a 100644
--- 
a/examples/celix-examples/services_example_cxx/foo/private/src/FooActivator.cc
+++ b/examples/celix-examples/services_example_cxx/foo/src/FooActivator.cc
@@ -19,16 +19,13 @@
 
 #include "Foo.h"
 #include "FooActivator.h"
+#include <celix_bundle_activator.h>
 
 using namespace celix::dm;
 
-DmActivator* DmActivator::create(DependencyManager& mng) {
-    return new FooActivator(mng);
-}
-
-void FooActivator::init() {
+FooActivator::FooActivator(std::shared_ptr<DependencyManager> mng) {
 
-    Component<Foo>& cmp = mng.createComponent<Foo>()
+    Component<Foo>& cmp = mng->createComponent<Foo>()
         .setCallbacks(nullptr, &Foo::start, &Foo::stop, nullptr);
 
     cmp.createServiceDependency<IAnotherExample>()
@@ -40,4 +37,6 @@ void FooActivator::init() {
             .setRequired(false)
             .setVersionRange(EXAMPLE_CONSUMER_RANGE)
             .setCallbacks(&Foo::setExample);
-}
\ No newline at end of file
+}
+
+CELIX_GEN_CXX_BUNDLE_ACTIVATOR(FooActivator)
\ No newline at end of file
diff --git 
a/examples/celix-examples/services_example_cxx/foo/private/include/FooActivator.h
 b/examples/celix-examples/services_example_cxx/foo/src/FooActivator.h
similarity index 83%
rename from 
examples/celix-examples/services_example_cxx/foo/private/include/FooActivator.h
rename to examples/celix-examples/services_example_cxx/foo/src/FooActivator.h
index 2917cbd..664a515 100644
--- 
a/examples/celix-examples/services_example_cxx/foo/private/include/FooActivator.h
+++ b/examples/celix-examples/services_example_cxx/foo/src/FooActivator.h
@@ -20,15 +20,13 @@
 #ifndef FOO_ACTIVATOR_H
 #define FOO_ACTIVATOR_H
 
-#include "celix/dm/DmActivator.h"
+#include "celix/dm/DependencyManager.h"
 
 using namespace celix::dm;
 
-class FooActivator : public DmActivator {
-private:
+class FooActivator  {
 public:
-    FooActivator(DependencyManager& mng) : DmActivator(mng) {}
-    virtual void init() override;
+    FooActivator(std::shared_ptr<DependencyManager> mng);
 };
 
 #endif //FOO_ACTIVATOR_H
diff --git a/examples/celix-examples/service_hook_example/CMakeLists.txt 
b/examples/celix-examples/track_tracker_example/CMakeLists.txt
similarity index 85%
rename from examples/celix-examples/service_hook_example/CMakeLists.txt
rename to examples/celix-examples/track_tracker_example/CMakeLists.txt
index 9dbe7c0..241c42f 100644
--- a/examples/celix-examples/service_hook_example/CMakeLists.txt
+++ b/examples/celix-examples/track_tracker_example/CMakeLists.txt
@@ -15,16 +15,15 @@
 # specific language governing permissions and limitations
 # under the License.
 
-add_celix_bundle(hook_example
-    BUNDLE_SYMBOLICNAME "Hook_Example"
+add_celix_bundle(track_tracker_example
     VERSION "1.0.0"
     SOURCES
-        src/activator
+        src/activator.c
 )
 
-add_celix_container(hook_service_example
+add_celix_container(track_tracker_example_cnt
     BUNDLES
         Celix::shell
         Celix::shell_tui
-        hook_example
+        track_tracker_example
 )
diff --git a/examples/celix-examples/track_tracker_example/src/activator.c 
b/examples/celix-examples/track_tracker_example/src/activator.c
new file mode 100644
index 0000000..f8f675b
--- /dev/null
+++ b/examples/celix-examples/track_tracker_example/src/activator.c
@@ -0,0 +1,103 @@
+/**
+ *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 <unistd.h>
+#include <stdio.h>
+
+#include <celix_api.h>
+
+#define CALC_SERVICE_NAME   "CALC_SERVICE"
+typedef struct calc_service {
+    void *handle;
+    int (*calc)(void *handle, int a);
+} calc_service_t;
+
+typedef struct activator_data {
+    int incr;
+
+    long trackerId;
+
+    long calcTrk1;
+    long calcTrk2;
+
+    calc_service_t svc;
+    long svcId;
+} activator_data_t;
+
+static void addCalcTracker(void *handle, const celix_service_tracker_info_t 
*info) {
+    activator_data_t *act = handle;
+    printf("Calc service tracker created with filter '%s'. Tracked with 
tracker id %li\n", info->filter->filterStr, act->trackerId);
+    const char *prop1Val = celix_filter_findAttribute(info->filter, "prop1");
+    const char *prop2Val = celix_filter_findAttribute(info->filter, "prop2");
+    printf("Found filter attribute value for prop1: %s and prop2: %s\n", 
prop1Val, prop2Val);
+}
+
+static void removeCalcTracker(void *handle, const celix_service_tracker_info_t 
*info) {
+    activator_data_t *act = handle;
+    printf("Calc service tracker with filter '%s' removed. Tracked with 
tracker id %li\n", info->filter->filterStr, act->trackerId);
+}
+
+static void addCalcSvc(void* handle __attribute__((unused)), void* svc) {
+    calc_service_t *calc = svc;
+    printf("Calc service added. result calc(2) is %i\n", 
calc->calc(calc->handle, 2));
+}
+
+static void removeCalcSvc(void* handle __attribute__((unused)), void* svc 
__attribute__((unused))) {
+    printf("Calc service removed\n");
+}
+
+static int calc(void *handle, int a) {
+    activator_data_t *act = handle;
+    return act->incr + a;
+}
+
+celix_status_t activator_start(activator_data_t* act, celix_bundle_context_t 
*ctx) {
+    act->incr = 42;
+
+    act->trackerId = celix_bundleContext_trackServiceTrackers(ctx, 
CALC_SERVICE_NAME, act, addCalcTracker, removeCalcTracker);
+
+    act->calcTrk1 = celix_bundleContext_trackServices(ctx, CALC_SERVICE_NAME, 
act, addCalcSvc, removeCalcSvc);
+
+    celix_service_tracking_options_t opts = 
CELIX_EMPTY_SERVICE_TRACKING_OPTIONS;
+    opts.filter.serviceName = CALC_SERVICE_NAME;
+    opts.filter.filter = "(&(prop1=val1)(prop2=val2))";
+    opts.callbackHandle = act;
+    opts.add = addCalcSvc;
+    opts.remove = removeCalcSvc;
+    act->calcTrk2 = celix_bundleContext_trackServicesWithOptions(ctx, &opts);
+
+    act->svc.handle = act;
+    act->svc.calc = calc;
+    //note only triggers on calcTrk1, because of filter restrictions
+    act->svcId = celix_bundleContext_registerService(ctx, &act->svc, 
CALC_SERVICE_NAME, NULL);
+
+    return CELIX_SUCCESS;
+}
+
+celix_status_t activator_stop(activator_data_t* act, celix_bundle_context_t 
*ctx) {
+    celix_bundleContext_unregisterService(ctx, act->svcId);
+    usleep(1000);
+    celix_bundleContext_stopTracker(ctx, act->calcTrk1);
+    celix_bundleContext_stopTracker(ctx, act->calcTrk2);
+    usleep(1000);
+    celix_bundleContext_stopTracker(ctx, act->trackerId);
+    return CELIX_SUCCESS;
+}
+
+CELIX_GEN_BUNDLE_ACTIVATOR(activator_data_t, activator_start, activator_stop);
\ No newline at end of file
diff --git a/libs/dependency_manager_cxx/CMakeLists.txt 
b/libs/dependency_manager_cxx/CMakeLists.txt
index 886b06d..1669e11 100644
--- a/libs/dependency_manager_cxx/CMakeLists.txt
+++ b/libs/dependency_manager_cxx/CMakeLists.txt
@@ -20,6 +20,7 @@ add_library(dependency_manager_cxx_static STATIC
 )
 set_target_properties(dependency_manager_cxx_static PROPERTIES OUTPUT_NAME 
"celix_dependency_manager_cxx_static")
 target_compile_options(dependency_manager_cxx_static PRIVATE -fPIC)
+target_compile_options(dependency_manager_cxx_static PRIVATE 
-Wno-deprecated-declarations)
 if (APPLE)
     target_link_libraries(dependency_manager_cxx_static Celix::framework 
"-undefined dynamic_lookup")
 else()
diff --git a/libs/dependency_manager_cxx/src/dm_activator.cc 
b/libs/dependency_manager_cxx/src/dm_activator.cc
index 6ac02c5..3017422 100644
--- a/libs/dependency_manager_cxx/src/dm_activator.cc
+++ b/libs/dependency_manager_cxx/src/dm_activator.cc
@@ -25,6 +25,9 @@
 #include "bundle_activator.h"
 
 
+/**
+ * Deprecated. Use the CELIX_GEN_CXX_BUNDLE_ACTIVATOR marco from 
celix_bundle_activator.h instead
+ */
 struct BundleActivatorData {
     DependencyManager mng;
     std::unique_ptr<celix::dm::DmActivator> act;
diff --git a/libs/framework/include/celix/dm/DmActivator.h 
b/libs/framework/include/celix/dm/DmActivator.h
index 55a7573..9370695 100644
--- a/libs/framework/include/celix/dm/DmActivator.h
+++ b/libs/framework/include/celix/dm/DmActivator.h
@@ -28,7 +28,7 @@
 
 namespace celix { namespace dm {
 
-    class DmActivator {
+    class __attribute__((deprecated)) DmActivator {
     public:
         DmActivator(DependencyManager& m) : mng(m), ctx{m.bundleContext()}  {}
         virtual ~DmActivator() = default;
diff --git a/libs/framework/include/celix_bundle_activator.h 
b/libs/framework/include/celix_bundle_activator.h
index 9bb2f6a..e8568be 100644
--- a/libs/framework/include/celix_bundle_activator.h
+++ b/libs/framework/include/celix_bundle_activator.h
@@ -100,10 +100,10 @@ celix_status_t celix_bundleActivator_destroy(void 
*userData, celix_bundle_contex
 
 
 /**
- * This macro generated the required bundle activator functions. These can be 
used to more type safe bundle activator
- * entries.
+ * This macro generates the required bundle activator functions for C.
+ * This can be used to more type safe bundle activator entries.
  *
- * The macro will create the following bundlea activator functions:
+ * The macro will create the following bundle activator functions:
  * - bundleActivator_create which allocates a pointer to the provided type.
  * - bundleActivator_start/stop which will call the respectively provided 
typed start/stop functions.
  * - bundleActivator_destroy will free the allocated for the provided type.
@@ -139,10 +139,77 @@ celix_status_t celix_bundleActivator_destroy(void 
*userData, celix_bundle_contex
 
 #ifdef __cplusplus
 }
-#endif
 
-#endif /* CELIX_BUNDLE_ACTIVATOR_H_ */
 
 /**
- * @}
+ * This macro generates the required bundle activator functions for C++.
+ * This can be used to more type safe bundle activator entries.
+ *
+ * The macro will create the following bundle activator functions:
+ * - bundleActivator_create which allocates a pointer to the provided type.
+ * - bundleActivator_start/stop which will call the respectively provided 
typed start/stop functions.
+ * - bundleActivator_destroy will free the allocated for the provided type.
+ *
+ * @param type The activator type (e.g. 'ShellActivator'). A type which should 
have a constructor with a single arugment of std::shared_ptr<DependencyManager>.
  */
+#define CELIX_GEN_CXX_BUNDLE_ACTIVATOR(actType)                                
                                        \
+                                                                               
                                        \
+namespace /*anon*/ {                                                           
                                        \
+struct BundleActivatorData {                                                   
                                        \
+    std::shared_ptr<DependencyManager> mng{};                                  
                                        \
+    std::unique_ptr<actType> activator{};                                      
                                        \
+};                                                                             
                                        \
+}                                                                              
                                        \
+                                                                               
                                        \
+extern "C" celix_status_t bundleActivator_create(celix_bundle_context_t 
*context, void** userData) {                   \
+    int status = CELIX_SUCCESS;                                                
                                        \
+                                                                               
                                        \
+    BundleActivatorData* data = nullptr;                                       
                                        \
+    data = new BundleActivatorData{};                                          
                                        \
+    if (data != nullptr) {                                                     
                                        \
+        data->mng = std::shared_ptr<celix::dm::DependencyManager>{new 
celix::dm::DependencyManager{context}};          \
+    }                                                                          
                                        \
+                                                                               
                                        \
+    if (data == nullptr || data->mng == nullptr) {                             
                                        \
+        status = CELIX_ENOMEM;                                                 
                                        \
+        if (data != nullptr) {                                                 
                                        \
+            delete data;                                                       
                                        \
+        }                                                                      
                                        \
+        *userData = nullptr;                                                   
                                        \
+    } else {                                                                   
                                        \
+        *userData = data;                                                      
                                        \
+    }                                                                          
                                        \
+    return status;                                                             
                                        \
+}                                                                              
                                        \
+                                                                               
                                        \
+extern "C" celix_status_t bundleActivator_start(void *userData, 
celix_bundle_context_t *) {                            \
+    auto* data = static_cast<BundleActivatorData*>(userData);                  
                                        \
+    if (data != nullptr) {                                                     
                                        \
+        data->activator = std::unique_ptr<actType>{new actType{data->mng}};    
                                        \
+        data->mng->start();                                                    
                                        \
+    }                                                                          
                                        \
+    return CELIX_SUCCESS;                                                      
                                        \
+}                                                                              
                                        \
+                                                                               
                                        \
+extern "C" celix_status_t bundleActivator_stop(void *userData, 
celix_bundle_context_t*) {                              \
+    auto* data = static_cast<BundleActivatorData*>(userData);                  
                                        \
+    if (data != nullptr) {                                                     
                                        \
+        data->mng->stop();                                                     
                                        \
+        data->activator = nullptr;                                             
                                        \
+        data->mng = nullptr;                                                   
                                        \
+    }                                                                          
                                        \
+    return CELIX_SUCCESS;                                                      
                                        \
+}                                                                              
                                        \
+                                                                               
                                        \
+extern "C" celix_status_t bundleActivator_destroy(void *userData, 
celix_bundle_context_t*) {                           \
+    auto* data = static_cast<BundleActivatorData*>(userData);                  
                                        \
+    if (data != nullptr) {                                                     
                                        \
+        delete data;                                                           
                                        \
+    }                                                                          
                                        \
+    return CELIX_SUCCESS;                                                      
                                        \
+}                                                                              
                                        \
+
+
+#endif
+
+#endif /* CELIX_BUNDLE_ACTIVATOR_H_ */
\ No newline at end of file
diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c
index 1e61138..b15dde4 100644
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@ -1166,6 +1166,9 @@ celix_status_t fw_stopBundle(framework_pt framework, 
bundle_pt bundle, bool reco
                 }
 
                 status = CELIX_DO_IF(status, 
framework_setBundleStateAndNotify(framework, bundle, 
OSGI_FRAMEWORK_BUNDLE_RESOLVED));
+            } else if (bndId == 0) {
+                //framework bundle
+                
celix_serviceTracker_syncForContext(framework->bundle->context);
             }
            }
 

Reply via email to