1 10 11 package org.mule.config; 12 13 import org.mule.config.pool.CommonsPoolFactory; 14 import org.mule.umo.model.UMOPoolFactory; 15 import org.mule.util.ObjectPool; 16 17 24 25 public class PoolingProfile 26 { 27 28 31 public static final int POOL_INITIALISE_NO_COMPONENTS = 0; 32 33 36 public static final int POOL_INITIALISE_ONE_COMPONENT = 1; 37 38 41 public static final int POOL_INITIALISE_ALL_COMPONENTS = 2; 42 43 50 public static final int DEFAULT_MAX_POOL_ACTIVE = ObjectPool.DEFAULT_MAX_SIZE; 51 52 59 public static final int DEFAULT_MAX_POOL_IDLE = ObjectPool.DEFAULT_MAX_SIZE; 60 61 66 public static final long DEFAULT_MAX_POOL_WAIT = ObjectPool.DEFAULT_MAX_WAIT; 67 68 78 public static final int DEFAULT_POOL_EXHAUSTED_ACTION = ObjectPool.WHEN_EXHAUSTED_GROW; 79 80 92 public static final int DEFAULT_POOL_INITIALISATION_POLICY = POOL_INITIALISE_ONE_COMPONENT; 93 94 private int maxActive = DEFAULT_MAX_POOL_ACTIVE; 95 96 private int maxIdle = DEFAULT_MAX_POOL_IDLE; 97 98 private long maxWait = DEFAULT_MAX_POOL_WAIT; 99 100 private int exhaustedAction = DEFAULT_POOL_EXHAUSTED_ACTION; 101 102 private int initialisationPolicy = DEFAULT_POOL_INITIALISATION_POLICY; 103 104 private UMOPoolFactory poolFactory = new CommonsPoolFactory(); 105 106 public PoolingProfile() 107 { 108 super(); 109 } 110 111 public PoolingProfile(PoolingProfile pp) 112 { 113 this.maxActive = pp.getMaxActive(); 114 this.maxIdle = pp.getMaxIdle(); 115 this.maxWait = pp.getMaxWait(); 116 this.exhaustedAction = pp.getExhaustedAction(); 117 this.initialisationPolicy = pp.getInitialisationPolicy(); 118 if (pp.getPoolFactory() != null) 119 { 120 poolFactory = pp.getPoolFactory(); 121 } 122 } 123 124 public PoolingProfile(int maxActive, 125 int maxIdle, 126 long maxWait, 127 int exhaustedAction, 128 int initialisationPolicy) 129 { 130 this.maxActive = maxActive; 131 this.maxIdle = maxIdle; 132 this.maxWait = maxWait; 133 this.exhaustedAction = exhaustedAction; 134 this.initialisationPolicy = initialisationPolicy; 135 } 136 137 140 public int getMaxIdle() 141 { 142 return maxIdle; 143 } 144 145 148 public int getMaxActive() 149 { 150 return maxActive; 151 } 152 153 158 public long getMaxWait() 159 { 160 return maxWait; 161 } 162 163 166 public int getExhaustedAction() 167 { 168 return exhaustedAction; 169 } 170 171 public int getInitialisationPolicy() 172 { 173 return initialisationPolicy; 174 } 175 176 public void setInitialisationPolicy(int policy) 177 { 178 initialisationPolicy = policy; 179 } 180 181 public void setMaxIdle(int maxIdle) 182 { 183 this.maxIdle = maxIdle; 184 } 185 186 public void setMaxActive(int maxActive) 187 { 188 this.maxActive = maxActive; 189 } 190 191 public void setMaxWait(long maxWait) 192 { 193 this.maxWait = maxWait; 194 } 195 196 public void setExhaustedAction(int exhaustedAction) 197 { 198 this.exhaustedAction = exhaustedAction; 199 } 200 201 public void setExhaustedActionString(String poolExhaustedAction) 202 { 203 if (poolExhaustedAction != null) 204 { 205 if ("GROW".equalsIgnoreCase(poolExhaustedAction)) 206 { 207 this.exhaustedAction = ObjectPool.WHEN_EXHAUSTED_GROW; 208 } 209 else if ("BLOCK".equalsIgnoreCase(poolExhaustedAction)) 210 { 211 this.exhaustedAction = ObjectPool.WHEN_EXHAUSTED_BLOCK; 212 } 213 else if ("FAIL".equalsIgnoreCase(poolExhaustedAction)) 214 { 215 this.exhaustedAction = ObjectPool.WHEN_EXHAUSTED_FAIL; 216 } 217 else 218 { 219 this.exhaustedAction = ObjectPool.DEFAULT_EXHAUSTED_ACTION; 220 } 221 } 222 } 223 224 public void setInitialisationPolicyString(String policy) 225 { 226 if (policy != null) 227 { 228 if ("INITIALISE_NONE".equalsIgnoreCase(policy)) 229 { 230 this.initialisationPolicy = POOL_INITIALISE_NO_COMPONENTS; 231 } 232 else if ("INITIALISE_ALL".equalsIgnoreCase(policy)) 233 { 234 this.initialisationPolicy = POOL_INITIALISE_ALL_COMPONENTS; 235 } 236 else 237 { 238 this.initialisationPolicy = POOL_INITIALISE_ONE_COMPONENT; 239 } 240 } 241 } 242 243 public UMOPoolFactory getPoolFactory() 244 { 245 return poolFactory; 246 } 247 248 public void setPoolFactory(UMOPoolFactory poolFactory) 249 { 250 this.poolFactory = poolFactory; 251 } 252 253 } 254 | Popular Tags |