1 package cz.cuni.amis.pogamut.udk.utils;
2
3 import java.util.List;
4 import java.util.logging.Level;
5
6 import cz.cuni.amis.pogamut.base.agent.IAgentId;
7 import cz.cuni.amis.pogamut.base.agent.impl.AgentId;
8 import cz.cuni.amis.pogamut.base.agent.params.IAgentParameters;
9 import cz.cuni.amis.pogamut.base.agent.params.impl.RemoteAgentParameters;
10 import cz.cuni.amis.pogamut.base.agent.utils.runner.impl.AgentRunner;
11 import cz.cuni.amis.pogamut.base.communication.connection.impl.socket.SocketConnectionAddress;
12 import cz.cuni.amis.pogamut.base.factory.IAgentFactory;
13 import cz.cuni.amis.pogamut.base.utils.Pogamut;
14 import cz.cuni.amis.pogamut.base.utils.PogamutPlatform;
15 import cz.cuni.amis.pogamut.base.utils.PogamutProperty;
16 import cz.cuni.amis.pogamut.udk.agent.params.UDKAgentParameters;
17 import cz.cuni.amis.pogamut.udk.server.IUDKServer;
18 import cz.cuni.amis.utils.exception.PogamutException;
19
20
21
22
23
24
25
26
27
28
29
30
31 public class UDKServerRunner<SERVER extends IUDKServer, PARAMS extends UDKAgentParameters> extends AgentRunner<SERVER, PARAMS> {
32
33
34
35
36 protected String host;
37
38
39
40
41 protected int port;
42
43
44
45
46 protected String name;
47
48
49
50
51
52
53
54
55
56 public UDKServerRunner(IAgentFactory<SERVER, PARAMS> factory, String name, String host, int port) {
57 super(factory);
58 this.name = name;
59 this.port = port;
60 this.host = host;
61 }
62
63
64
65
66
67
68
69 public UDKServerRunner(IAgentFactory<SERVER, PARAMS> factory, String name) {
70 this(
71 factory,
72 name,
73 Pogamut.getPlatform().getProperty(PogamutUDKProperty.POGAMUT_UDK_SERVER_HOST.getKey()),
74 Pogamut.getPlatform().getIntProperty(PogamutUDKProperty.POGAMUT_UDK_SERVER_PORT.getKey())
75 );
76 }
77
78 @Override
79 public SERVER startAgent() throws PogamutException {
80 return super.startAgent();
81 }
82
83 @Override
84 public List<SERVER> startAgents(int count) throws PogamutException {
85 return super.startAgents(count);
86 }
87
88 @Override
89 public List<SERVER> startAgents(PARAMS... agentParameters) throws PogamutException {
90 return super.startAgents(agentParameters);
91 };
92
93
94
95
96
97
98
99 public UDKServerRunner(IAgentFactory<SERVER, PARAMS> factory) {
100 this(factory, "UDKServer");
101 }
102
103
104
105
106
107 @Override
108 protected IAgentParameters newDefaultAgentParameters() {
109 return new UDKAgentParameters().setAgentId(new AgentId(name)).setWorldAddress(new SocketConnectionAddress(host, port));
110 }
111
112 }