📄 butorhostlistener.java
字号:
/* * Copyright (C) butor.com. All rights reserved. * * This software is published under the terms of the GNU Library General * Public License (GNU LGPL), a copy of which has been included with this * distribution in the LICENSE.txt file. */package org.butor.web.listener;import java.io.File;import java.io.IOException;import org.apache.catalina.LifecycleEvent;import org.apache.catalina.LifecycleListener;import org.butor.config.ConfigFactory;import org.butor.config.IConfig;import org.butor.fwService.starter.FwServiceStarter;import org.butor.helper.PropertiesHelper;import org.butor.log.Log;/** * @version 1.0 * @author */public class ButorHostListener implements LifecycleListener { // System arguments. public static final String PARAM_HOST_CONFIG = "butor_host_config"; public static final String PARAM_ENV = "butor_env"; public static final String PARAM_REPOSITORY_CONF_DIR = "butor_repository_conf_dir"; protected FwServiceStarter f_services = null; protected String f_confDir = null; protected IConfig f_config = null; public void lifecycleEvent(LifecycleEvent e) { Log.logStr(this, Log.LOG_TYPE_INFO, "lifecycleEvent()", "Event: " +e.getType()); if (e.getType().equals("start")) { startServices(); } else if (e.getType().equals("stop")) { stopServices(); } } /** * Initialize this servlet. * * @exception ServletException if we cannot configure ourselves correctly */ protected void startServices() { PropertiesHelper.loadSystemProperties(); Log.logStr(this, Log.LOG_TYPE_INFO, "startServices()", "Starting services ..."); loadConfig(); f_services = new FwServiceStarter(f_config); if (Log.shouldLog(this.getClass().getName(), Log.LOG_LEVEL_LOW)) { Log.logStr(this, Log.LOG_TYPE_INFO, "startServices()", "Final config: " +f_config); } } /** * */ protected void stopServices() { Log.logStr(this, Log.LOG_TYPE_INFO, "stopServices()", "Stopping services ..."); f_services.shutdown(); } /** * Init config. */ protected void loadConfig() { f_config = null; String confFile = System.getProperty(PARAM_HOST_CONFIG, null); if (confFile == null) { Log.logStr(this, Log.LOG_TYPE_WARN, "loadConfig()", "Missing " + PARAM_HOST_CONFIG +" parameter!"); return; } String env = System.getProperty(PARAM_ENV, null); String externalConfPath = System.getProperty(PARAM_REPOSITORY_CONF_DIR, null); Log.logStr(this, Log.LOG_TYPE_INFO, "loadConfig()", "Got parameters: " +PARAM_HOST_CONFIG +"=[" + confFile +"] " + PARAM_ENV +"=[" + env +"] " + PARAM_REPOSITORY_CONF_DIR + "=[" + externalConfPath +"]"); int pos = confFile.lastIndexOf(File.separator); if (pos > -1) { f_confDir = confFile.substring(0, pos); } String[] externalConfSuffixes = ConfigFactory.getConfigSuffixes(null); try { f_config = ConfigFactory.loadConfigFile(confFile, f_confDir, externalConfPath, ConfigFactory.getLogDir(), externalConfSuffixes); } catch (IOException e) { Log.logException(this, Log.LOG_TYPE_WARN, "loadConfig()", e); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -