5 Replies Latest reply on Mar 22, 2008 3:41 PM by Clint Popetz

    Inject Production Settings

    Tom Goring Apprentice

      Hi,


      I'd like to be able to deploy the same EAR in test and production and override some injection settings.
      E.g.
      components.properties


      jndiPattern \#{ejbName}/local
      debug true



      Is there a way to have a property e.g. located in jboss_home/server/default/conf that can override the settings in the EAR some how ?


      Or can I some how get seam to load some configuration from the filesystem (rather than the EAR).


      Thanks


      Tom

        • 1. Re: Inject Production Settings
          Norman Richards Expert

          Everything in Seam is read from the classpath, and server/default/conf is on your classpath.  You can't reliably override your application's configuration files by duplicating them there, but you certainly can put some configuration files there. 


          Are you using seam-gen as the basis of your app?  Seam-gen already has the notion of dev and prod profiles.

          • 2. Re: Inject Production Settings
            Tom Goring Apprentice

            Hi Norman,


            Thanks for that.


            I am using a seam-gen app started a couple of months ago.


            I don't like the idea of rebuilding a ear because I want to deploy into production.  I'm fine with the 'debug' vs 'non debug' versions though.


            Basically I want to add a couple of settings that I know for sure will be set correctly in dev (like don't send emails, etc, etc).


            Looks like I need to add a properties file in ../conf and then load that up in an Application scoped seam component.  (this is kind of what I used todo in the old version of my app). 


            I was hoping that I could tell seam to load up properties from my.properties (located in ../conf) and allow seam to inject them onto my components as required?





            • 3. Re: Inject Production Settings
              Clint Popetz Apprentice

              Another possibility, which we use to allow us to have a single ear run in multiple environments...start your production jboss instance(s) with -Dyour.property.name=foo and have the setter for the property in question check to see if System.getProperty("your.property.name") is non-null, and if it is, use that value and ignore what the setter was passed.


              Ugly, but very flexible.  We have scripts that set up multiple jboss nodes in clusters, and they know how to set these properties based on the target environment.  It's much nicer than building and tracking multiple ears for each tuple of environmental differences (debug / qa / load testing / production / static-mirror / etc.)


              In my spring days (shudder) we had a property override mechanism for doing exactly this, in a generic fashion for all properties.  It would be nice to have the same in seam, i.e. something you could turn on in components.xml that would allow environment-variable overrides a la components.properties.


              • 4. Re: Inject Production Settings
                Siarhei Dudzin Apprentice

                There is server/<profile>/deploy/properties-service.xml which allows to specify proprties or location of property files. No need for -D then.

                • 5. Re: Inject Production Settings
                  Clint Popetz Apprentice

                  Siarhei Dudzin wrote on Mar 22, 2008 02:57 PM:


                  There is server/<profile>/deploy/properties-service.xml which allows to specify proprties or location of property files. No need for -D then.


                  Cool, thanks for the tip.  I wasn't aware of that service.