Professional Java Tools for Extreme Programming: Ant, XDoclet, JUnit, Cactus, and Maven (Programmer to Programmer)

If you consider the init-param values we added to the comments, we really didn't gain anything from a standpoint of making the necessary changes between a production and a development run. In either case, we need to open the source code to add the appropriate table and account values. However, we can use Ant to further abstract the init-param values. Remember that Ant and XDoclet have the ability to replace value based on the properties defined within an Ant build script. With this in mind, we could create a two properties such as the following in our Ant build script:

<property name="table" value="production"/> <property name="account" value=" accounts"/>

Now in the webdoclet tags for the servlet, the following tags

@web-servlet-init-param name="table" value="production" @web-servlet-init-param name="account" value="accounts"

will be replaced with

@web-servlet-init-param name="table" value="$j table {" @web-servlet-init-param name="account" value="${account }"

When the Ant build script is executed, the task to create the deployment descriptor will automatically replace the ${table} and ${account} with the values set by the properties.

Категории