W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
我們知道在消息應(yīng)用中,數(shù)據(jù)一般是以 POJO 的形式出現(xiàn)的,除了實際的消息數(shù)據(jù),可以保存配置或處理消息。在這個應(yīng)用程序里,消息的單元是一個“事件”。因為數(shù)據(jù)來自于一個日志文件,我們就將其稱之為LogEvent。
清單13.1顯示了這個簡單的POJO的細(xì)節(jié)。
Listing 13.1 LogEvent message
public final class LogEvent {
public static final byte SEPARATOR = (byte) ':';
private final InetSocketAddress source;
private final String logfile;
private final String msg;
private final long received;
public LogEvent(String logfile, String msg) { //1
this(null, -1, logfile, msg);
}
public LogEvent(InetSocketAddress source, long received, String logfile, String msg) { //2
this.source = source;
this.logfile = logfile;
this.msg = msg;
this.received = received;
}
public InetSocketAddress getSource() { //3
return source;
}
public String getLogfile() { //4
return logfile;
}
public String getMsg() { //5
return msg;
}
public long getReceivedTimestamp() { //6
return received;
}
}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: