Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, QOS.ch. All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
 
 package ch.qos.logback.core.spi;
 
 
A ReentrantReadWriteLock based implementation of the AppenderAttachable interface.

Author(s):
Ceki Gülcü
 
 public class AppenderAttachableImpl<E> implements AppenderAttachable<E> {
 
   final private CopyOnWriteArrayList<Appender<E>> appenderList = new CopyOnWriteArrayList<Appender<E>>();

  
Attach an appender. If the appender is already in the list in won't be added again.
 
   public void addAppender(Appender<E> newAppender) {
     if (newAppender == null) {
       throw new IllegalArgumentException("Null argument disallowed");
     }
      .addIfAbsent(newAppender);
   }

  
Call the doAppend method on all attached appenders.
 
   public int appendLoopOnAppenders(E e) {
     int size = 0;
       for (Appender<E> appender : ) {
         appender.doAppend(e);
         size++;
       }
     return size;
   }

  
Get all attached appenders as an Enumeration. If there are no attached appenders null is returned.

Returns:
Iterator An iterator of attached appenders.
 
   public Iterator<Appender<E>> iteratorForAppenders() {
     return .iterator();
   }

  
Look for an attached appender named as name.

Return the appender with that name if in the list. Return null otherwise.

 
   public Appender<E> getAppender(String name) {
     if (name == null) {
       return null;
     }
     Appender<E> found = null;
     for (Appender<E> appender : ) {
       if (name.equals(appender.getName())) {
         return appender;
       }
     }
     return null;
   }

  
Returns true if the specified appender is in the list of attached appenders, false otherwise.

Since:
1.2
 
   public boolean isAttached(Appender<E> appender) {
     if (appender == null) {
       return false;
     }
     for (Appender<E> a : ) {
       if (a == appenderreturn true;
     }
     return false;
   }

  
Remove and stop all previously attached appenders.
  public void detachAndStopAllAppenders() {
    for (Appender<E> a : ) {
      a.stop();
    }
  }
  static final long START = System.currentTimeMillis();

  
Remove the appender passed as parameter form the list of attached appenders.
  public boolean detachAppender(Appender<E> appender) {
    if (appender == null) {
      return false;
    }
    boolean result;
    result = .remove(appender);
    return result;
  }

  
Remove the appender with the name passed as parameter form the list of appenders.
  public boolean detachAppender(String name) {
    if (name == null) {
      return false;
    }
    boolean removed = false;
      for (Appender<E> a : ) {
        if (name.equals((a).getName())) {
          removed = .remove(a);
          break;
        }
      }
    return removed;
  }
New to GrepCode? Check out our FAQ X