An Example Task


Let's assume that we have a Java application that works in a peer-to-peer environment. The application is called TDSS, and it is made up of individual nodes. Each node is a separate class executing in a Java Virtual Machine (JVM). There are a few different parameters that our nodes can set, and we want the ability to gather statistics after the system has executed and output those results in a file. Based on the requirements of our applicaton, we might be able to configure everything using the Ant task. The next listing shows an example TDSS Ant task that would handle our requirements.

 <TDSS     TDSSDir="${buildDir}"  displayoutput="${output}"     verbose="true"     outputfile="${buildDir}/output.txt" >     <classpath refid="fullclasspath">     <node         id="1"         username="node2"         password="password"         popularity="4"         raid="true"         if="devrun"     />     <node         id="2"         username="node3"         password="password"         popularity="14"         raid="false"         if="prodrun"     /> </TDSS> 

First, let's look at the options in the <TDSS> element itself. The options are considered global for the entire application. When the individual nodes are launched, they are provided with the value of the displayoutput and verbose attributes. The TDSSDir attribute is used to assemble any intermediate code, and the outputfile attribute is used to consolidate output from the application. The entire application consists of one or more <node> elements, which represent real Java applications running in their own VM. We have chosen to provide five different attributes for each of the nodes. The attribute is supplied on the command line of the running node. Notice the use of the if attribute to determine which nodes will execute for a given run of the application using the conditional attribute. Now we can begin the process of building our Ant task.




Professional Java Tools for Extreme Programming
Professional Java Tools for Extreme Programming: Ant, XDoclet, JUnit, Cactus, and Maven (Programmer to Programmer)
ISBN: 0764556177
EAN: 2147483647
Year: 2003
Pages: 228

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net