001package org.javasimon.callback.logging; 002 003import org.javasimon.Split; 004 005/** 006 * Log template which awakes only when split is longer than given threshold. 007 * 008 * @author gquintana 009 */ 010public class SplitThresholdLogTemplate extends DelegateLogTemplate<Split> { 011 012 /** Split duration theshold. */ 013 private final long threshold; 014 015 /** 016 * Constructor. 017 * 018 * @param delegate Concreate log template 019 * @param threshold Theshold 020 */ 021 public SplitThresholdLogTemplate(LogTemplate<Split> delegate, long threshold) { 022 super(delegate); 023 this.threshold = threshold; 024 } 025 026 @Override 027 protected boolean isEnabled(Split split) { 028 return split.runningFor() > threshold && super.isEnabled(split); 029 } 030 031 protected long getThreshold() { 032 return threshold; 033 } 034}