× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Ant has the ability to process replacement values in files (even source files if you need to). Basically, all you have to do is create a property file with your replacement values in it, specify a filterset for the file and then, tell the copy to use the filterset. Here is an example:

Build.properties (this is just general Ant settings)
----------------
build.debug=true
servlet.jar=C:/tomcat4.0.5/common/lib/servlet.jar

staging.properties
------------------
local-db-jndiname=jdbc/webdev
remote-db-jndiname=jdbc/tlow400
local-db-name=WEBDEV
remote-db-name=TLOW400
logPath=/was51/b2blogs/B2bLoginws.log

prod.properties
---------------
local-db-jndiname=jdbc/itpsrv
remote-db-jndiname=jdbc/swp
local-db-name=ITPSRV
remote-db-name=SWP
logPath=/was51/PlusSites/logs/PlusSites/B2bLoginws.log

build.xml
---------
<project name="b2bstore" basedir="." default="create-ear">
<property file="build.properties"/>
<property name="build" value="build"/>
<property name="dist" value="dist"/>
<property name="lib" value="lib"/>
<property name="src" value="src"/>
<property name="src.java" value="${src}/java"/>
<property name="src.web" value="${src}/web"/>
<property name="src.web.webinf" value="${src.web}/WEB-INF"/>
<property name="src.web.webinf.classes" value="${src.web.webinf}/classes"/>
<property name="build.webinf" value="${build}/WEB-INF"/>
<property name="build.webinf.classes" value="${build.webinf}/classes"/>
<property name="build.webinf.lib" value="${build.webinf}/lib"/>
<property name="war.file" value="${build}/B2bLoginws.war"/>
<property name="ear.file" value="${dist}/B2bLoginws.ear" />
<property name="web.xml.name" value="${src.web.webinf}/web.xml.template" />

<filterset id="staging.filterset">
<filtersfile file="${basedir}/staging.properties"/>
</filterset>
<filterset id="prod.filterset">
<filtersfile file="${basedir}/prod.properties"/>
</filterset>

<target name="staging-init">
<property name="filter.ref" value="staging.filterset"/>
<property file="staging.properties"/>
</target>
<target name="prod-init">
<property name="filter.ref" value="prod.filterset"/>
<property file="prod.properties"/>
</target>

<target name="clean">
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>

<target name="prepare" depends="clean">
<mkdir dir="${build}"/>
<mkdir dir="${build.webinf}"/>
<mkdir dir="${build.webinf.classes}"/>
<mkdir dir="${build.webinf.lib}"/>
<mkdir dir="${dist}"/>
</target>
<target name="compile" depends="prepare">
<javac srcdir="${src.java}" debug="${build.debug}" destdir="${build.webinf.classes}">
<include name="com/cl/ecomm/**/*"/>
<classpath>
<fileset dir="${lib}"/>
<pathelement location="${servlet.jar}"/>
</classpath>
</javac>
</target>

<target name="copy-web-dir">
<copy todir="${build}" preservelastmodified="yes">
<fileset dir="${src.web}" excludes="**/*.template"/>
</copy>
</target>

<target name="copy-files" depends="compile,copy-web-dir">
<copy file="${web.xml.name}" overwrite="true" tofile="${build.webinf}/web.xml">
<filterset refid="${filter.ref}"/>
</copy>
<copy file="${src.web.webinf.classes}/ApplicationResources.properties.template" overwrite="true"
tofile="${build.webinf.classes}/ApplicationResources.properties">
<filterset refid="${filter.ref}"/>
</copy>
<copy file="${src.web.webinf.classes}/log4j.properties.template" overwrite="true"
tofile="${build.webinf.classes}/log4j.properties">
<filterset refid="${filter.ref}"/>
</copy>
<copy file="${lib}/log4j-1.2.8.jar" overwrite="true" tofile="${build.webinf.lib}/log4j-1.2.8.jar" />
</target>

<target name="war" depends="compile">
<zip basedir="${build}" destfile="${war.file}"/>
</target>

<target name="earit" depends="war">
<ear destfile="${ear.file}" appxml="${src.java}/META-INF/application.xml">
<fileset dir="${build}" includes="*.jar,*.war"/>
</ear>
</target>

