public class ContextBase extends java.lang.Object implements Context, LifeCycle
| Modifier and Type | Field and Description |
|---|---|
private long |
birthTime |
(package private) LogbackLock |
configurationLock |
private java.util.concurrent.ExecutorService |
executorService |
private LifeCycleManager |
lifeCycleManager |
private java.lang.String |
name |
(package private) java.util.Map<java.lang.String,java.lang.Object> |
objectMap |
(package private) java.util.Map<java.lang.String,java.lang.String> |
propertyMap |
private java.util.concurrent.ScheduledExecutorService |
scheduledExecutorService |
protected java.util.List<java.util.concurrent.ScheduledFuture<?>> |
scheduledFutures |
private StatusManager |
sm |
private boolean |
started |
| Constructor and Description |
|---|
ContextBase() |
| Modifier and Type | Method and Description |
|---|---|
void |
addScheduledFuture(java.util.concurrent.ScheduledFuture<?> scheduledFuture) |
long |
getBirthTime()
The time at which this context was created, expressed in
millisecond elapsed since the epoch (1.1.1970).
|
java.lang.Object |
getConfigurationLock()
Object used for synchronization purposes.
|
java.util.Map<java.lang.String,java.lang.String> |
getCopyOfPropertyMap()
Get a copy of the property map
|
java.util.concurrent.ExecutorService |
getExecutorService()
Every context has an ExecutorService which be invoked to execute certain
tasks in a separate thread.
|
(package private) LifeCycleManager |
getLifeCycleManager()
Gets the life cycle manager for this context.
|
java.lang.String |
getName()
Contexts are named objects.
|
java.lang.Object |
getObject(java.lang.String key)
A Context can act as a store for various objects used by LOGBack
components.
|
java.lang.String |
getProperty(java.lang.String key)
Given a key, return the corresponding property value.
|
java.util.concurrent.ScheduledExecutorService |
getScheduledExecutorService()
Returns the ScheduledExecutorService for this context.
|
java.util.List<java.util.concurrent.ScheduledFuture<?>> |
getScheduledFutures() |
StatusManager |
getStatusManager()
Return the StatusManager instance in use.
|
protected void |
initCollisionMaps() |
boolean |
isStarted() |
void |
putObject(java.lang.String key,
java.lang.Object value)
Store an object under 'key'.
|
void |
putProperty(java.lang.String key,
java.lang.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(java.lang.String key) |
private void |
removeShutdownHook() |
void |
reset()
Clear the internal objectMap and all properties.
|
void |
setName(java.lang.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() |
private void |
stopExecutorServices() |
java.lang.String |
toString() |
private long birthTime
private java.lang.String name
private StatusManager sm
java.util.Map<java.lang.String,java.lang.String> propertyMap
java.util.Map<java.lang.String,java.lang.Object> objectMap
LogbackLock configurationLock
private java.util.concurrent.ExecutorService executorService
private java.util.concurrent.ScheduledExecutorService scheduledExecutorService
protected java.util.List<java.util.concurrent.ScheduledFuture<?>> scheduledFutures
private LifeCycleManager lifeCycleManager
private boolean started
public StatusManager getStatusManager()
ContextgetStatusManager in interface ContextStatusManager instance in use.public void setStatusManager(StatusManager statusManager)
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 managerpublic java.util.Map<java.lang.String,java.lang.String> getCopyOfPropertyMap()
ContextgetCopyOfPropertyMap in interface ContextgetCopyOfPropertyMap in interface PropertyContainerpublic void putProperty(java.lang.String key,
java.lang.String val)
ContextputProperty in interface Contextprotected void initCollisionMaps()
public java.lang.String getProperty(java.lang.String key)
getProperty in interface ContextgetProperty in interface PropertyContainerkey - public java.lang.Object getObject(java.lang.String key)
Contextpublic void putObject(java.lang.String key,
java.lang.Object value)
Contextpublic void removeObject(java.lang.String key)
public java.lang.String getName()
Contextpublic void reset()
public void setName(java.lang.String name)
throws java.lang.IllegalStateException
public long getBirthTime()
ContextgetBirthTime in interface Contextpublic java.lang.Object getConfigurationLock()
ContextgetConfigurationLock in interface Contextpublic java.util.concurrent.ExecutorService getExecutorService()
ContextgetExecutorService in interface Contextpublic java.util.concurrent.ScheduledExecutorService getScheduledExecutorService()
ContextgetScheduledExecutorService in interface Contextprivate void stopExecutorServices()
private void removeShutdownHook()
public void register(LifeCycle component)
ContextAll components registered via this method will be stopped and removed from the context when the context is reset.
LifeCycleManager getLifeCycleManager()
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.
public java.lang.String toString()
toString in class java.lang.Objectpublic void addScheduledFuture(java.util.concurrent.ScheduledFuture<?> scheduledFuture)
addScheduledFuture in interface Contextpublic java.util.List<java.util.concurrent.ScheduledFuture<?>> getScheduledFutures()