KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tcsimulator > distrunner > ServerSpecImpl


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

4 package com.tcsimulator.distrunner;
5
6 import org.apache.commons.lang.builder.HashCodeBuilder;
7
8 import com.tc.simulator.distrunner.ArgParser;
9
10 import java.util.ArrayList JavaDoc;
11 import java.util.List JavaDoc;
12
13 public class ServerSpecImpl implements ServerSpec {
14
15   private final String JavaDoc hostname;
16   private final String JavaDoc testHome;
17   private final int hashCode;
18   private final List JavaDoc jvmOpts;
19   private final int cache;
20   private final int jmxPort;
21   private final int dsoPort;
22   private final int type;
23
24   public ServerSpecImpl(String JavaDoc hostname, String JavaDoc testHome, int cache, int jmxPort, int dsoPort, List JavaDoc jvmOpts, int type) {
25     if (hostname == null) throw new AssertionError JavaDoc();
26     if (testHome == null) throw new AssertionError JavaDoc();
27     this.hostname = hostname;
28     this.testHome = testHome;
29     this.cache = cache;
30     this.jmxPort = jmxPort;
31     this.dsoPort = dsoPort;
32     this.jvmOpts = jvmOpts;
33     this.type = type;
34     this.hashCode = new HashCodeBuilder(17, 37).append(hostname).append(testHome).append(cache).append(jmxPort)
35         .append(dsoPort).append(jvmOpts).append(type).toHashCode();
36   }
37
38   public boolean isNull() {
39     return false;
40   }
41
42   public String JavaDoc getHostName() {
43     return this.hostname;
44   }
45
46   public String JavaDoc getTestHome() {
47     return this.testHome;
48   }
49
50   public boolean equals(Object JavaDoc o) {
51     if (o instanceof ServerSpecImpl) {
52       ServerSpecImpl cmp = (ServerSpecImpl) o;
53       return hostname.equals(cmp.hostname) && testHome.equals(cmp.testHome) && cache == cmp.cache
54              && jmxPort == cmp.jmxPort && dsoPort == cmp.dsoPort && jvmOpts.equals(cmp.jvmOpts);
55     }
56     return false;
57   }
58
59   public int hashCode() {
60     return this.hashCode;
61   }
62
63   public String JavaDoc toString() {
64     return ArgParser.getArgumentForServerSpec(this);
65   }
66
67   public List JavaDoc getJvmOpts() {
68     return new ArrayList JavaDoc(jvmOpts);
69   }
70
71   public int getCache() {
72     return cache;
73   }
74
75   public int getJmxPort() {
76     return jmxPort;
77   }
78
79   public int getDsoPort() {
80     return dsoPort;
81   }
82
83   public ServerSpec copy() {
84     return new ServerSpecImpl(hostname, testHome, cache, jmxPort, dsoPort, new ArrayList JavaDoc(jvmOpts), type);
85   }
86
87   public int getType() {
88     return type;
89   }
90
91 }
92
Popular Tags