/** * Used to invoke the monitor lifecycle method MonitoringEngine.process on this monitor. */ protected void process() { if (processed) { log.error("This monitor has already been processed: " + this); } else { MonitoringEngine.getInstance().process(this); processed = true; } }
/** * This method should be called by all CompositeMonitor implementations * before they call process(). * * @param monitor the monitor that is completed */ public void compositeMonitorCompleted(CompositeMonitor monitor) { LinkedList stack = getStack(); if (stack != null && !stack.isEmpty()) { StackFrame target = new StackFrame(monitor); if (!stack.getLast().equals(target) && !stack.contains(target)) { // This monitor is being double processed on accident. // Ignore it. return; } while (!stack.getLast().equals(target)) { // A child monitor was not processed, process them now. StackFrame stackFrame = (StackFrame) stack.removeLast(); CompositeMonitor missedMonitor = stackFrame.getCompositeMonitor(); String name = (String) missedMonitor.get(Attribute.NAME); log.warn("unfinished child monitor \""+name+"\" found so will process now and remove; app is fine"); MonitoringEngine.getInstance().process(missedMonitor); } stack.removeLast(); } }