Top Fields Constructors Methods
ch.qos.logback.core

public Class ContextBase

extends Object
implements Context, LifeCycle
Class Inheritance
All Implemented Interfaces
ch.qos.logback.core.spi.LifeCycle, ch.qos.logback.core.Context, ch.qos.logback.core.spi.PropertyContainer
Static Imports
ch.qos.logback.core.CoreConstants.CONTEXT_NAME_KEY, .CoreConstants.FA_FILENAME_COLLISION_MAP, .CoreConstants.HOSTNAME_KEY, .CoreConstants.RFA_FILENAME_PATTERN_COLLISION_MAP

Field Summary

Modifier and TypeField and Description
private ExecutorService
private long
private final List<ConfigurationEventListener>
pack-priv LogbackLock
private LifeCycleManager
private String
pack-priv Map<String, Object>
pack-priv Map<String, String>
private ScheduledExecutorService
protected List<ScheduledFuture<?>>
private SequenceNumberGenerator
private StatusManager
private boolean
private ThreadPoolExecutor

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
addScheduledFuture(ScheduledFuture<?> scheduledFuture)

Implements ch.qos.logback.core.Context.addScheduledFuture.

Add scheduledFuture parameter to the list of known futures.
public void
public void
public synchronized ExecutorService
getAlternateExecutorService()

Overrides default ch.qos.logback.core.Context.getAlternateExecutorService.

Return an alternate ExecutorService used for one task per thread execution.
public long
getBirthTime()

Implements ch.qos.logback.core.Context.getBirthTime.

The time at which this context was created, expressed in millisecond elapsed since the epoch (1.1.1970).
public Object
getConfigurationLock()

Implements ch.qos.logback.core.Context.getConfigurationLock.

Object used for synchronization purposes.
public Map<String, String>
getCopyOfPropertyMap()

Implements ch.qos.logback.core.Context.getCopyOfPropertyMap.

Get a copy of the property map
public List<ScheduledFuture<?>>
public synchronized ExecutorService
getExecutorService()

Implements ch.qos.logback.core.Context.getExecutorService.

Every context has an ExecutorService which be invoked to execute certain tasks in a separate thread.
pack-priv synchronized LifeCycleManager

Returns:

manager object
getLifeCycleManager
()

Gets the life cycle manager for this context.

public String
getName()

Implements ch.qos.logback.core.Context.getName.

Contexts are named objects.
public Object
getObject(String key)

Implements ch.qos.logback.core.Context.getObject.

A Context can act as a store for various objects used by LOGBack components.
public String
getProperty(String key)

Implements ch.qos.logback.core.Context.getProperty.

Given a key, return the corresponding property value.
public synchronized ScheduledExecutorService
getScheduledExecutorService()

Implements ch.qos.logback.core.Context.getScheduledExecutorService.

Returns the ScheduledExecutorService for this context.
public List<ScheduledFuture<?>>
getScheduledFutures()

Deprecated replaced by getCopyOfScheduledFutures
public SequenceNumberGenerator
public StatusManager
getStatusManager()

Implements ch.qos.logback.core.Context.getStatusManager.

Return the StatusManager instance in use.
protected void
public boolean
private String
private void
public void
putObject(String key, Object value)

Implements ch.qos.logback.core.Context.putObject.

Store an object under 'key'.
public void
putProperty(String key, String val)

Implements ch.qos.logback.core.Context.putProperty.

Set a property of this context.
public void
register(LifeCycle
the subject component
component
)

Implements ch.qos.logback.core.Context.register.

Register a component that participates in the context's life cycle.
public void
private void
public void
reset()

Clear the internal objectMap and all properties.

public void
setName(String name)

Implements ch.qos.logback.core.Context.setName.

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.
public void
public void
setStatusManager(StatusManager
the new status manager
statusManager
)

Set the StatusManager for this context.

public void
public void
private synchronized void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

