Package ch.qos.logback.core

# Class ContextBase

java.lang.Object
ch.qos.logback.core.ContextBase

All Implemented Interfaces:
  `Context`, `LifeCycle`, `PropertyContainer`

Direct Known Subclasses:
  `AccessContext`, `LoggerContext`, `RequestLogImpl`

public class ContextBase extends Object implements Context, LifeCycle

## Field Summary

Fields
Modifier and Type
Field
Description
`protected List<ScheduledFuture<?>>`
`scheduledFutures`

## Constructor Summary

Constructors
Constructor
Description
`ContextBase()`

## Method Summary

Modifier and Type
Method
Description
`void`
`addScheduledFuture(ScheduledFuture<?> scheduledFuture)`
`long`
`getBirthTime()`
The time at which this context was created, expressed in millisecond elapsed since the epoch (1.1.1970).
`Object`
`getConfigurationLock()`
Object used for synchronization purposes.
`Map<String,String>`
`getCopyOfPropertyMap()`
Get a copy of the property map
`ExecutorService`
`getExecutorService()`
Every context has an ExecutorService which be invoked to execute certain tasks in a separate thread.
`String`
`getName()`
Contexts are named objects.
`Object`
`getObject(String key)`
A Context can act as a store for various objects used by LOGBack components.
`String`
`getProperty(String key)`
Given a key, return the corresponding property value.
`ScheduledExecutorService`
`getScheduledExecutorService()`
Returns the ScheduledExecutorService for this context.
`List<ScheduledFuture<?>>`
`getScheduledFutures()`
`StatusManager`
`getStatusManager()`
Return the StatusManager instance in use.
`protected void`
`initCollisionMaps()`
`boolean`
`isStarted()`
`void`
`putObject(String key, Object value)`
Store an object under 'key'.
`void`
`putProperty(String key, String val)`
Set a property of this context.
`void`
`register(LifeCycle component)`
Register a component that participates in the context's life cycle.
`void`
`removeObject(String key)`
`void`
`reset()`
Clear the internal objectMap and all properties.
`void`
`setName(String name)`
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.
`void`
`setStatusManager(StatusManager statusManager)`
Set the `StatusManager` for this context.
`void`
`start()`
`void`
`stop()`
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### scheduledFutures

protected List<ScheduledFuture<?>> scheduledFutures

## Constructor Details

### ContextBase

public ContextBase()

## Method Details

### getStatusManager

public StatusManager getStatusManager()
Description copied from interface: `Context`
Return the StatusManager instance in use.

Specified by:
  `getStatusManager` in interface `Context`
Returns:
  the `StatusManager` instance in use.

### setStatusManager

public void setStatusManager(StatusManager statusManager)
Set the `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.

Parameters:
  `statusManager` - the new status manager

### getCopyOfPropertyMap

public Map<String,String> getCopyOfPropertyMap()
Description copied from interface: `Context`
Get a copy of the property map

Specified by:
  `getCopyOfPropertyMap` in interface `Context`
Specified by:
  `getCopyOfPropertyMap` in interface `PropertyContainer`

### putProperty

public void putProperty(String key, String val)
Description copied from interface: `Context`
Set a property of this context.

Specified by:
  `putProperty` in interface `Context`

### initCollisionMaps

protected void initCollisionMaps()

### getProperty

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

Specified by:
  `getProperty` in interface `Context`
Specified by:
  `getProperty` in interface `PropertyContainer`
Parameters:
  `key` -
Returns:

### getObject

public Object getObject(String key)
Description copied from interface: `Context`
A Context can act as a store for various objects used by LOGBack components.

Specified by:
  `getObject` in interface `Context`
Returns:
  The object stored under 'key'.

### putObject

public void putObject(String key, Object value)
Description copied from interface: `Context`
Store an object under 'key'. If no object can be found, null is returned.

Specified by:
  `putObject` in interface `Context`

### removeObject

public void removeObject(String key)

### getName

public String getName()
Description copied from interface: `Context`
Contexts are named objects.

Specified by:
  `getName` in interface `Context`
Returns:
  the name for this context

### start

public void start()

Specified by:
  `start` in interface `LifeCycle`

### stop

public void stop()

Specified by:
  `stop` in interface `LifeCycle`

### isStarted

public boolean isStarted()

Specified by:
  `isStarted` in interface `LifeCycle`

### reset

public void reset()
Clear the internal objectMap and all properties. Removes registered shutdown hook

### setName

public void setName(String name) throws IllegalStateException
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.

Specified by:
  `setName` in interface `Context`
Throws:
  `IllegalStateException` - if the context already has a name, other than "default".

### getBirthTime

public long getBirthTime()
Description copied from interface: `Context`
The time at which this context was created, expressed in millisecond elapsed since the epoch (1.1.1970).

Specified by:
  `getBirthTime` in interface `Context`
Returns:
  The time as measured when this class was created.

### getConfigurationLock

public Object getConfigurationLock()
Description copied from interface: `Context`
Object used for synchronization purposes. INTENDED FOR INTERNAL USAGE.

Specified by:
  `getConfigurationLock` in interface `Context`

### getExecutorService

public ExecutorService getExecutorService()
Description copied from interface: `Context`
Every context has an ExecutorService which be invoked to execute certain tasks in a separate thread.

Specified by:
  `getExecutorService` in interface `Context`
Returns:
  the executor for this context.

### getScheduledExecutorService

public ScheduledExecutorService getScheduledExecutorService()
Description copied from interface: `Context`
Returns the ScheduledExecutorService for this context.

Specified by:
  `getScheduledExecutorService` in interface `Context`
Returns:

### register

public void register(LifeCycle component)
Description copied from interface: `Context`
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.

Specified by:
  `register` in interface `Context`
Parameters:
  `component` - the subject component

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### addScheduledFuture

public void addScheduledFuture(ScheduledFuture<?> scheduledFuture)

Specified by:
  `addScheduledFuture` in interface `Context`

### getScheduledFutures

public List<ScheduledFuture<?>> getScheduledFutures()