001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.access.spi;
015
016import java.util.Iterator;
017import java.util.List;
018
019import ch.qos.logback.core.Appender;
020import ch.qos.logback.core.ContextBase;
021import ch.qos.logback.core.filter.Filter;
022import ch.qos.logback.core.spi.AppenderAttachable;
023import ch.qos.logback.core.spi.AppenderAttachableImpl;
024import ch.qos.logback.core.spi.FilterAttachable;
025import ch.qos.logback.core.spi.FilterAttachableImpl;
026import ch.qos.logback.core.spi.FilterReply;
027
028/**
029 * A minimal context implementation used by certain logback-access components,
030 * mainly SocketServer.
031 * 
032 * @author Sébastien Pennec
033 */
034public class AccessContext extends ContextBase
035        implements AppenderAttachable<IAccessEvent>, FilterAttachable<IAccessEvent> {
036
037    AppenderAttachableImpl<IAccessEvent> aai = new AppenderAttachableImpl<IAccessEvent>();
038    FilterAttachableImpl<IAccessEvent> fai = new FilterAttachableImpl<IAccessEvent>();
039
040    public void callAppenders(IAccessEvent event) {
041        aai.appendLoopOnAppenders(event);
042    }
043
044    @Override
045    public void addAppender(Appender<IAccessEvent> newAppender) {
046        aai.addAppender(newAppender);
047    }
048
049    @Override
050    public void detachAndStopAllAppenders() {
051        aai.detachAndStopAllAppenders();
052    }
053
054    @Override
055    public boolean detachAppender(Appender<IAccessEvent> appender) {
056        return aai.detachAppender(appender);
057    }
058
059    @Override
060    public boolean detachAppender(String name) {
061        return aai.detachAppender(name);
062    }
063
064    @Override
065    public Appender<IAccessEvent> getAppender(String name) {
066        return aai.getAppender(name);
067    }
068
069    @Override
070    public boolean isAttached(Appender<IAccessEvent> appender) {
071        return aai.isAttached(appender);
072    }
073
074    @Override
075    public Iterator<Appender<IAccessEvent>> iteratorForAppenders() {
076        return aai.iteratorForAppenders();
077    }
078
079    @Override
080    public void addFilter(Filter<IAccessEvent> newFilter) {
081        fai.addFilter(newFilter);
082    }
083
084    @Override
085    public void clearAllFilters() {
086        fai.clearAllFilters();
087    }
088
089    @Override
090    public List<Filter<IAccessEvent>> getCopyOfAttachedFiltersList() {
091        return fai.getCopyOfAttachedFiltersList();
092    }
093
094    @Override
095    public FilterReply getFilterChainDecision(IAccessEvent event) {
096        return fai.getFilterChainDecision(event);
097    }
098}