summaryrefslogtreecommitdiff
path: root/qpid/java/common/src/main/java/org/apache/qpid/BrokerOptions.java
blob: a6a8d6daaf7091be881aaa2cc24e7b1d65cd9cf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
package org.apache.qpid;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

public class BrokerOptions extends HashMap<String, List<String>>
{
    /** serialVersionUID */
    private static final long serialVersionUID = 8051825964945442234L;
    
    public static final Integer DEFAULT_PORT = 5672;
    public static final String DEFAULT_CONFIG_FILE = "etc/config.xml";
    public static final String DEFAULT_LOG_CONFIG_FILENAME = "log4j.xml";
    public static final String QPID_HOME = "QPID_HOME";
    
    public static final String PORTS = "p";
    public static final String EXCLUDE_0_10 = "exclude-0-10";
    public static final String EXCLUDE_0_9_1 = "exclude-0-9-1";
    public static final String EXCLUDE_0_9 = "exclude-0-9";
    public static final String EXCLUDE_0_8 = "exclude-0-8";
    public static final String BIND = "b";
    public static final String MANAGEMENT = "m";
    public static final String LOG4J = "l";
    public static final String WATCH = "w";
    public static final String CONFIG = "c";
    public static final String PROTOCOL = "t";
    
    public static final String[] COMMAND_LINE_OPTIONS = new String[] {
        PORTS, EXCLUDE_0_10, EXCLUDE_0_9_1, EXCLUDE_0_9, EXCLUDE_0_8,
        BIND, MANAGEMENT, LOG4J, WATCH, CONFIG, PROTOCOL,
    };
    
    public void setPorts(Integer...ports)
    {
        put(PORTS, ports);
    }
    
    public List<Integer> getPorts()
    {
        return getList(PORTS);
    }
    
    public void setExclude_0_10Ports(Integer...ports)
    {
        put(EXCLUDE_0_10, ports);
    }
    
    public List<Integer> getExclude_0_10Ports()
    {
        return getList(EXCLUDE_0_10);
    }
    
    public void setExclude_0_9_1Ports(Integer...ports)
    {
        put(EXCLUDE_0_9_1, ports);
    }
    
    public List<Integer> getExclude_0_9_1Ports()
    {
        return getList(EXCLUDE_0_9_1);
    }
    
    public void setExclude_0_9Ports(Integer...ports)
    {
        put(EXCLUDE_0_9, ports);
    }
    
    public List<Integer> getExclude_0_9Ports()
    {
        return getList(EXCLUDE_0_9);
    }
    
    public void setExclude_0_8Ports(Integer...ports)
    {
        put(EXCLUDE_0_8, ports);
    }
    
    public List<Integer> getExclude_0_8Ports()
    {
        return getList(EXCLUDE_0_8);
    }
    
    public void setManagementPort(Integer management)
    {
        put(MANAGEMENT, Integer.toString(management));
    }
    
    public Integer getManagementPort()
    {
        return getInteger(MANAGEMENT);
    }
    
    public void setBind(String bind)
    {
        put(BIND, bind);
    }
    
    public String getBind()
    {
        return getValue(BIND);
    }
    
    public void setLog4JFile(String log4j)
    {
        put(LOG4J, log4j);
    }
    
    public String getLog4JFile()
    {
        return getValue(LOG4J);
    }
    
    public void setLog4JWatch(Integer watch)
    {
        put(WATCH, Integer.toString(watch));
    }
    
    public Integer getLog4JWatch()
    {
        return getInteger(WATCH);
    }
    
    public void setConfigFile(String config)
    {
        put(CONFIG, config);
    }
    
    public String getConfigFile()
    {
        return getValue(CONFIG);
    }
    
    public void setProtocol(String protocol)
    {
        put(PROTOCOL, protocol);
    }
    
    public String getProtocol()
    {
        return getValue(PROTOCOL);
    }
    
    public void put(String key, String value)
    {
        if (value != null)
        {
	        put(key, Collections.singletonList(value));
        }
    }
    
    public void put(String key, String...values)
    {
        if (values != null)
        {
            put(key, Arrays.asList(values));
        }
    }
    
    public void put(String key, Integer...values)
    {
        List<String> list = new ArrayList<String>();
        for (Integer i : values)
        {
            list.add(Integer.toString(i));
        }
        put(key, list);
    }
    
    public Integer getInteger(Object key)
    {
        return getInteger(key, null);
    }
    
    public Integer getInteger(Object key, Integer defaultValue)
    {
        if (!containsKey(key))
        {
            return defaultValue;
        }
        List<String> values = get(key);
        return Integer.valueOf(values.get(0));
    }
    
    public List<Integer> getList(Object key)
    {
        return getList(key, null);
    }
    
    public List<Integer> getList(Object key, List<Integer> defaultValues)
    {
        if (!containsKey(key))
        {
            return defaultValues;
        }
        List<String> list = get(key);
        List<Integer> values = new ArrayList<Integer>();
        for (String s : list)
        {
            values.add(Integer.valueOf(s));
        }
        return values;
    }
    
    public String getValue(Object key)
    {
        return getValue(key, null);
    }
    
    public String getValue(Object key, String defaultValue)
    {
        if (!containsKey(key))
        {
            return defaultValue;
        }
        List<String> values = get(key);
        return values.get(0);
    }
    
    public List<String> get(Object key, List<String> defaultValues)
    {
        if (!containsKey(key))
        {
            return defaultValues;
        }
        return get(key);
    }
}