001 package railo.runtime.engine; 002 003 import railo.commons.lang.types.RefBoolean; 004 import railo.runtime.config.ConfigServer; 005 import railo.runtime.config.ConfigServerImpl; 006 007 /** 008 * own thread how check the main thread and his data 009 */ 010 public final class Monitor extends Thread { 011 012 013 private static final long INTERVALL = 5000; 014 private final RefBoolean run; 015 private final ConfigServerImpl configServer; 016 017 /** 018 * @param contextes 019 * @param interval 020 * @param run 021 */ 022 public Monitor(ConfigServer configServer,RefBoolean run) { 023 024 this.run=run; 025 this.configServer=(ConfigServerImpl) configServer; 026 027 } 028 029 /** 030 * @see java.lang.Runnable#run() 031 */ 032 public void run() { 033 short tries=0; 034 while(run.toBooleanValue()) { 035 try { 036 sleep(INTERVALL); 037 } 038 catch (InterruptedException e) { 039 e.printStackTrace(); 040 } 041 042 if(!configServer.isMonitoringEnabled()) return; 043 railo.runtime.monitor.IntervallMonitor[] monitors = configServer.getIntervallMonitors(); 044 045 int logCount=0; 046 if(monitors!=null)for(int i=0;i<monitors.length;i++){ 047 if(monitors[i].isLogEnabled()) { 048 logCount++; 049 try { 050 monitors[i].log(); 051 } 052 catch (Throwable e) { 053 e.printStackTrace(); 054 } 055 } 056 } 057 058 if(logCount==0) { 059 tries++; 060 if(tries>=10)return; 061 } 062 } 063 } 064 065 }