01: /*
02: * Copyright 2000,2005 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13: package org.wings.recorder;
14:
15: public class Client extends Thread {
16: private Script script;
17: protected String userid;
18: protected String passwd;
19: private int initialDelay = 0;
20: private int iterations = 1;
21: private int currentIteration = 0;
22:
23: public void init(Script script) {
24: this .script = script;
25: }
26:
27: public String getUserid() {
28: return userid;
29: }
30:
31: public void setUserid(String userid) {
32: this .userid = userid;
33: }
34:
35: public void setPasswd(String passwd) {
36: this .passwd = passwd;
37: }
38:
39: public void setInitialDelay(int initialDelay) {
40: this .initialDelay = initialDelay;
41: }
42:
43: public void setIterations(int iterations) {
44: this .iterations = iterations;
45: }
46:
47: public int getCurrentIteration() {
48: return currentIteration;
49: }
50:
51: public void run() {
52: try {
53: if (initialDelay > 0)
54: sleep(initialDelay);
55: } catch (InterruptedException e) { /* shit happens */
56: }
57:
58: login();
59:
60: for (currentIteration = 1; currentIteration <= iterations; currentIteration++) {
61: try {
62: long millis = System.currentTimeMillis();
63: System.out.println("CLIENT: " + getUserid()
64: + " begin (" + currentIteration + ")");
65: script.execute();
66: System.out.println("CLIENT: " + getUserid() + " end ("
67: + currentIteration + ") after "
68: + (System.currentTimeMillis() - millis) + "ms");
69: } catch (Exception e) {
70: System.out.println("CLIENT: " + getUserid()
71: + " in iteration " + currentIteration
72: + " threw exception: " + e.getClass().getName()
73: + ": " + e.getMessage());
74: System.err.println(e.getMessage());
75: e.printStackTrace(System.err);
76: }
77: }
78: }
79:
80: protected void login() {
81: }
82: }
|