1
2
3
4
5
6
7
8
9
10
11 package org.mule.config;
12
13 import java.util.Map;
14
15 import org.apache.commons.collections.map.CaseInsensitiveMap;
16
17
18
19
20
21
22
23 public class PoolingProfile
24 {
25
26
27
28
29 public static final int INITIALISE_NONE = 0;
30
31
32
33
34 public static final int INITIALISE_ONE = 1;
35
36
37
38
39 public static final int INITIALISE_ALL = 2;
40
41
42 public static final int WHEN_EXHAUSTED_FAIL = 0;
43
44 public static final int WHEN_EXHAUSTED_BLOCK = 1;
45 public static final int WHEN_EXHAUSTED_WAIT = 1;
46 public static final int WHEN_EXHAUSTED_GROW = 2;
47
48
49
50
51
52
53
54
55 public static final int DEFAULT_MAX_POOL_ACTIVE = 5;
56
57
58
59
60
61
62
63
64 public static final int DEFAULT_MAX_POOL_IDLE = 5;
65
66
67
68
69
70
71 public static final long DEFAULT_MAX_POOL_WAIT = 4000;
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86 public static final int DEFAULT_POOL_EXHAUSTED_ACTION = WHEN_EXHAUSTED_GROW;
87
88
89
90
91
92
93
94
95
96
97
98 public static final int DEFAULT_POOL_INITIALISATION_POLICY = INITIALISE_ONE;
99
100
101 public static final Map POOL_EXHAUSTED_ACTIONS = new CaseInsensitiveMap()
102 {
103 private static final long serialVersionUID = 1L;
104
105
106 {
107
108
109
110 Integer value = new Integer(WHEN_EXHAUSTED_WAIT);
111 this.put("WHEN_EXHAUSTED_WAIT", value);
112
113 value = new Integer(WHEN_EXHAUSTED_FAIL);
114 this.put("WHEN_EXHAUSTED_FAIL", value);
115
116 value = new Integer(WHEN_EXHAUSTED_GROW);
117 this.put("WHEN_EXHAUSTED_GROW", value);
118 }
119 };
120
121
122 public static final Map POOL_INITIALISATION_POLICIES = new CaseInsensitiveMap()
123 {
124 private static final long serialVersionUID = 1L;
125
126
127 {
128 Integer value = new Integer(INITIALISE_NONE);
129 this.put("INITIALISE_NONE", value);
130
131 value = new Integer(INITIALISE_ONE);
132 this.put("INITIALISE_ONE", value);
133
134 value = new Integer(INITIALISE_ALL);
135 this.put("INITIALISE_ALL", value);
136 }
137 };
138
139 private int maxActive = DEFAULT_MAX_POOL_ACTIVE;
140
141 private int maxIdle = DEFAULT_MAX_POOL_IDLE;
142
143 private long maxWait = DEFAULT_MAX_POOL_WAIT;
144
145 private int exhaustedAction = DEFAULT_POOL_EXHAUSTED_ACTION;
146
147 private int initialisationPolicy = DEFAULT_POOL_INITIALISATION_POLICY;
148
149
150
151 public PoolingProfile()
152 {
153 super();
154 }
155
156 public PoolingProfile(PoolingProfile pp)
157 {
158 this.maxActive = pp.getMaxActive();
159 this.maxIdle = pp.getMaxIdle();
160 this.maxWait = pp.getMaxWait();
161 this.exhaustedAction = pp.getExhaustedAction();
162 this.initialisationPolicy = pp.getInitialisationPolicy();
163
164
165
166
167 }
168
169 public PoolingProfile(int maxActive,
170 int maxIdle,
171 long maxWait,
172 int exhaustedAction,
173 int initialisationPolicy)
174 {
175 this.maxActive = maxActive;
176 this.maxIdle = maxIdle;
177 this.maxWait = maxWait;
178 this.exhaustedAction = exhaustedAction;
179 this.initialisationPolicy = initialisationPolicy;
180 }
181
182
183
184
185 public int getMaxIdle()
186 {
187 return maxIdle;
188 }
189
190
191
192
193 public int getMaxActive()
194 {
195 return maxActive;
196 }
197
198
199
200
201
202
203 public long getMaxWait()
204 {
205 return maxWait;
206 }
207
208
209
210
211 public int getExhaustedAction()
212 {
213 return exhaustedAction;
214 }
215
216 public int getInitialisationPolicy()
217 {
218 return initialisationPolicy;
219 }
220
221 public void setInitialisationPolicy(int policy)
222 {
223 initialisationPolicy = policy;
224 }
225
226 public void setMaxIdle(int maxIdle)
227 {
228 this.maxIdle = maxIdle;
229 }
230
231 public void setMaxActive(int maxActive)
232 {
233 this.maxActive = maxActive;
234 }
235
236 public void setMaxWait(long maxWait)
237 {
238 this.maxWait = maxWait;
239 }
240
241 public void setExhaustedAction(int exhaustedAction)
242 {
243 this.exhaustedAction = exhaustedAction;
244 }
245
246
247
248
249
250
251
252
253
254
255
256 }