KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > runner > TransparentAppConfig


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
3  * notice. All rights reserved.
4  */

5 package com.tctest.runner;
6
7 import com.tc.object.config.DSOClientConfigHelper;
8 import com.tc.objectserver.control.ServerControl;
9 import com.tc.simulator.app.ApplicationConfig;
10 import com.tc.simulator.app.ApplicationConfigBuilder;
11 import com.tc.simulator.app.GlobalIdGenerator;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Map JavaDoc;
15
16 public class TransparentAppConfig implements ApplicationConfig, ApplicationConfigBuilder {
17
18   private final String JavaDoc applicationClassname;
19   private final GlobalIdGenerator idGenerator;
20   private final Map JavaDoc extraConfigAttributes = new HashMap JavaDoc();
21   private final ServerControl serverControl;
22   // private int globalParticipantCount;
23
private int intensity;
24   private int clientCount;
25   private int applicationInstancePerClientCount = 1;
26
27   public TransparentAppConfig(String JavaDoc applicationClassname, GlobalIdGenerator idGenerator, int clientCount, int intensity, ServerControl serverControl) {
28     this.applicationClassname = applicationClassname;
29     this.idGenerator = idGenerator;
30     if (clientCount < 1) throw new AssertionError JavaDoc("Client count must be greater than 0");
31     this.clientCount = clientCount;
32     this.intensity = intensity;
33     this.serverControl = serverControl;
34   }
35
36   public void setAttribute(String JavaDoc key, String JavaDoc value) {
37     extraConfigAttributes.put(key, value);
38   }
39
40   public String JavaDoc getAttribute(String JavaDoc key) {
41     return (String JavaDoc) extraConfigAttributes.get(key);
42   }
43
44   public int nextGlobalId() {
45     return (int) idGenerator.nextId();
46   }
47
48   public int getGlobalParticipantCount() {
49     return this.clientCount * this.applicationInstancePerClientCount;
50   }
51
52   public TransparentAppConfig setApplicationInstancePerClientCount(int applicationInstanceCount) {
53     this.applicationInstancePerClientCount = applicationInstanceCount;
54     return this;
55   }
56
57   public int getApplicationInstancePerClientCount() {
58     return this.applicationInstancePerClientCount;
59   }
60
61   public int getClientCount() {
62     return this.clientCount;
63   }
64
65   public TransparentAppConfig setClientCount(int i) {
66     this.clientCount = i;
67     return this;
68   }
69
70   public int getIntensity() {
71     return this.intensity;
72   }
73
74   public TransparentAppConfig setIntensity(int i) {
75     this.intensity = i;
76     return this;
77   }
78
79   public String JavaDoc getApplicationClassname() {
80     return this.applicationClassname;
81   }
82
83   // ApplicationConfigBuilder interface...
84

85   public void visitClassLoaderConfig(DSOClientConfigHelper config) {
86     return;
87   }
88
89   public ApplicationConfig newApplicationConfig() {
90     return this;
91   }
92
93   public ApplicationConfig copy() {
94     throw new AssertionError JavaDoc();
95   }
96
97   public ServerControl getServerControl() {
98     return serverControl;
99   }
100
101 }
102
Popular Tags