00001
00026 package org.objectweb.jonas.dbm;
00027
00028
00029 import org.objectweb.jonas.management.ReconfiguredProp;
00030 import org.objectweb.jonas.management.j2eemanagement.J2EEManagedObject;
00031
00040 public class JDBCDataSource extends J2EEManagedObject {
00041
00045 private String jdbcDriver = null;
00046
00050 private ConnectionManager cm = null;
00051
00055 private Pool pool = null;
00056
00060 private String datasourceName = null;
00061
00065 private long sequenceNumber = 0;
00066
00071 public JDBCDataSource(String objectName, ConnectionManager cm) {
00072 super(objectName);
00073 this.cm = cm;
00074 this.pool = cm.getPool();
00075 this.datasourceName = cm.getDatasourceName();
00076 }
00077
00078
00079
00083 public String getJdbcDriver() {
00084 return jdbcDriver;
00085 }
00086
00090 public void setJdbcDriver(String jdbcDriverObjectName) {
00091 jdbcDriver = jdbcDriverObjectName;
00092 }
00093
00099 public String getName() {
00100 return datasourceName;
00101 }
00102
00106 public String getJndiName() {
00107 return cm.getDSName();
00108 }
00109
00113 public String getDescription() {
00114 return cm.getDataSourceDescription();
00115 }
00116
00120 public String getUrl() {
00121 return cm.getUrl();
00122 }
00123
00127 public String getUserName() {
00128 return cm.getUserName();
00129 }
00130
00134 public String getUserPassword() {
00135 return cm.getPassword();
00136 }
00137
00141 public String getMapperName() {
00142 return cm.getMapperName();
00143 }
00144
00145
00146
00150 public Integer getJdbcConnCheckLevel() {
00151 return new Integer(pool.getCheckLevel());
00152 }
00157 public void setJdbcConnCheckLevel(Integer level) {
00158 pool.setCheckLevel(level.intValue());
00159 String propName = DataBaseServiceImpl.CONNCHECKLEVEL;
00160 ReconfiguredProp prop = new ReconfiguredProp(propName, level.toString());
00161
00162 sendReconfigNotification(getSequenceNumber(), datasourceName, prop);
00163 }
00164
00168 public Integer getJdbcConnMaxAge() {
00169 return new Integer(pool.getMaxAge());
00170 }
00174 public void setJdbcConnMaxAge(Integer mn) {
00175 pool.setMaxAge(mn.intValue());
00176 String propName = DataBaseServiceImpl.CONNMAXAGE;
00177 ReconfiguredProp prop = new ReconfiguredProp(propName, mn.toString());
00178
00179 sendReconfigNotification(getSequenceNumber(), datasourceName, prop);
00180 }
00181
00185 public Integer getJdbcMaxConnPool() {
00186 return new Integer(pool.getPoolMax());
00187 }
00191 public void setJdbcMaxConnPool(Integer max) {
00192 pool.setPoolMax(max.intValue());
00193
00194 String propName = DataBaseServiceImpl.MAXCONPOOL;
00195 ReconfiguredProp prop = new ReconfiguredProp(propName, max.toString());
00196
00197 sendReconfigNotification(getSequenceNumber(), datasourceName, prop);
00198 }
00199
00203 public Integer getJdbcMaxOpenTime() {
00204 return new Integer(pool.getMaxOpenTime());
00205 }
00209 public void setJdbcMaxOpenTime(Integer mn) {
00210 pool.setMaxOpenTime(mn.intValue());
00211 String propName = DataBaseServiceImpl.MAXOPENTIME;
00212 ReconfiguredProp prop = new ReconfiguredProp(propName, mn.toString());
00213
00214 sendReconfigNotification(getSequenceNumber(), datasourceName, prop);
00215 }
00216
00220 public Integer getJdbcMaxWaiters() {
00221 return new Integer(pool.getMaxWaiters());
00222 }
00226 public void setJdbcMaxWaiters(Integer max) {
00227 pool.setMaxWaiters(max.intValue());
00228
00229 String propName = DataBaseServiceImpl.MAXWAITERS;
00230 ReconfiguredProp prop = new ReconfiguredProp(propName, max.toString());
00231
00232 sendReconfigNotification(getSequenceNumber(), datasourceName, prop);
00233 }
00234
00238 public Integer getJdbcMaxWaitTime() {
00239 return new Integer(pool.getMaxWaitTime());
00240 }
00241
00245 public void setJdbcMaxWaitTime(Integer max) {
00246 pool.setMaxWaitTime(max.intValue());
00247
00248 String propName = DataBaseServiceImpl.MAXWAITTIME;
00249 ReconfiguredProp prop = new ReconfiguredProp(propName, max.toString());
00250
00251 sendReconfigNotification(getSequenceNumber(), datasourceName, prop);
00252 }
00253
00257 public Integer getJdbcMinConnPool() {
00258 return new Integer(pool.getPoolMin());
00259 }
00264 public void setJdbcMinConnPool(Integer min) {
00265 pool.setPoolMin(min.intValue());
00266
00267 String propName = DataBaseServiceImpl.MINCONPOOL;
00268 ReconfiguredProp prop = new ReconfiguredProp(propName, min.toString());
00269
00270 sendReconfigNotification(getSequenceNumber(), datasourceName, prop);
00271 }
00272
00276 public Integer getJdbcSamplingPeriod() {
00277 return new Integer(pool.getSamplingPeriod());
00278 }
00279
00283 public void setJdbcSamplingPeriod(Integer i) {
00284 pool.setSamplingPeriod(i.intValue());
00285
00286 String propName = DataBaseServiceImpl.SAMPLINGPERIOD;
00287 ReconfiguredProp prop = new ReconfiguredProp(propName, i.toString());
00288
00289 sendReconfigNotification(getSequenceNumber(), datasourceName, prop);
00290 }
00291
00295 public String getJdbcTestStatement() {
00296 return pool.getTestStatement();
00297 }
00301 public void setJdbcTestStatement(String test) {
00302 pool.setTestStatement(test);
00303 String propName = DataBaseServiceImpl.CONNTESTSTMT;
00304 ReconfiguredProp prop = new ReconfiguredProp(propName, test);
00305
00306 sendReconfigNotification(getSequenceNumber(), datasourceName, prop);
00307 }
00308
00309
00310
00314 public Integer getConnectionFailures() {
00315 return new Integer(pool.getConnectionFailures());
00316 }
00320 public Integer getConnectionLeaks() {
00321 return new Integer(pool.getConnectionLeaks());
00322 }
00326 public Integer getCurrentBusy() {
00327 return new Integer(pool.getCurrentBusy());
00328 }
00332 public Integer getBusyMax() {
00333 return new Integer(pool.getBusyMaxRecent());
00334 }
00338 public Integer getBusyMin() {
00339 return new Integer(pool.getBusyMinRecent());
00340 }
00344 public Integer getCurrentInTx() {
00345 return new Integer(pool.getCurrentInTx());
00346 }
00350 public Integer getCurrentOpened() {
00351 return new Integer(pool.getCurrentOpened());
00352 }
00356 public Integer getCurrentWaiters() {
00357 return new Integer(pool.getCurrentWaiters());
00358 }
00362 public Integer getOpenedCount() {
00363 return new Integer(pool.getOpenedCount());
00364 }
00368 public Integer getRejectedFull() {
00369 return new Integer(pool.getRejectedFull());
00370 }
00374 public Integer getRejectedOpen() {
00375 return new Integer(pool.getRejectedOpen());
00376 }
00380 public Integer getRejectedOther() {
00381 return new Integer(pool.getRejectedOther());
00382 }
00386 public Integer getRejectedTimeout() {
00387 return new Integer(pool.getRejectedTimeout());
00388 }
00392 public Integer getServedOpen() {
00393 return new Integer(pool.getServedOpen());
00394 }
00398 public Integer getWaiterCount() {
00399 return new Integer(pool.getWaiterCount());
00400 }
00404 public Integer getWaitersHigh() {
00405 return new Integer(pool.getWaitersHigh());
00406 }
00410 public Integer getWaitersHighRecent() {
00411 return new Integer(pool.getWaitersHighRecent());
00412 }
00416 public Long getWaitingHigh() {
00417 return new Long(pool.getWaitingHigh());
00418 }
00422 public Long getWaitingHighRecent() {
00423 return new Long(pool.getWaitingHighRecent());
00424 }
00428 public Long getWaitingTime() {
00429 return new Long(pool.getWaitingTime());
00430 }
00435 protected long getSequenceNumber() {
00436 return ++sequenceNumber;
00437 }
00438
00442 public void saveConfig() {
00443 sendSaveNotification(getSequenceNumber(), datasourceName);
00444 }
00445 }