PDA

View Full Version : different configurations of bundles?


mmayer
May 15th, 2008, 09:45 AM
Hello,

I'm new to Spring Dynamic Modules and have a question about using different configuration variants of the same application. I would like to have a application as one monolithic variant and also a variant divided into two parts using remoting.

A "normal" spring-managed application uses one or more xml-configuration files beside the components to define the application structure, etc... I can use both deployment variants by connecting the needed component-jars with an individual xml-configuration.

But how could I use different configurations with Spring Dynamic Modules? The configuration lays inside the bundle-jars. What if I would like to switch between a regular bean and a RmiProxyFactoryBean: do I have to repack the bundle jar or do I have to use a different bundle for each variant?

regards
Mark

Costin Leau
May 15th, 2008, 02:59 PM
No for this case you could use OSGi fragments:
http://static.springframework.org/osgi/docs/current/reference/html/appendix-tips.html#appendix-tips:fragments

I won't repeat what the docs already say but basically you can add new resources and imports to your bundle. Depending on your OSGi platform, the fragment can be attached even during runtime (the spec doesn't mandates this behaviour).
In your case, it seems that this is what you can use - keep the common configuration in the main/host bundle and the rest in fragments which can be attached or not in your environment.

mmayer
May 16th, 2008, 03:27 AM
Hallo Costin,

thank you for your reply. I read your hints about fragment bundles and using them can be the solution.

This will result in multiple fragment-bundles: one per variant. I have a plan for a matrix of variants based on multiple spring configurations which have to be combined. So I have to combine these fragment-bundles. I'll try it.

regards
Mark

Costin Leau
May 16th, 2008, 06:20 AM
Sounds good. One thing to keep in mind is that fragments cannot override existing information, they can only add new resources (and manifest headers).
See the chapter in the OSGi spec for the full story.
Cheers,