// --- BEGIN COPYRIGHT BLOCK --- // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // (C) 2007 Red Hat, Inc. // All rights reserved. // --- END COPYRIGHT BLOCK --- package com.netscape.cmscore.logging; import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.base.IConfigStore; import com.netscape.certsrv.base.ISubsystem; import com.netscape.certsrv.logging.ELogException; import com.netscape.certsrv.logging.ILogEventListener; import com.netscape.certsrv.logging.ILogQueue; import com.netscape.certsrv.logging.ILogSubsystem; import com.netscape.certsrv.logging.LogPlugin; import com.netscape.cmscore.util.Debug; /** * A class represents a log subsystem. *
*
* @author thomask
* @author mzhao
* @version $Revision$, $Date$
*/
public class LogSubsystem implements ILogSubsystem {
private static LogSubsystem mInstance = new LogSubsystem();
private static ILogQueue mLogQueue = LogQueue.getLogQueue();
private IConfigStore mConfig = null;
public static final String PROP_LOGGING = "log";
public static final String ID = "log";
public static final String PROP_CLASS = "class";
public static final String PROP_IMPL = "impl";
public static final String PROP_PLUGIN = "pluginName";
public static final String PROP_INSTANCE = "instance";
public Hashtable
*
* @param owner owner of this subsystem
* @param config configuration store
*/
public void init(ISubsystem owner, IConfigStore config)
throws EBaseException {
mConfig = config;
mLogQueue.init();
// load log plugin implementation
IConfigStore c = config.getSubStore(PROP_IMPL);
Enumeration
*/
public void shutdown() {
mLogQueue.shutdown();
}
/**
* Returns the root configuration storage of this system.
*
*
* @return configuration store of this subsystem
*/
public IConfigStore getConfigStore() {
return mConfig;
}
/**
* Retrieves singleton: the LogSubsystem.
*/
public static LogSubsystem getInstance() {
return mInstance;
}
/**
* Retrieves LogQueue.
*/
public static ILogQueue getLogQueue() {
return mLogQueue;
}
public String getLogPluginName(ILogEventListener log) {
IConfigStore cs = log.getConfigStore();
try {
return cs.getString("pluginName", "");
} catch (EBaseException e) {
e.printStackTrace();
return "";
} catch (NullPointerException e) {
e.printStackTrace();
return "";
}
}
/**
* Retrieve log instance by it's name
*/
public ILogEventListener getLogInstance(String insName) {
return mLogInsts.get(insName);
}
public Hashtable