C - component type
public abstract class AbstractComponentTracker<C> extends Objectimplements ComponentTracker <C>
buildComponent(String),
processPriorToRemoval(Object), and
isComponentStale(Object) methods as appropriate for their component type.
| Modifier and Type | Field and Description |
|---|---|
static long |
LINGERING_TIMEOUT
|
protected int |
maxComponents
|
protected long |
timeout
|
static long |
WAIT_BETWEEN_SUCCESSIVE_REMOVAL_ITERATIONS
The minimum amount of time that has to elapse between successive removal iterations.
|
DEFAULT_MAX_COMPONENTS, DEFAULT_TIMEOUT| Constructor and Description |
|---|
AbstractComponentTracker()
|
| Modifier and Type | Method and Description |
|---|---|
Collection |
allComponents()
Returns the collection of all components tracked by this instance.
|
Set |
allKeys()
Set of all keys in this tracker in no particular order.
|
protected abstract C |
buildComponent(String
Build a component based on the key.
|
void |
endOfLife(String
Mark component identified by 'key' as having reached its end-of-life.
|
C |
find(String
Find the component identified by 'key', without updating the timestamp.
|
int |
getComponentCount()
Returns the number of components tracked.
|
int |
getMaxComponents()
|
C |
getOrCreate(String
Get the component identified by 'key', updating its timestamp in the process.
|
long |
getTimeout()
|
protected abstract boolean |
isComponentStale(C c)
Components can declare themselves stale.
|
protected abstract void |
processPriorToRemoval(C component)
Stop or clean the component.
|
void |
removeStaleComponents(long now)
Clear (and detach) components which are stale.
|
void |
setMaxComponents(int maxComponents)
|
void |
setTimeout(long timeout)
|
public static final long LINGERING_TIMEOUT
public static final long WAIT_BETWEEN_SUCCESSIVE_REMOVAL_ITERATIONS
protected int maxComponents
protected long timeout
protected abstract void processPriorToRemoval(C component)
component -
protected abstract C buildComponent(Stringkey)
key -
protected abstract boolean isComponentStale(C c)
c -
public int getComponentCount()
ComponentTracker
getComponentCount in interface
ComponentTracker<C>
public C find(Stringkey)
Note that this method is synchronized.
find in interface
ComponentTracker<C>
key -
public C getOrCreate(Stringkey, long timestamp)
Note that this method is atomic, i.e. synchronized.
getOrCreate in interface
ComponentTracker<C>
key -
timestamp -
public void endOfLife(Stringkey)
endOfLife in interface
ComponentTracker<C>
key -
public void removeStaleComponents(long now)
removeStaleComponents in interface
ComponentTracker<C>
now -
public Set<String > allKeys()
ComponentTracker
allKeys in interface
ComponentTracker<C>
public Collection<C> allComponents()
ComponentTracker
allComponents in interface
ComponentTracker<C>
public long getTimeout()
public void setTimeout(long timeout)
public int getMaxComponents()
public void setMaxComponents(int maxComponents)