views:

901

answers:

3

I added a system property in my run.conf of my JBOSS like this:

JAVA_OPTS="$JAVA_OPTS -Dfoo=bar"

Now my question is, if there is a way to resolve this property in a web.xml file in a way something like this:

...
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>
    classpath:applicationContext-common.xml
    classpath:conf/${foo}/applicationContext-local.xml
  </param-value>
</context-param>
...
+1  A: 

I don't know any possibility. But in my opinion this should be implemented in the application. Why you wanna increase the indirection? Normaly you access the contents of the web.xml from within you application ( app > web.xml). Why do this: app > web.xml > environment variable?

Mork0075
I know, it is only one possible option I investigate. if I could resolve it in my web.xml file, it would be easy, without touching each and every file of the application configuration.
Mauli
If your systems design is well, you should not touch it that often. you can hide the "implementation", which means the getting of the property, behind a static method. The you encapsolute the way you get it. How many times you call it should be equal for both solutions.
Mork0075
+2  A: 

web.xml should apply to a single web application only. It should not have global configuration. So no. In any case, by the time the server and your webapp has loaded, it's way to late to start playing command line arguments.

Tom Hawtin - tackline
+1  A: 

Since JBoss internally uses the tomcat web-container, it should work like your example (${foo}/applicationContext-local.xml). I haven't tried the JBoss case, but we use this technique all the time in Tomcat.