Results 1 to 4 of 4

Thread: How to read external config file when starting a bundle

  1. #1
    Join Date
    Apr 2010
    Posts
    1

    Default 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. #2
    Join Date
    Jul 2011
    Posts
    3

    Default Solution?

    Quote 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!

  3. #3
    Join Date
    Sep 2006
    Location
    Russia
    Posts
    28

    Default

    Quote 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.

    Quote 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.

  4. #4
    Join Date
    Jul 2011
    Posts
    3

    Default

    Quote 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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •