View Javadoc

1   /**
2    * Logback: the generic, reliable, 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.spi;
11  
12  import java.io.Serializable;
13  import java.util.Map;
14  
15  import ch.qos.logback.classic.LoggerContext;
16  
17  /**
18   * LoggerContextRemoteView offers a restricted view of LoggerContext intended to
19   * be exposed by LoggingEvent. This restricted view is optimised for
20   * serialisation.
21   * 
22   * Some of the LoggerContext or Logger attributes should not survive
23   * serialization, e.g appenders, level values etc, as these attributes may have
24   * other values on the remote platform. LoggerContextRemoteView class exposes
25   * the minimal (relevant) attributes to remote host, instead of having to deal
26   * with an incomplete LoggerContext with many null references.
27   * 
28   * @author Ceki Gülcü
29   * @author Sébastien Pennec
30   */
31  public class LoggerContextRemoteView implements Serializable {
32  
33    private static final long serialVersionUID = 5488023392483144387L;
34  
35    final String name;
36    final Map<String, String> propertyMap;
37  
38    public LoggerContextRemoteView(LoggerContext lc) {
39      // this(lc.getName(), lc.getPropertyMap());
40      this.name = lc.getName();
41      this.propertyMap = lc.getCopyOfPropertyMap();
42    }
43  
44    // public LoggerContextRemoteView(String name, Map<String, String>
45    // propertyMap) {
46    // this.name = name;
47    // this.propertyMap = propertyMap;
48    // }
49  
50    public String getName() {
51      return name;
52    }
53  
54    public Map<String, String> getPropertyMap() {
55      return propertyMap;
56    }
57  
58  }