Announcement Announcement Module
Collapse
No announcement yet.
Injecting properties to a ApplicationContext at deploy time Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Injecting properties to a ApplicationContext at deploy time

    I have a web application that uses spring mvc and I would like to provide values for the placeholders in my ApplicationContext at deploy time. I don't want them to be baked into the war file. Also, I am looking for something that allows me to specify the values per deployment so that if I run two applications on the same tcServer instance, and those 2 applications happen to use some of the same placeholder names, I can provide each deployment with a different set of values for its placeholders.

    Is there a standard way of handling this ?

  • #2
    Put the properties file on the filesystem and not in the war... Properties files can come from anywhere, I also suggest you take a look at Spring 3.1 with the new profile support and finally you could specify the parameters with -D or in your context file.

    Comment


    • #3
      Thank you. I suppose I could have a convention that puts some "config" folder on the server class path at startup and then in each application context, I could specify, in the PropertyPlaceholderConfigurer that the properties file is at "classpath:my-application/config.properties" That would give each app its own distinct settings.

      Before I made up my own convention, I wanted to check and see if there is already something in common usage.

      Also, does tcServer support any mechanism to provide settings (or a properties file) directly at deploy time?

      Comment


      • #4
        It doesn't have to be on the classpath!... You could even use a placeholder (${config.file.location} for instance) and do something like {$config.file.location}/myapp.properties as a file name..

        Originally posted by wrmay
        Also, does tcServer support any mechanism to provide settings (or a properties file) directly at deploy time?
        Already answered that..

        Originally posted by Marten Deinum
        finally you could specify the parameters with -D or in your context file

        Comment


        • #5
          Sorry for being thick but I don't understand about the -D. Isn't that specified at server start time rather than deploy time ?

          Comment


          • #6
            Tend to have a tomcat per application so depends on your setup . But indeed it is server start time which for the setup here is deploy time. The only way to do that is to specify them in a properties file and put them in a location from where the PPHC will load it, location could be partially configured through -D.

            A last resort would be to modify the PPHC and retrieve some values from JNDI...

            Comment

            Working...
            X