1 package cz.cuni.amis.pogamut.ut2004.utils;
2
3 import java.util.List;
4
5 import cz.cuni.amis.pogamut.base.agent.IAgentId;
6 import cz.cuni.amis.pogamut.base.agent.params.IAgentParameters;
7 import cz.cuni.amis.pogamut.base.agent.utils.runner.impl.AgentRunner;
8 import cz.cuni.amis.pogamut.base.communication.connection.impl.socket.SocketConnectionAddress;
9 import cz.cuni.amis.pogamut.base.factory.IAgentFactory;
10 import cz.cuni.amis.pogamut.base.utils.Pogamut;
11 import cz.cuni.amis.pogamut.base.utils.PogamutPlatform;
12 import cz.cuni.amis.pogamut.ut2004.bot.IUT2004Bot;
13 import cz.cuni.amis.pogamut.ut2004.bot.IUT2004BotController;
14 import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
15 import cz.cuni.amis.pogamut.ut2004.bot.params.UT2004BotParameters;
16 import cz.cuni.amis.pogamut.ut2004.factory.guice.remoteagent.UT2004BotFactory;
17 import cz.cuni.amis.pogamut.ut2004.factory.guice.remoteagent.UT2004BotModule;
18 import cz.cuni.amis.utils.NullCheck;
19 import cz.cuni.amis.utils.exception.PogamutException;
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 public abstract class UTBotRunner<BOT extends IUT2004Bot, PARAMS extends UT2004BotParameters> extends AgentRunner<BOT, PARAMS> {
36
37
38
39
40 protected String host;
41
42
43
44
45 protected int port;
46
47
48
49
50 protected String name;
51
52
53
54
55
56
57
58
59
60 public UTBotRunner(IAgentFactory<BOT, PARAMS> factory, String name, String host, int port) {
61 super(factory);
62 this.name = name;
63 this.port = port;
64 this.host = host;
65 }
66
67
68
69
70
71
72
73
74 public UTBotRunner(IAgentFactory<BOT, PARAMS> factory, String name) {
75 this(
76 factory,
77 name,
78 Pogamut.getPlatform().getProperty(PogamutUT2004Property.POGAMUT_UT2004_BOT_HOST.getKey()) == null ?
79 "localhost"
80 : Pogamut.getPlatform().getProperty(PogamutUT2004Property.POGAMUT_UT2004_BOT_HOST.getKey()),
81 Pogamut.getPlatform().getIntProperty(PogamutUT2004Property.POGAMUT_UT2004_BOT_PORT.getKey()) == 0 ?
82 3000
83 : Pogamut.getPlatform().getIntProperty(PogamutUT2004Property.POGAMUT_UT2004_BOT_PORT.getKey())
84 );
85 }
86
87
88
89
90
91
92
93 public UTBotRunner(IAgentFactory<BOT, PARAMS> factory) {
94 this(factory, "UT2004Bot");
95 }
96
97
98
99
100
101
102
103 public String getName() {
104 return name;
105 }
106
107
108
109
110
111
112
113
114
115 public UTBotRunner<BOT, PARAMS> setName(String name) {
116 if (name == null) name = "UTBot";
117 this.name = name;
118 return this;
119 }
120
121
122
123
124
125
126 public String getHost() {
127 return host;
128 }
129
130
131
132
133
134
135
136 public UTBotRunner<BOT, PARAMS> setHost(String host) {
137 this.host = host;
138 NullCheck.check(this.host, "host");
139 return this;
140 }
141
142
143
144
145
146
147 public int getPort() {
148 return port;
149 }
150
151
152
153
154
155
156
157 public UTBotRunner<BOT, PARAMS> setPort(int port) {
158 this.port = port;
159 return this;
160 }
161
162
163
164
165
166 @Override
167 protected abstract IAgentParameters newDefaultAgentParameters();
168
169 }