chris@3: /* chris@3: * SONEWS News Server chris@3: * see AUTHORS for the list of contributors chris@3: * chris@3: * This program is free software: you can redistribute it and/or modify chris@3: * it under the terms of the GNU General Public License as published by chris@3: * the Free Software Foundation, either version 3 of the License, or chris@3: * (at your option) any later version. chris@3: * chris@3: * This program is distributed in the hope that it will be useful, chris@3: * but WITHOUT ANY WARRANTY; without even the implied warranty of chris@3: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the chris@3: * GNU General Public License for more details. chris@3: * chris@3: * You should have received a copy of the GNU General Public License chris@3: * along with this program. If not, see . chris@3: */ chris@3: chris@3: package org.sonews.config; chris@3: chris@3: /** chris@3: * Configuration facade class. chris@3: * @author Christian Lins chris@3: * @since sonews/1.0 chris@3: */ chris@3: public class Config extends AbstractConfig chris@3: { chris@3: chris@3: public static final int LEVEL_CLI = 1; chris@3: public static final int LEVEL_FILE = 2; chris@3: public static final int LEVEL_BACKEND = 3; chris@3: chris@3: public static final String CONFIGFILE = "sonews.configfile"; chris@3: chris@3: /** BackendConfig key constant. Value is the maximum article size in kilobytes. */ chris@3: public static final String ARTICLE_MAXSIZE = "sonews.article.maxsize"; chris@3: chris@3: /** BackendConfig key constant. Value: Amount of news that are feeded per run. */ chris@3: public static final String EVENTLOG = "sonews.eventlog"; chris@3: public static final String FEED_NEWSPERRUN = "sonews.feed.newsperrun"; chris@3: public static final String FEED_PULLINTERVAL = "sonews.feed.pullinterval"; chris@3: public static final String HOSTNAME = "sonews.hostname"; chris@3: public static final String PORT = "sonews.port"; chris@3: public static final String TIMEOUT = "sonews.timeout"; cli@15: public static final String LOGLEVEL = "sonews.loglevel"; chris@3: public static final String MLPOLL_DELETEUNKNOWN = "sonews.mlpoll.deleteunknown"; chris@3: public static final String MLPOLL_HOST = "sonews.mlpoll.host"; chris@3: public static final String MLPOLL_PASSWORD = "sonews.mlpoll.password"; chris@3: public static final String MLPOLL_USER = "sonews.mlpoll.user"; chris@3: public static final String MLSEND_ADDRESS = "sonews.mlsend.address"; chris@3: public static final String MLSEND_RW_FROM = "sonews.mlsend.rewrite.from"; chris@3: public static final String MLSEND_RW_SENDER = "sonews.mlsend.rewrite.sender"; chris@3: public static final String MLSEND_HOST = "sonews.mlsend.host"; chris@3: public static final String MLSEND_PASSWORD = "sonews.mlsend.password"; chris@3: public static final String MLSEND_PORT = "sonews.mlsend.port"; chris@3: public static final String MLSEND_USER = "sonews.mlsend.user"; chris@3: chris@3: /** Key constant. If value is "true" every I/O is written to logfile chris@3: * (which is a lot!) chris@3: */ chris@3: public static final String DEBUG = "sonews.debug"; chris@3: chris@3: /** Key constant. Value is classname of the JDBC driver */ chris@3: public static final String STORAGE_DBMSDRIVER = "sonews.storage.dbmsdriver"; chris@3: chris@3: /** Key constant. Value is JDBC connect String to the database. */ chris@3: public static final String STORAGE_DATABASE = "sonews.storage.database"; chris@3: chris@3: /** Key constant. Value is the username for the DBMS. */ chris@3: public static final String STORAGE_USER = "sonews.storage.user"; chris@3: chris@3: /** Key constant. Value is the password for the DBMS. */ chris@3: public static final String STORAGE_PASSWORD = "sonews.storage.password"; chris@3: chris@3: /** Key constant. Value is the name of the host which is allowed to use the chris@3: * XDAEMON command; default: "localhost" */ chris@3: public static final String XDAEMON_HOST = "sonews.xdaemon.host"; chris@3: chris@3: /** The config key for the filename of the logfile */ chris@3: public static final String LOGFILE = "sonews.log"; chris@3: cli@12: public static final String[] AVAILABLE_KEYS = { chris@3: ARTICLE_MAXSIZE, chris@3: EVENTLOG, chris@3: FEED_NEWSPERRUN, chris@3: FEED_PULLINTERVAL, chris@3: HOSTNAME, chris@3: MLPOLL_DELETEUNKNOWN, chris@3: MLPOLL_HOST, chris@3: MLPOLL_PASSWORD, chris@3: MLPOLL_USER, chris@3: MLSEND_ADDRESS, chris@3: MLSEND_HOST, chris@3: MLSEND_PASSWORD, chris@3: MLSEND_PORT, chris@3: MLSEND_RW_FROM, chris@3: MLSEND_RW_SENDER, chris@3: MLSEND_USER, chris@3: PORT, chris@3: TIMEOUT, chris@3: XDAEMON_HOST chris@3: }; chris@3: chris@3: private static Config instance = new Config(); chris@3: chris@3: public static Config inst() chris@3: { chris@3: return instance; chris@3: } chris@3: chris@3: private Config(){} chris@3: chris@3: @Override chris@3: public String get(String key, String def) chris@3: { chris@3: String val = CommandLineConfig.getInstance().get(key, null); chris@3: chris@3: if(val == null) chris@3: { chris@3: val = FileConfig.getInstance().get(key, null); chris@3: } chris@3: chris@3: if(val == null) chris@3: { chris@3: val = BackendConfig.getInstance().get(key, def); chris@3: } chris@3: chris@3: return val; chris@3: } chris@3: chris@3: public String get(int level, String key, String def) chris@3: { chris@3: switch(level) chris@3: { chris@3: case LEVEL_CLI: chris@3: { chris@3: return CommandLineConfig.getInstance().get(key, def); chris@3: } chris@3: case LEVEL_FILE: chris@3: { chris@3: return FileConfig.getInstance().get(key, def); chris@3: } chris@3: case LEVEL_BACKEND: chris@3: { chris@3: return BackendConfig.getInstance().get(key, def); chris@3: } chris@3: } chris@3: return null; chris@3: } chris@3: chris@3: @Override chris@3: public void set(String key, String val) chris@3: { chris@3: set(LEVEL_BACKEND, key, val); chris@3: } chris@3: chris@3: public void set(int level, String key, String val) chris@3: { chris@3: switch(level) chris@3: { chris@3: case LEVEL_CLI: chris@3: { chris@3: CommandLineConfig.getInstance().set(key, val); chris@3: break; chris@3: } chris@3: case LEVEL_FILE: chris@3: { chris@3: FileConfig.getInstance().set(key, val); chris@3: break; chris@3: } chris@3: case LEVEL_BACKEND: chris@3: { chris@3: BackendConfig.getInstance().set(key, val); chris@3: break; chris@3: } chris@3: } chris@3: } chris@3: chris@3: }