1 23 24 29 42 43 48 49 package com.sun.enterprise.util.pool; 50 51 import java.util.Properties ; 52 53 public class PoolProperties { 54 55 58 public static final String FACTORY_CLASS_NAME = "pool.factory.class"; 59 60 63 public static final String MINIMUM_SIZE = "pool.minsize"; 64 public static final String INITIAL_SIZE = "pool.initialsize"; 65 public static final String LOW_WATER_MARK = "pool.lowwatermark"; 66 public static final String HI_WATER_MARK = "pool.hiwatermark"; 67 public static final String MAX_STRONG_REFERENCES = "pool.maxstrongrefs"; 68 public static final String POOL_LIMIT = "pool.limit"; 69 public static final String MAX_IDLE_TIME = "pool.maxidletime"; 70 71 public long key; 72 public String factoryClassName; 73 76 public int minimumSize; 77 78 81 public int initialSize; 82 83 86 public int lowWaterMark; 87 88 91 public int hiWaterMark; 92 93 99 public int maxStrongRefs; 100 101 105 public int poolLimit; 106 public long maxIdleTime; 107 108 public PoolProperties() { 109 } 110 111 public PoolProperties(int minimumSize, int poolLimit) { 112 this.minimumSize = minimumSize; 113 this.poolLimit = poolLimit; 114 } 115 116 public PoolProperties(Properties props) { 117 factoryClassName = props.getProperty(FACTORY_CLASS_NAME); 118 minimumSize = getIntProperty(props, MINIMUM_SIZE, 0); 119 initialSize = getIntProperty(props, INITIAL_SIZE, 0); 120 lowWaterMark = getIntProperty(props, LOW_WATER_MARK, 0); 121 hiWaterMark = getIntProperty(props, HI_WATER_MARK, 0); 122 poolLimit = getIntProperty(props, POOL_LIMIT, 0); 123 maxIdleTime = getLongProperty(props, MAX_IDLE_TIME, 60 * 1000); 124 } 125 126 public String getFactoryClassName() { 127 return this.factoryClassName; 128 } 129 130 public void setFactoryClassName(String name) { 131 this.factoryClassName = name; 132 } 133 134 135 public int getMinimumSize() { 136 return this.minimumSize; 137 } 138 public void setMinimumSize(int val) { 139 this.minimumSize = val; 140 } 141 142 143 public int getInitialSize() { 144 return this.initialSize; 145 } 146 public void setInitialSize(int val) { 147 this.initialSize = val; 148 } 149 150 151 public int getLowWaterMark() { 152 return this.lowWaterMark; 153 } 154 public void setLowWaterMark(int val) { 155 this.lowWaterMark = val; 156 } 157 158 159 public int getHiWaterMark() { 160 return this.hiWaterMark; 161 } 162 public void setHiWaterMark(int val) { 163 this.hiWaterMark = val; 164 } 165 166 167 public int getMaxStrongRefs() { 168 return this.maxStrongRefs; 169 } 170 public void setMaxStrongRefs(int val) { 171 this.maxStrongRefs = val; 172 } 173 174 175 public int getPoolLimit() { 176 return this.poolLimit; 177 } 178 public void setPoolLimit(int val) { 179 this.poolLimit = val; 180 } 181 182 183 public long getMaxIdleTime() { 184 return this.maxIdleTime; 185 } 186 public void setMaxIdleTime(long val) { 187 this.maxIdleTime = val; 188 } 189 190 191 192 193 private int getIntProperty(Properties props, String name, int defaultValue) { 194 try { 195 return Integer.parseInt(props.getProperty(name)); 196 } catch (Throwable th) { 197 return defaultValue; 198 } 199 } 200 201 202 private long getLongProperty(Properties props, String name, long defaultValue) { 203 try { 204 return Long.parseLong(props.getProperty(name)); 205 } catch (Throwable th) { 206 return defaultValue; 207 } 208 } 209 210 public String toString() { 211 StringBuffer sbuf = new StringBuffer (); 212 sbuf.append("key: ").append(key) 213 .append("; min: ").append(minimumSize) 214 .append("; init: ").append(initialSize) 215 .append("; lowWM: ").append(lowWaterMark) 216 .append("; hiWM: ").append(hiWaterMark) 217 .append("; maxSRefs: ").append(maxStrongRefs) 218 .append("; limit: ").append(poolLimit); 219 return sbuf.toString(); 220 } 221 222 } 223 | Popular Tags |