1 23 24 31 32 package com.sun.enterprise.tools.common.deploy; 33 34 import java.beans.*; 35 import java.util.List ; 36 import java.io.File ; 38 import com.sun.enterprise.tools.common.deploy.IJdbcConnectionPool; 40 import com.sun.enterprise.tools.common.util.diagnostics.Reporter; 41 42 public class JdbcConnectionPool extends Object implements java.io.Serializable { 43 44 private String name; 45 private String id; 46 private String JdbcFactoryClassName; 47 private String ResType; 48 private String MinConnectionsInPool; 52 private String MaxConnectionsInPool; 54 private String MaxConnectionWaitTimeInMillis; 55 private String ConnectionsIncrement; 56 private String ConnectionIdleTimeoutInSeconds; 57 private String IsConnectionValidationRequired; 58 private String ConnectionValidationType; 59 private String ValidationTableName; 60 private String FailAllConnections; 61 private String XIsolationLevel; 62 private String IsIsolationLevelGuaranteed; 63 private NameValuePair[] extParams; 64 65 transient private PropertyChangeSupport propertySupport; 66 67 public JdbcConnectionPool(List resource) { 68 propertySupport = new PropertyChangeSupport ( this ); 69 70 id = "PoolName"; JdbcFactoryClassName = "DatasourceClassName"; ResType = "javax.sql.DataSource"; MinConnectionsInPool = "8"; MaxConnectionsInPool = "32"; MaxConnectionWaitTimeInMillis = "60000"; ConnectionsIncrement = "2"; ConnectionIdleTimeoutInSeconds = "300"; IsConnectionValidationRequired = "false"; ConnectionValidationType = "auto-commit"; ValidationTableName = "TAB_NAME"; FailAllConnections = "false"; XIsolationLevel = ""; IsIsolationLevelGuaranteed = "true"; extParams = new NameValuePair[0]; 89 90 String t_name = null; 92 if(resource.size() != 0){ 93 int num = resource.size()+1; 94 t_name = "JdbcConnectionPool_" + num; boolean exists = FactoryName(t_name, resource); 96 while(exists){ 97 num++; 98 t_name = "JdbcConnectionPool_" + num; exists = FactoryName(t_name, resource); 100 } 101 } else { 102 t_name = "JdbcConnectionPool_1"; } 104 name = t_name; 105 id = t_name; 106 } 107 108 private void initPropertyChangeSupport(){ 109 if(propertySupport==null) 110 propertySupport = new PropertyChangeSupport ( this ); 111 112 } 113 114 public void addPropertyChangeListener (PropertyChangeListener listener) { 115 initPropertyChangeSupport(); 116 propertySupport.addPropertyChangeListener (listener); 117 } 118 119 public void removePropertyChangeListener (PropertyChangeListener listener) { 120 initPropertyChangeSupport(); 121 propertySupport.removePropertyChangeListener (listener); 122 } 123 124 public String getName() { 125 return name; 126 } 127 public void setName(String value) { 128 String oldValue = name; 129 this.name = value; 130 initPropertyChangeSupport(); 131 propertySupport.firePropertyChange ("name", oldValue, name); } 133 134 public String getId() { 135 return id; 136 } 137 138 public void setId(String value) { 139 String oldValue = id; 140 this.id = value; 141 initPropertyChangeSupport(); 142 propertySupport.firePropertyChange ("id", oldValue, id); setName(id); 144 } 145 146 public void simpleSetId(String value) { 147 this.id = value; 148 setName(id); 149 } 150 170 public String getJdbcFactoryClassName() { 171 return JdbcFactoryClassName; 172 } 173 public void setJdbcFactoryClassName(java.lang.String facname) { 174 String prev = JdbcFactoryClassName; 175 this.JdbcFactoryClassName = facname; 176 initPropertyChangeSupport(); 177 propertySupport.firePropertyChange ("JdbcFactoryClassName", prev, JdbcFactoryClassName); } 179 180 public String getResType() { 181 return ResType; 182 } 183 public void setResType(java.lang.String val) { 184 String prev = this.ResType; 185 this.ResType = val; 186 initPropertyChangeSupport(); 187 propertySupport.firePropertyChange ("ResType", prev, ResType); } 189 210 public void setMinConnectionsInPool(String value) 211 { 212 String oldValue = MinConnectionsInPool; 213 this.MinConnectionsInPool = value; 214 initPropertyChangeSupport(); 215 propertySupport.firePropertyChange ("MinConnectionsInPool", oldValue, MinConnectionsInPool); } 217 218 public String getMinConnectionsInPool() 219 { 220 return MinConnectionsInPool; 221 } 222 236 public void setMaxConnectionsInPool(String value) 237 { 238 String oldValue = MaxConnectionsInPool; 239 this.MaxConnectionsInPool = value; 240 initPropertyChangeSupport(); 241 propertySupport.firePropertyChange ("MaxConnectionsInPool", oldValue, MaxConnectionsInPool); } 243 244 public String getMaxConnectionsInPool() 246 { 247 return MaxConnectionsInPool; 248 } 249 250 public void setMaxConnectionWaitTimeInMillis(String value) 251 { 252 String oldValue = MaxConnectionWaitTimeInMillis; 253 this.MaxConnectionWaitTimeInMillis = value; 254 initPropertyChangeSupport(); 255 propertySupport.firePropertyChange ("MaxConnectionWaitTimeInMillis", oldValue, MaxConnectionWaitTimeInMillis); } 257 258 public String getMaxConnectionWaitTimeInMillis() 259 { 260 return MaxConnectionWaitTimeInMillis; 261 } 262 263 public void setConnectionsIncrement(String value) 264 { 265 String oldValue = ConnectionsIncrement; 266 this.ConnectionsIncrement = value; 267 initPropertyChangeSupport(); 268 propertySupport.firePropertyChange ("ConnectionsIncrement", oldValue, ConnectionsIncrement); } 270 271 public String getConnectionsIncrement() 272 { 273 return ConnectionsIncrement; 274 } 275 276 public void setConnectionIdleTimeoutInSeconds(String value) 277 { 278 String oldValue = ConnectionIdleTimeoutInSeconds; 279 this.ConnectionIdleTimeoutInSeconds = value; 280 initPropertyChangeSupport(); 281 propertySupport.firePropertyChange ("ConnectionIdleTimeoutInSeconds", oldValue, ConnectionIdleTimeoutInSeconds); } 283 284 public String getConnectionIdleTimeoutInSeconds() 285 { 286 return ConnectionIdleTimeoutInSeconds; 287 } 288 289 public void setIsConnectionValidationRequired(String value) 290 { 291 String oldValue = IsConnectionValidationRequired; 292 this.IsConnectionValidationRequired = value; 293 initPropertyChangeSupport(); 294 propertySupport.firePropertyChange ("IsConnectionValidationRequired", oldValue, IsConnectionValidationRequired); } 296 297 public String getIsConnectionValidationRequired() 298 { 299 return IsConnectionValidationRequired; 300 } 301 302 public void setConnectionValidationType(String value) 303 { 304 String oldValue = ConnectionValidationType; 305 this.ConnectionValidationType = value; 306 initPropertyChangeSupport(); 307 propertySupport.firePropertyChange ("ConnectionValidationType", oldValue, ConnectionValidationType); } 309 310 public String getConnectionValidationType() 311 { 312 return ConnectionValidationType; 313 } 314 315 public void setValidationTableName(String value) 316 { 317 String oldValue = ValidationTableName; 318 this.ValidationTableName = value; 319 initPropertyChangeSupport(); 320 propertySupport.firePropertyChange ("ValidationTableName", oldValue, ValidationTableName); } 322 323 public String getValidationTableName() 324 { 325 return ValidationTableName; 326 } 327 328 public void setFailAllConnections(String value) 329 { 330 String oldValue = FailAllConnections; 331 this.FailAllConnections = value; 332 initPropertyChangeSupport(); 333 propertySupport.firePropertyChange ("FailAllConnections", oldValue, FailAllConnections); } 335 336 public String getFailAllConnections() 337 { 338 return FailAllConnections; 339 } 340 341 public String getXIsolationLevel() { 342 return XIsolationLevel; 343 } 344 public void setXIsolationLevel(java.lang.String val) { 345 String prev = this.XIsolationLevel; 346 this.XIsolationLevel = val; 347 initPropertyChangeSupport(); 348 propertySupport.firePropertyChange ("XIsolationLevel", prev, XIsolationLevel); } 350 351 public String getIsIsolationLevelGuaranteed() { 352 return IsIsolationLevelGuaranteed; 353 } 354 public void setIsIsolationLevelGuaranteed(java.lang.String val) { 355 String prev = this.IsIsolationLevelGuaranteed; 356 this.IsIsolationLevelGuaranteed = val; 357 initPropertyChangeSupport(); 358 propertySupport.firePropertyChange ("IsIsolationLevelGuaranteed", prev, IsIsolationLevelGuaranteed); } 360 361 public NameValuePair[] getExtParams() { 362 return extParams; 363 } 364 365 public void setExtParams(Object [] value) { 366 Reporter.info(new Integer (value.length)); NameValuePair[] pairs = new NameValuePair[value.length]; 368 for (int i = 0; i < value.length; i++) { 369 NameValuePair val = (NameValuePair)value[i]; 370 NameValuePair pair = new NameValuePair(); 371 pair.setParamName(val.getParamName()); 372 pair.setParamValue(val.getParamValue()); 373 pair.setParamDescription(val.getParamDescription()); 374 Reporter.info(pair.getParamName() + " " + pair.getParamValue()); pairs[i] = pair; 376 } 377 NameValuePair[] oldValue = extParams; 378 this.extParams = pairs; 379 initPropertyChangeSupport(); 380 propertySupport.firePropertyChange ("extParams", oldValue, extParams); } 382 383 public boolean FactoryName(String value, List resources){ 384 boolean exists = false; 385 for(int i=0; i<resources.size(); i++){ 387 IJdbcConnectionPool instance = (IJdbcConnectionPool) resources.get(i); 388 String inst = instance.getName(); 389 if(inst.equals(value)) 390 exists = true; 391 } return exists; 393 } 394 } 395 | Popular Tags |