001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tcsimulator.distrunner;
005:
006: import org.apache.commons.lang.builder.HashCodeBuilder;
007:
008: import com.tc.simulator.distrunner.ArgParser;
009:
010: import java.util.ArrayList;
011: import java.util.List;
012:
013: public class ServerSpecImpl implements ServerSpec {
014:
015: private final String hostname;
016: private final String testHome;
017: private final int hashCode;
018: private final List jvmOpts;
019: private final int cache;
020: private final int jmxPort;
021: private final int dsoPort;
022: private final int type;
023:
024: public ServerSpecImpl(String hostname, String testHome, int cache,
025: int jmxPort, int dsoPort, List jvmOpts, int type) {
026: if (hostname == null)
027: throw new AssertionError();
028: if (testHome == null)
029: throw new AssertionError();
030: this .hostname = hostname;
031: this .testHome = testHome;
032: this .cache = cache;
033: this .jmxPort = jmxPort;
034: this .dsoPort = dsoPort;
035: this .jvmOpts = jvmOpts;
036: this .type = type;
037: this .hashCode = new HashCodeBuilder(17, 37).append(hostname)
038: .append(testHome).append(cache).append(jmxPort).append(
039: dsoPort).append(jvmOpts).append(type)
040: .toHashCode();
041: }
042:
043: public boolean isNull() {
044: return false;
045: }
046:
047: public String getHostName() {
048: return this .hostname;
049: }
050:
051: public String getTestHome() {
052: return this .testHome;
053: }
054:
055: public boolean equals(Object o) {
056: if (o instanceof ServerSpecImpl) {
057: ServerSpecImpl cmp = (ServerSpecImpl) o;
058: return hostname.equals(cmp.hostname)
059: && testHome.equals(cmp.testHome)
060: && cache == cmp.cache && jmxPort == cmp.jmxPort
061: && dsoPort == cmp.dsoPort
062: && jvmOpts.equals(cmp.jvmOpts);
063: }
064: return false;
065: }
066:
067: public int hashCode() {
068: return this .hashCode;
069: }
070:
071: public String toString() {
072: return ArgParser.getArgumentForServerSpec(this );
073: }
074:
075: public List getJvmOpts() {
076: return new ArrayList(jvmOpts);
077: }
078:
079: public int getCache() {
080: return cache;
081: }
082:
083: public int getJmxPort() {
084: return jmxPort;
085: }
086:
087: public int getDsoPort() {
088: return dsoPort;
089: }
090:
091: public ServerSpec copy() {
092: return new ServerSpecImpl(hostname, testHome, cache, jmxPort,
093: dsoPort, new ArrayList(jvmOpts), type);
094: }
095:
096: public int getType() {
097: return type;
098: }
099:
100: }
|