开发者

Ways to override context-param in web.xml during or after deployment in JBoss AS 6

In my current JSF 2 project, one setting in the web.xml is

<context-param>
    <param-name>javax.faces.PROJEC开发者_开发技巧T_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>

And its value should be set to Production instead Development on deployment in JBoss AS.

Are there simple ways to override or modify this web.xml entry during or after deployment?


Update: I found this article which explains the files in JBoss AS5 deployers directory. The author writes:

There are times when you want a configuration to apply to all web applications, JBoss has global versions of these files which are located in the deployers directory

So for a global-level configuration of web.xml, the file deployers/jbossweb.deployer/web.xml can be used. I will check if these files can override values or only add values to the application-level web.xml

If you know if deployers/jbossweb.deployer/web.xml overrides values in the application level web.xml, please leave a message here ;)


If you are using Maven you can do a filtered copy of web.xml and set the values from a properties file. Example:

<properties>
    <stage.dir>Development</stage.dir>
</properties>
<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
                <include>**/*.properties</include>
            </includes>
        </resource>
    </resources>
</build>

And set different values per profile, so you just have to deploy with mvn goal -P production. See properties, profiles.


As the default value of the javax.faces.PROJECT_STAGE parameter is Production, I will remove this context-param it from the web.xml so it will be Production on the live servers, and for the development environment (which is actually a GlassFish v3) I add the context-param to the default web.xml. As application parameters override global parameters, I think this is the most standards based way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