<target name="create-ear-prod" depends="prod-init,compile,copy-files,war,earit"/>
<target name="create-ear-staging" depends="staging-init,compile,copy-files,war,earit"/>
</project>


Our convention is that all of the files that have replacement values in them end with ".template". Here is what's in my ApplicationResources.properties.template file:

localDataSource=java:comp/env/@local-db-jndiname@
remoteDataSource=java:comp/env/@remote-db-jndiname@
localDbName=@local-db-name@
remoteDbName=@remote-db-name@

If I run target create-ear-prod, I end up with a file called ApplicationResources.properties that looks like this:

localDataSource=java:comp/env/jdbc/itpsrv
remoteDataSource=java:comp/env/jdbc/swp
localDbName=ITPSRV
remoteDbName=SWP

In this example, I also process my web.xml and log4j.properties files the same way. The Ant documentation is pretty good and this is pretty basic stuff (Ant can also call programs and do all sorts of other processing). If you want to play around using this example script, you need to set up your directory structure like this:

Project (this can be called anything)
|-lib
|-src
| |-java
| | |-(your packages)
| | |-META-INF
| |-web
| | |-WEB-INF
| | | |-classes

Build.xml, build.properties, staging.properties, and prod.properties need to go in the "Project" directory. Also note that I have partial package names in build.xml so those will need to be changed to match your code.

The Ant script will create a build directory under "Project" which will contain the compiled code and the processed files. It will also create a dist directory that has the Ear file in it.

Matt

-----Original Message-----
From: wdsci-l-bounces@xxxxxxxxxxxx [mailto:wdsci-l-bounces@xxxxxxxxxxxx] On Behalf Of Christen, Duane J.
Sent: Friday, April 18, 2008 9:21 AM
To: 'Websphere Development Studio Client for iSeries'
Subject: Re: [WDSCI-L] Web Service .config file

Matt;

Would you mind expanding on how you use Ant scripts for applying environment differences and/or creating deployments?

Duane Christen

-----Original Message-----
From: wdsci-l-bounces@xxxxxxxxxxxx
[mailto:wdsci-l-bounces@xxxxxxxxxxxx]On Behalf Of Haas, Matt (CL Tech
Sv)
Sent: Thursday, April 03, 2008 11:36 AM
To: Websphere Development Studio Client for iSeries
Subject: Re: [WDSCI-L] Web Service .config file


Duane,

We use Ant to handle configuration differences between different environments. The Ant script takes care of applying the differences and creating the deployments (no exporting or anything else IDE specific).

As far as the password goes, we typically create users with non-expiring passwords for this type of thing.

Matt

-----Original Message-----
From: wdsci-l-bounces@xxxxxxxxxxxx [mailto:wdsci-l-bounces@xxxxxxxxxxxx] On Behalf Of Christen, Duane J.
Sent: Thursday, April 03, 2008 1:35 PM
To: Websphere Development Studio Client for iSeries (E-mail)
Subject: [WDSCI-L] Web Service .config file

The .config file for a web service contains "hard coded" connection, library list and authentication information supplied to the Web Service Wizard.
This is fine for testing/development but when I promote the web service to the QA, Training, and Production environments this information will have to be changed for each environment. I think that changing the library lists in the .config file after the web service has been deployed to Websphere will work for each environment, but the user profile used by the web service has the password changed every month.

How do I automatically change the .config file for the web service each month?

I am sure I am missing something basic, could someone let me know what that is?

Thanks
Duane Christen


[http://www.paetec.com/eSignature/My_PAETEC_signature_r1_c1.gif] [http://www.paetec.com/eSignature/My_PAETEC_signature_r1_c2.gif] Duane Christen
Software Developer Analyst II
(319) 790-7162 Office
(319) 431-6227 Cell
dchristen@xxxxxxxxxxxxx<mailto:dchristen@xxxxxxxxxxxxx>

[http://www.paetec.com/eSignature/My_PAETEC_signature_r2_c1.gif]<http://www.paetec.com/>
[http://www.paetec.com/eSignature/My_PAETEC_signature_r3_c1.gif]

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.