1 8 package org.jivesoftware.util.log.filter; 9 10 import org.jivesoftware.util.log.FilterTarget; 11 import org.jivesoftware.util.log.LogEvent; 12 import org.jivesoftware.util.log.LogTarget; 13 14 20 public abstract class AbstractFilterTarget 21 implements FilterTarget, LogTarget { 22 private LogTarget m_targets[]; 24 25 30 public void addTarget(final LogTarget target) { 31 if (null == m_targets) { 32 m_targets = new LogTarget[]{target}; 33 } 34 else { 35 final LogTarget oldTargets[] = m_targets; 36 m_targets = new LogTarget[oldTargets.length + 1]; 37 System.arraycopy(oldTargets, 0, m_targets, 0, oldTargets.length); 38 m_targets[m_targets.length - 1] = target; 39 } 40 } 41 42 48 protected abstract boolean filter(LogEvent event); 49 50 55 public void processEvent(final LogEvent event) { 56 if (null == m_targets || filter(event)) 57 return; 58 else { 59 for (int i = 0; i < m_targets.length; i++) { 60 m_targets[i].processEvent(event); 61 } 62 } 63 } 64 } 65 | Popular Tags |