Skip to content

Commit 311bb79

Browse files
committed
iluwatar#467 data-bus: members: StatusMember: records start and stop times
1 parent f495a88 commit 311bb79

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

data-bus/src/main/java/com/iluwatar/databus/members/StatusMember.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.iluwatar.databus.data.StartingData;
3030
import com.iluwatar.databus.data.StoppingData;
3131

32+
import java.time.LocalDateTime;
3233
import java.util.logging.Logger;
3334

3435
/**
@@ -42,6 +43,10 @@ public class StatusMember implements Member {
4243

4344
private final int id;
4445

46+
private LocalDateTime started;
47+
48+
private LocalDateTime stopped;
49+
4550
public StatusMember(int id) {
4651
this.id = id;
4752
}
@@ -56,12 +61,22 @@ public void accept(final DataType data) {
5661
}
5762

5863
private void handleEvent(StartingData data) {
59-
LOGGER.info(String.format("Receiver #%d sees application started at %s", id, data.getWhen()));
64+
started = data.getWhen();
65+
LOGGER.info(String.format("Receiver #%d sees application started at %s", id, started));
6066
}
6167

6268
private void handleEvent(StoppingData data) {
63-
LOGGER.info(String.format("Receiver #%d sees application stopping at %s", id, data.getWhen()));
69+
stopped = data.getWhen();
70+
LOGGER.info(String.format("Receiver #%d sees application stopping at %s", id, stopped));
6471
LOGGER.info(String.format("Receiver #%d sending goodbye message", id));
6572
data.getDataBus().publish(MessageData.of(String.format("Goodbye cruel world from #%d!", id)));
6673
}
74+
75+
public LocalDateTime getStarted() {
76+
return started;
77+
}
78+
79+
public LocalDateTime getStopped() {
80+
return stopped;
81+
}
6782
}

0 commit comments

Comments
 (0)