📄 abstractalertsender.java
字号:
package net.sf.dz.util.alert;import org.freehold.jukebox.logger.LogAware;import org.freehold.jukebox.logger.LogChannel;import org.freehold.jukebox.logger.Logger;import org.freehold.jukebox.service.Messenger;/** * An abstract message delivery agent. * * @author Copyright © <a href="mailto:vt@freehold.crocodile.org">Vadim Tkachenko</a> 2004 * @version $Id: AbstractAlertSender.java,v 1.2 2004/01/25 08:35:39 vtt Exp $ */abstract public class AbstractAlertSender extends LogAware { public static final LogChannel CH_AAS = new LogChannel("Alert/Abstract"); private String destination; public AbstractAlertSender(String destination) { // Initial sanity check if ( destination == null ) { throw new IllegalArgumentException("Destination can't be null"); } // Let's delegate a thorough sanity check to subclasses checkDestination(destination); this.destination = destination; } protected final String getDestination() { return destination; } public final void send(String severity, String source, String message) { // Initial sanity check if ( severity == null || source == null || message == null ) { throw new IllegalArgumentException("One of parameters is null:" + " severity: " + severity + " source: " + source + " message: " + message); } // Let's delegate thorough sanity checks to subclasses checkSeverity(severity); checkSource(source); checkMessage(message); createSender(severity, source, message).start(); } protected void checkDestination(String destination) { complain(LOG_WARNING, CH_AAS, "Stub: checkDestination(" + destination + ")"); } protected void checkSeverity(String severity) { complain(LOG_WARNING, CH_AAS, "Stub: checkSeverity(" + severity + ")"); } protected void checkSource(String source) { complain(LOG_WARNING, CH_AAS, "Stub: checkSource(" + source + ")"); } protected void checkMessage(String message) { complain(LOG_WARNING, CH_AAS, "Stub: checkMessage(" + message + ")"); } abstract protected Sender createSender(String severity, String source, String message); abstract protected class Sender extends Messenger { /** * Message severity. */ private String severity; /** * Message source. */ private String source; /** * Message body. */ private String message; public Sender(Logger logger, String severity, String source, String message) { super(logger); // No sanity checks are performed, because they've been just // done by the outer class this.severity = severity; this.source = source; this.message = message; } protected final String getSeverity() { return severity; } protected final String getSource() { return source; } protected final String getMessage() { return message; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -