1 25 26 package org.objectweb.jonas.dbm; 27 28 import org.objectweb.jonas.management.ReconfiguredProp; 30 import org.objectweb.jonas.management.j2eemanagement.J2EEManagedObject; 31 32 40 public class JDBCDataSource extends J2EEManagedObject { 41 42 45 private String jdbcDriver = null; 46 47 50 private ConnectionManager cm = null; 51 52 55 private Pool pool = null; 56 57 60 private String datasourceName = null; 61 62 65 private long sequenceNumber = 0; 66 67 71 public JDBCDataSource(String objectName, ConnectionManager cm) { 72 super(objectName); 73 this.cm = cm; 74 this.pool = cm.getPool(); 75 this.datasourceName = cm.getDatasourceName(); 76 } 77 78 80 83 public String getJdbcDriver() { 84 return jdbcDriver; 85 } 86 87 90 public void setJdbcDriver(String jdbcDriverObjectName) { 91 jdbcDriver = jdbcDriverObjectName; 92 } 93 94 99 public String getName() { 100 return datasourceName; 101 } 102 103 106 public String getJndiName() { 107 return cm.getDSName(); 108 } 109 110 113 public String getDescription() { 114 return cm.getDataSourceDescription(); 115 } 116 117 120 public String getUrl() { 121 return cm.getUrl(); 122 } 123 124 127 public String getUserName() { 128 return cm.getUserName(); 129 } 130 131 134 public String getUserPassword() { 135 return cm.getPassword(); 136 } 137 138 141 public String getMapperName() { 142 return cm.getMapperName(); 143 } 144 145 147 150 public Integer getJdbcConnCheckLevel() { 151 return new Integer (pool.getCheckLevel()); 152 } 153 157 public void setJdbcConnCheckLevel(Integer level) { 158 pool.setCheckLevel(level.intValue()); 159 String propName = DataBaseServiceImpl.CONNCHECKLEVEL; 160 ReconfiguredProp prop = new ReconfiguredProp(propName, level.toString()); 161 sendReconfigNotification(getSequenceNumber(), datasourceName, prop); 163 } 164 165 168 public Integer getJdbcConnMaxAge() { 169 return new Integer (pool.getMaxAge()); 170 } 171 174 public void setJdbcConnMaxAge(Integer mn) { 175 pool.setMaxAge(mn.intValue()); 176 String propName = DataBaseServiceImpl.CONNMAXAGE; 177 ReconfiguredProp prop = new ReconfiguredProp(propName, mn.toString()); 178 sendReconfigNotification(getSequenceNumber(), datasourceName, prop); 180 } 181 182 185 public Integer getJdbcMaxConnPool() { 186 return new Integer (pool.getPoolMax()); 187 } 188 191 public void setJdbcMaxConnPool(Integer max) { 192 pool.setPoolMax(max.intValue()); 193 String propName = DataBaseServiceImpl.MAXCONPOOL; 195 ReconfiguredProp prop = new ReconfiguredProp(propName, max.toString()); 196 sendReconfigNotification(getSequenceNumber(), datasourceName, prop); 198 } 199 200 203 public Integer getJdbcMaxOpenTime() { 204 return new Integer (pool.getMaxOpenTime()); 205 } 206 209 public void setJdbcMaxOpenTime(Integer mn) { 210 pool.setMaxOpenTime(mn.intValue()); 211 String propName = DataBaseServiceImpl.MAXOPENTIME; 212 ReconfiguredProp prop = new ReconfiguredProp(propName, mn.toString()); 213 sendReconfigNotification(getSequenceNumber(), datasourceName, prop); 215 } 216 217 220 public Integer getJdbcMaxWaiters() { 221 return new Integer (pool.getMaxWaiters()); 222 } 223 226 public void setJdbcMaxWaiters(Integer max) { 227 pool.setMaxWaiters(max.intValue()); 228 String propName = DataBaseServiceImpl.MAXWAITERS; 230 ReconfiguredProp prop = new ReconfiguredProp(propName, max.toString()); 231 sendReconfigNotification(getSequenceNumber(), datasourceName, prop); 233 } 234 235 238 public Integer getJdbcMaxWaitTime() { 239 return new Integer (pool.getMaxWaitTime()); 240 } 241 242 245 public void setJdbcMaxWaitTime(Integer max) { 246 pool.setMaxWaitTime(max.intValue()); 247 String propName = DataBaseServiceImpl.MAXWAITTIME; 249 ReconfiguredProp prop = new ReconfiguredProp(propName, max.toString()); 250 sendReconfigNotification(getSequenceNumber(), datasourceName, prop); 252 } 253 254 257 public Integer getJdbcMinConnPool() { 258 return new Integer (pool.getPoolMin()); 259 } 260 264 public void setJdbcMinConnPool(Integer min) { 265 pool.setPoolMin(min.intValue()); 266 String propName = DataBaseServiceImpl.MINCONPOOL; 268 ReconfiguredProp prop = new ReconfiguredProp(propName, min.toString()); 269 sendReconfigNotification(getSequenceNumber(), datasourceName, prop); 271 } 272 273 276 public Integer getJdbcSamplingPeriod() { 277 return new Integer (pool.getSamplingPeriod()); 278 } 279 280 283 public void setJdbcSamplingPeriod(Integer i) { 284 pool.setSamplingPeriod(i.intValue()); 285 String propName = DataBaseServiceImpl.SAMPLINGPERIOD; 287 ReconfiguredProp prop = new ReconfiguredProp(propName, i.toString()); 288 sendReconfigNotification(getSequenceNumber(), datasourceName, prop); 290 } 291 292 295 public String getJdbcTestStatement() { 296 return pool.getTestStatement(); 297 } 298 301 public void setJdbcTestStatement(String test) { 302 pool.setTestStatement(test); 303 String propName = DataBaseServiceImpl.CONNTESTSTMT; 304 ReconfiguredProp prop = new ReconfiguredProp(propName, test); 305 sendReconfigNotification(getSequenceNumber(), datasourceName, prop); 307 } 308 309 311 314 public Integer getConnectionFailures() { 315 return new Integer (pool.getConnectionFailures()); 316 } 317 320 public Integer getConnectionLeaks() { 321 return new Integer (pool.getConnectionLeaks()); 322 } 323 326 public Integer getCurrentBusy() { 327 return new Integer (pool.getCurrentBusy()); 328 } 329 332 public Integer getBusyMax() { 333 return new Integer (pool.getBusyMaxRecent()); 334 } 335 338 public Integer getBusyMin() { 339 return new Integer (pool.getBusyMinRecent()); 340 } 341 344 public Integer getCurrentInTx() { 345 return new Integer (pool.getCurrentInTx()); 346 } 347 350 public Integer getCurrentOpened() { 351 return new Integer (pool.getCurrentOpened()); 352 } 353 356 public Integer getCurrentWaiters() { 357 return new Integer (pool.getCurrentWaiters()); 358 } 359 362 public Integer getOpenedCount() { 363 return new Integer (pool.getOpenedCount()); 364 } 365 368 public Integer getRejectedFull() { 369 return new Integer (pool.getRejectedFull()); 370 } 371 374 public Integer getRejectedOpen() { 375 return new Integer (pool.getRejectedOpen()); 376 } 377 380 public Integer getRejectedOther() { 381 return new Integer (pool.getRejectedOther()); 382 } 383 386 public Integer getRejectedTimeout() { 387 return new Integer (pool.getRejectedTimeout()); 388 } 389 392 public Integer getServedOpen() { 393 return new Integer (pool.getServedOpen()); 394 } 395 398 public Integer getWaiterCount() { 399 return new Integer (pool.getWaiterCount()); 400 } 401 404 public Integer getWaitersHigh() { 405 return new Integer (pool.getWaitersHigh()); 406 } 407 410 public Integer getWaitersHighRecent() { 411 return new Integer (pool.getWaitersHighRecent()); 412 } 413 416 public Long getWaitingHigh() { 417 return new Long (pool.getWaitingHigh()); 418 } 419 422 public Long getWaitingHighRecent() { 423 return new Long (pool.getWaitingHighRecent()); 424 } 425 428 public Long getWaitingTime() { 429 return new Long (pool.getWaitingTime()); 430 } 431 435 protected long getSequenceNumber() { 436 return ++sequenceNumber; 437 } 438 439 442 public void saveConfig() { 443 sendSaveNotification(getSequenceNumber(), datasourceName); 444 } 445 } 446 | Popular Tags |