Top Description Fields Methods
ch.qos.logback.core.spi

public Interface ComponentTracker<C>

Known Direct Implementers
ch.qos.logback.core.spi.AbstractComponentTracker
Imports
ch.qos.logback.core.CoreConstants, java.util.Collection, .Set

Interface for tracking various components by key. Components which have not been accessed for more than a user-specified duration are deemed stale and removed. Components can also be explicitly marked as having reached their endOfLife(String) in which case they will linger for a few seconds and then be removed.
Authors
Tommy Becker, Ceki Gulcu, David Roussel
Since
1.0.12

Field Summary

Modifier and TypeField and Description
public static final int
DEFAULT_MAX_COMPONENTS

By default an unlimited number of elements can be tracked.

public static final int
DEFAULT_TIMEOUT

The default timeout duration is 30 minutes

Method Summary

Modifier and TypeMethod and Description
public Collection<C>

Returns:

collection of components
allComponents
()

Returns the collection of all components tracked by this instance.

public Set<String>
allKeys()

Set of all keys in this tracker in no particular order.

public void
endOfLife(String key)

Mark component identified by 'key' as having reached its end-of-life.

public C

Returns:

corresponding component, may be null
find
(String key)

Find the component identified by 'key', without updating the timestamp.

public int

Returns:

number of components
getComponentCount
()

Returns the number of components tracked.

public C
getOrCreate(String key, long timestamp)

Get the component identified by 'key', updating its timestamp in the process.

public void
removeStaleComponents(long
current time in milliseconds
now
)

Remove components which are deemed stale.

Field Detail

DEFAULT_MAX_COMPONENTSback to summary
public static final int DEFAULT_MAX_COMPONENTS

By default an unlimited number of elements can be tracked.

DEFAULT_TIMEOUTback to summary
public static final int DEFAULT_TIMEOUT

The default timeout duration is 30 minutes

Method Detail

allComponentsback to summary
public Collection<C> allComponents()

Returns the collection of all components tracked by this instance.

Returns:Collection<C>

collection of components

allKeysback to summary
public Set<String> allKeys()

Set of all keys in this tracker in no particular order.

endOfLifeback to summary
public void endOfLife(String key)

Mark component identified by 'key' as having reached its end-of-life. End-of-lifed components will linger for a few more seconds before being removed.

findback to summary
public C find(String key)

Find the component identified by 'key', without updating the timestamp. Returns null if no corresponding component could be found.

Returns:C

corresponding component, may be null

getComponentCountback to summary
public int getComponentCount()

Returns the number of components tracked.

Returns:int

number of components

getOrCreateback to summary
public C getOrCreate(String key, long timestamp)

Get the component identified by 'key', updating its timestamp in the process. If the corresponding component could not be found, it is created.

removeStaleComponentsback to summary
public void removeStaleComponents(long now)

Remove components which are deemed stale. Components which have not been accessed for more than a user-specified duration are deemed stale.

If the number of components exceeds, getComponentCount(), components in excess will be removed.

Depending on the component type, components will be cleared or stopped (as appropriate) right before removal.

Parameters
now:long

current time in milliseconds