01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tcsimulator;
05:
06: import com.tcsimulator.distrunner.ServerSpec;
07:
08: import java.util.ArrayList;
09: import java.util.Collection;
10: import java.util.Iterator;
11:
12: public class TestEnvironmentViewImpl implements TestEnvironmentView {
13: private ServerViewImpl serverView;
14: private Collection clientViews;
15: private final int intensity;
16:
17: /*
18: * Copies of specs are pass in.
19: */
20: public TestEnvironmentViewImpl(ServerSpec serverSpec,
21: Collection clientSpecs, int intensity) {
22: this .intensity = intensity;
23: this .clientViews = new ArrayList();
24: update(serverSpec, clientSpecs);
25: }
26:
27: public synchronized void update(ServerSpec serverSpec,
28: Collection clientSpecs) {
29: update(serverSpec);
30: update(clientSpecs);
31: }
32:
33: public synchronized void update(ServerSpec serverSpec) {
34: this .serverView = new ServerViewImpl(serverSpec);
35: }
36:
37: public synchronized void update(Collection clientSpecs) {
38: for (Iterator i = clientSpecs.iterator(); i.hasNext();) {
39: ClientSpec cSpec = (ClientSpec) i.next();
40: ClientView cView = new ClientViewImpl(cSpec);
41: this .clientViews.add(cView);
42: }
43: }
44:
45: public synchronized void setServerRunning(int val) {
46: this .serverView.setServerRunning(val);
47: }
48:
49: public synchronized ServerView getServerView() {
50: return this .serverView.copy();
51: }
52:
53: public synchronized Collection getClientViews() {
54: return new ArrayList(this .clientViews);
55: }
56:
57: public int getIntensity() {
58: return this.intensity;
59: }
60:
61: }
|