View Javadoc

1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * 
4    * Copyright (C) 1999-2006, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  package ch.qos.logback.classic.selector;
11  
12  import java.util.Arrays;
13  import java.util.List;
14  
15  import ch.qos.logback.classic.LoggerContext;
16  
17  public class DefaultContextSelector implements ContextSelector {
18  
19    private LoggerContext context;
20    
21    public DefaultContextSelector(LoggerContext context) {
22      this.context = context;
23    }
24    
25    public LoggerContext getLoggerContext() {
26      return getDefaultLoggerContext();
27    }
28  
29    public LoggerContext getDefaultLoggerContext() {
30      return context;
31    }
32  
33    public LoggerContext detachLoggerContext(String loggerContextName) {
34      return context;
35    }
36    
37    public List<String> getContextNames() {
38      return Arrays.asList(context.getName());
39    }
40    
41    public LoggerContext getLoggerContext(String name) {
42      if (context.getName().equals(name)) {
43        return context;
44      } else {
45        return null;
46      }
47    }
48  }