All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ch.qos.logback.core.Context Maven / Gradle / Ivy

/**
 * Logback: the reliable, generic, fast and flexible logging framework.
 * Copyright (C) 1999-2013, QOS.ch. 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 java.util.concurrent.ExecutorService;

import ch.qos.logback.core.spi.LifeCycle;
import ch.qos.logback.core.spi.PropertyContainer;
import ch.qos.logback.core.status.StatusManager;

/**
 * A context is the main anchorage point of all logback components.
 *
 * @author Ceki Gulcu
 *
 */
public interface Context extends PropertyContainer {

  /**
   * Return the StatusManager instance in use.
   *
   * @return the {@link StatusManager} instance in use.
   */
  StatusManager getStatusManager();

  /**
   * A Context can act as a store for various objects used by logback
   * components.
   *
   * @param key the key of the object
   * @return The object stored under 'key'.
   */
  Object getObject(String key);

  /**
   * Store an object under 'key'. If no object can be found, null is returned.
   *
   * @param key the key of the object
   * @param value the value to associate with the key
   */
  void putObject(String key, Object value);

  /**
   * Get the property of this context.
   * @param key the key of the property
   * @return the associated string value
   */
  String getProperty(String key);

  /**
   * Set a property of this context.
   * @param key the property's key
   * @param value the value associated with the key
   */
  void putProperty(String key, String value);


  /**
   * Get a copy of the property map
   * @return the property map copy
   * @since 0.9.20
   */
  Map getCopyOfPropertyMap();

  /**
   * Contexts are named objects.
   *
   * @return the name for this context
   */
  String getName();

  /**
   * The name of the context. This can be set only once.
   *
   * @param name the desired context name
   */
  void setName(String name);

  /**
   * The time at which this context was created, expressed in
   * millisecond elapsed since the epoch (1.1.1970).
   *
   * @return The time as measured when this class was created.
   */
  long getBirthTime();

  /**
   * Object used for synchronization purposes.
   * INTENDED FOR INTERNAL USAGE.
   * @return the configuration lock
   */
  Object getConfigurationLock();


  /**
   * Every context has an ExecutorService which be invoked to execute certain
   * tasks in a separate thread.
   *
   * @return the executor for this context.
   * @since 1.0.0
   */
  ExecutorService getExecutorService();

  /**
   * Register a component that participates in the context's life cycle.
   * 

* All components registered via this method will be stopped and removed * from the context when the context is reset. * * @param component the subject component */ void register(LifeCycle component); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy