-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #588 from apache/feature/585-celix-conditions
Feature/585 celix conditions
- Loading branch information
Showing
57 changed files
with
1,835 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# 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. | ||
|
||
celix_subproject(COMPONENTS_READY_CHECK "Bundle that checks if all components becomes active and reports this using a condition service" ON) | ||
if (COMPONENTS_READY_CHECK) | ||
|
||
add_library(components_ready_api INTERFACE) | ||
target_include_directories(components_ready_api INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/api>) | ||
add_library(Celix::components_ready_api ALIAS components_ready_api) | ||
install(TARGETS components_ready_api EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT components_ready | ||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/celix_components_ready_api) | ||
install(DIRECTORY api/ DESTINATION include/celix_components_ready_api COMPONENT components_ready) | ||
|
||
|
||
set(COMPONENTS_READY_CHECK_SRC src/celix_components_ready_check.c) | ||
set(COMPONENTS_READY_CHECK_DEPS Celix::framework Celix::components_ready_api) | ||
add_celix_bundle(components_ready_check | ||
SOURCES src/celix_components_ready_check_activator.c ${COMPONENTS_READY_CHECK_SRC} | ||
VERSION 1.0.0 | ||
SYMBOLIC_NAME "apache_celix_components_ready_check" | ||
GROUP "Celix/Conditions" | ||
NAME "Apache Celix Components Ready Check" | ||
FILENAME celix_components_ready_check | ||
) | ||
target_include_directories(components_ready_check PRIVATE src) | ||
target_link_libraries(components_ready_check PRIVATE ${COMPONENTS_READY_CHECK_DEPS}) | ||
add_library(Celix::components_ready_check ALIAS components_ready_check) | ||
install_celix_bundle(components_ready_check EXPORT celix COMPONENT components_ready) | ||
|
||
if (ENABLE_TESTING) | ||
add_library(components_ready_cut STATIC ${COMPONENTS_READY_CHECK_SRC}) | ||
target_include_directories(components_ready_cut PUBLIC src) | ||
target_link_libraries(components_ready_cut PUBLIC ${COMPONENTS_READY_CHECK_DEPS}) | ||
add_subdirectory(gtest) | ||
endif() | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
title: Shell | ||
--- | ||
|
||
<!-- | ||
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. | ||
--> | ||
|
||
# Apache Celix Component Ready | ||
|
||
## Intro | ||
The Apache Celix Component Ready provides an api and bundle which can be used to check if all components are ready. | ||
|
||
## API library | ||
The Apache Celix Component Ready Check provides a single api library `Celix::component_ready_api` which contains | ||
the condition id constant used to register the "components.ready" condition service. | ||
|
||
## Bundle | ||
The Apache Celix Component Ready Check provides the `Celix::components_ready_check` bundle which registers the | ||
"components.ready" condition service. | ||
|
||
The "components.ready" condition service will be registered when the "framework.ready" service is registered, | ||
all components have become active and the event queue is empty. | ||
|
||
If the "components.ready" condition service is registered and some components become inactive or the event queue is | ||
not empty, the "components.ready" condition is **not** removed. The "components.ready" condition is meant to indicate | ||
that the components in the initial framework startup phase are ready. | ||
|
||
## CMake options | ||
|
||
- COMPONENTS_READY_CHECK=ON | ||
|
||
## Using info | ||
|
||
If the Apache Celix Component Ready is installed, `find_package(Celix)` will set: | ||
- The `Celix::component_ready_api` interface (i.e. header only) library target | ||
- The `Celix::components_ready_check` bundle target |
39 changes: 39 additions & 0 deletions
39
bundles/components_ready_check/api/celix_components_ready_constants.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
*/ | ||
|
||
#ifndef CELIX_COMPONENTS_READY_CONSTANTS_H_ | ||
#define CELIX_COMPONENTS_READY_CONSTANTS_H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/*! | ||
* @brief The unique identifier for the components.ready condition. | ||
* | ||
* The components ready condition is registered by the framework if the framework.ready condition is registered | ||
* and all components active. | ||
*/ | ||
#define CELIX_CONDITION_ID_COMPONENTS_READY "components.ready" | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* CELIX_COMPONENTS_READY_CONSTANTS_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# 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. | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
#Add active/inactive test component bundles | ||
add_celix_bundle(ActiveComponentBundle SOURCES src/ActiveComponentBundle.cc VERSION 1.0.0) | ||
add_celix_bundle(InactiveComponentBundle SOURCES src/InactiveComponentBundle.cc VERSION 1.0.0) | ||
|
||
add_executable(test_components_ready src/ComponentsReadyTestSuite.cc) | ||
target_link_libraries(test_components_ready PRIVATE | ||
Celix::framework | ||
Celix::components_ready_api | ||
GTest::gtest | ||
GTest::gtest_main | ||
) | ||
if (ENABLE_TESTING_ON_CI) | ||
target_compile_definitions(test_components_ready PRIVATE TESTING_ON_CI=1) | ||
endif () | ||
celix_target_bundle_set_definition(test_components_ready NAME COMPONENTS_READY_CHECK_BUNDLE_SET Celix::components_ready_check) | ||
celix_target_bundle_set_definition(test_components_ready NAME ACTIVE_CMP_TEST_BUNDLE_SET ActiveComponentBundle) | ||
celix_target_bundle_set_definition(test_components_ready NAME INACTIVE_CMP_TEST_BUNDLE_SET InactiveComponentBundle) | ||
|
||
add_test(NAME test_components_ready COMMAND test_components_ready) | ||
setup_target_for_coverage(test_components_ready SCAN_DIR ..) | ||
|
||
if (LINKER_WRAP_SUPPORTED) | ||
add_executable(test_components_ready_with_ei src/ComponentsReadyWithErrorInjectionTestSuite.cc) | ||
target_link_libraries(test_components_ready_with_ei PRIVATE | ||
framework_cut | ||
components_ready_cut | ||
Celix::components_ready_api | ||
Celix::malloc_ei | ||
Celix::threads_ei | ||
Celix::bundle_ctx_ei | ||
Celix::properties_ei | ||
GTest::gtest | ||
GTest::gtest_main | ||
) | ||
|
||
add_test(NAME test_components_ready_with_ei COMMAND test_components_ready_with_ei) | ||
setup_target_for_coverage(test_components_ready_with_ei SCAN_DIR ..) | ||
endif () |
41 changes: 41 additions & 0 deletions
41
bundles/components_ready_check/gtest/src/ActiveComponentBundle.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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 "celix/BundleActivator.h" | ||
#include "celix_condition.h" | ||
|
||
/** | ||
* @brief Empty Test Component for testing the condition service | ||
*/ | ||
class CondComponent { | ||
public: | ||
CondComponent() = default; | ||
}; | ||
|
||
class ActiveComponentBundle { | ||
public: | ||
explicit ActiveComponentBundle(const std::shared_ptr<celix::BundleContext>& ctx) { | ||
ctx->getDependencyManager()->createComponent<CondComponent>().build(); | ||
} | ||
|
||
private: | ||
std::shared_ptr<celix::ServiceRegistration> registration{}; | ||
}; | ||
|
||
CELIX_GEN_CXX_BUNDLE_ACTIVATOR(ActiveComponentBundle) |
Oops, something went wrong.