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 public class PoolingProfile
23 {
24
25
26
27
28 public static final int INITIALISE_NONE = 0;
29
30
31
32
33 public static final int INITIALISE_ONE = 1;
34
35
36
37
38 public static final int INITIALISE_ALL = 2;
39
40
41 public static final int WHEN_EXHAUSTED_FAIL = 0;
42 public static final int WHEN_EXHAUSTED_WAIT = 1;
43 public static final int WHEN_EXHAUSTED_GROW = 2;
44
45
46
47
48
49
50
51
52 public static final int DEFAULT_MAX_POOL_ACTIVE = 5;
53
54
55
56
57
58
59
60
61 public static final int DEFAULT_MAX_POOL_IDLE = 5;
62
63
64
65
66
67
68 public static final long DEFAULT_MAX_POOL_WAIT = 4000;
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 public static final int DEFAULT_POOL_EXHAUSTED_ACTION = WHEN_EXHAUSTED_GROW;
84
85
86
87
88
89
90
91
92
93
94
95 public static final int DEFAULT_POOL_INITIALISATION_POLICY = INITIALISE_ONE;
96
97
98 @SuppressWarnings("unchecked")
99 public static final Map<String, Integer> POOL_EXHAUSTED_ACTIONS = new CaseInsensitiveMap()
100 {
101 private static final long serialVersionUID = 1L;
102
103
104 {
105
106
107
108 this.put("WHEN_EXHAUSTED_WAIT", WHEN_EXHAUSTED_WAIT);
109 this.put("WHEN_EXHAUSTED_FAIL", WHEN_EXHAUSTED_FAIL);
110 this.put("WHEN_EXHAUSTED_GROW", WHEN_EXHAUSTED_GROW);
111 }
112 };
113
114
115 @SuppressWarnings("unchecked")
116 public static final Map<String, Integer> POOL_INITIALISATION_POLICIES = new CaseInsensitiveMap()
117 {
118 private static final long serialVersionUID = 1L;
119
120
121 {
122 this.put("INITIALISE_NONE", INITIALISE_NONE);
123 this.put("INITIALISE_ONE", INITIALISE_ONE);
124 this.put("INITIALISE_ALL", INITIALISE_ALL);
125 }
126 };
127
128 private int maxActive = DEFAULT_MAX_POOL_ACTIVE;
129
130 private int maxIdle = DEFAULT_MAX_POOL_IDLE;
131
132 private long maxWait = DEFAULT_MAX_POOL_WAIT;
133
134 private int exhaustedAction = DEFAULT_POOL_EXHAUSTED_ACTION;
135
136 private int initialisationPolicy = DEFAULT_POOL_INITIALISATION_POLICY;
137
138 public PoolingProfile()
139 {
140 super();
141 }
142
143 public PoolingProfile(PoolingProfile pp)
144 {
145 this.maxActive = pp.getMaxActive();
146 this.maxIdle = pp.getMaxIdle();
147 this.maxWait = pp.getMaxWait();
148 this.exhaustedAction = pp.getExhaustedAction();
149 this.initialisationPolicy = pp.getInitialisationPolicy();
150 }
151
152 public PoolingProfile(int maxActive,
153 int maxIdle,
154 long maxWait,
155 int exhaustedAction,
156 int initialisationPolicy)
157 {
158 this.maxActive = maxActive;
159 this.maxIdle = maxIdle;
160 this.maxWait = maxWait;
161 this.exhaustedAction = exhaustedAction;
162 this.initialisationPolicy = initialisationPolicy;
163 }
164
165
166
167
168 public int getMaxIdle()
169 {
170 return maxIdle;
171 }
172
173
174
175
176 public int getMaxActive()
177 {
178 return maxActive;
179 }
180
181
182
183
184
185
186 public long getMaxWait()
187 {
188 return maxWait;
189 }
190
191
192
193
194 public int getExhaustedAction()
195 {
196 return exhaustedAction;
197 }
198
199 public int getInitialisationPolicy()
200 {
201 return initialisationPolicy;
202 }
203
204 public void setInitialisationPolicy(int policy)
205 {
206 initialisationPolicy = policy;
207 }
208
209 public void setMaxIdle(int maxIdle)
210 {
211 this.maxIdle = maxIdle;
212 }
213
214 public void setMaxActive(int maxActive)
215 {
216 this.maxActive = maxActive;
217 }
218
219 public void setMaxWait(long maxWait)
220 {
221 this.maxWait = maxWait;
222 }
223
224 public void setExhaustedAction(int exhaustedAction)
225 {
226 this.exhaustedAction = exhaustedAction;
227 }
228
229 }