You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2018/05/27 18:52:58 UTC
[50/60] [abbrv] [partial] celix git commit: CELIX-424: Cleans up the
directory structure. Moves all libraries to the libs subdir and all bundles
to the bundles subdir
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/config_admin/CMakeLists.txt b/bundles/config_admin/CMakeLists.txt
new file mode 100644
index 0000000..fc42f7e
--- /dev/null
+++ b/bundles/config_admin/CMakeLists.txt
@@ -0,0 +1,61 @@
+# 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.
+
+
+#TODO refactor and improve impl
+#celix_subproject(CONFIG_ADMIN "Option to enable building the Config Admin Service bundle and its examples" OFF DEPS framework launcher shell_tui log_writer)
+set(CONFIG_AMDIN FALSE)
+if (CONFIG_ADMIN)
+
+ add_subdirectory(service)
+ add_subdirectory(example)
+
+ 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)
+
+
+ add_celix_container(config_admin_deploy
+ NAME "config_admin"
+ BUNDLES
+ config_admin
+ Celix::shell
+ Celix::shell_tui
+ log_service
+ log_writer
+ config_admin_example
+ )
+
+endif (CONFIG_ADMIN)
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/config_admin_tst/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/config_admin/config_admin_tst/CMakeLists.txt b/bundles/config_admin/config_admin_tst/CMakeLists.txt
new file mode 100644
index 0000000..f0abb8c
--- /dev/null
+++ b/bundles/config_admin/config_admin_tst/CMakeLists.txt
@@ -0,0 +1,47 @@
+# 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_FILE)
+get_property(example_test_bundle_file TARGET example_test PROPERTY BUNDLE_FILE)
+get_property(example_test2_bundle_file TARGET example_test2 PROPERTY BUNDLE_FILE)
+
+configure_file(config.properties.in config.properties @ONLY)
+
+
+#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/3bce889b/bundles/config_admin/config_admin_tst/config.properties.in
----------------------------------------------------------------------
diff --git a/bundles/config_admin/config_admin_tst/config.properties.in b/bundles/config_admin/config_admin_tst/config.properties.in
new file mode 100644
index 0000000..7e8c14d
--- /dev/null
+++ b/bundles/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/3bce889b/bundles/config_admin/config_admin_tst/config_admin_test.cpp
----------------------------------------------------------------------
diff --git a/bundles/config_admin/config_admin_tst/config_admin_test.cpp b/bundles/config_admin/config_admin_tst/config_admin_test.cpp
new file mode 100644
index 0000000..04cd6d7
--- /dev/null
+++ b/bundles/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.
+ */
+/*
+ * config_admin_test.cpp
+ *
+ * \date Sep 15, 2015
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \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, test2Ref, (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) {
+ const 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) {
+ const 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) {
+ const 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) {
+ const 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;
+ const 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/3bce889b/bundles/config_admin/config_admin_tst/example_test/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/config_admin/config_admin_tst/example_test/CMakeLists.txt b/bundles/config_admin/config_admin_tst/example_test/CMakeLists.txt
new file mode 100644
index 0000000..80419b5
--- /dev/null
+++ b/bundles/config_admin/config_admin_tst/example_test/CMakeLists.txt
@@ -0,0 +1,31 @@
+# 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")
+
+add_celix_bundle(example_test
+ VERSION 0.1.0
+ SOURCES
+ private/src/activator
+ private/src/example_managed_service_impl
+)
+
+target_link_libraries(example_test PRIVATE Celix::framework celix_utils config_admin)
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/config_admin_tst/example_test/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/bundles/config_admin/config_admin_tst/example_test/META-INF/MANIFEST.MF b/bundles/config_admin/config_admin_tst/example_test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..15593d6
--- /dev/null
+++ b/bundles/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/3bce889b/bundles/config_admin/config_admin_tst/example_test/private/include/example_managed_service_impl.h
----------------------------------------------------------------------
diff --git a/bundles/config_admin/config_admin_tst/example_test/private/include/example_managed_service_impl.h b/bundles/config_admin/config_admin_tst/example_test/private/include/example_managed_service_impl.h
new file mode 100644
index 0000000..c34647f
--- /dev/null
+++ b/bundles/config_admin/config_admin_tst/example_test/private/include/example_managed_service_impl.h
@@ -0,0 +1,68 @@
+/**
+ *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:dev@celix.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);
+celix_status_t managedServiceImpl_destroy(managed_service_pt *instance);
+
+
+
+#endif /* MANAGED_SERVICE_IMPL_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/config_admin_tst/example_test/private/src/activator.c
----------------------------------------------------------------------
diff --git a/bundles/config_admin/config_admin_tst/example_test/private/src/activator.c b/bundles/config_admin/config_admin_tst/example_test/private/src/activator.c
new file mode 100644
index 0000000..bae4daf
--- /dev/null
+++ b/bundles/config_admin/config_admin_tst/example_test/private/src/activator.c
@@ -0,0 +1,207 @@
+/**
+ *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:dev@celix.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;
+
+ service_registration_pt mgmReg;
+ managed_service_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";
+ configuration_pt configuration;
+ /* ------------------ get Configuration -------------------*/
+ (*confAdminServ->getConfiguration)(confAdminServ->configAdmin,pid, &configuration);
+ act->configAdminServ = confAdminServ;
+ act->configAdminServRef = ref;
+ managed_service_pt managedService;
+ status = managedServiceImpl_create(ctx, &managedService);
+ if (status != CELIX_SUCCESS){
+ return status;
+ }
+ struct test_managed_service *test_msp = (struct test_managed_service*) managedService;
+ test_msp->handle = act;
+ test_msp->store_props = store_properties;
+
+ status = managedService_create(ctx, &act->mgmServ);
+
+ if (status != CELIX_SUCCESS){
+ return status;
+ }
+
+ act->mgmServ->managedService = managedService;
+ act->mgmServ->updated = managedServiceImpl_updated;
+ properties_pt dictionary;
+ 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");
+ }
+ // the service has to be registered with a properties/dictionary structure that at least contains a pid to assure it
+ // is picked up by the managedServiceTracker of the configuration Admin
+ status = bundleContext_registerService(ctx, (char *) MANAGED_SERVICE_SERVICE_NAME, act->mgmServ, 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;
+
+ managedServiceImpl_destroy(&act->mgmServ->managedService);
+ 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/3bce889b/bundles/config_admin/config_admin_tst/example_test/private/src/example_managed_service_impl.c
----------------------------------------------------------------------
diff --git a/bundles/config_admin/config_admin_tst/example_test/private/src/example_managed_service_impl.c b/bundles/config_admin/config_admin_tst/example_test/private/src/example_managed_service_impl.c
new file mode 100644
index 0000000..7bcbf36
--- /dev/null
+++ b/bundles/config_admin/config_admin_tst/example_test/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:dev@celix.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;
+}
+
+
+celix_status_t managedServiceImpl_destroy(managed_service_pt *instance) {
+ free(*instance);
+
+ return CELIX_SUCCESS;
+}
+
+/* -------------------- 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 = (char*)properties_get(properties, "type");
+ char *value2 = (char*)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/3bce889b/bundles/config_admin/config_admin_tst/example_test2/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/config_admin/config_admin_tst/example_test2/CMakeLists.txt b/bundles/config_admin/config_admin_tst/example_test2/CMakeLists.txt
new file mode 100644
index 0000000..1579eaf
--- /dev/null
+++ b/bundles/config_admin/config_admin_tst/example_test2/CMakeLists.txt
@@ -0,0 +1,30 @@
+# 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")
+
+add_celix_bundle(example_test2 SOURCES
+ private/src/activator
+ private/src/example_managed_service_impl
+ VERSION 0.1.0
+)
+
+target_link_libraries(example_test2 Celix::framework celix_utils config_admin)
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/config_admin_tst/example_test2/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/bundles/config_admin/config_admin_tst/example_test2/META-INF/MANIFEST.MF b/bundles/config_admin/config_admin_tst/example_test2/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..15593d6
--- /dev/null
+++ b/bundles/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/3bce889b/bundles/config_admin/config_admin_tst/example_test2/private/include/example2_managed_service_impl.h
----------------------------------------------------------------------
diff --git a/bundles/config_admin/config_admin_tst/example_test2/private/include/example2_managed_service_impl.h b/bundles/config_admin/config_admin_tst/example_test2/private/include/example2_managed_service_impl.h
new file mode 100644
index 0000000..ab63215
--- /dev/null
+++ b/bundles/config_admin/config_admin_tst/example_test2/private/include/example2_managed_service_impl.h
@@ -0,0 +1,66 @@
+/**
+ *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:dev@celix.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);
+celix_status_t managedServiceImpl_destroy(managed_service_pt *instance);
+
+
+
+#endif /* TEST2_SERVICE_IMPL_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/config_admin_tst/example_test2/private/src/activator.c
----------------------------------------------------------------------
diff --git a/bundles/config_admin/config_admin_tst/example_test2/private/src/activator.c b/bundles/config_admin/config_admin_tst/example_test2/private/src/activator.c
new file mode 100644
index 0000000..a5ff343
--- /dev/null
+++ b/bundles/config_admin/config_admin_tst/example_test2/private/src/activator.c
@@ -0,0 +1,227 @@
+/**
+ *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:dev@celix.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_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;
+
+ managed_service_pt managedService;
+ status = managedServiceImpl_create(ctx, &managedService);
+ if (status != CELIX_SUCCESS){
+ return status;
+ }
+
+ status = managedService_create(ctx, &act->mgmServ);
+ if (status != CELIX_SUCCESS){
+ return status;
+ }
+
+ act->mgmServ->managedService = managedService;
+ act->mgmServ->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,
+ act->mgmServ, 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;
+ managedServiceImpl_destroy(&act->mgmServ->managedService);
+ 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/3bce889b/bundles/config_admin/config_admin_tst/example_test2/private/src/example_managed_service_impl.c
----------------------------------------------------------------------
diff --git a/bundles/config_admin/config_admin_tst/example_test2/private/src/example_managed_service_impl.c b/bundles/config_admin/config_admin_tst/example_test2/private/src/example_managed_service_impl.c
new file mode 100644
index 0000000..249bc66
--- /dev/null
+++ b/bundles/config_admin/config_admin_tst/example_test2/private/src/example_managed_service_impl.c
@@ -0,0 +1,108 @@
+/**
+ *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:dev@celix.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;
+}
+
+celix_status_t managedServiceImpl_destroy(managed_service_pt *instance) {
+ free(*instance);
+
+ return CELIX_SUCCESS;
+}
+
+/* -------------------- 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/3bce889b/bundles/config_admin/example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/config_admin/example/CMakeLists.txt b/bundles/config_admin/example/CMakeLists.txt
new file mode 100644
index 0000000..b0b4810
--- /dev/null
+++ b/bundles/config_admin/example/CMakeLists.txt
@@ -0,0 +1,25 @@
+
+
+SET(
+ BUNDLE_NAME
+ "config_admin_example"
+)
+
+SET(
+ BUNDLE_SYMBOLICNAME
+ "org.apache.celix.config_admin.example"
+)
+
+include_directories(
+ "private/include"
+ "public/include"
+ ${PROJECT_SOURCE_DIR}/utils/public/include
+ ../service/public/include
+)
+
+add_celix_bundle(config_admin_example
+ VERSION 0.0.1
+ SOURCES
+ private/src/bundle_activator
+ private/src/example
+)
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/example/private/include/example.h
----------------------------------------------------------------------
diff --git a/bundles/config_admin/example/private/include/example.h b/bundles/config_admin/example/private/include/example.h
new file mode 100644
index 0000000..7239ea5
--- /dev/null
+++ b/bundles/config_admin/example/private/include/example.h
@@ -0,0 +1,18 @@
+#ifndef __EXAMPLE_H_
+#define __EXAMPLE_H_
+
+
+
+#include <celix_errno.h>
+#include <array_list.h>
+#include <properties.h>
+
+typedef struct example *example_pt;
+
+celix_status_t example_create(example_pt *component);
+celix_status_t example_start(example_pt component);
+celix_status_t example_stop(example_pt component);
+celix_status_t example_destroy(example_pt component);
+celix_status_t example_updated(example_pt component, properties_pt updatedProperties);
+
+#endif //__EXAMPLE_H_
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/example/private/src/bundle_activator.c
----------------------------------------------------------------------
diff --git a/bundles/config_admin/example/private/src/bundle_activator.c b/bundles/config_admin/example/private/src/bundle_activator.c
new file mode 100644
index 0000000..3e4622f
--- /dev/null
+++ b/bundles/config_admin/example/private/src/bundle_activator.c
@@ -0,0 +1,75 @@
+#include <stdlib.h>
+#include <pthread.h>
+
+#include <constants.h>
+#include <bundle_context.h>
+#include <service_tracker.h>
+
+#include "example.h"
+#include "managed_service.h"
+
+struct activator {
+ bundle_context_pt context;
+ example_pt example;
+ managed_service_service_pt managed;
+ service_registration_pt managedServiceRegistry;
+};
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+ celix_status_t status = CELIX_SUCCESS;
+ struct activator *activator = calloc(1, sizeof(struct activator));
+ if (activator != NULL) {
+ (*userData) = activator;
+ activator->example = NULL;
+ example_create(&activator->example);
+ activator->managed = NULL;
+ activator->managedServiceRegistry = NULL;
+
+ } else {
+ status = CELIX_ENOMEM;
+ }
+ return status;
+}
+
+celix_status_t bundleActivator_start(void *userData, bundle_context_pt context) {
+ celix_status_t status = CELIX_SUCCESS;
+ struct activator *activator = userData;
+
+ example_start(activator->example);
+
+ activator->managed = calloc(1, sizeof(*activator->managed));
+ properties_pt props = properties_create();
+
+ if (activator->managed != NULL && props != NULL) {
+ properties_set(props, "service.pid", "org.example.config.admin");
+ activator->managed->managedService = (void *)activator->example;
+ activator->managed->updated = (void *)example_updated;
+ bundleContext_registerService(context, (char *) MANAGED_SERVICE_SERVICE_NAME, activator->managed, props, &activator->managedServiceRegistry);
+ }
+
+ return status;
+}
+
+celix_status_t bundleActivator_stop(void *userData, bundle_context_pt context) {
+ celix_status_t status = CELIX_SUCCESS;
+ struct activator *activator = userData;
+
+ if (activator->managed != NULL) {
+ serviceRegistration_unregister(activator->managedServiceRegistry);
+ }
+ example_stop(activator->example);
+
+ return status;
+}
+
+celix_status_t bundleActivator_destroy(void *userData, bundle_context_pt context) {
+ celix_status_t status = CELIX_SUCCESS;
+ struct activator *activator = userData;
+
+ example_destroy(activator->example);
+ if (activator->managed != NULL) {
+ free(activator->managed);
+ }
+
+ return status;
+}
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/example/private/src/example.c
----------------------------------------------------------------------
diff --git a/bundles/config_admin/example/private/src/example.c b/bundles/config_admin/example/private/src/example.c
new file mode 100644
index 0000000..517b252
--- /dev/null
+++ b/bundles/config_admin/example/private/src/example.c
@@ -0,0 +1,59 @@
+#include <stdlib.h>
+
+#include <pthread.h>
+
+#include "hash_map.h"
+
+#include "example.h"
+
+struct example {
+};
+
+//Create function
+celix_status_t example_create(example_pt *result) {
+ celix_status_t status = CELIX_SUCCESS;
+
+ example_pt component = calloc(1, sizeof(*component));
+ if (component != NULL) {
+ (*result) = component;
+ } else {
+ status = CELIX_ENOMEM;
+ }
+ return status;
+}
+
+celix_status_t example_destroy(example_pt component) {
+ celix_status_t status = CELIX_SUCCESS;
+ if (component != NULL) {
+ free(component);
+ } else {
+ status = CELIX_ILLEGAL_ARGUMENT;
+ }
+ return status;
+}
+
+celix_status_t example_start(example_pt component) {
+ celix_status_t status = CELIX_SUCCESS;
+ return status;
+}
+
+celix_status_t example_stop(example_pt component) {
+ celix_status_t status = CELIX_SUCCESS;
+ return status;
+}
+
+celix_status_t example_updated(example_pt component, properties_pt updatedProperties) {
+ printf("updated called\n");
+ hash_map_pt map = (hash_map_pt)updatedProperties;
+ if (map != NULL) {
+ hash_map_iterator_pt iter = hashMapIterator_create(map);
+ while(hashMapIterator_hasNext(iter)) {
+ char *key = hashMapIterator_nextKey(iter);
+ const char *value = properties_get(updatedProperties, key);
+ printf("got property %s:%s\n", key, value);
+ }
+ } else {
+ printf("updated with NULL properties\n");
+ }
+ return CELIX_SUCCESS;
+}
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/readme.md
----------------------------------------------------------------------
diff --git a/bundles/config_admin/readme.md b/bundles/config_admin/readme.md
new file mode 100644
index 0000000..607a810
--- /dev/null
+++ b/bundles/config_admin/readme.md
@@ -0,0 +1,54 @@
+<!--
+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.
+-->
+
+# Configuration Admin
+
+---
+
+## Introduction
+The configuration Admin service allows defining and deploying configuration data to bundles.
+When compared to config.properties it adds the option to update configuration data by providing a persisten storage. It also allows changing configuration data at run-time.
+
+---
+
+## Design
+
+The config_admin bundle implements the configuration_admin service, the interface to configuration objects and the interface of a managed service. At the moment, the implementation uses a config_admin_factory to generate config_admin services for each bundle that wants to use this service. This is an inheritance of the original design and not needed.
+The configuration data is stored persistently in a subdirectory store of the current bundle directory.
+The filenames have the name of the PID and have an extension pid, e.g. base.device1.pid
+The files contains a list of key/value pairs. At least the following keys need to be present:
+service.bundleLocation
+service.pid
+
+---
+
+## TODO
+
+1. Test the configuration of a service_factory
+2. Think about the option to allow remote update of the managed_services
+3. Support configuration of multiple managed services with the same PID. At the moment, only one service is bound to a configuration object.
+ To support this the getConfiguration2 function needs to be called with a location NULL according to the spec.
+
+---
+
+## Usage
+
+1. Bundle that needs configuration data
+ This bundle has to register next to its normal service a managed service that has an update method. This managed service needs to be registered with a properties object that contains the key/value pair service.pid=<PID NAME>.
+ Use config_admin_tst/example_test as an example (it is better than example_test2)
+2. Bundle/application that wants to update the configuration data of the system
+ This bundle needs to retrieve the running config_admin service. With this service it can retrieve all configuration objects for all known Persistent Identifiers (PIDs). For each PID, get all properites that need to be updated. See config_admin_test for an example.
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/service/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/bundles/config_admin/service/CMakeLists.txt b/bundles/config_admin/service/CMakeLists.txt
new file mode 100644
index 0000000..b4ace88
--- /dev/null
+++ b/bundles/config_admin/service/CMakeLists.txt
@@ -0,0 +1,36 @@
+# 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("public/include")
+include_directories("private/include")
+
+add_celix_bundle(config_admin
+ VERSION 0.0.1
+ SOURCES
+ private/src/activator
+ private/src/configuration_admin_factory
+ private/src/configuration_admin_impl
+ private/src/configuration_impl
+ private/src/configuration_store
+ private/src/managed_service_impl.c
+ private/src/managed_service_tracker.c
+ private/src/updated_thread_pool.c
+)
+
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/service/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/bundles/config_admin/service/META-INF/MANIFEST.MF b/bundles/config_admin/service/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..a1b65e2
--- /dev/null
+++ b/bundles/config_admin/service/META-INF/MANIFEST.MF
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Bundle-SymbolicName: config_admin
+Bundle-Version: 1.0.0
+library: config_admin
+Export-Service: configuration_admin
+Import-Service: configuration_admin
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/service/private/include/configuration_admin_factory.h
----------------------------------------------------------------------
diff --git a/bundles/config_admin/service/private/include/configuration_admin_factory.h b/bundles/config_admin/service/private/include/configuration_admin_factory.h
new file mode 100644
index 0000000..a7c79d8
--- /dev/null
+++ b/bundles/config_admin/service/private/include/configuration_admin_factory.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.
+ */
+/*
+ * configuration_admin_factory.h
+ *
+ * \date Aug 12, 2013
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+
+#ifndef CONFIGURATION_ADMIN_FACTORY_H_
+#define CONFIGURATION_ADMIN_FACTORY_H_
+
+#include <stdbool.h>
+
+/* celix.framework */
+#include "bundle.h"
+#include "bundle_context.h"
+#include "celix_errno.h"
+#include "service_reference.h"
+#include "service_factory.h"
+#include "properties.h"
+/* celix.config_admin.public*/
+#include "configuration_admin.h"
+
+
+typedef struct configuration_admin_factory *configuration_admin_factory_pt;
+
+
+/* METHODS */
+
+celix_status_t configurationAdminFactory_create(bundle_context_pt context, service_factory_pt *factory, configuration_admin_factory_pt *instance);
+celix_status_t configurationAdminFactory_destroy( bundle_context_pt context, configuration_admin_factory_pt instance);
+celix_status_t configurationAdminFactory_start(configuration_admin_factory_pt factory);
+celix_status_t configurationAdminFactory_stop(configuration_admin_factory_pt factory);
+
+// public void bundleChanged(BundleEvent event)
+
+celix_status_t configurationAdminFactory_checkConfigurationPermission(configuration_admin_factory_pt factory);
+
+celix_status_t configurationAdminFactory_dispatchEvent(configuration_admin_factory_pt factory, int type, char *factoryPid, char *pid);
+
+celix_status_t configurationAdminFactory_notifyConfigurationUpdated(configuration_admin_factory_pt factory, configuration_pt configuration, bool isFactory);
+celix_status_t configurationAdminFactory_notifyConfigurationDeleted(configuration_admin_factory_pt factory, configuration_pt configuration, bool isFactory);
+
+celix_status_t configurationAdminFactory_modifyConfiguration(configuration_admin_factory_pt factory, service_reference_pt reference, properties_pt properties);
+
+#endif /* CONFIGURATION_ADMIN_FACTORY_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/service/private/include/configuration_admin_impl.h
----------------------------------------------------------------------
diff --git a/bundles/config_admin/service/private/include/configuration_admin_impl.h b/bundles/config_admin/service/private/include/configuration_admin_impl.h
new file mode 100644
index 0000000..b90a21d
--- /dev/null
+++ b/bundles/config_admin/service/private/include/configuration_admin_impl.h
@@ -0,0 +1,68 @@
+/**
+ *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.
+ */
+/*
+ * configuration_admin_impl.h
+ *
+ * \date Aug 12, 2013
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+#ifndef CONFIGURATION_ADMIN_IMP_H_
+#define CONFIGURATION_ADMIN_IMP_H_
+
+
+/* config_admin.ConfigAdmin*/
+#include "configuration_admin.h"
+
+/* celix.framework */
+#include "bundle.h"
+/* celix.config_admin.public */
+#include "configuration.h"
+/* celix.config_admin.private */
+#include "configuration_admin_factory.h"
+#include "configuration_store.h"
+
+
+struct configuration_admin{
+
+ bundle_pt bundle;
+
+ configuration_admin_factory_pt configurationAdminFactory;
+ configuration_store_pt configurationStore;
+};
+
+
+/* METHODS: celix.config_admin.private */
+celix_status_t configurationAdmin_create(configuration_admin_factory_pt factory, configuration_store_pt store, bundle_pt bundle,
+ configuration_admin_service_pt *service);
+celix_status_t configurationAdmin_destroy(configuration_admin_service_pt *service);
+
+/* METHODS: celix.config_admin.public */
+celix_status_t configurationAdmin_createFactoryConfiguration(configuration_admin_pt configAdmin, char *factoryPid, configuration_pt *configuration);
+celix_status_t configurationAdmin_createFactoryConfiguration2(configuration_admin_pt configAdmin, char *factoryPid, char *location, configuration_pt *configuration);
+
+celix_status_t configurationAdmin_getConfiguration(configuration_admin_pt configAdmin, char *pid, configuration_pt *configuration);
+celix_status_t configurationAdmin_getConfiguration2(configuration_admin_pt configAdmin, char *pid, char *location, configuration_pt *configuration);
+
+celix_status_t configurationAdmin_listConfigurations(configuration_admin_pt configAdmin, char *filter, array_list_pt *configurations);
+
+
+#endif /* CONFIGURATION_ADMIN_IMP_H_ */
+
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/service/private/include/configuration_impl.h
----------------------------------------------------------------------
diff --git a/bundles/config_admin/service/private/include/configuration_impl.h b/bundles/config_admin/service/private/include/configuration_impl.h
new file mode 100644
index 0000000..e8a0acd
--- /dev/null
+++ b/bundles/config_admin/service/private/include/configuration_impl.h
@@ -0,0 +1,72 @@
+/**
+ *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.
+ */
+/*
+ * configuration_impl.h
+ *
+ * \date Aug 12, 2013
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+
+#ifndef CONFIGURATION_IMPL_H_
+#define CONFIGURATION_IMPL_H_
+
+/*celix.config_admin.Configuration */
+#include "configuration.h"
+
+/* celix.framework */
+#include "bundle_context.h"
+/* celix.config_admin.private*/
+#include "configuration_admin_factory.h"
+#include "configuration_store.h"
+
+typedef struct configuration_impl *configuration_impl_pt;
+//typedef struct configuration_impl *configuration_pt;
+
+#if 0
+
+
+
+
+
+
+
+celix_status_t configuration_getFactoryPid2(configuration_pt configuration, bool checkDeleted, char **factoryPid);
+celix_status_t configuration_getPid2(configuration_pt configuration, bool checkDeleted, char **pid);
+
+celix_status_t configuration_isDeleted(configuration_pt configuration, bool *isDeleted);
+#endif
+celix_status_t configuration_lock(configuration_impl_pt configuration);
+celix_status_t configuration_unlock(configuration_impl_pt configuration);
+celix_status_t configuration_create( configuration_admin_factory_pt factory, configuration_store_pt store,
+ char *factoryPid, char *pid, char *bundleLocation,
+ configuration_pt *configuration);
+celix_status_t configuration_create2(configuration_admin_factory_pt factory, configuration_store_pt store,
+ properties_pt dictionary,
+ configuration_pt *configuration);
+celix_status_t configuration_getBundleLocation2(configuration_impl_pt configuration, bool checkPermission, char **location);
+celix_status_t configuration_bind(configuration_impl_pt configuration, bundle_pt bundle, bool *isBind);
+celix_status_t configuration_unbind(configuration_impl_pt configuration, bundle_pt bundle);
+celix_status_t configuration_checkLocked(configuration_impl_pt configuration);
+celix_status_t configuration_getAllProperties(configuration_impl_pt configuration, properties_pt *properties);
+
+celix_status_t configuration_getPid(void *handle, char **pid);
+celix_status_t configuration_getProperties(void *handle, properties_pt *properties);
+#endif /* CONFIGURATION_IMPL_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/service/private/include/configuration_store.h
----------------------------------------------------------------------
diff --git a/bundles/config_admin/service/private/include/configuration_store.h b/bundles/config_admin/service/private/include/configuration_store.h
new file mode 100644
index 0000000..824ff63
--- /dev/null
+++ b/bundles/config_admin/service/private/include/configuration_store.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.
+ */
+/*
+ * configuration_store.h
+ *
+ * \date Aug 12, 2013
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+
+#ifndef CONFIGURATION_STORE_H_
+#define CONFIGURATION_STORE_H_
+
+/* celix.utils.public*/
+#include "array_list.h"
+/* celix.framework */
+#include "bundle.h"
+#include "bundle_context.h"
+#include "filter.h"
+/* celix.config_admin.public */
+#include "configuration.h"
+/* celix.config_admin.private */
+#include "configuration_admin_factory.h"
+
+typedef struct configuration_store *configuration_store_pt;
+
+/* METHODS */
+celix_status_t configurationStore_create(bundle_context_pt context, configuration_admin_factory_pt factory, configuration_store_pt *store);
+celix_status_t configurationStore_destroy(configuration_store_pt store);
+
+celix_status_t configurationStore_lock(configuration_store_pt store);
+celix_status_t configurationStore_unlock(configuration_store_pt store);
+
+celix_status_t configurationStore_saveConfiguration(configuration_store_pt store, char *pid, configuration_pt configuration);
+celix_status_t configurationStore_removeConfiguration(configuration_store_pt store, char *pid);
+
+celix_status_t configurationStore_getConfiguration(configuration_store_pt store, char *pid, char *location, configuration_pt *configuration);
+celix_status_t configurationStore_createFactoryConfiguration(configuration_store_pt store, char *factoryPid, char *location, configuration_pt *configuration);
+
+celix_status_t configurationStore_findConfiguration(configuration_store_pt store, char *pid, configuration_pt *configuration);
+
+celix_status_t configurationStore_getFactoryConfigurations(configuration_store_pt store, char *factoryPid, configuration_pt *configuration);
+
+celix_status_t configurationStore_listConfigurations(configuration_store_pt store, filter_pt filter, array_list_pt *configurations);
+
+celix_status_t configurationStore_unbindConfigurations(configuration_store_pt store, bundle_pt bundle);
+
+#endif /* CONFIGURATION_STORE_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/service/private/include/framework_patch.h
----------------------------------------------------------------------
diff --git a/bundles/config_admin/service/private/include/framework_patch.h b/bundles/config_admin/service/private/include/framework_patch.h
new file mode 100644
index 0000000..98194e1
--- /dev/null
+++ b/bundles/config_admin/service/private/include/framework_patch.h
@@ -0,0 +1,39 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements. See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership. The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * framework_patch.h
+ *
+ * \date Aug 12, 2013
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+
+#ifndef BUNDLE_PATCH_H_
+#define BUNDLE_PATCH_H_
+
+
+/* celix.framework.public */
+#include "celix_errno.h"
+#include "bundle.h"
+#include "service_reference.h"
+
+celix_status_t bundle_getBundleLocation(bundle_pt bundle, const char **location);
+
+#endif /* BUNDLE_PATCH_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/service/private/include/managed_service_tracker.h
----------------------------------------------------------------------
diff --git a/bundles/config_admin/service/private/include/managed_service_tracker.h b/bundles/config_admin/service/private/include/managed_service_tracker.h
new file mode 100644
index 0000000..9ce4516
--- /dev/null
+++ b/bundles/config_admin/service/private/include/managed_service_tracker.h
@@ -0,0 +1,60 @@
+/**
+ *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.
+ */
+/*
+ * managed_service_tracker.h
+ *
+ * \date Aug 12, 2013
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+
+#ifndef MANAGED_service_tracker_pt_H_
+#define MANAGED_service_tracker_pt_H_
+
+/* celix.framework */
+#include "bundle_context.h"
+#include "celix_errno.h"
+#include "service_reference.h"
+#include "service_tracker.h"
+/* celix.config_admin.public */
+#include "configuration.h"
+/* celix.config_admin.private */
+#include "configuration_admin_factory.h"
+#include "configuration_store.h"
+
+
+typedef struct managed_service_tracker *managed_service_tracker_pt;
+
+
+celix_status_t managedServiceTracker_create(bundle_context_pt context,
+ configuration_admin_factory_pt factory, configuration_store_pt store,
+ managed_service_tracker_pt *trackerHandle, service_tracker_pt *tracker);
+celix_status_t managedServiceTracker_destroy(bundle_context_pt context, managed_service_tracker_pt handle, service_tracker_pt tracker);
+
+celix_status_t managedServiceTracker_notifyDeleted(managed_service_tracker_pt tracker, configuration_pt configuration);
+celix_status_t managedServiceTracker_notifyUpdated(managed_service_tracker_pt tracker, configuration_pt configuration);
+
+celix_status_t managedServiceTracker_addingService(void * handle, service_reference_pt reference, void **service);
+celix_status_t managedServiceTracker_addedService(void * handle, service_reference_pt reference, void * service);
+celix_status_t managedServiceTracker_modifiedService(void * handle, service_reference_pt reference, void * service);
+celix_status_t managedServiceTracker_removedService(void * handle, service_reference_pt reference, void * service);
+
+
+#endif /* MANAGED_service_tracker_pt_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/bundles/config_admin/service/private/include/updated_thread_pool.h
----------------------------------------------------------------------
diff --git a/bundles/config_admin/service/private/include/updated_thread_pool.h b/bundles/config_admin/service/private/include/updated_thread_pool.h
new file mode 100644
index 0000000..ce1e6b6
--- /dev/null
+++ b/bundles/config_admin/service/private/include/updated_thread_pool.h
@@ -0,0 +1,52 @@
+/**
+ *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.
+ */
+/*
+ * updated_thread_pool.h
+ *
+ * \date Aug 12, 2013
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+
+#ifndef UPDATED_THREAD_POOL_H_
+#define UPDATED_THREAD_POOL_H_
+
+
+#define INIT_THREADS 0
+#define MAX_THREADS 10
+
+
+typedef struct updated_thread_pool *updated_thread_pool_pt;
+
+/* celix.framework.public */
+#include "bundle_context.h"
+#include "celix_errno.h"
+#include "properties.h"
+/* celix.config_admin.public*/
+#include "managed_service.h"
+
+
+
+celix_status_t updatedThreadPool_create( bundle_context_pt context, int maxTreads, updated_thread_pool_pt *updatedThreadPool);
+celix_status_t updatedThreadPool_destroy(updated_thread_pool_pt pool);
+celix_status_t updatedThreadPool_push(updated_thread_pool_pt updatedThreadPool, managed_service_service_pt service, properties_pt properties);
+
+
+#endif /* UPDATED_THREAD_POOL_H_ */