java.lang.Object
ch.qos.logback.core.spi.AbstractComponentTracker<C>
- Type Parameters:
C- component type
- All Implemented Interfaces:
ComponentTracker<C>
- Direct Known Subclasses:
AppenderTracker,CyclicBufferTracker
An abstract implementation of the ComponentTracker interface. Derived classes
must implement
buildComponent(String),
processPriorToRemoval(Object), and isComponentStale(Object)
methods as appropriate for their component type.- Author:
- Tommy Becker, Ceki Gulcu, David Roussel
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longprotected intprotected longstatic final longThe minimum amount of time that has to elapse between successive removal iterations.Fields inherited from interface ch.qos.logback.core.spi.ComponentTracker
DEFAULT_MAX_COMPONENTS, DEFAULT_TIMEOUT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the collection of all components tracked by this instance.allKeys()Set of all keys in this tracker in no particular order.protected abstract CbuildComponent(String key) Build a component based on the key.voidMark component identified by 'key' as having reached its end-of-life.Find the component identified by 'key', without updating the timestamp.intReturns the number of components tracked.intgetOrCreate(String key, long timestamp) Get the component identified by 'key', updating its timestamp in the process.longprotected abstract booleanComponents can declare themselves stale.protected abstract voidprocessPriorToRemoval(C component) Stop or clean the component.voidremoveStaleComponents(long now) Clear (and detach) components which are stale.voidsetMaxComponents(int maxComponents) voidsetTimeout(long timeout)
-
Field Details
-
LINGERING_TIMEOUT
- See Also:
-
WAIT_BETWEEN_SUCCESSIVE_REMOVAL_ITERATIONS
The minimum amount of time that has to elapse between successive removal iterations.- See Also:
-
maxComponents
-
timeout
-
-
Constructor Details
-
AbstractComponentTracker
public AbstractComponentTracker()
-
-
Method Details
-
processPriorToRemoval
Stop or clean the component.- Parameters:
component-
-
buildComponent
Build a component based on the key.- Parameters:
key-- Returns:
-
isComponentStale
Components can declare themselves stale. Such components may be removed before they time out.- Parameters:
c-- Returns:
-
getComponentCount
Description copied from interface:ComponentTrackerReturns the number of components tracked.- Specified by:
getComponentCountin interfaceComponentTracker<C>- Returns:
- number of components
-
find
Find the component identified by 'key', without updating the timestamp. Returns null if no corresponding component could be found.Note that this method is synchronized.
- Specified by:
findin interfaceComponentTracker<C>- Parameters:
key-- Returns:
- corresponding component, may be null
-
getOrCreate
Get the component identified by 'key', updating its timestamp in the process. If the corresponding component could not be found, it is created.Note that this method is atomic, i.e. synchronized.
- Specified by:
getOrCreatein interfaceComponentTracker<C>- Parameters:
key-timestamp-- Returns:
-
endOfLife
Mark component identified by 'key' as having reached its end-of-life.- Specified by:
endOfLifein interfaceComponentTracker<C>- Parameters:
key-
-
removeStaleComponents
Clear (and detach) components which are stale. Components which have not been accessed for more than a user-specified duration are deemed stale.- Specified by:
removeStaleComponentsin interfaceComponentTracker<C>- Parameters:
now-
-
allKeys
Description copied from interface:ComponentTrackerSet of all keys in this tracker in no particular order.- Specified by:
allKeysin interfaceComponentTracker<C>- Returns:
-
allComponents
Description copied from interface:ComponentTrackerReturns the collection of all components tracked by this instance.- Specified by:
allComponentsin interfaceComponentTracker<C>- Returns:
- collection of components
-
getTimeout
-
setTimeout
-
getMaxComponents
-
setMaxComponents
-