alternateExecutorServiceback to summary
private ExecutorService alternateExecutorService
birthTimeback to summary
private long birthTime
configurationEventListenerListback to summary
private final List<ConfigurationEventListener> configurationEventListenerList
configurationLockback to summary
pack-priv LogbackLock configurationLock
lifeCycleManagerback to summary
private LifeCycleManager lifeCycleManager
nameback to summary
private String name
objectMapback to summary
pack-priv Map<String, Object> objectMap
propertyMapback to summary
pack-priv Map<String, String> propertyMap
scheduledExecutorServiceback to summary
private ScheduledExecutorService scheduledExecutorService
scheduledFuturesback to summary
protected List<ScheduledFuture<?>> scheduledFutures
sequenceNumberGeneratorback to summary
private SequenceNumberGenerator sequenceNumberGenerator
smback to summary
private StatusManager sm
startedback to summary
private boolean started
threadPoolExecutorback to summary
private ThreadPoolExecutor threadPoolExecutor

Constructor Detail

ContextBaseback to summary
public ContextBase()

Method Detail

addConfigurationEventListenerback to summary
public void addConfigurationEventListener(ConfigurationEventListener listener)

Implements ch.qos.logback.core.Context.addConfigurationEventListener.

Doc from ch.qos.logback.core.Context.addConfigurationEventListener.

Add a ConfigurationEventListener to this context.

Configuration events are supposed to be rare and listeners to such events rarer still.

The propagation of configuration events is intended for internal testing as well as some coordination between configurators.

Annotations
@Override
addScheduledFutureback to summary
public void addScheduledFuture(ScheduledFuture<?> scheduledFuture)

Implements ch.qos.logback.core.Context.addScheduledFuture.

Doc from ch.qos.logback.core.Context.addScheduledFuture.

Add scheduledFuture parameter to the list of known futures.

Annotations
@Override
addSubstitutionPropertyback to summary
public void addSubstitutionProperty(String key, String value)

Implements ch.qos.logback.core.spi.PropertyContainer.addSubstitutionProperty.

Annotations
@Override
fireConfigurationEventback to summary
public void fireConfigurationEvent(ConfigurationEvent configurationEvent)

Implements ch.qos.logback.core.Context.fireConfigurationEvent.

Doc from ch.qos.logback.core.Context.fireConfigurationEvent.

Fire ConfigurationEvent by invoking registered listeners.

Note that it is the role of configurators to invoke this method as a context does not necessarily know when it is being configured.

Annotations
@Override
getAlternateExecutorServiceback to summary
public synchronized ExecutorService getAlternateExecutorService()

Overrides default ch.qos.logback.core.Context.getAlternateExecutorService.

Doc from ch.qos.logback.core.Context.getAlternateExecutorService.

Return an alternate ExecutorService used for one task per thread execution.

Returns:ExecutorService

ExecutorService

Annotations
@Override
getBirthTimeback to summary
public long getBirthTime()

Implements ch.qos.logback.core.Context.getBirthTime.

Doc from ch.qos.logback.core.Context.getBirthTime.

The time at which this context was created, expressed in millisecond elapsed since the epoch (1.1.1970).

Returns:long

The time as measured when this class was created.

getConfigurationLockback to summary
public Object getConfigurationLock()

Implements ch.qos.logback.core.Context.getConfigurationLock.

Doc from ch.qos.logback.core.Context.getConfigurationLock.

Object used for synchronization purposes. INTENDED FOR INTERNAL USAGE.

getCopyOfPropertyMapback to summary
public Map<String, String> getCopyOfPropertyMap()

Implements ch.qos.logback.core.Context.getCopyOfPropertyMap.

Doc from ch.qos.logback.core.Context.getCopyOfPropertyMap.

Get a copy of the property map

getCopyOfScheduledFuturesback to summary
public List<ScheduledFuture<?>> getCopyOfScheduledFutures()
getExecutorServiceback to summary
public synchronized ExecutorService getExecutorService()

Implements ch.qos.logback.core.Context.getExecutorService.

Doc from ch.qos.logback.core.Context.getExecutorService.

Every context has an ExecutorService which be invoked to execute certain tasks in a separate thread.

Returns:ExecutorService

the executor for this context.

Annotations
@Override
getLifeCycleManagerback to summary
pack-priv synchronized LifeCycleManager getLifeCycleManager()

Gets the life cycle manager for this context.

The default implementation lazily initializes an instance of LifeCycleManager. Subclasses may override to provide a custom manager implementation, but must take care to return the same manager object for each call to this method.

This is exposed primarily to support instrumentation for unit testing.

Returns:LifeCycleManager

manager object

getNameback to summary
public String getName()

Implements ch.qos.logback.core.Context.getName.

Doc from ch.qos.logback.core.Context.getName.

Contexts are named objects.

Returns:String

the name for this context

getObjectback to summary
public Object getObject(String key)

Implements ch.qos.logback.core.Context.getObject.

Doc from ch.qos.logback.core.Context.getObject.

A Context can act as a store for various objects used by LOGBack components.

Returns:Object

The object stored under 'key'.

getPropertyback to summary
public String getProperty(String key)

Implements ch.qos.logback.core.Context.getProperty.

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

getScheduledExecutorServiceback to summary
public synchronized ScheduledExecutorService getScheduledExecutorService()

Implements ch.qos.logback.core.Context.getScheduledExecutorService.

Doc from ch.qos.logback.core.Context.getScheduledExecutorService.

Returns the ScheduledExecutorService for this context.

Returns:ScheduledExecutorService

ScheduledExecutorService

Annotations
@Override
getScheduledFuturesback to summary
public List<ScheduledFuture<?>> getScheduledFutures()

Deprecated

replaced by getCopyOfScheduledFutures

Annotations
@Deprecated
getSequenceNumberGeneratorback to summary
public SequenceNumberGenerator getSequenceNumberGenerator()

Implements ch.qos.logback.core.Context.getSequenceNumberGenerator.

getStatusManagerback to summary
public StatusManager getStatusManager()

Implements ch.qos.logback.core.Context.getStatusManager.

Doc from ch.qos.logback.core.Context.getStatusManager.

Return the StatusManager instance in use.

Returns:StatusManager

the StatusManager instance in use.

initCollisionMapsback to summary
protected void initCollisionMaps()
isStartedback to summary
public boolean isStarted()

Implements ch.qos.logback.core.spi.LifeCycle.isStarted.

lazyGetHostnameback to summary
private String lazyGetHostname()
putHostnamePropertyback to summary
private void putHostnameProperty(String hostname)
putObjectback to summary
public void putObject(String key, Object value)

Implements ch.qos.logback.core.Context.putObject.

Doc from ch.qos.logback.core.Context.putObject.

Store an object under 'key'. If no object can be found, null is returned.

putPropertyback to summary
public void putProperty(String key, String val)

Implements ch.qos.logback.core.Context.putProperty.

Doc from ch.qos.logback.core.Context.putProperty.

Set a property of this context.

registerback to summary
public void register(LifeCycle component)

Implements ch.qos.logback.core.Context.register.

Doc from ch.qos.logback.core.Context.register.

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.

Parameters
component:LifeCycle

the subject component

removeObjectback to summary
public void removeObject(String key)
removeShutdownHookback to summary
private void removeShutdownHook()
resetback to summary
public void reset()

Clear the internal objectMap and all properties. Removes any registered shutdown hook.

setNameback to summary
public void setName(String name) throws IllegalStateException

Implements ch.qos.logback.core.Context.setName.

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.

Exceptions
IllegalStateException:
if the context already has a name, other than "default".
setSequenceNumberGeneratorback to summary
public void setSequenceNumberGenerator(SequenceNumberGenerator sequenceNumberGenerator)

Implements ch.qos.logback.core.Context.setSequenceNumberGenerator.

setStatusManagerback to summary
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:StatusManager

the new status manager

startback to summary
public void start()

Implements ch.qos.logback.core.spi.LifeCycle.start.

Annotations
@Override
stopback to summary
public void stop()

Implements ch.qos.logback.core.spi.LifeCycle.stop.

stopExecutorServicesback to summary
private synchronized void stopExecutorServices()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override