1 10 package org.mmbase.module.database; 11 12 import org.mmbase.module.core.MMBaseContext; 13 import org.mmbase.util.logging.Logger; 14 import org.mmbase.util.logging.Logging; 15 16 23 public class JDBCProbe implements Runnable { 24 private static final Logger log = Logging.getLoggerInstance(JDBCProbe.class); 25 26 private JDBC parent = null; 27 private long checkTime; 28 29 30 public JDBCProbe(JDBC parent) { 31 this(parent, 30); 32 } 33 34 public JDBCProbe(JDBC parent, int ct) { 35 this(parent, (long) ct * 1000); 36 } 37 38 public JDBCProbe(JDBC parent, long ct) { 39 this.parent = parent; 40 checkTime = ct; 41 MMBaseContext.startThread(this, "JDBCProbe"); 42 } 43 44 47 public void run () { 48 log.service("JDBC probe starting with sleep time of " +( checkTime / 1000) + " s"); 49 while (true) { 51 try { 52 Thread.sleep(checkTime); 53 } catch(InterruptedException e) { 54 log.debug(Thread.currentThread().getName() +" was interrupted."); 55 break; } 57 58 try { 59 parent.checkTime(); 60 } catch (Exception e) { 61 log.error(e.getMessage()); 62 } 63 } 64 } 65 } 66 | Popular Tags |