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