Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoload bundles #6

Open
fmilano opened this issue May 28, 2019 · 4 comments
Open

Autoload bundles #6

fmilano opened this issue May 28, 2019 · 4 comments

Comments

@fmilano
Copy link

fmilano commented May 28, 2019

I'm looking into writing a bundle to implement autoloading for bundles (this should not require any change in the framework at all). This is the first step to migrate the CppMicroServices version of MITK to the lastest CppMicroServices.

I'm opening this issue to discuss different interface and implementation options.

@saschazelzer suggested using Apache Felix File Install as a source for the bundle design. What functionality do you think we should define first?

An important implementation decision would be selecting between std::filesystem (and moving to C++17) or using a third party library/implementing the directory monitoring by ourselves.

@jeffdiclemente
Copy link
Member

@fmilano If MITK is currently using CppMicroServices 2.x and its auto-loading feature is sufficient for MITK, one idea could be to implement the auto-loading feature which exists in CppMicroServices 2.x as a bundle using CppMicroServices 3.x. If the auto-loading in 2.x already meets your requirements, that may be an easier path towards migrating MITK. What do you think?

As for the decision to use std::filesystem or something else, I believe in the long term std::filesystem is the way to go and boost offers a clean migration path to std::filesystem if you aren't ready to adopt C++17 yet.

@fmilano
Copy link
Author

fmilano commented Jul 31, 2021

Hi. For watching a directory for changes (new bundles, updated bundles, deleted bundles) I would need to start a background task, probably using a thread to poll the directory. Do you foresee any issues if a shared_ptr to the BundleContext is kept in a background thread and used for installing/uninstalling the detected bundles?

@jeffdiclemente
Copy link
Member

as long as the thread's lifetime is scoped to the lifetime of the BundleContext object used by the thread, I don't see an issue. If the BundleContext object's lifetime can't be guaranteed to outlive the thread's lifetime then a check needs to be made before using the BundleContext as it could have been invalidated through a call to BundleContext::Stop or shutting down the CppMicroServices framework on another thread.

To scope the thread's lifetime you could create a bundle and start the thread in the bundle's BundleActivator::Start method and stop and join the thread in the BundleActivator::Stop method, which would guarantee that the BundleContext is valid for the lifetime of the thread. This way you don't have to check for a valid BundleContext object in the thread.

@fmilano
Copy link
Author

fmilano commented Aug 14, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants