4 Replies Latest reply on May 8, 2012 4:15 AM by paul berry

    Multiple bundles using same external config

    paul berry Newbie

      I'm currently engineering a solution using multiple camel bundles, deployed into servicemix.  For obvious reasons I'd like to be able to control the configuration of this project from one place.

       

      I'm using the blueprint 'property-placeholder' tag to read my external config file, however if I have two bundles using this tag with the same 'persistent-id' servicemix throws an error.

       

      I did try using the 'propertyPlaceholder' tag within a camel context, however some of my configuration proeprties refer to things outside the camel context (ie Bean configuration options) so this isn't really suitable.

       

      Is there a way to do what I want?  My basic requirements are a way to read the same config file from multiple bundles.  I need to be able to access the same properties from within camel routes, in blueprint xml files outside the camel context and from within java beans.

       

      Edited by: paul.berry on May 4, 2012 9:03 AM

        • 1. Re: Multiple bundles using same external config
          Gert Vanthienen Novice

          Paul,

           

          One possible solution could be to build a bundle specifically for handling the configuration for all your other application bundles.

           

          That bundle has the property placeholder or managed properties tag to automatically pick up the configuration file contents and inject the values into a bean.  You can then export that bean in the OSGi Service Registry and reference it from all your other bundles. 

           

          Regards,

           

          Gert Vanthienen

          • 2. Re: Multiple bundles using same external config
            paul berry Newbie

            Hi Gert, thanks for your response.

             

            I've been looking at a couple of possible solutions and the bean idea seems like a good one, however would I be able to access the properties from my camel routes?  How would I go abut doing this?

             

            The other idea I came up with is to use a simple camel route with a splitter to monitor a root config file, and copy it to all the required config files when it changes.  This seems a bit long winded for such a simple problem though.

            • 3. Re: Multiple bundles using same external config
              Gert Vanthienen Novice

              Hi Paul,

               

               

              If you're using Blueprint, I think you should be able to use <ext:property-placeholder defaults-ref="..."/> to point to a map of key value pairs.  You could use this to point to the configuration provided by your shared bean.  When using Spring, PropertyPlaceHolderConfigurer should also allow you to inject the map of properties directly instead of reading them from a file.

               

               

              Regards,

               

              Gert

              • 4. Re: Multiple bundles using same external config
                paul berry Newbie

                Hi Gert,

                 

                Again, thanks for taking the time to respond to this.  I'm using blueprint, how exactly would I go about setting these propertyplaceholders in my code and then using them in my routes?  Are there any examples of doing this?

                 

                It seems like a bit of an oversight that there's no easily accessible way of keeping all your configuration in one place for multiple bundles.  I imagine most large integration solutions have multiple bundles that require at least some of the same configuration options, unless I'm just missing something.