View Javadoc

1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.access.spi;
15  
16  import java.util.Iterator;
17  import java.util.List;
18  
19  import ch.qos.logback.core.Appender;
20  import ch.qos.logback.core.ContextBase;
21  import ch.qos.logback.core.filter.Filter;
22  import ch.qos.logback.core.spi.AppenderAttachable;
23  import ch.qos.logback.core.spi.AppenderAttachableImpl;
24  import ch.qos.logback.core.spi.FilterAttachable;
25  import ch.qos.logback.core.spi.FilterAttachableImpl;
26  import ch.qos.logback.core.spi.FilterReply;
27  
28  /**
29   * A minimal context implementation used by certain logback-access components,
30   * mainly SocketServer.
31   * 
32   * @author Sébastien Pennec
33   */
34  public class AccessContext extends ContextBase implements
35      AppenderAttachable<IAccessEvent>, FilterAttachable<IAccessEvent> {
36  
37    AppenderAttachableImpl<IAccessEvent> aai = new AppenderAttachableImpl<IAccessEvent>();
38    FilterAttachableImpl<IAccessEvent> fai = new FilterAttachableImpl<IAccessEvent>();
39  
40    public void callAppenders(IAccessEvent event) {
41      aai.appendLoopOnAppenders(event);
42    }
43  
44    public void addAppender(Appender<IAccessEvent> newAppender) {
45      aai.addAppender(newAppender);
46    }
47  
48    public void detachAndStopAllAppenders() {
49      aai.detachAndStopAllAppenders();
50    }
51  
52    public boolean detachAppender(Appender<IAccessEvent> appender) {
53      return aai.detachAppender(appender);
54    }
55  
56    public boolean detachAppender(String name) {
57      return aai.detachAppender(name);
58    }
59  
60    public Appender<IAccessEvent> getAppender(String name) {
61      return aai.getAppender(name);
62    }
63  
64    public boolean isAttached(Appender<IAccessEvent> appender) {
65      return aai.isAttached(appender);
66    }
67  
68    public Iterator<Appender<IAccessEvent>> iteratorForAppenders() {
69      return aai.iteratorForAppenders();
70    }
71  
72    public void addFilter(Filter<IAccessEvent> newFilter) {
73      fai.addFilter(newFilter);
74    }
75  
76    public void clearAllFilters() {
77      fai.clearAllFilters();
78    }
79  
80    public List<Filter<IAccessEvent>> getCopyOfAttachedFiltersList() {
81      return fai.getCopyOfAttachedFiltersList();
82    }
83  
84    public FilterReply getFilterChainDecision(IAccessEvent event) {
85      return fai.getFilterChainDecision(event);
86    }
87  }