JaVa
   

An Example Task

Let's assume that we have a Java app that works in a peer-to-peer environment. The app 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 ref >
 <node
 
 user 
 password="password"
 popularity="4"
 ra 
 if="devrun"
 />
 <node
 
 user 
 password="password"
 popularity="14"
 ra 
 if="prodrun"
 />
</TDSS>


First, let's look at the options in the <TDSS> element itself. The options are considered global for the entire app. 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 app. The entire app consists of one or more <node> elements, which represent real Java apps 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 app using the conditional attribute. Now we can begin the process of building our Ant task.


JaVa
   
Comments