Announcement Announcement Module
Collapse

Spring Dynamic Modules forum decommissioned in favor of Eclipse Gemini Blueprint

With the official first release of Eclipse Gemini Blueprint shipped, the migration of the Spring Dynamic Modules code base to the Eclipse Foundation, as part of the Gemini project, has been completed.

As such, this forum has been decommissioned in favour of the Eclipse Gemini forums.
See more
See less
How to read external config file when starting a bundle Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to read external config file when starting a bundle

    Hi All,

    I'm working on FUSE ESB 4 with spring dm. Is it possible to read an external config file (not in any jar file, but in the esb's etc directory), to get some properties to be used in the BundleActivator.start method?

    Thanks for any clue,
    chongkai

  • #2
    Solution?

    Originally posted by chongkai View Post
    Hi All,

    I'm working on FUSE ESB 4 with spring dm. Is it possible to read an external config file (not in any jar file, but in the esb's etc directory), to get some properties to be used in the BundleActivator.start method?

    Thanks for any clue,
    chongkai
    I also need to do a similar thing within Fuse, I just want my Bundle to start up SpringPowered as usual, but by have Spring read the XML under fuse/etc/... instead of META-INF/spring within jar. Did you find a good solution for this?
    Thanks in advance!

    Comment


    • #3
      Originally posted by chongkai View Post
      Hi All,

      I'm working on FUSE ESB 4 with spring dm. Is it possible to read an external config file (not in any jar file, but in the esb's etc directory), to get some properties to be used in the BundleActivator.start method?

      Thanks for any clue,
      chongkai
      I didn't work with FUSE ESB 4, but I have an idea.
      OSGi framework usually have a framework properties folder. And usually it's folder called "etc".
      To check it, just put in "etc" folder any file with ".properties" extension, put in file any property and value and in your bundle call:

      Code:
      String propValue = bundleContext.getProperty("your.prop.name");
      If it didn't work, you can use ConfigAdimn service from OSGi spec.

      Originally posted by gcristof View Post
      I also need to do a similar thing within Fuse, I just want my Bundle to start up SpringPowered as usual, but by have Spring read the XML under fuse/etc/... instead of META-INF/spring within jar. Did you find a good solution for this?
      Thanks in advance!
      You have the different task.

      Default implamentation of spring osgi can deploy context only from "META-INF/spring" folder or from the "Spring-Context" attribute on manifest. I don't think that you can attach application context to bundle from outside the bundle jar. In this way, you need to start application context manually.

      Comment


      • #4
        Originally posted by polosatiy View Post
        I didn't work with FUSE ESB 4, but I have an idea.
        OSGi framework usually have a framework properties folder. And usually it's folder called "etc".
        To check it, just put in "etc" folder any file with ".properties" extension, put in file any property and value and in your bundle call:

        Code:
        String propValue = bundleContext.getProperty("your.prop.name");
        If it didn't work, you can use ConfigAdimn service from OSGi spec.



        You have the different task.

        Default implamentation of spring osgi can deploy context only from "META-INF/spring" folder or from the "Spring-Context" attribute on manifest. I don't think that you can attach application context to bundle from outside the bundle jar. In this way, you need to start application context manually.
        Thanks for your reply. Yes I need to use an external Spring config file, not just a properties file. I was able to accomplish it by using a very minimal spring config in the bundle jar that has a single import statement between the <beans> tag:
        <beans>
        <import resource="file:etc/path/to/file.xml"/>
        </beans>

        The external xml file needs to be a full xml doc (all xml tags, spring namespaces, etc..) and contain the beans you want set up in the bundle's context. Modifying this external xml file and restarting the bundle is all that needs to be done to change the Spring context configuration.

        Comment

        Working...
        X