ConfigurationAdmin, PropertyPlaceholder, Chicken and Egg
There is a little gap in the osgix:cm-properties support in spring-powered bundles, and the ability to get configuration injected into ConfigurationAdmin. This is particularly true for integration testing.
It is highly desirable for integration tests to be able to inject test-specific configuration into ConfigurationAdmin, and allow the code being tested to consume that configuration. It is trivial to write a bundle to read test configuration property files from a system path or the bundle being tested and inject them into ConfigurationAdmin PIDs. But delaying the test bundle startup so that the configuration is injected before it is consumed is extremely hard.
The problem here seems to be in the startup of a spring-powered bundle. The property placeholder attached to the osgix:cm-properties is resolved before the bundle pauses to satisfy its service dependencies. Service dependencies are the only dependency pause point provided by DM, and so if you want to try to make sure everything is available before the spring context is refreshed, you need to use service dependencies. There is no way to tell the bundle not to even begin context creation until a set of conditions are satisfied. Therefore you can't prevent the PropertyPlaceholder from reading from ConfigurationAdmin when the spring context is created, but before the context is refreshed.
Having such a feature would certainly help in defining a complete platform against which a bundle under test could be tested against. Of course, the same problem can happen in full deployment if you require an initial startup to first load configuration data into ConfigurationAdmin.
Or is there another way that has escaped me?
Infor Global Solutions