KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > ui > tcp > CmpTcpConfiguration


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13 package org.ejbca.ui.tcp;
14 /*************************************************************************
15  * *
16  * *
17  * This software is free software; you can redistribute it and/or *
18  * modify it under the terms of the GNU Lesser General Public *
19  * License as published by the Free Software Foundation; either *
20  * version 2.1 of the License, or any later version. *
21  * *
22  * See terms of license at gnu.org. *
23  * *
24  *************************************************************************/

25  
26 import java.util.Properties JavaDoc;
27
28 import org.apache.commons.lang.StringUtils;
29
30 /**
31  * A singleton holding configuration information about the CMP TCP service
32  *
33  * @author tomas
34  * @version $Id: CmpTcpConfiguration.java,v 1.2 2007/01/16 11:44:29 anatom Exp $
35  */

36 public class CmpTcpConfiguration {
37
38     /** Singleton instance */
39     private static CmpTcpConfiguration config = null;
40     
41     /** Variable holding the properties configuration */
42     private Properties JavaDoc prop = null;
43     
44     private static final int DEFAULT_PORT = 829;
45     private static final String JavaDoc DEFAULT_BIND_HOST="0.0.0.0";
46     private static final String JavaDoc DEFAULT_LOG_DIR="./log";
47     private static final String JavaDoc DEFAULT_CONF_FILE="";
48     
49     private CmpTcpConfiguration() {
50     }
51     
52     public static CmpTcpConfiguration instance() {
53         if (config == null) {
54             config = new CmpTcpConfiguration();
55         }
56         return config;
57     }
58     
59     public void init(Properties JavaDoc prop) {
60         this.prop = prop;
61     }
62     
63     public int getPort() {
64         int ret = DEFAULT_PORT;
65         String JavaDoc str = prop.getProperty("portNo");
66         if (StringUtils.isNotEmpty(str)) {
67             ret = new Integer JavaDoc(str).intValue();
68         }
69         return ret;
70     }
71     public String JavaDoc getLogDir() {
72         String JavaDoc ret = DEFAULT_LOG_DIR;
73         String JavaDoc str = prop.getProperty("logDir");
74         if (StringUtils.isNotEmpty(str)) {
75             ret = str;
76         }
77         return ret;
78     }
79     public String JavaDoc getConfFile() {
80         String JavaDoc ret = DEFAULT_CONF_FILE;
81         String JavaDoc str = prop.getProperty("confFile");
82         if (StringUtils.isNotEmpty(str)) {
83             ret = str;
84         }
85         return ret;
86     }
87
88     public String JavaDoc getBindHost() {
89         String JavaDoc ret = DEFAULT_BIND_HOST;
90         String JavaDoc str = prop.getProperty("bindHost");
91         if (StringUtils.isNotEmpty(str)) {
92             ret = str;
93         }
94         return ret;
95     }
96     public Properties JavaDoc getProperties() {
97         return prop;
98     }
99 }
100
Popular Tags