de.is24.util.monitoring
Class HistorizableList

java.lang.Object
  extended by de.is24.util.monitoring.HistorizableList
All Implemented Interfaces:
Reportable, Iterable<Historizable>

public class HistorizableList
extends Object
implements Reportable, Iterable<Historizable>

This list manages ordering and discarding of registered Historizables with the same name.

Author:
OSchmitz

Field Summary
private  int fMaxEntriesToKeep
           
private  LinkedList<Historizable> historizables
           
private static org.apache.log4j.Logger LOGGER
           
private  String name
           
private static long serialVersionUID
           
 
Constructor Summary
HistorizableList(String name, int aMaxEntriesToKeep)
          This class is only constructed by InApplicationMonitor
 
Method Summary
 void accept(ReportVisitor aVisitor)
          Implements the visitor pattern to read this Counter
 void add(Historizable historizable)
          add a Historizable instance to this list and remove the oldest instance if necessary.
 Historizable get(int index)
          This method is thread-safe in combination with size().
 int getMaxEntriesToKeep()
           
 String getName()
           
 Iterator<Historizable> iterator()
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

name

private String name

fMaxEntriesToKeep

private final int fMaxEntriesToKeep

historizables

private LinkedList<Historizable> historizables

LOGGER

private static final org.apache.log4j.Logger LOGGER
Constructor Detail

HistorizableList

HistorizableList(String name,
                 int aMaxEntriesToKeep)
This class is only constructed by InApplicationMonitor

Parameters:
name - name of this Counter
Method Detail

accept

public void accept(ReportVisitor aVisitor)
Implements the visitor pattern to read this Counter

Specified by:
accept in interface Reportable

getName

public String getName()
Specified by:
getName in interface Reportable
Returns:
name of the managed Historizables

add

public void add(Historizable historizable)
add a Historizable instance to this list and remove the oldest instance if necessary.

Parameters:
historizable - the Historizable to add

iterator

public Iterator<Historizable> iterator()
Specified by:
iterator in interface Iterable<Historizable>
Returns:
an iterator over the Historizable entries. The iterator actually iterates over a clone of the internal list, to prevent concorrent modification problems.

getMaxEntriesToKeep

public int getMaxEntriesToKeep()
Returns:
the maximum number of entries that can be contained in this list.

size

public int size()
Returns:
the actual amount of contained Historizables.

get

public Historizable get(int index)
This method is thread-safe in combination with size(). The size returned is always the least available size.

Parameters:
index - the index of the Historizable to be returned. Can never be greater or equal than getMaxEntriesToKeep().
Returns:
the Historizable at the index position.
Throws:
IndexOutOfBoundsException - if the index argument is greater or equal the size of this list.


Copyright © 2013 Immobilien Scout GmbH. All Rights Reserved.