KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > utilities > LimitChecker


1 package org.enhydra.shark.utilities;
2
3 import org.enhydra.shark.api.client.wfservice.LimitAdministration;
4
5 /**
6  * Checks activity and process limits.
7  *
8  * @author Sasa Bojanic
9  */

10 public class LimitChecker extends Thread JavaDoc {
11
12    private LimitAdministration limitAdmin;
13    private long delay;
14
15    boolean stopped=false;
16
17    public LimitChecker(LimitAdministration la,long delay) {
18       this.limitAdmin=la;
19       this.delay=delay;
20       System.out.println("Limit checking time initialized to "+delay+" ms");
21       start();
22    }
23
24    public void setDelay (long delay) {
25       this.delay=delay;
26    }
27
28    public void stopChecker () {
29       stopped=true;
30    }
31
32    public void startChecker () {
33       stopped=false;
34    }
35
36    public void run() {
37       while (true) {
38          try {
39             sleep(delay);
40             if (!stopped) {
41                System.out.println("Checking limits ...");
42                long start=System.currentTimeMillis();
43                limitAdmin.checkLimits();
44                long end=System.currentTimeMillis();
45                System.out.println("Limit check finished - it lasted "+(end-start)+" ms");
46             }
47          } catch (Exception JavaDoc e) {
48             e.printStackTrace();
49          }
50       }
51    }
52
53 }
54
55
Popular Tags