diff options
Diffstat (limited to 'src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Module.java')
-rw-r--r-- | src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Module.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Module.java b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Module.java new file mode 100644 index 0000000..9744971 --- /dev/null +++ b/src/main/java/pl/edu/mimuw/cloudatlas/agent/modules/Module.java @@ -0,0 +1,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(); + } +} |