ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Cheesman <jch...@msl.es>
Subject Re: Forcing a (Windoze) Reboot from Ant?
Date Fri, 27 Jul 2001 09:57:00 GMT
At 11:12 AM 27/07/01, you wrote:
>On Fri, 27 Jul 2001, Jim Cheesman <jchees@msl.es> wrote:
>
> > One <tea/> task, coming up...
>
>Jim, Ant 1.x is supposed to be JDK 1.1 compatible, could you please
>remove the Collection classes and replace them with their JDK 1.1
>equivalents?  Otherwise this will have to become an optional task,
>while it really belongs into the core 8-)


Apologies...  fix follows:
<code>
/*
  *  Jim Cheesman
  *  Copyright 2001
  *  All rights reserved
  */
package jim.utilities;
import java.io.*;
import java.util.*;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;

/**
  * Coffee task to fake doing something useful. Use at your own risk.
  *
  *@author     Jim Cheesman
  *@created    May 23, 2001
  */
public class Coffee extends Task {
   private int time = 60000;
   private String message1 = "Reengineering high-granularity cyclic 
dependencies";
   private String message2 = "Reengineering low-granularity cyclic 
dependencies";
   private String message3 = "Processing synergic package influences";

   public Coffee() {
   }


   public void setTime(String sTime) {
     time *= Integer.parseInt(sTime);
   }

   public void setMessage1(String message1) {
     this.message1 = message1;
   }

   public void setMessage2(String message2) {
     this.message2 = message2;
   }

   public void setMessage3(String message3) {
     this.message3 = message3;
   }


   String[] randomData() {
     Vector result = new Vector();
     Properties props = System.getProperties();
     for (Enumeration e = props.propertyNames() ; e.hasMoreElements() ;) {
       String key = (String) e.nextElement();
       result.add(key);
       result.add(props.getProperty(key));
     }
     String[] list = getProject().getBaseDir().list();
     for (int i=0; i<list.length; i++) {
       result.add(list[i]);
     }
     String[] toReturn = new String[result.size()];
     int counter = 0;
     for (Enumeration e = result.elements() ; e.hasMoreElements() ;) {
       toReturn[counter++] = (String) e.nextElement();
     }
     return toReturn;
   }


   int getRandom(int factor) {
     return (int)(Math.random()*factor);
   }


   public void execute() {
     String[] randomData = randomData();
     int randomValue;
     int delay = 1000000;
     int slice = time / 3;
     long currentTime = System.currentTimeMillis();
     long time1 = currentTime + slice;
     long time2 = time1 + slice;
     long time3 = time2 + slice;
     log(message1);
     while ((currentTime = System.currentTimeMillis()) < time1) {
       randomValue = getRandom(delay);
       if (randomValue < 1) log("collision found [" + 
randomData[getRandom(randomData.length)] + "]");
     }
     log(message2);
     while ((currentTime = System.currentTimeMillis()) < time2) {
       randomValue = getRandom(delay);
       if (randomValue < 1) log("fixing lossy compile fault: " + 
randomData[getRandom(randomData.length)]);

     }
     log(message3);
     while ((currentTime = System.currentTimeMillis()) < time3) {
       randomValue = getRandom(delay);
       if (randomValue < 1) log("reentrant filehoser condition:" + 
randomData[getRandom(randomData.length)]);
     }
   }
}

</code>

--

                           *   Jim Cheesman   *
             Trabajo: 
jchees@msl.es - (34)(91) 724 9200 x 2360
   The shortest distance between 
two points is how far apart they are.



Mime
View raw message