m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pl/edu/mimuw/cloudatlas/agent/messages/AgentMessage.java
blob: f343e0fef1651d665c79bb6c47cfe14f9852ef0f (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package pl.edu.mimuw.cloudatlas.agent.messages;

import pl.edu.mimuw.cloudatlas.agent.modules.Module;
import pl.edu.mimuw.cloudatlas.agent.modules.ModuleType;

public abstract class AgentMessage {
    private String messageId;
    private ModuleType destinationModule;
    private long timestamp;

    public AgentMessage(String messageId, ModuleType destinationModule, long timestamp) {
        this.messageId = messageId;
        this.destinationModule = destinationModule;
        this.timestamp = timestamp;
    }

    public AgentMessage(String messageId, ModuleType destinationModule) {
        this.messageId = messageId;
        this.destinationModule = destinationModule;
        this.timestamp = System.currentTimeMillis() / 1000L;
    }

    public String getMessageId() {
        return messageId;
    }

    public void setMessageId(String messageId) {
        this.messageId = messageId;
    }

    public ModuleType getDestinationModule() {
        return destinationModule;
    }

    public void setDestinationModule(ModuleType destinationModule) {
        this.destinationModule = destinationModule;
    }

    public abstract void callMe(Module module) throws InterruptedException, Module.InvalidMessageType;

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }
}