blob: 9744971b74af48ae6a92cc8d88b92829349cc8a2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package pl.edu.mimuw.cloudatlas.agent.modules;
import pl.edu.mimuw.cloudatlas.agent.Executor;
import pl.edu.mimuw.cloudatlas.agent.messages.AgentMessage;
/*
* A Module is a (potentially stateful) event handler.
*/
public abstract class Module {
protected AgentMessage.AgentModule moduleType;
protected Executor executor;
public Module(AgentMessage.AgentModule moduleType) {
this.moduleType = moduleType;
}
public abstract void handle(AgentMessage event) throws InterruptedException ;
public void setExecutor(Executor executor) {
this.executor = executor;
}
public void sendMessage(AgentMessage event) throws InterruptedException {
this.executor.passMessage(event);
}
@Override
public String toString() {
return moduleType.toString();
}
}
|