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 2016/01/06 15:39:59 UTC
[3/5] celix git commit: CELIX-77: Update config_admin implementation
CELIX-77: Update config_admin implementation
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/d3c94184
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/d3c94184
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/d3c94184
Branch: refs/heads/develop
Commit: d3c94184e570ecb0c73d41d006f64412e6959fa5
Parents: 62f65cf
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Wed Jan 6 15:14:47 2016 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Wed Jan 6 15:14:47 2016 +0100
----------------------------------------------------------------------
CMakeLists.txt | 1 +
config_admin/CMakeLists.txt | 25 +-
config_admin/config_admin_tst/CMakeLists.txt | 51 +++
.../config_admin_tst/config.properties.in | 20 +
.../config_admin_tst/config_admin_test.cpp | 404 +++++++++++++++++++
.../example_test/CMakeLists.txt | 32 ++
.../example_test/META-INF/MANIFEST.MF | 5 +
.../include/example_managed_service_impl.h | 67 +++
.../example_test/private/src/activator.c | 205 ++++++++++
.../private/src/example_managed_service_impl.c | 97 +++++
.../example_test2/CMakeLists.txt | 32 ++
.../example_test2/META-INF/MANIFEST.MF | 5 +
.../include/example2_managed_service_impl.h | 65 +++
.../example_test2/private/src/activator.c | 225 +++++++++++
.../private/src/example_managed_service_impl.c | 103 +++++
config_admin/examples/CMakeLists.txt | 21 -
.../examples/example_test/CMakeLists.txt | 32 --
.../examples/example_test/META-INF/MANIFEST.MF | 5 -
.../include/example_managed_service_impl.h | 53 ---
.../example_test/private/src/activator.c | 188 ---------
.../private/src/example_managed_service_impl.c | 94 -----
.../examples/example_test2/CMakeLists.txt | 21 -
.../bundle_configuring/CMakeLists.txt | 30 --
.../bundle_configuring/META-INF/MANIFEST.MF | 5 -
.../bundle_configuring/private/src/activator.c | 94 -----
.../bundle_managed_service/CMakeLists.txt | 32 --
.../bundle_managed_service/META-INF/MANIFEST.MF | 5 -
.../include/example_managed_service_impl.h | 55 ---
.../private/src/activator.c | 120 ------
.../private/src/example_managed_service_impl.c | 95 -----
config_admin/readme.md | 29 ++
.../include/configuration_admin_factory.h | 2 +-
.../private/include/configuration_impl.h | 36 +-
.../private/include/configuration_store.h | 1 +
.../private/include/managed_service_tracker.h | 9 +-
.../private/include/updated_thread_pool.h | 8 +-
config_admin/service/private/src/activator.c | 10 +-
.../private/src/configuration_admin_factory.c | 25 +-
.../private/src/configuration_admin_impl.c | 13 +-
.../service/private/src/configuration_impl.c | 313 ++++++++------
.../service/private/src/configuration_store.c | 78 ++--
.../service/private/src/managed_service_impl.c | 5 +
.../private/src/managed_service_tracker.c | 166 ++++----
.../service/private/src/updated_thread_pool.c | 41 +-
.../service/public/include/configuration.h | 27 +-
.../service/public/include/managed_service.h | 2 +-
framework/private/src/service_registry.c | 4 +-
47 files changed, 1794 insertions(+), 1162 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9453411..4670987 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,6 +39,7 @@ ENDIF()
IF(UNIX)
SET(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=gnu99 -Wall -Werror ${CMAKE_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS "-Wall -Werror ${CMAKE_CXX_FLAGS}")
ENDIF()
IF(UNIX AND NOT APPLE)
SET(CMAKE_C_FLAGS "-pthread ${CMAKE_C_FLAGS}")
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/CMakeLists.txt b/config_admin/CMakeLists.txt
index 8075c31..3801e6e 100644
--- a/config_admin/CMakeLists.txt
+++ b/config_admin/CMakeLists.txt
@@ -20,6 +20,29 @@ celix_subproject(CONFIG_ADMIN "Option to enable building the Config Admin Servic
if (CONFIG_ADMIN)
add_subdirectory(service)
- add_subdirectory(examples)
+# add_subdirectory(examples)
+
+ if (ENABLE_TESTING)
+ find_package(CppUTest REQUIRED)
+
+ include_directories(${CPPUTEST_INCLUDE_DIR})
+ add_subdirectory(config_admin_tst)
+# find_package(CppUTest REQUIRED)
+#
+# include_directories(${CUNIT_INCLUDE_DIRS})
+# include_directories(${CPPUTEST_INCLUDE_DIR})
+# include_directories("${PROJECT_SOURCE_DIR}/config_admin/service/public/include")
+# include_directories("${PROJECT_SOURCE_DIR}/config_admin/service/private/include")
+# include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+#
+# add_executable(config_admin_test config_admin_tst/config_admin_test.cpp)
+# target_link_libraries(config_admin_test celix_utils ${CPPUTEST_LIBRARY} pthread)
+#
+#
+# add_test(NAME run_config_admin_test COMMAND config_admin_test)
+# SETUP_TARGET_FOR_COVERAGE(config_admin_test config_admin_test ${CMAKE_BINARY_DIR}/coverage/config_admin_test/config_admin_test)
+
+ endif(ENABLE_TESTING)
+
endif (CONFIG_ADMIN)
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/config_admin_tst/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/CMakeLists.txt b/config_admin/config_admin_tst/CMakeLists.txt
new file mode 100644
index 0000000..ee2e2ec
--- /dev/null
+++ b/config_admin/config_admin_tst/CMakeLists.txt
@@ -0,0 +1,51 @@
+# 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_directories(
+ ${PROJECT_SOURCE_DIR}/framework/public/include
+ ${PROJECT_SOURCE_DIR}/utils/public/include
+ ${PROJECT_SOURCE_DIR}/utils/public/include
+ ${PROJECT_SOURCE_DIR}/config_admin/service/public/include
+ example_test/private/include
+ example_test2/private/include
+)
+
+add_subdirectory(example_test)
+add_subdirectory(example_test2)
+
+SET(CMAKE_SKIP_BUILD_RPATH FALSE) #TODO needed?
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) #TODO needed?
+SET(CMAKE_INSTALL_RPATH "${PROJECT_BINARY_DIR}/framework" "${PROJECT_BINARY_DIR}/utils" )
+
+add_executable(config_admin_test config_admin_test.cpp)
+target_link_libraries(config_admin_test celix_framework ${CELIX_LIBRARIES} ${CPPUTEST_LIBRARY} pthread)
+
+
+get_property(config_admin_bundle_file TARGET config_admin PROPERTY BUNDLE)
+get_property(example_test_bundle_file TARGET example_test PROPERTY BUNDLE)
+get_property(example_test2_bundle_file TARGET example_test2 PROPERTY BUNDLE)
+
+configure_file(config.properties.in config.properties @ONLY)
+#configure_file(client.properties.in client.properties @ONLY)
+#configure_file(server.properties.in server.properties @ONLY)
+
+#add_dependencies(test_rsa_dfi remote_service_admin_dfi calculator)
+
+
+#ADD_TARGET_FOR_TEST(config_admin_test)
+add_test(NAME run_config_admin_test COMMAND config_admin_test)
+SETUP_TARGET_FOR_COVERAGE(config_admin_test config_admin_test ${CMAKE_BINARY_DIR}/coverage/config_admin_test/config_admin_test)
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/config_admin_tst/config.properties.in
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/config.properties.in b/config_admin/config_admin_tst/config.properties.in
new file mode 100644
index 0000000..7e8c14d
--- /dev/null
+++ b/config_admin/config_admin_tst/config.properties.in
@@ -0,0 +1,20 @@
+# 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.
+
+cosgi.auto.start.1=@config_admin_bundle_file@ @example_test_bundle_file@ @example_test2_bundle_file@
+LOGHELPER_ENABLE_STDOUT_FALLBACK=true
+org.osgi.framework.storage.clean=onFirstInit
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/config_admin_tst/config_admin_test.cpp
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/config_admin_test.cpp b/config_admin/config_admin_tst/config_admin_test.cpp
new file mode 100644
index 0000000..8215f15
--- /dev/null
+++ b/config_admin/config_admin_tst/config_admin_test.cpp
@@ -0,0 +1,404 @@
+/**
+ *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.
+ */
+/*
+ * array_list_test.cpp
+ *
+ * \date Sep 15, 2015
+ * \author Menno van der Graaf & Alexander
+ * \copyright Apache License, Version 2.0
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "CppUTest/TestHarness.h"
+#include "CppUTest/TestHarness_c.h"
+#include "CppUTest/CommandLineTestRunner.h"
+
+extern "C" {
+#include "celix_threads.h"
+#include "array_list.h"
+
+#include "celix_launcher.h"
+#include "constants.h"
+#include "framework.h"
+#include "configuration_admin.h"
+#include "example_managed_service_impl.h"
+#include "example2_managed_service_impl.h"
+
+
+static framework_pt framework = NULL;
+static bundle_context_pt context = NULL;
+
+service_reference_pt confAdminRef = NULL;
+configuration_admin_service_pt confAdminServ = NULL;
+
+service_reference_pt testRef = NULL;
+tst_service_pt testServ = NULL;
+
+service_reference_pt test2Ref = NULL;
+tst2_service_pt test2Serv = NULL;
+
+ void setupFw(void) {
+ int rc = 0;
+
+ rc = celixLauncher_launch("config.properties", &framework);
+ CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+ bundle_pt bundle = NULL;
+ rc = framework_getFrameworkBundle(framework, &bundle);
+ CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+ rc = bundle_getContext(bundle, &context);
+ CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+ rc = bundleContext_getServiceReference(context, (char *) CONFIGURATION_ADMIN_SERVICE_NAME, &confAdminRef);
+ CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+ rc = bundleContext_getService(context, confAdminRef, (void **) &confAdminServ);
+ CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+ rc = bundleContext_getServiceReference(context, (char *) TST_SERVICE_NAME, &testRef);
+ CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+ rc = bundleContext_getService(context, testRef, (void **)&testServ);
+ CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+ rc = bundleContext_getServiceReference(context, (char *) TST2_SERVICE_NAME, &test2Ref);
+ CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+ rc = bundleContext_getService(context, testRef, (void **)&test2Serv);
+ CHECK_EQUAL(CELIX_SUCCESS, rc);
+ }
+
+ void teardownFw(void) {
+ int rc = 0;
+
+ rc = bundleContext_ungetService(context, testRef, NULL);
+ CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+ rc = bundleContext_ungetServiceReference(context, testRef);
+ CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+ rc = bundleContext_ungetService(context, test2Ref, NULL);
+ CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+ rc = bundleContext_ungetServiceReference(context, test2Ref);
+ CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+ rc = bundleContext_ungetService(context, confAdminRef, NULL);
+ CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+ rc = bundleContext_ungetServiceReference(context, confAdminRef);
+ CHECK_EQUAL(CELIX_SUCCESS, rc);
+
+ celixLauncher_stop(framework);
+ celixLauncher_waitForShutdown(framework);
+ celixLauncher_destroy(framework);
+
+ test2Ref = NULL;
+ test2Serv = NULL;
+ testRef = NULL;
+ testServ = NULL;
+ confAdminRef = NULL;
+ confAdminServ = NULL;
+ context = NULL;
+ framework = NULL;
+ }
+
+ static void cleanUp(void) {
+ system("rm -rf .cache");
+ system("rm -rf store");
+ }
+ static void testBundles(void) {
+ printf("begin: %s\n", __func__);
+ array_list_pt bundles = NULL;
+
+ int rc = bundleContext_getBundles(context, &bundles);
+ CHECK_EQUAL(0, rc);
+ CHECK_EQUAL(4, arrayList_size(bundles)); //framework, config_admin, example_test, example_test2
+ arrayList_destroy(bundles);
+ printf("end: %s\n", __func__);
+ }
+
+
+ static void testManagedService(void) {
+ printf("begin: %s\n", __func__);
+ const char *pid = "base.device1";
+ char value[80];
+ properties_pt properties;
+ /* ------------------ get Configuration -------------------*/
+
+ configuration_pt configuration;
+ (*confAdminServ->getConfiguration)(confAdminServ->configAdmin,(char *)pid, &configuration);
+ configuration->configuration_getProperties(configuration->handle, &properties);
+ CHECK((properties == NULL));
+ testServ->get_type(testServ->handle, value);
+ CHECK_TEXT("default_value", value);
+
+ /* ------------------ clear configuration ----------------*/
+ configuration->configuration_update(configuration->handle , NULL);
+ sleep(1);
+ /* check if it is also cleared in the service */
+ testServ->get_type(testServ->handle, value);
+ CHECK_TEXT("", value);
+
+ /* ------------------ update Configuration ----------------*/
+ const char *prop1 = "type";
+ const char *value1 = "printer";
+ properties = properties_create();
+ properties_set(properties, (char *)prop1, (char *)value1);
+ // configuration_update transfers ownership of properties structure to the configuration object
+ configuration->configuration_update(configuration->handle , properties);
+
+ sleep(1);
+ testServ->get_type(testServ->handle, value);
+ CHECK_TEXT("printer", value);
+ properties = NULL;
+ configuration->configuration_getProperties(configuration->handle, &properties);
+ if (properties != NULL) {
+ char *test_value = properties_get(properties, (char*)OSGI_FRAMEWORK_SERVICE_PID);
+ CHECK_TEXT("base.device1", test_value);
+ test_value = properties_get(properties, (char *)prop1);
+ CHECK_TEXT("printer", test_value);
+ }
+ printf("end: %s\n", __func__);
+ }
+
+ static void testManagedServicePersistent(void) {
+ printf("begin: %s\n", __func__);
+ const char *pid = "base.device1";
+ properties_pt properties = NULL;
+ const char *key = "type";
+ /* ------------------ get Configuration -------------------*/
+
+ configuration_pt configuration;
+ (*confAdminServ->getConfiguration)(confAdminServ->configAdmin, (char *)pid, &configuration);
+ configuration->configuration_getProperties(configuration->handle, &properties);
+ CHECK((properties != NULL));
+ if (properties != NULL) {
+ char *test_value = properties_get(properties, (char*)OSGI_FRAMEWORK_SERVICE_PID);
+ CHECK_TEXT("base.device1", test_value);
+ test_value = properties_get(properties, (char *)key);
+ CHECK_TEXT("printer", test_value);
+ }
+
+ printf("end: %s\n", __func__);
+ }
+
+ static void testTwoManagedService(void) {
+ printf("begin: %s\n", __func__);
+ const char *pid = "base.device1";
+ const char *tst2Pid = "test2_pid";
+ char value[80];
+ properties_pt properties;
+ properties_pt properties2;
+ /* ------------------ get Configuration -------------------*/
+
+ configuration_pt configuration;
+ configuration_pt configuration2;
+ (*confAdminServ->getConfiguration)(confAdminServ->configAdmin, (char *)pid, &configuration);
+ (*confAdminServ->getConfiguration)(confAdminServ->configAdmin, (char *)tst2Pid, &configuration2);
+
+ /* ------------------ update Configuration ----------------*/
+ const char *prop1 = "type";
+ const char *value1 = "printer";
+ properties = properties_create();
+ properties_set(properties, (char *)prop1, (char *)value1);
+ // configuration_update transfers ownership of properties structure to the configuration object
+ configuration->configuration_update(configuration->handle , properties);
+ properties2 = properties_create();
+ properties_set(properties2, (char *)prop1, (char *)"test2_printer");
+ // configuration_update transfers ownership of properties structure to the configuration object
+ configuration2->configuration_update(configuration2->handle , properties2);
+
+ sleep(1);
+ testServ->get_type(testServ->handle, value);
+ CHECK_TEXT("printer", value);
+ test2Serv->get_type(test2Serv->handle, value);
+ CHECK_TEXT("test2_printer", value);
+ properties = NULL;
+ configuration->configuration_getProperties(configuration->handle, &properties);
+ if (properties != NULL) {
+ char *test_value = properties_get(properties, (char*)OSGI_FRAMEWORK_SERVICE_PID);
+ CHECK_TEXT("base.device1", test_value);
+ test_value = properties_get(properties, (char *)prop1);
+ CHECK_TEXT("printer", test_value);
+ }
+ configuration2->configuration_getProperties(configuration2->handle, &properties);
+ if (properties != NULL) {
+ char *test_value = properties_get(properties, (char*)OSGI_FRAMEWORK_SERVICE_PID);
+ CHECK_TEXT("test2_pid", test_value);
+ test_value = properties_get(properties, (char *)prop1);
+ CHECK_TEXT("test2_printer", test_value);
+ }
+ printf("end: %s\n", __func__);
+ }
+
+ static void testAddManagedServiceProperty(void) {
+ printf("begin: %s\n", __func__);
+ const char *pid = "base.device1";
+ char value[80];
+ properties_pt properties;
+ /* ------------------ get Configuration -------------------*/
+
+ configuration_pt configuration;
+ (*confAdminServ->getConfiguration)(confAdminServ->configAdmin, (char *)pid, &configuration);
+
+ /* ------------------ update Configuration ----------------*/
+ const char *prop1 = "type";
+ const char *value1 = "printer";
+ const char *prop2 = "second_type";
+ const char *value2 = "my_second_value";
+ properties = properties_create();
+ properties_set(properties, (char *)prop1, (char *)value1);
+ // configuration_update transfers ownership of properties structure to the configuration object
+ configuration->configuration_update(configuration->handle , properties);
+ sleep(1);
+ testServ->get_type(testServ->handle, value);
+ CHECK_TEXT("printer", value);
+ configuration->configuration_getProperties(configuration->handle, &properties);
+ CHECK((properties != NULL));
+ properties_set(properties, (char *)prop2, (char *)value2);
+ // extend an existing configuration with a new property
+ configuration->configuration_update(configuration->handle, properties);
+ value2 = NULL;
+ testServ->get_second_type(testServ->handle, value);
+ CHECK_TEXT("my_second_value", value);
+ printf("end: %s\n", __func__);
+ }
+
+ static void testManagedServiceRemoved(void) {
+ printf("begin: %s\n", __func__);
+ const char *pid = "base.device1";
+ char value[80];
+ properties_pt properties = NULL;
+ bundle_pt bundle = NULL;
+ bundle_pt fwBundle = NULL;
+ bundle_archive_pt archive = NULL;
+ bundle_context_pt context = NULL;
+ char *location = NULL;
+ /* ------------------ get Configuration -------------------*/
+
+ configuration_pt configuration;
+ (*confAdminServ->getConfiguration)(confAdminServ->configAdmin, (char *)pid, &configuration);
+
+ /* ------------------ update Configuration ----------------*/
+ const char *prop1 = "type";
+ const char *value1 = "printer";
+ const char *prop2 = "second_type";
+ const char *value2 = "my_second_value";
+ char org_location[128];
+ properties = properties_create();
+ properties_set(properties, (char *)prop1, (char *)value1);
+ properties_set(properties, (char *)prop2, (char *)value2);
+ // configuration_update transfers ownership of properties structure to the configuration object
+ configuration->configuration_update(configuration->handle , properties);
+ sleep(1);
+ serviceReference_getBundle(testRef, &bundle);
+ bundle_getArchive(bundle, &archive);
+ bundle_getBundleLocation(bundle, &location);
+ bundle_stop(bundle);
+ strcpy(org_location, location);
+ configuration->configuration_getProperties(configuration->handle, &properties);
+ bundle_uninstall(bundle);
+ configuration->configuration_getProperties(configuration->handle, &properties);
+ CHECK((properties != NULL));
+ bundle = NULL;
+ framework_getFrameworkBundle(framework, &fwBundle);
+ bundle_getContext(fwBundle, &context);
+ bundleContext_installBundle(context, org_location, &bundle);
+ bundle_startWithOptions(bundle, 0);
+ // extend an existing configuration with a new property
+ configuration->configuration_getProperties(configuration->handle, &properties);
+ CHECK((properties != NULL));
+ testRef = NULL;
+ bundleContext_getServiceReference(context, (char *) TST_SERVICE_NAME, &testRef);
+ testServ = NULL;
+ bundleContext_getService(context, testRef, (void **)&testServ);
+ testServ->get_second_type(testServ->handle, value);
+ CHECK_TEXT("my_second_value", value);
+ printf("end: %s\n", __func__);
+ }
+}
+
+
+
+int main(int argc, char** argv) {
+ return RUN_ALL_TESTS(argc, argv);
+}
+
+
+//----------------------TEST THREAD FUNCTION DECLARATIONS----------------------
+
+//----------------------TESTGROUP DEFINES----------------------
+
+TEST_GROUP(managed_service) {
+
+ void setup(void) {
+ cleanUp();
+ setupFw();
+ }
+
+ void teardown(void) {
+ teardownFw();
+ }
+
+};
+
+TEST_GROUP(managed_service_persistent) {
+
+ void setup(void) {
+ setupFw();
+ }
+
+ void teardown(void) {
+ teardownFw();
+ }
+
+};
+
+// TODO: test service factory PID
+
+//----------------------THREAD_POOL TESTS----------------------
+TEST(managed_service, test_managed_service_removed) {
+ testManagedServiceRemoved();
+}
+
+TEST(managed_service, add_managed_service_property) {
+ testAddManagedServiceProperty();
+}
+
+TEST(managed_service, test_two_managed_service) {
+ testTwoManagedService();
+}
+
+TEST(managed_service_persistent, test_persistent) {
+ testManagedServicePersistent();
+}
+
+TEST(managed_service, test_managed_service) {
+ testManagedService();
+}
+
+TEST(managed_service, test_bundles) {
+ testBundles();
+}
+
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/config_admin_tst/example_test/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/example_test/CMakeLists.txt b/config_admin/config_admin_tst/example_test/CMakeLists.txt
new file mode 100644
index 0000000..7782c0d
--- /dev/null
+++ b/config_admin/config_admin_tst/example_test/CMakeLists.txt
@@ -0,0 +1,32 @@
+# 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_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
+include_directories("${PROJECT_SOURCE_DIR}/config_admin/service/public/include")
+include_directories("private/include")
+
+SET(BUNDLE_SYMBOLICNAME "example_test")
+SET(BUNDLE_VERSION "0.1.0")
+
+bundle(example_test SOURCES
+ private/src/activator
+ private/src/example_managed_service_impl
+)
+
+target_link_libraries(example_test celix_framework celix_utils config_admin)
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/config_admin_tst/example_test/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/example_test/META-INF/MANIFEST.MF b/config_admin/config_admin_tst/example_test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..15593d6
--- /dev/null
+++ b/config_admin/config_admin_tst/example_test/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Bundle-SymbolicName: example_test
+Bundle-Version: 1.0.0
+library: example_test
+Import-Service: configuration_admin
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/config_admin_tst/example_test/private/include/example_managed_service_impl.h
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/example_test/private/include/example_managed_service_impl.h b/config_admin/config_admin_tst/example_test/private/include/example_managed_service_impl.h
new file mode 100644
index 0000000..6f94994
--- /dev/null
+++ b/config_admin/config_admin_tst/example_test/private/include/example_managed_service_impl.h
@@ -0,0 +1,67 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements. See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership. The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * example_managed_service_impl.h
+ *
+ * \date Aug 12, 2013
+ * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+
+#ifndef MANAGED_SERVICE_IMPL_H_
+#define MANAGED_SERVICE_IMPL_H_
+
+
+/* celix.utils*/
+#include "properties.h"
+/* celix.framework */
+#include "celix_errno.h"
+#include "service_registration.h"
+#include "bundle_context.h"
+/* celix.config_admin.ManagedService */
+#include "managed_service.h"
+
+struct test_managed_service{
+
+ bundle_context_pt context;
+
+ service_registration_pt registration;
+ properties_pt properties;
+ void *handle;
+ void (*store_props)(void *handle, char* type, char* second_type);
+
+};
+
+#define TST_SERVICE_NAME "tst_service"
+
+struct tst_service {
+ void *handle;
+ int (*get_type)(void *handle, char *value);
+ int (*get_second_type)(void *handle, char *value);
+};
+
+typedef struct tst_service *tst_service_pt;
+
+celix_status_t managedServiceImpl_create(bundle_context_pt context, managed_service_pt *instance);
+celix_status_t managedServiceImpl_updated(managed_service_pt instance, properties_pt properties);
+
+
+
+#endif /* MANAGED_SERVICE_IMPL_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/config_admin_tst/example_test/private/src/activator.c
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/example_test/private/src/activator.c b/config_admin/config_admin_tst/example_test/private/src/activator.c
new file mode 100644
index 0000000..4adfcaa
--- /dev/null
+++ b/config_admin/config_admin_tst/example_test/private/src/activator.c
@@ -0,0 +1,205 @@
+/**
+ *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 12, 2013
+ * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+/* celix.framework */
+#include "bundle_activator.h"
+#include "bundle_context.h"
+#include "constants.h"
+#include "properties.h"
+#include "utils.h"
+/* celix.utils */
+#include "hash_map.h"
+/* celix.configadmin */
+#include "configuration_admin.h"
+#include "configuration.h"
+#include "managed_service.h"
+#include "service_registration.h"
+/* celix.config_admin.examples.private */
+#include "example_managed_service_impl.h"
+
+
+//static void test_debugConfiguration(configuration_pt configuration, char* pid);
+struct activator {
+ bundle_context_pt context;
+ tst_service_pt tstServ;
+ service_registration_pt tstReg;
+
+// struct managed_service mgmServ;
+ service_registration_pt mgmReg;
+ managed_service_pt mgmServ;
+
+ service_reference_pt configAdminServRef;
+ configuration_admin_service_pt configAdminServ;
+
+ char type_value[125];
+ char second_type_value[125];
+};
+
+
+void store_properties(void *handle, char* type, char* second) {
+ struct activator *act = (struct activator *)handle;
+ if (type == NULL)
+ act->type_value[0] = 0x00;
+ else
+ strcpy(act->type_value, type);
+ if (second == NULL)
+ act->second_type_value[0] = 0x00;
+ else
+ strcpy(act->second_type_value, second);
+}
+int my_get_type(void *handle, char* value) {
+ struct activator *act = (struct activator *)handle;
+ strcpy(value, act->type_value);
+
+ return 0;
+}
+
+int my_get_second_type(void *handle, char* value) {
+ struct activator *act = (struct activator *)handle;
+ strcpy(value, act->second_type_value);
+
+ return 0;
+}
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+ struct activator *act = calloc(1, sizeof(struct activator));
+ act->mgmReg = NULL;
+ act->mgmServ = NULL;
+ act->tstServ = calloc(1, sizeof(*act->tstServ));
+ act->tstServ->handle = act;
+ act->tstServ->get_type = my_get_type;
+ act->tstServ->get_second_type = my_get_second_type;
+ act->tstReg = NULL;
+ act->configAdminServ = NULL;
+ act->configAdminServRef = NULL;
+ act->type_value[0] = 0x00;
+ act->second_type_value[0] = 0x00;
+ *userData = act;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt ctx) {
+
+ struct activator *act = (struct activator *)userData;
+ service_reference_pt ref;
+ celix_status_t status = bundleContext_getServiceReference(ctx, (char *) CONFIGURATION_ADMIN_SERVICE_NAME, &ref);
+
+ if (status == CELIX_SUCCESS) {
+
+ if (ref == NULL) {
+ printf("[configAdminClient]: ConfigAdminService reference not available\n");
+ } else {
+ configuration_admin_service_pt confAdminServ = NULL;
+ bundleContext_getService(ctx, ref, (void *) &confAdminServ);
+
+ if (confAdminServ == NULL){
+ printf("[ TEST ]: ConfigAdminService not available\n");
+ } else {
+ char *pid = "base.device1";
+ properties_pt dictionary;
+ configuration_pt configuration;
+ /* ------------------ get Configuration -------------------*/
+ (*confAdminServ->getConfiguration)(confAdminServ->configAdmin,pid, &configuration);
+ act->configAdminServ = confAdminServ;
+ act->configAdminServRef = ref;
+
+ status = managedServiceImpl_create(ctx, &act->mgmServ);
+ if (status != CELIX_SUCCESS){
+ return status;
+ }
+ struct test_managed_service *test_msp = (struct test_managed_service*)act->mgmServ;
+ test_msp->handle = act;
+ test_msp->store_props = store_properties;
+
+ managed_service_service_pt managedService;
+ status = managedService_create(ctx, &managedService);
+ if (status != CELIX_SUCCESS){
+ return status;
+ }
+
+ managedService->managedService = act->mgmServ;
+ managedService->updated = managedServiceImpl_updated;
+ configuration->configuration_getProperties(configuration->handle, &dictionary);
+ if (dictionary == NULL) {
+ dictionary = properties_create();
+ properties_set(dictionary, (char *) OSGI_FRAMEWORK_SERVICE_PID, pid);
+ properties_set(dictionary, (char *) "type", (char*)"default_value");
+ }
+ status = bundleContext_registerService(ctx, (char *) MANAGED_SERVICE_SERVICE_NAME,
+ managedService, dictionary, &act->mgmReg);
+ if (status != CELIX_SUCCESS){
+ printf("[ ERROR ]: Managed Service not registered \n");
+ return status;
+ }
+
+ status = bundleContext_registerService(ctx, (char *)TST_SERVICE_NAME, act->tstServ, NULL, &act->tstReg);
+
+ }
+ }
+ }
+ return status;
+
+ return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+ celix_status_t status;
+ struct activator *act = (struct activator *)userData;
+ if (act->mgmReg != NULL)
+ status = serviceRegistration_unregister(act->mgmReg);
+ if (act->tstReg != NULL)
+ status = serviceRegistration_unregister(act->tstReg);
+ if (act->configAdminServRef != NULL) {
+ status = bundleContext_ungetService(context, act->configAdminServRef, NULL);
+ status = bundleContext_ungetServiceReference(context, act->configAdminServRef);
+ }
+ return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+ struct activator *act = (struct activator *)userData;
+ managedService_destroy(act->mgmServ);
+ free(act->tstServ);
+ free(act);
+ return CELIX_SUCCESS;
+}
+
+#if 0
+void test_debugConfiguration(configuration_pt configuration, char* pid){
+
+ if (configuration == NULL){
+ printf("[ TEST ]: Configuration(pid=%s) is NULL \n", pid);
+ } else{
+ printf("[ TEST ]: Configuration(pid=%s) OK \n", pid);
+ }
+
+}
+#endif
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/config_admin_tst/example_test/private/src/example_managed_service_impl.c
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/example_test/private/src/example_managed_service_impl.c b/config_admin/config_admin_tst/example_test/private/src/example_managed_service_impl.c
new file mode 100644
index 0000000..02d5df5
--- /dev/null
+++ b/config_admin/config_admin_tst/example_test/private/src/example_managed_service_impl.c
@@ -0,0 +1,97 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements. See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership. The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * example_managed_service_impl.c
+ *
+ * \date Aug 12, 2013
+ * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "example_managed_service_impl.h"
+
+/* ------------------------ Constructor -------------------------------------*/
+
+celix_status_t managedServiceImpl_create(bundle_context_pt context, managed_service_pt *instance){
+
+ celix_status_t status = CELIX_SUCCESS;
+
+ struct test_managed_service *managedService = calloc(1, sizeof(*managedService));
+ if(!managedService){
+ printf("[ ERROR ]: ManagedServiceImpl - Not initialized (ENOMEM) \n");
+ return CELIX_ENOMEM;
+ }
+
+ managedService->context = context;
+ managedService->registration = NULL;
+ managedService->properties = NULL;
+
+ printf("[ ManagedServiceImpl ]: ManagedServiceImpl - Initialized \n");
+ *instance = (managed_service_pt)managedService;
+ return status;
+}
+
+
+/* -------------------- Implementation --------------------------------------*/
+
+celix_status_t managedServiceImpl_updated(managed_service_pt managedService, properties_pt properties){
+ struct test_managed_service *msp = (struct test_managed_service *) managedService;
+
+ if (properties == NULL){
+ printf("[ managedServiceImpl ]: updated - Received NULL properties \n");
+ msp->store_props(msp->handle, "", "");
+ }else{
+ printf("[ managedServiceImpl ]: updated - Received New Properties \n");
+ char *value = properties_get(properties, "type");
+ char *value2 = properties_get(properties, "second_type");
+ msp->store_props(msp->handle, value, value2);
+ // it would be nicer if we get the property values here and store them in the activator structure.
+ }
+
+ return CELIX_SUCCESS;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/config_admin_tst/example_test2/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/example_test2/CMakeLists.txt b/config_admin/config_admin_tst/example_test2/CMakeLists.txt
new file mode 100644
index 0000000..ddad504
--- /dev/null
+++ b/config_admin/config_admin_tst/example_test2/CMakeLists.txt
@@ -0,0 +1,32 @@
+# 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_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
+include_directories("${PROJECT_SOURCE_DIR}/config_admin/service/public/include")
+include_directories("private/include")
+
+SET(BUNDLE_SYMBOLICNAME "example_test2")
+SET(BUNDLE_VERSION "0.1.0")
+
+bundle(example_test2 SOURCES
+ private/src/activator
+ private/src/example_managed_service_impl
+)
+
+target_link_libraries(example_test2 celix_framework celix_utils config_admin)
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/config_admin_tst/example_test2/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/example_test2/META-INF/MANIFEST.MF b/config_admin/config_admin_tst/example_test2/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..15593d6
--- /dev/null
+++ b/config_admin/config_admin_tst/example_test2/META-INF/MANIFEST.MF
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+Bundle-SymbolicName: example_test
+Bundle-Version: 1.0.0
+library: example_test
+Import-Service: configuration_admin
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/config_admin_tst/example_test2/private/include/example2_managed_service_impl.h
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/example_test2/private/include/example2_managed_service_impl.h b/config_admin/config_admin_tst/example_test2/private/include/example2_managed_service_impl.h
new file mode 100644
index 0000000..8292721
--- /dev/null
+++ b/config_admin/config_admin_tst/example_test2/private/include/example2_managed_service_impl.h
@@ -0,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.
+ */
+/*
+ * example_managed_service_impl.h
+ *
+ * \date Aug 12, 2013
+ * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+
+#ifndef TEST2_SERVICE_IMPL_H_
+#define TEST2_SERVICE_IMPL_H_
+
+
+/* celix.utils*/
+#include "properties.h"
+/* celix.framework */
+#include "celix_errno.h"
+#include "service_registration.h"
+#include "bundle_context.h"
+/* celix.config_admin.ManagedService */
+#include "managed_service.h"
+
+/*
+struct managed_service2{
+
+ bundle_context_pt context;
+
+ service_registration_pt registration;
+ properties_pt properties;
+
+};
+*/
+#define TST2_SERVICE_NAME "tst2_service"
+
+struct tst2_service {
+ void *handle;
+ int (*get_type)(void *handle, char *value);
+};
+
+typedef struct tst2_service *tst2_service_pt;
+
+celix_status_t managedServiceImpl_create(bundle_context_pt context, managed_service_pt *instance);
+celix_status_t managedServiceImpl_updated(managed_service_pt instance, properties_pt properties);
+
+
+
+#endif /* TEST2_SERVICE_IMPL_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/config_admin_tst/example_test2/private/src/activator.c
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/example_test2/private/src/activator.c b/config_admin/config_admin_tst/example_test2/private/src/activator.c
new file mode 100644
index 0000000..400c63c
--- /dev/null
+++ b/config_admin/config_admin_tst/example_test2/private/src/activator.c
@@ -0,0 +1,225 @@
+/**
+ *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 12, 2013
+ * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "example2_managed_service_impl.h"
+/* celix.framework */
+#include "bundle_activator.h"
+#include "bundle_context.h"
+#include "constants.h"
+#include "properties.h"
+#include "utils.h"
+/* celix.utils */
+#include "hash_map.h"
+/* celix.configadmin */
+#include "configuration_admin.h"
+#include "configuration.h"
+#include "managed_service.h"
+#include "service_registration.h"
+/* celix.config_admin.examples.private */
+
+
+//static void test_debugConfiguration(configuration_pt configuration, char* pid);
+struct activator {
+ bundle_context_pt context;
+ tst2_service_pt tstServ;
+ service_registration_pt tstReg;
+
+ service_registration_pt mgmReg;
+ managed_service_pt mgmServ;
+
+ service_reference_pt configAdminServRef;
+ configuration_admin_service_pt configAdminServ;
+
+ configuration_pt configuration;
+
+};
+
+
+int my_get_type(void *handle, char* value) {
+ struct activator *act = (struct activator *)handle;
+ if (act->configuration != NULL) {
+ properties_pt propsRx;
+ act->configuration->configuration_getProperties(act->configuration->handle, &propsRx);
+ if (propsRx != NULL) {
+ printf("[ TEST ]: PROP=%s - VALUE=%s \n", (char*)OSGI_FRAMEWORK_SERVICE_PID, properties_get(propsRx,(char*)OSGI_FRAMEWORK_SERVICE_PID));
+ strcpy(value, properties_get(propsRx,"type"));
+ }
+ else {
+ printf("[ TEST ]: No properties found \n");
+ strcpy(value, "");
+ }
+ }
+ else
+ value[0] = 0x00;
+ return 0;
+}
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+ struct activator *act = calloc(1, sizeof(struct activator));
+ act->mgmReg = NULL;
+ act->mgmServ = NULL;
+ act->tstServ = calloc(1, sizeof(*act->tstServ));
+ act->tstServ->handle = act;
+ act->tstServ->get_type = my_get_type;
+ act->tstReg = NULL;
+ act->configAdminServ = NULL;
+ act->configAdminServRef = NULL;
+ act->configuration = NULL;
+ *userData = act;
+ return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt ctx) {
+
+ struct activator *act = (struct activator *)userData;
+ service_reference_pt ref;
+ celix_status_t status = bundleContext_getServiceReference(ctx, (char *) CONFIGURATION_ADMIN_SERVICE_NAME, &ref);
+
+ if (status == CELIX_SUCCESS) {
+
+ if (ref == NULL) {
+ printf("[configAdminClient]: ConfigAdminService reference not available\n");
+ } else {
+ configuration_admin_service_pt confAdminServ = NULL;
+ bundleContext_getService(ctx, ref, (void *) &confAdminServ);
+
+ if (confAdminServ == NULL){
+ printf("[ TEST ]: ConfigAdminService not available\n");
+ } else {
+ char *pid = "test2_pid";
+ /* In example_test a managed service is registered for which there already exists a
+ * configuration object. In this case, a managed service is register for which there
+ * is no configuration object in the configAdmin
+ */
+ /* ------------------ get Configuration -------------------*
+ (*confAdminServ->getConfiguration)(confAdminServ->configAdmin,pid, &act->configuration);
+ */
+ act->configAdminServ = confAdminServ;
+ act->configAdminServRef = ref;
+
+ status = managedServiceImpl_create(ctx, &act->mgmServ);
+ if (status != CELIX_SUCCESS){
+ return status;
+ }
+
+ managed_service_service_pt managedService;
+ status = managedService_create(ctx, &managedService);
+ if (status != CELIX_SUCCESS){
+ return status;
+ }
+
+ managedService->managedService = act->mgmServ;
+ managedService->updated = managedServiceImpl_updated;
+
+ properties_pt dictionary;
+ dictionary = properties_create();
+ properties_set(dictionary, (char *) OSGI_FRAMEWORK_SERVICE_PID, pid);
+ properties_set(dictionary, (char *) "type", (char*)"test2_default_value");
+
+ status = bundleContext_registerService(ctx, (char *) MANAGED_SERVICE_SERVICE_NAME,
+ managedService, dictionary, &act->mgmReg);
+ if (status != CELIX_SUCCESS){
+ printf("[ ERROR ]: Managed Service not registered \n");
+ return status;
+ }
+
+ status = bundleContext_registerService(ctx, (char *)TST2_SERVICE_NAME, act->tstServ, NULL, &act->tstReg);
+
+#if 0
+ /* ------------------ update Configuration ----------------*/
+
+ printf("------------------- TEST04 -------------------- \n");
+ printf("[ TEST ]: configuration update NULL \n");
+ configuration_update(configuration , NULL);
+
+ /* ------------------ update Configuration ----------------*/
+
+ printf("------------------- TEST05 -------------------- \n");
+ printf("[ TEST ]: configuration update New Properties \n");
+ char *prop1 = "type";
+ char *value1 = "printer";
+ properties_pt properties = properties_create();
+ properties_set(properties, prop1, value1);
+ configuration_update(configuration , properties);
+
+ /* ------------------ Configuration get Props ----------------*/
+
+ printf("------------------- TEST06 -------------------- \n");
+ printf("[ TEST ]: configuration get properties \n");
+
+ properties_pt propsRx = properties_create();
+ configuration_getProperties(configuration, &propsRx);
+
+ printf("[ TEST ]: PROP=%s - VALUE=%s \n", (char*)OSGI_FRAMEWORK_SERVICE_PID, properties_get(propsRx,(char*)OSGI_FRAMEWORK_SERVICE_PID));
+ printf("[ TEST ]: PROP=%s - VALUE=%s \n", prop1, properties_get(propsRx,prop1));
+
+ printf("/////////////////// END TESTS ///////////////// \n");
+#endif
+ }
+ }
+ }
+ return status;
+
+ return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+ celix_status_t status;
+ struct activator *act = (struct activator *)userData;
+ if (act->mgmReg != NULL)
+ status = serviceRegistration_unregister(act->mgmReg);
+ if (act->tstReg != NULL)
+ status = serviceRegistration_unregister(act->tstReg);
+ if (act->configAdminServRef != NULL) {
+ status = bundleContext_ungetService(context, act->configAdminServRef, NULL);
+ status = bundleContext_ungetServiceReference(context, act->configAdminServRef);
+ }
+ return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+ struct activator *act = (struct activator *)userData;
+ managedService_destroy(act->mgmServ);
+ free(act->tstServ);
+ free(act);
+ return CELIX_SUCCESS;
+}
+
+#if 0
+void test_debugConfiguration(configuration_pt configuration, char* pid){
+
+ if (configuration == NULL){
+ printf("[ TEST ]: Configuration(pid=%s) is NULL \n", pid);
+ } else{
+ printf("[ TEST ]: Configuration(pid=%s) OK \n", pid);
+ }
+
+}
+#endif
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/config_admin_tst/example_test2/private/src/example_managed_service_impl.c
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/example_test2/private/src/example_managed_service_impl.c b/config_admin/config_admin_tst/example_test2/private/src/example_managed_service_impl.c
new file mode 100644
index 0000000..270e705
--- /dev/null
+++ b/config_admin/config_admin_tst/example_test2/private/src/example_managed_service_impl.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.
+ */
+/*
+ * example_managed_service_impl.c
+ *
+ * \date Aug 12, 2013
+ * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "example2_managed_service_impl.h"
+
+
+struct managed_service{
+
+ bundle_context_pt context;
+
+ service_registration_pt registration;
+ properties_pt properties;
+
+};
+
+/* ------------------------ Constructor -------------------------------------*/
+
+celix_status_t managedServiceImpl_create(bundle_context_pt context, managed_service_pt *instance){
+
+ celix_status_t status = CELIX_SUCCESS;
+
+ managed_service_pt managedService = calloc(1, sizeof(*managedService));
+ if(!managedService){
+ printf("[ ERROR ]: ManagedServiceImpl - Not initialized (ENOMEM) \n");
+ return CELIX_ENOMEM;
+ }
+
+ managedService->context = context;
+ managedService->registration = NULL;
+ managedService->properties = NULL;
+
+ *instance = managedService;
+ return status;
+}
+
+
+/* -------------------- Implementation --------------------------------------*/
+
+celix_status_t managedServiceImpl_updated(managed_service_pt managedService, properties_pt properties){
+
+ if (properties == NULL){
+ printf("[ managedServiceImpl ]: updated - Received NULL properties \n");
+ managedService->properties = NULL;
+ }else{
+ printf("[ managedServiceImpl ]: updated - Received New Properties \n");
+ managedService->properties = properties_create();
+ managedService->properties = properties;
+ }
+
+ return CELIX_SUCCESS;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/examples/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/examples/CMakeLists.txt b/config_admin/examples/CMakeLists.txt
deleted file mode 100644
index 6c0188d..0000000
--- a/config_admin/examples/CMakeLists.txt
+++ /dev/null
@@ -1,21 +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.
-
-
-add_subdirectory(example_test)
-add_subdirectory(example_test2)
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/examples/example_test/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/examples/example_test/CMakeLists.txt b/config_admin/examples/example_test/CMakeLists.txt
deleted file mode 100644
index 5529d45..0000000
--- a/config_admin/examples/example_test/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/config_admin/service/public/include")
-include_directories("private/include")
-
-SET(BUNDLE_SYMBOLICNAME "example_test")
-SET(BUNDLE_VERSION "0.1.0")
-
-bundle(example_test SOURCES
- private/src/activator
- private/src/example_managed_service_impl
-)
-
-target_link_libraries(example_test celix_framework celix_utils config_admin ${APR_LIBRARY})
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/examples/example_test/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/config_admin/examples/example_test/META-INF/MANIFEST.MF b/config_admin/examples/example_test/META-INF/MANIFEST.MF
deleted file mode 100644
index 15593d6..0000000
--- a/config_admin/examples/example_test/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,5 +0,0 @@
-Manifest-Version: 1.0
-Bundle-SymbolicName: example_test
-Bundle-Version: 1.0.0
-library: example_test
-Import-Service: configuration_admin
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/examples/example_test/private/include/example_managed_service_impl.h
----------------------------------------------------------------------
diff --git a/config_admin/examples/example_test/private/include/example_managed_service_impl.h b/config_admin/examples/example_test/private/include/example_managed_service_impl.h
deleted file mode 100644
index de51c6f..0000000
--- a/config_admin/examples/example_test/private/include/example_managed_service_impl.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * example_managed_service_impl.h
- *
- * \date Aug 12, 2013
- * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-#ifndef MANAGED_SERVICE_IMPL_H_
-#define MANAGED_SERVICE_IMPL_H_
-
-
-/* celix.utils*/
-#include "properties.h"
-/* celix.framework */
-#include "celix_errno.h"
-#include "service_registration.h"
-#include "bundle_context.h"
-/* celix.config_admin.ManagedService */
-#include "managed_service.h"
-
-struct managed_service{
-
- bundle_context_pt context;
-
- service_registration_pt registration;
- properties_pt properties;
-
-};
-
-celix_status_t managedServiceImpl_create(bundle_context_pt context, managed_service_pt *instance);
-celix_status_t managedServiceImpl_updated(managed_service_pt instance, properties_pt properties);
-
-#endif /* MANAGED_SERVICE_IMPL_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/examples/example_test/private/src/activator.c
----------------------------------------------------------------------
diff --git a/config_admin/examples/example_test/private/src/activator.c b/config_admin/examples/example_test/private/src/activator.c
deleted file mode 100644
index f1d985e..0000000
--- a/config_admin/examples/example_test/private/src/activator.c
+++ /dev/null
@@ -1,188 +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 12, 2013
- * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#include <stdbool.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-/* celix.framework */
-#include "bundle_activator.h"
-#include "bundle_context.h"
-#include "constants.h"
-#include "properties.h"
-#include "utils.h"
-/* celix.utils */
-#include "hash_map.h"
-/* celix.configadmin */
-#include "configuration_admin.h"
-#include "configuration.h"
-#include "managed_service.h"
-/* celix.config_admin.examples.private */
-#include "example_managed_service_impl.h"
-
-
-static void test_debugConfiguration(configuration_pt configuration, char* pid);
-
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- *userData = NULL;
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt ctx) {
-
- service_reference_pt ref = NULL;
- celix_status_t status = bundleContext_getServiceReference(ctx, (char *) CONFIGURATION_ADMIN_SERVICE_NAME, &ref);
-
- if (status == CELIX_SUCCESS) {
-
- if (ref == NULL) {
-
- printf("[configAdminClient]: ConfigAdminService reference not available\n");
-
- } else {
-
- printf("------------------- DEMO ---------------------- \n");
-
- configuration_admin_service_pt confAdminServ = NULL;
- bundleContext_getService(ctx, ref, (void *) &confAdminServ);
-
- if (confAdminServ == NULL){
-
- printf("[ TEST ]: ConfigAdminService not available\n");
-
- } else {
-
- printf("/////////////////// TESTS ///////////////////// \n");
-
- char *pid = "base.device1";
-
- /* ------------------ get Configuration -------------------*/
-
- printf("------------------- TEST01 -------------------- \n");
- printf("[ TEST ]: getConfiguration(pid=%s) - It's new \n",pid);
- configuration_pt configuration;
- (*confAdminServ->getConfiguration)(confAdminServ->configAdmin,pid, &configuration);
-
- test_debugConfiguration(configuration, pid);
-
- /* ------------------ get Configuration -------------------*/
-
- char *pid2 = "base.device1";
-
- printf("------------------- TEST02--------------------- \n");
- printf("[ TEST ]: getConfiguration(pid=%s) - Looking for it in Cache \n",pid2);
- configuration_pt configuration2;
- (*confAdminServ->getConfiguration)(confAdminServ->configAdmin,pid2, &configuration2);
-
- test_debugConfiguration(configuration2, pid2);
-
- /* ------------------ register ManagedService -------------*/
-
- printf("------------------- TEST03 -------------------- \n");
- printf("[ TEST ]: register ManagedService(pid=%s) \n",pid);
-
-
- managed_service_pt instance;
- status = managedServiceImpl_create(ctx, &instance);
- if (status != CELIX_SUCCESS){
- return status;
- }
-
- managed_service_service_pt managedService;
- status = managedService_create(ctx, &managedService);
- if (status != CELIX_SUCCESS){
- return status;
- }
-
- managedService->managedService = instance;
- managedService->updated = managedServiceImpl_updated;
-
- properties_pt dictionary;
- dictionary = properties_create();
- properties_set(dictionary, (char *) OSGI_FRAMEWORK_SERVICE_PID, pid);
-
- status = bundleContext_registerService(ctx, (char *) MANAGED_SERVICE_SERVICE_NAME,
- managedService, dictionary, &instance->registration);
- if (status != CELIX_SUCCESS){
- printf("[ ERROR ]: Managed Service not registered \n");
- return status;
- }
-
- printf("[ TEST ]: ManagedService(pid=%s) registered \n",pid);
-
- /* ------------------ update Configuration ----------------*/
-
- printf("------------------- TEST04 -------------------- \n");
- printf("[ TEST ]: configuration update NULL \n");
- configuration_update(configuration , NULL);
-
- /* ------------------ update Configuration ----------------*/
-
- printf("------------------- TEST05 -------------------- \n");
- printf("[ TEST ]: configuration update New Properties \n");
- char *prop1 = "type";
- char *value1 = "printer";
- properties_pt properties = properties_create();
- properties_set(properties, prop1, value1);
- configuration_update(configuration , properties);
-
- /* ------------------ Configuration get Props ----------------*/
-
- printf("------------------- TEST06 -------------------- \n");
- printf("[ TEST ]: configuration get properties \n");
-
- properties_pt propsRx = properties_create();
- configuration_getProperties(configuration, &propsRx);
-
- printf("[ TEST ]: PROP=%s - VALUE=%s \n", (char*)OSGI_FRAMEWORK_SERVICE_PID, properties_get(propsRx,(char*)OSGI_FRAMEWORK_SERVICE_PID));
- printf("[ TEST ]: PROP=%s - VALUE=%s \n", prop1, properties_get(propsRx,prop1));
-
- printf("/////////////////// END TESTS ///////////////// \n");
-
- }
- }
- }
- return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
- return CELIX_SUCCESS;
-}
-
-void test_debugConfiguration(configuration_pt configuration, char* pid){
-
- if (configuration == NULL){
- printf("[ TEST ]: Configuration(pid=%s) is NULL \n", pid);
- } else{
- printf("[ TEST ]: Configuration(pid=%s) OK \n", pid);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/examples/example_test/private/src/example_managed_service_impl.c
----------------------------------------------------------------------
diff --git a/config_admin/examples/example_test/private/src/example_managed_service_impl.c b/config_admin/examples/example_test/private/src/example_managed_service_impl.c
deleted file mode 100644
index c4dab02..0000000
--- a/config_admin/examples/example_test/private/src/example_managed_service_impl.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * example_managed_service_impl.c
- *
- * \date Aug 12, 2013
- * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "example_managed_service_impl.h"
-
-/* ------------------------ Constructor -------------------------------------*/
-
-celix_status_t managedServiceImpl_create(bundle_context_pt context, managed_service_pt *instance){
-
- celix_status_t status = CELIX_SUCCESS;
-
- managed_service_pt managedService = calloc(1, sizeof(*managedService));
- if(!managedService){
- printf("[ ERROR ]: ManagedServiceImpl - Not initialized (ENOMEM) \n");
- return CELIX_ENOMEM;
- }
-
- managedService->context = context;
- managedService->registration = NULL;
- managedService->properties = NULL;
-
- printf("[ ManagedServiceImpl ]: ManagedServiceImpl - Initialized \n");
- *instance = managedService;
- return status;
-}
-
-
-/* -------------------- Implementation --------------------------------------*/
-
-celix_status_t managedServiceImpl_updated(managed_service_pt managedService, properties_pt properties){
-
- if (properties == NULL){
- printf("[ managedServiceImpl ]: updated - Received NULL properties \n");
- managedService->properties = NULL;
- }else{
- printf("[ managedServiceImpl ]: updated - Received New Properties \n");
- managedService->properties = properties_create();
- managedService->properties = properties;
- }
-
- return CELIX_SUCCESS;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/examples/example_test2/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/examples/example_test2/CMakeLists.txt b/config_admin/examples/example_test2/CMakeLists.txt
deleted file mode 100644
index 4adf560..0000000
--- a/config_admin/examples/example_test2/CMakeLists.txt
+++ /dev/null
@@ -1,21 +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.
-
-
-add_subdirectory(bundle_configuring)
-add_subdirectory(bundle_managed_service)
-
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/examples/example_test2/bundle_configuring/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/examples/example_test2/bundle_configuring/CMakeLists.txt b/config_admin/examples/example_test2/bundle_configuring/CMakeLists.txt
deleted file mode 100644
index 344ace2..0000000
--- a/config_admin/examples/example_test2/bundle_configuring/CMakeLists.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/config_admin/service/public/include")
-
-SET(BUNDLE_SYMBOLICNAME "bundle_configuraring")
-SET(BUNDLE_VERSION "0.1.0")
-
-bundle(bundle_configuring SOURCES
- private/src/activator
-)
-
-target_link_libraries(bundle_configuring celix_framework celix_utils config_admin ${APR_LIBRARY})
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/examples/example_test2/bundle_configuring/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/config_admin/examples/example_test2/bundle_configuring/META-INF/MANIFEST.MF b/config_admin/examples/example_test2/bundle_configuring/META-INF/MANIFEST.MF
deleted file mode 100644
index e8f0896..0000000
--- a/config_admin/examples/example_test2/bundle_configuring/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,5 +0,0 @@
-Manifest-Version: 1.0
-Bundle-SymbolicName: bundle_configuring
-Bundle-Version: 1.0.0
-library: bundle_configuring
-Import-Service: configuration_admin
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/examples/example_test2/bundle_configuring/private/src/activator.c
----------------------------------------------------------------------
diff --git a/config_admin/examples/example_test2/bundle_configuring/private/src/activator.c b/config_admin/examples/example_test2/bundle_configuring/private/src/activator.c
deleted file mode 100644
index 8ba4122..0000000
--- a/config_admin/examples/example_test2/bundle_configuring/private/src/activator.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- ============================================================================
- Name : activator.c
- Developed at : Thales
- Supervisor : Pepijn NOLTES
- Author : Jorge SANCHEZ
- Version : 0.1 - Jul 12, 2013
- Package : celix.config_admin.examples.example_test2
- Description : Example
- Reviews :
- ============================================================================
- */
-
-#include <stdbool.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-/* celix.framework */
-#include "bundle_activator.h"
-#include "bundle_context.h"
-#include "constants.h"
-#include "properties.h"
-#include "utils.h"
-/* celix.utils */
-#include "hash_map.h"
-/* celix.configadmin */
-#include "configuration_admin.h"
-#include "configuration.h"
-
-
-celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
- *userData = NULL;
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt ctx) {
-
- service_reference_pt ref = NULL;
- celix_status_t status = bundleContext_getServiceReference(ctx, (char *) CONFIGURATION_ADMIN_SERVICE_NAME, &ref);
-
- if (status == CELIX_SUCCESS) {
-
- if (ref == NULL) {
-
- printf("[configAdminClient]: ConfigAdminService reference not available\n");
-
- } else {
-
- configuration_admin_service_pt confAdminServ = NULL;
- bundleContext_getService(ctx, ref, (void *) &confAdminServ);
-
- if (confAdminServ == NULL){
-
- printf("[ BUNDLE configuring ]: ConfigAdminService not available\n");
-
- } else {
-
- char *pid = "base.device1";
-
- configuration_pt configuration;
- char *configurationLocation;
-
- /* ------------------ get Configuration -------------------*/
- printf("[ BUNDLE configuring ]: getConfiguration(pid=%s) \n",pid);
-
- (*confAdminServ->getConfiguration)(confAdminServ->configAdmin,pid, &configuration);
-
- /* ------------------ Configuration get Props ----------------*/
- printf("[ BUNDLE configuring ]: configuration getBundleLocation \n");
-
- configuration_getBundleLocation(configuration, &configurationLocation);
-
- /* -------------------- Validation ---------------------------*/
-
- printf("[ BUNDLE configuring ]: I have a Configuration that belongs to: \n ");
- printf(" %s \n ", configurationLocation);
-
- printf("[ BUNDLE configuring ]: END \n");
-
- }
- }
- }
- return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
- return CELIX_SUCCESS;
-}
-
-
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/examples/example_test2/bundle_managed_service/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/examples/example_test2/bundle_managed_service/CMakeLists.txt b/config_admin/examples/example_test2/bundle_managed_service/CMakeLists.txt
deleted file mode 100644
index 3de8d69..0000000
--- a/config_admin/examples/example_test2/bundle_managed_service/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/config_admin/service/public/include")
-include_directories("private/include")
-
-SET(BUNDLE_SYMBOLICNAME "bundle_managed_service")
-SET(BUNDLE_VERSION "0.1.0")
-
-bundle(bundle_managed_service SOURCES
- private/src/activator
- private/src/example_managed_service_impl
-)
-
-target_link_libraries(bundle_managed_service celix_framework celix_utils config_admin ${APR_LIBRARY})
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/examples/example_test2/bundle_managed_service/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/config_admin/examples/example_test2/bundle_managed_service/META-INF/MANIFEST.MF b/config_admin/examples/example_test2/bundle_managed_service/META-INF/MANIFEST.MF
deleted file mode 100644
index 3ed3eab..0000000
--- a/config_admin/examples/example_test2/bundle_managed_service/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,5 +0,0 @@
-Manifest-Version: 1.0
-Bundle-SymbolicName: bundle_managed_service
-Bundle-Version: 1.0.0
-library: bundle_managed_service
-Import-Service: configuration_admin
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/examples/example_test2/bundle_managed_service/private/include/example_managed_service_impl.h
----------------------------------------------------------------------
diff --git a/config_admin/examples/example_test2/bundle_managed_service/private/include/example_managed_service_impl.h b/config_admin/examples/example_test2/bundle_managed_service/private/include/example_managed_service_impl.h
deleted file mode 100644
index 6089826..0000000
--- a/config_admin/examples/example_test2/bundle_managed_service/private/include/example_managed_service_impl.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * example_managed_service_impl.h
- *
- * \date Aug 12, 2013
- * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-#ifndef MANAGED_SERVICE_IMPL_H_
-#define MANAGED_SERVICE_IMPL_H_
-
-
-/* celix.utils*/
-#include "properties.h"
-/* celix.framework */
-#include "celix_errno.h"
-#include "service_registration.h"
-#include "bundle_context.h"
-/* celix.config_admin.ManagedService */
-#include "managed_service.h"
-
-
-struct managed_service{
-
- bundle_context_pt context;
-
- service_registration_pt registration;
- properties_pt properties;
-
-};
-
-
-celix_status_t managedServiceImpl_create(bundle_context_pt context, managed_service_pt *instance);
-celix_status_t managedServiceImpl_updated(managed_service_pt instance, properties_pt properties);
-
-#endif /* MANAGED_SERVICE_IMPL_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/d3c94184/config_admin/examples/example_test2/bundle_managed_service/private/src/activator.c
----------------------------------------------------------------------
diff --git a/config_admin/examples/example_test2/bundle_managed_service/private/src/activator.c b/config_admin/examples/example_test2/bundle_managed_service/private/src/activator.c
deleted file mode 100644
index 5f0d961..0000000
--- a/config_admin/examples/example_test2/bundle_managed_service/private/src/activator.c
+++ /dev/null
@@ -1,120 +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 12, 2013
- * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-
-#include <stdbool.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-/* celix.framework */
-#include "bundle_activator.h"
-#include "bundle_context.h"
-#include "constants.h"
-#include "properties.h"
-#include "utils.h"
-/* celix.utils */
-#include "hash_map.h"
-/* celix.configadmin */
-#include "configuration_admin.h"
-#include "configuration.h"
-#include "managed_service.h"
-/* celix.config_admin.examples.private */
-#include "example_managed_service_impl.h"
-
-
-celix_status_t bundleActivator_start(void * userData, bundle_context_pt ctx) {
-
- service_reference_pt ref = NULL;
- celix_status_t status = bundleContext_getServiceReference(ctx, (char *) CONFIGURATION_ADMIN_SERVICE_NAME, &ref);
-
- if (status == CELIX_SUCCESS) {
-
- if (ref == NULL) {
-
- printf("[configAdminClient]: ConfigAdminService reference not available\n");
-
- } else {
-
- printf("------------------- DEMO ---------------------- \n");
-
- configuration_admin_service_pt confAdminServ = NULL;
- bundleContext_getService(ctx, ref, (void *) &confAdminServ);
-
- if (confAdminServ == NULL){
-
- printf("[ TEST ]: ConfigAdminService not available\n");
-
- } else {
-
- char *pid = "base.device1";
- /* ------------------ register ManagedService -------------*/
-
- printf("[ BUNDLE example_managed_service ]: register ManagedService(pid=%s) \n",pid);
-
-
- managed_service_pt instance;
- status = managedServiceImpl_create(ctx, &instance);
- if (status != CELIX_SUCCESS){
- return status;
- }
-
- managed_service_service_pt managedService;
- status = managedService_create(ctx, &managedService);
- if (status != CELIX_SUCCESS){
- return status;
- }
-
- managedService->managedService = instance;
- managedService->updated = managedServiceImpl_updated;
-
- properties_pt dictionary;
- dictionary = properties_create();
- properties_set(dictionary, (char *) OSGI_FRAMEWORK_SERVICE_PID, pid);
-
- status = bundleContext_registerService(ctx, (char *) MANAGED_SERVICE_SERVICE_NAME,
- managedService, dictionary, &instance->registration);
- if (status != CELIX_SUCCESS){
- printf("[ ERROR ]: Managed Service not registered \n");
- return status;
- }
-
- printf("[ BUNDLE example_managed_service ]: ManagedService(pid=%s) registered \n",pid);
-
- }
- }
- }
- return status;
-}
-
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
- return CELIX_SUCCESS;
-}
-
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
- return CELIX_SUCCESS;
-}
-
-