org/sonews/config/Config.java
changeset 35 ed84c8bdd87b
parent 34 9f0b95aafaa3
child 36 c404a87db5b7
     1.1 --- a/org/sonews/config/Config.java	Sun Aug 29 17:04:25 2010 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,175 +0,0 @@
     1.4 -/*
     1.5 - *   SONEWS News Server
     1.6 - *   see AUTHORS for the list of contributors
     1.7 - *
     1.8 - *   This program is free software: you can redistribute it and/or modify
     1.9 - *   it under the terms of the GNU General Public License as published by
    1.10 - *   the Free Software Foundation, either version 3 of the License, or
    1.11 - *   (at your option) any later version.
    1.12 - *
    1.13 - *   This program is distributed in the hope that it will be useful,
    1.14 - *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 - *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.16 - *   GNU General Public License for more details.
    1.17 - *
    1.18 - *   You should have received a copy of the GNU General Public License
    1.19 - *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1.20 - */
    1.21 -
    1.22 -package org.sonews.config;
    1.23 -
    1.24 -/**
    1.25 - * Configuration facade class.
    1.26 - * @author Christian Lins
    1.27 - * @since sonews/1.0
    1.28 - */
    1.29 -public class Config extends AbstractConfig
    1.30 -{
    1.31 -  
    1.32 -  public static final int LEVEL_CLI     = 1;
    1.33 -  public static final int LEVEL_FILE    = 2;
    1.34 -  public static final int LEVEL_BACKEND = 3;
    1.35 -
    1.36 -  public static final String CONFIGFILE = "sonews.configfile";
    1.37 -  
    1.38 -    /** BackendConfig key constant. Value is the maximum article size in kilobytes. */
    1.39 -  public static final String ARTICLE_MAXSIZE   = "sonews.article.maxsize";
    1.40 -
    1.41 -  /** BackendConfig key constant. Value: Amount of news that are feeded per run. */
    1.42 -  public static final String EVENTLOG          = "sonews.eventlog";
    1.43 -  public static final String FEED_NEWSPERRUN   = "sonews.feed.newsperrun";
    1.44 -  public static final String FEED_PULLINTERVAL = "sonews.feed.pullinterval";
    1.45 -  public static final String HOSTNAME          = "sonews.hostname";
    1.46 -  public static final String PORT              = "sonews.port";
    1.47 -  public static final String TIMEOUT           = "sonews.timeout";
    1.48 -  public static final String LOGLEVEL          = "sonews.loglevel";
    1.49 -  public static final String MLPOLL_DELETEUNKNOWN = "sonews.mlpoll.deleteunknown";
    1.50 -  public static final String MLPOLL_HOST       = "sonews.mlpoll.host";
    1.51 -  public static final String MLPOLL_PASSWORD   = "sonews.mlpoll.password";
    1.52 -  public static final String MLPOLL_USER       = "sonews.mlpoll.user";
    1.53 -  public static final String MLSEND_ADDRESS    = "sonews.mlsend.address";
    1.54 -  public static final String MLSEND_RW_FROM    = "sonews.mlsend.rewrite.from";
    1.55 -  public static final String MLSEND_RW_SENDER  = "sonews.mlsend.rewrite.sender";
    1.56 -  public static final String MLSEND_HOST       = "sonews.mlsend.host";
    1.57 -  public static final String MLSEND_PASSWORD   = "sonews.mlsend.password";
    1.58 -  public static final String MLSEND_PORT       = "sonews.mlsend.port";
    1.59 -  public static final String MLSEND_USER       = "sonews.mlsend.user";
    1.60 -  
    1.61 -  /** Key constant. If value is "true" every I/O is written to logfile
    1.62 -   * (which is a lot!)
    1.63 -   */
    1.64 -  public static final String DEBUG              = "sonews.debug";
    1.65 -
    1.66 -  /** Key constant. Value is classname of the JDBC driver */
    1.67 -  public static final String STORAGE_DBMSDRIVER = "sonews.storage.dbmsdriver";
    1.68 -
    1.69 -  /** Key constant. Value is JDBC connect String to the database. */
    1.70 -  public static final String STORAGE_DATABASE   = "sonews.storage.database";
    1.71 -
    1.72 -  /** Key constant. Value is the username for the DBMS. */
    1.73 -  public static final String STORAGE_USER       = "sonews.storage.user";
    1.74 -
    1.75 -  /** Key constant. Value is the password for the DBMS. */
    1.76 -  public static final String STORAGE_PASSWORD   = "sonews.storage.password";
    1.77 -
    1.78 -  /** Key constant. Value is the name of the host which is allowed to use the
    1.79 -   *  XDAEMON command; default: "localhost" */
    1.80 -  public static final String XDAEMON_HOST       = "sonews.xdaemon.host";
    1.81 -
    1.82 -  /** The config key for the filename of the logfile */
    1.83 -  public static final String LOGFILE = "sonews.log";
    1.84 -
    1.85 -  public static final String[] AVAILABLE_KEYS = {
    1.86 -      ARTICLE_MAXSIZE,
    1.87 -      EVENTLOG,
    1.88 -      FEED_NEWSPERRUN,
    1.89 -      FEED_PULLINTERVAL,
    1.90 -      HOSTNAME,
    1.91 -      MLPOLL_DELETEUNKNOWN,
    1.92 -      MLPOLL_HOST,
    1.93 -      MLPOLL_PASSWORD,
    1.94 -      MLPOLL_USER,
    1.95 -      MLSEND_ADDRESS,
    1.96 -      MLSEND_HOST,
    1.97 -      MLSEND_PASSWORD,
    1.98 -      MLSEND_PORT,
    1.99 -      MLSEND_RW_FROM,
   1.100 -      MLSEND_RW_SENDER,
   1.101 -      MLSEND_USER,
   1.102 -      PORT,
   1.103 -      TIMEOUT,
   1.104 -      XDAEMON_HOST
   1.105 -  };
   1.106 -
   1.107 -  private static Config instance = new Config();
   1.108 -  
   1.109 -  public static Config inst()
   1.110 -  {
   1.111 -    return instance;
   1.112 -  }
   1.113 -  
   1.114 -  private Config(){}
   1.115 -
   1.116 -  @Override
   1.117 -  public String get(String key, String def)
   1.118 -  {
   1.119 -    String val = CommandLineConfig.getInstance().get(key, null);
   1.120 -    
   1.121 -    if(val == null)
   1.122 -    {
   1.123 -      val = FileConfig.getInstance().get(key, null);
   1.124 -    }
   1.125 -
   1.126 -    if(val == null)
   1.127 -    {
   1.128 -      val = BackendConfig.getInstance().get(key, def);
   1.129 -    }
   1.130 -
   1.131 -    return val;
   1.132 -  }
   1.133 -
   1.134 -  public String get(int maxLevel, String key, String def)
   1.135 -  {
   1.136 -    String val = CommandLineConfig.getInstance().get(key, null);
   1.137 -
   1.138 -    if(val == null && maxLevel >= LEVEL_FILE)
   1.139 -    {
   1.140 -      val = FileConfig.getInstance().get(key, null);
   1.141 -      if(val == null && maxLevel >= LEVEL_BACKEND)
   1.142 -      {
   1.143 -        val = BackendConfig.getInstance().get(key, def);
   1.144 -      }
   1.145 -    }
   1.146 -
   1.147 -    return val != null ? val : def;
   1.148 -  }
   1.149 -
   1.150 -  @Override
   1.151 -  public void set(String key, String val)
   1.152 -  {
   1.153 -    set(LEVEL_BACKEND, key, val);
   1.154 -  }
   1.155 -
   1.156 -  public void set(int level, String key, String val)
   1.157 -  {
   1.158 -    switch(level)
   1.159 -    {
   1.160 -      case LEVEL_CLI:
   1.161 -      {
   1.162 -        CommandLineConfig.getInstance().set(key, val);
   1.163 -        break;
   1.164 -      }
   1.165 -      case LEVEL_FILE:
   1.166 -      {
   1.167 -        FileConfig.getInstance().set(key, val);
   1.168 -        break;
   1.169 -      }
   1.170 -      case LEVEL_BACKEND:
   1.171 -      {
   1.172 -        BackendConfig.getInstance().set(key, val);
   1.173 -        break;
   1.174 -      }
   1.175 -    }
   1.176 -  }
   1.177 -
   1.178 -}