Wednesday 16 September 2015

Spring OSGI bundle, how does Karaf know where to get the bean configuration files

I have been working with some OSGI based applications and they are deployed on the OSGI container Karaf. I know I should have looked it up earlier however I recently realized I did not know how the Karaf knew where it could find my bean configuration files. I looked around and found out the answer.
Quick answer is below and for more keep reading.
Karaf looks at two places to get the clue of where the bean configuration files are :

  1. META-INF/MANIFEST.MF (if Spring-Context attribute is present)
  2. META-INF/spring (if it contains XML files)
To be able to load an Spring application Karaf needs a feature called Spring Dynamic Modules or in short Spring DM. To query the list of the features you can run

features:list

Or some combination of the same command (I'm using Talend Karaf runtime).

Spring-DM feature loads following bundles
  • org.springframeork.osgi.bundle.extender
  • org.springframeork.osgi.bundle.core
  • org.springframeork.osgi.bundle.io
org.springframeork.osgi.bundle.extender keeps on querying the OSGI container for the newly loaded bundles to see if they are powered by Spring. It checks first the Spring-Context attribute in META-INF/MANIFEST.MF if not present it checks the META-INF/spring for XML files.
When bundles containing the configuration files are found, it simply initializes the Spring Context.

I found this information on an old entry on Javaworld
Introduction to Spring Dynamic Modules

Though old information here is still relevant and true. Spring DM in all likelihood is probably dead and it is succeeded by Eclipse Gemini Blueprint.
Follow the links for more info :
Spring Dynamic Modules becomes Eclipse Gemini Blueprint
relationship between Spring Dynamic Modules and Gemini Blueprint

However even after all this time Spring-DM can be seen at work in many places and it still works fine out of the box.

1 comment:

  1. JTG Casino & Resort – Hollywood, MD | JTG Hospitality
    JTG Casino & Resort is a hotel-casino 당진 출장샵 located 20 춘천 출장마사지 miles northwest 경상북도 출장안마 of Chicago. 의정부 출장샵 Located just minutes' drive 김포 출장샵 from the bustling Mall of America,

    ReplyDelete