tcalmant / ipopo

iPOPO: a Service-Oriented Component Model for Python
https://ipopo.readthedocs.io/
Apache License 2.0
69 stars 28 forks source link

Cannot avoid creating configadmin 'conf' folder #113

Closed svidoso closed 4 years ago

svidoso commented 4 years ago

Hi,

I want to write a custom Configadmin persistence service (SERVICE_CONFIGADMIN_PERSISTENCE). It seems that one cannot avoid creating the default service ('pelix-services-configuration-json-default') which will always create the 'conf' folder during validation. Is that right?

I also realized that the Configadmin will be created through @Instantiate decorator but the Eventadmin is not. This feels inconsistent.

Thanks for developing this project.

tcalmant commented 4 years ago

Hi, Indeed, this is a behavior that could be changed, but not too much for compatibility reasons.

Currently, the JSON default configuration provider component creates the ./conf folder when it is validated (pelix.services.configadmin@1047). We could replace os.getcwd() by the use of a component property (and inherit it from framework properties for the default instance).

I also realized that the Configadmin will be created through @instantiate decorator but the Eventadmin is not. This feels inconsistent.

That is true, but the issue is more on the JSON persistence service. Indeed: the ConfigurationAdmin component doesn't have configuration properties (it's just a bridge between the managed services and the persistence providers). In other words: the ConfigAdmin component can be instantiated automatically, it won't work alone.

That being said, the JSON persistence service should be instantiated manually, in order to have its own configuration through instance properties.

For retro-compatibility reasons, I think the best would be to add a service controller to the default JSON persistence instance, to disable it if we don't want to have the default behavior.

tcalmant commented 4 years ago

Hi, With commit 38431df, you can now set the framework property "pelix.configadmin.persistence.default.disable" to any non-empty value to disable the automatic instantiation of the default persistence service.

It is defined as a constant for programmatic use: pelix.services.FRAMEWORK_PROP_CONFIGADMIN_DISABLE_DEFAULT_PERSISTENCE

When using the shell directly, this can be done with the -D argument:

python -m pelix.shell -D configadmin.provider.default.disable=1
svidoso commented 4 years ago

Great, that will work. Thank you!