📄 asyncfilehandler.java
字号:
/*
* @(#)AsyncFileHandler.java ver 1.2 6/20/2005
*
* Copyright 2005 Weishuai Yang (wyang@cs.binghamton.edu).
* All rights reserved.
*
*/
package gps.util;
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.LogRecord;
/**
* Asynchronous file handler, asynchronously handles log record.
* The purpose of this class is to intercept publish and close.
* Log records are published to a log server.
* The regular publish and close become AsynchPublish and AsynchClose.
*
*
* @author Weishuai Yang
* @version 1.2, 6/20/2005
*/
public class AsyncFileHandler extends FileHandler {
/**
* global logserver
*/
private static LogServer mLogServer=LogServer.getInstance();
/**
* asynchronous close flag
*/
private boolean mClosed=false;
/**
* constructor, simply call super class
*/
public AsyncFileHandler() throws IOException, SecurityException {
super();
}
/**
* constructor, simply call super class
*/
public AsyncFileHandler(String pattern) throws IOException, SecurityException {
super(pattern);
}
/**
* constructor, simply call super class
*/
public AsyncFileHandler(String pattern, boolean append) throws IOException, SecurityException {
super(pattern, append);
}
/**
* constructor, simply call super class
*/
public AsyncFileHandler(String pattern, int limit, int count) throws IOException, SecurityException {
super(pattern, limit, count);
}
/**
* constructor, simply call super class
*/
public AsyncFileHandler(String pattern, int limit, int count, boolean append) throws IOException, SecurityException {
super(pattern, limit, count, append);
}
/**
* Asynchronous publish. If asynchronous log server existing,
* publish to log server, otherwise use regular synchronous publish
*
* @param record description of the log event. A null record is
* silently ignored and is not published
*/
public synchronized void publish(LogRecord record) {
if(mLogServer!=null)
mLogServer.log(this, record);
else super.publish(record);
}
/**
* call regular publish
* @param record logrecord to be published
*/
public synchronized void syncPublish(LogRecord record) {
super.publish(record);
}
/**
* Asynchronous close. Just set close flag, doesn't really colse
*/
public synchronized void close() throws SecurityException {
mClosed=true;
}
/**
* call regular close
*/
public synchronized void syncClose() throws SecurityException {
super.close();
}
/**
* Asynchronous isClose. Check close status.
* @return true if closed, otherwise false
*/
public synchronized boolean isClosed(){
return mClosed;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -