5 Replies Latest reply on Dec 29, 2011 1:06 AM by njiang

    Deploying OSGi bundle with VM arguments

    eric.bender

      I was wondering how to go about creating an osgi bundle that would allow me to run it with VM arguments.  Basically I need to set which of our development environments we'll be testing against whenever we deploy the package, and so normally I would have just set something like -Denv=QA or something like that, but I am not sure how to do this in regards to deployed OSGi bundles as of

        • 1. Re: Deploying OSGi bundle with VM arguments
          eric.bender

          In my POM I added

           

          
                          <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>
                            <version>2.11</version>
                            <configuration>
                              <systemPropertyVariables>
                                <ENV>QA</ENV>
                              </systemPropertyVariables>
                            </configuration>
                          </plugin>
          
          

           

          Then trying to reference this var in the camel-context.xml I tried something like this:

           

          <to uri="velocity://velocity/environments/${ENV}/Login.vm" />
          

           

          But currently that is not working so I was hoping for some direction on how to take a system argument and feed it through properly to the underlying spring DSL docs

          • 2. Re: Deploying OSGi bundle with VM arguments
            ffang

            Hi,

             

            You have two options

            1.simply put that property into $FUSE_ESB/etc/system.properties, which means it's available for whole OSGi container.

             

            2. use property place holder in your camel-context spring-dm configuration, which leverage ConfigAdmin service under the hood,  which means you need put a file in

            $FUSE_ESB/etc folder with the name like $.cfg, take a look at camel-osgi example shipped with FUSE ESB kit, which demonstrate how it works.

             

            Freeman

            • 3. Re: Deploying OSGi bundle with VM arguments
              njiang

              I did some test today[1], you can define a properties component[2] in the spring configuration file. It will pick up the system property by default.

               

              http://svn.apache.org/viewvc?rev=1225077&view=rev

              http://camel.apache.org/properties.html

               

               

              Willem

              • 4. Re: Deploying OSGi bundle with VM arguments
                eric.bender

                I've been using the properties placeholder for a while now to load a properties file.  But how can I leverage a dynamic load of a properties file? 

                 

                Lets say I have a different properties file setup for each environment I want to run my package in.  One in /conf/QA/runtime.properties and another in /conf/DEV/runtime.properties.  Ideally then in this case I could dynamically set something like /conf/{{ENV}}/runtime.properties and have that ENV argument set when generating the bundle like I mentioned above. 

                 

                I know there is a way to set a systemPropertyVariables tag within the maven POM that you can then use somehow in the spring DSL, I just can't seem to get it in scope properly yet.

                • 5. Re: Deploying OSGi bundle with VM arguments
                  njiang

                  I think I should make something clear.

                  First Camel properties component supports to load the property file which location can be changed with the System properties like this

                     location=file:${env:APP_HOME}/etc/foo.properties
                  

                   

                  Second, the other Camel component support to pick up its URI with the Camel properties component variable like this

                     "vm:{{myproperties.evn}}"
                  

                   

                   

                  Willem