ModuleProbe was originally a Runnable, intended to periodically call the maintenance() method on the MMBase modules.
I simplified it tremendously by having it extend Thread instead of implementing all kinds of likely unnecessary methods.
Included is the result.
Note that the invocation from Module needs to change to use it. The class should be instantiated with:
new ModuleProbe();
I can replace this class in the 1.7 branche for testing (don't expect any problems), but I am willing to keep it out of CVS until 1.8. I think it cleans up tremendously and possibly this can be used for a lot of other threads.
-- Pierre van Rooden Mediapark, C 107 tel. +31 (0)35 6772815 "Never summon anything bigger than your head."
/*
This software is OSI Certified Open Source Software. OSI Certified is a certification mark of the Open Source Initiative. The license (Mozilla version 1.0) can be read at the MMBase site. See http://www.MMBase.org/license */ package org.mmbase.module; import java.util.*; import org.mmbase.util.logging.Logger; import org.mmbase.util.logging.Logging; /** * ModuleProbe is a deamon thread that periodically calls the maintenance() method * of the modules active in MMBase. * The number of milliseconds of the invocation period is approcimately 1 minute. * * @author Pierre van Rooden * @author Daniel Ockeloen * @version $Id: ModuleProbe.java,v 1.8 2003/03/26 10:15:20 kees Exp $ */ public class ModuleProbe extends Thread { private static final Logger log = Logging.getLoggerInstance(ModuleProbe.class); // Sleeptime (needs to be configurable?) private int invocationPeriod = 60*1000; public ModuleProbe() { super("ModuleProbe"); setDaemon(true); log.service("Starting ModuleProbe"); start(); } /** * Periodically invoke the maintainance method of all active MMBase modules. */ public void run() { while (true) { // sleep try { Thread.sleep(invocationPeriod); } catch (InterruptedException e){ return; } // call each module's maintenance routine for (Iterator i = Module.getModules(); i.hasNext();) { Module module = (Module) i.next(); try { module.maintainance(); } catch (Exception er) { log.error("Exception on maintainance call : " + module.getName()); } } } } }
