29
29
import com .iluwatar .databus .data .StartingData ;
30
30
import com .iluwatar .databus .data .StoppingData ;
31
31
32
+ import java .time .LocalDateTime ;
32
33
import java .util .logging .Logger ;
33
34
34
35
/**
@@ -42,6 +43,10 @@ public class StatusMember implements Member {
42
43
43
44
private final int id ;
44
45
46
+ private LocalDateTime started ;
47
+
48
+ private LocalDateTime stopped ;
49
+
45
50
public StatusMember (int id ) {
46
51
this .id = id ;
47
52
}
@@ -56,12 +61,22 @@ public void accept(final DataType data) {
56
61
}
57
62
58
63
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 ));
60
66
}
61
67
62
68
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 ));
64
71
LOGGER .info (String .format ("Receiver #%d sending goodbye message" , id ));
65
72
data .getDataBus ().publish (MessageData .of (String .format ("Goodbye cruel world from #%d!" , id )));
66
73
}
74
+
75
+ public LocalDateTime getStarted () {
76
+ return started ;
77
+ }
78
+
79
+ public LocalDateTime getStopped () {
80
+ return stopped ;
81
+ }
67
82
}
0 commit comments