Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
 package ch.qos.logback.core;
 import java.util.Map;
 import static ch.qos.logback.core.CoreConstants.CONTEXT_NAME_KEY;
 public class ContextBase implements Context {
   private long birthTime = System.currentTimeMillis();
   private String name;
   private StatusManager sm = new BasicStatusManager();
   // TODO propertyMap should be observable so that we can be notified
   // when it changes so that a new instance of propertyMap can be
   // serialized. For the time being, we ignore this shortcoming.
   Map<StringObjectobjectMap = new HashMap<StringObject>();
   // CORE_POOL_SIZE must be 1 for JDK 1.5. For JD 1.6 or higher it's set to 0
   // so that there are no idle threads
   private static final int CORE_POOL_SIZE = EnvUtil.isJDK5() ? 1 : 0;
   // 0 (JDK 1,6+) or 1 (JDK 1.5) idle threads, 2 maximum threads, no idle waiting
           0L, .,
           new LinkedBlockingQueue<Runnable>());
   public StatusManager getStatusManager() {
     return ;

Set the ch.qos.logback.core.status.StatusManager for this context. Note that by default this context is initialized with a BasicStatusManager. A null value for the 'statusManager' argument is not allowed.

A malicious attacker can set the status manager to a dummy instance, disabling internal error reporting.

statusManager the new status manager
   public void setStatusManager(StatusManager statusManager) {
     // this method was added in response to
     if ( == null) {
       throw new IllegalArgumentException("null StatusManager not allowed");
     this. = statusManager;
   public Map<StringStringgetCopyOfPropertyMap() {
     return new HashMap<StringString>();
   public void putProperty(String keyString val) {

Given a key, return the corresponding property value. If invoked with the special key "CONTEXT_NAME", the name of the context is returned.

   public String getProperty(String key) {
     if (.equals(key))
       return getName();
     return (Stringthis..get(key);
   public Object getObject(String key) {
     return .get(key);
   public void putObject(String keyObject value) {
  public String getName() {
    return ;

Clear the internal objectMap and all properties.
  public void reset() {

The context name can be set only if it is not already set, or if the current name is the default context name, namely "default", or if the current name and the old name are the same.

java.lang.IllegalStateException if the context already has a name, other than "default".
  public void setName(String namethrows IllegalStateException {
    if (name != null && name.equals(this.)) {
      return// idempotent naming
    if (this. == null
            || ..equals(this.)) {
      this. = name;
    } else {
      throw new IllegalStateException("Context has been already given a name");
  public long getBirthTime() {
    return ;
    return ;
    return  ;
  public String toString() {
    return ;
New to GrepCode? Check out our FAQ X