View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, 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 AppenderAttachable<IAccessEvent>, FilterAttachable<IAccessEvent> {
35  
36      AppenderAttachableImpl<IAccessEvent> aai = new AppenderAttachableImpl<IAccessEvent>();
37      FilterAttachableImpl<IAccessEvent> fai = new FilterAttachableImpl<IAccessEvent>();
38  
39      public void callAppenders(IAccessEvent event) {
40          aai.appendLoopOnAppenders(event);
41      }
42  
43      @Override
44      public void addAppender(Appender<IAccessEvent> newAppender) {
45          aai.addAppender(newAppender);
46      }
47  
48      @Override
49      public void detachAndStopAllAppenders() {
50          aai.detachAndStopAllAppenders();
51      }
52  
53      @Override
54      public boolean detachAppender(Appender<IAccessEvent> appender) {
55          return aai.detachAppender(appender);
56      }
57  
58      @Override
59      public boolean detachAppender(String name) {
60          return aai.detachAppender(name);
61      }
62  
63      @Override
64      public Appender<IAccessEvent> getAppender(String name) {
65          return aai.getAppender(name);
66      }
67  
68      @Override
69      public boolean isAttached(Appender<IAccessEvent> appender) {
70          return aai.isAttached(appender);
71      }
72  
73      @Override
74      public Iterator<Appender<IAccessEvent>> iteratorForAppenders() {
75          return aai.iteratorForAppenders();
76      }
77  
78      @Override
79      public void addFilter(Filter<IAccessEvent> newFilter) {
80          fai.addFilter(newFilter);
81      }
82  
83      @Override
84      public void clearAllFilters() {
85          fai.clearAllFilters();
86      }
87  
88      @Override
89      public List<Filter<IAccessEvent>> getCopyOfAttachedFiltersList() {
90          return fai.getCopyOfAttachedFiltersList();
91      }
92  
93      @Override
94      public FilterReply getFilterChainDecision(IAccessEvent event) {
95          return fai.getFilterChainDecision(event);
96      }
97  }