1 55 package org.apache.log.filter; 56 57 import org.apache.log.FilterTarget; 58 import org.apache.log.LogEvent; 59 import org.apache.log.LogTarget; 60 61 68 public abstract class AbstractFilterTarget 69 implements FilterTarget, LogTarget 70 { 71 private LogTarget m_targets[]; 73 74 79 public void addTarget( final LogTarget target ) 80 { 81 if( null == m_targets ) 82 { 83 m_targets = new LogTarget[]{target}; 84 } 85 else 86 { 87 final LogTarget oldTargets[] = m_targets; 88 m_targets = new LogTarget[ oldTargets.length + 1 ]; 89 System.arraycopy( oldTargets, 0, m_targets, 0, oldTargets.length ); 90 m_targets[ m_targets.length - 1 ] = target; 91 } 92 } 93 94 100 protected abstract boolean filter( LogEvent event ); 101 102 107 public void processEvent( final LogEvent event ) 108 { 109 if( null == m_targets || filter( event ) ) 110 { 111 return; 112 } 113 else 114 { 115 for( int i = 0; i < m_targets.length; i++ ) 116 { 117 m_targets[ i ].processEvent( event ); 118 } 119 } 120 } 121 } 122 | Popular Tags |