|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
info.monitorenter.reflection.ObjectRecorder
public class ObjectRecorder
The ObjectRecorder
takes records(inspections) of an objects
state using reflection and accessibility- framework.
It's strategy is to:
- try to set any field accessible. - try to get the value of the field. - if not suceed: try to invoke a bean- conform getter. - if NoSuchMethod, it's useless (no implementation of MagicClazz here).
Furthermore the ObjectRecorder
has a history - size (buffer)
and an adjustable distance between each inspection.
Nested Class Summary | |
---|---|
class |
ObjectRecorder.ObjectInspection
Data container for the inspection of the internal intance. |
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
protected IRingBuffer |
m_buffer
Fast buffer to store recorded fiels. |
protected EventListenerList |
m_changeListeners
The listeners on this recorder. |
protected Field[] |
m_fields
The fields to inspect on the instance. |
protected long |
m_interval
The time - interval between to inspections of the Object. |
protected Object |
m_toinspect
The instance to instpec. |
protected static boolean |
VERBOSE
Verbosity constant. |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
ObjectRecorder(Object toinspect,
long interval)
Creates an instance that will inspect the given Object in the given time interval. |
Method Summary | |
---|---|
void |
addChangeListener(ChangeListener x)
Adds a change listener that will be informed about new recordings of the inpected instances. |
protected void |
fireChange()
Informs the listeners about a change of this instance. |
TimeStampedValue[] |
getAttributeHistory(String attributeName)
The History returned by this Method represents the past of the field specified by attributeName. |
String[] |
getAttributeNames()
Returns the names of the fields to inspect. |
Object |
getInspected()
Returns the inspected instance. |
TimeStampedValue |
getLastValue(String fieldname)
Returns the last recoreded value taken from the given field along with the timestamp identifying the time this value was recored. |
IRingBuffer |
getRingBuffer()
Returns the internal fifo buffer that stores the ObjectRecorder.ObjectInspection instances that have been done. |
void |
inspect()
Makes a record of the state of the object specified in the constructor. |
void |
removeChangeListener(ChangeListener x)
Removes the given listener for changes of the inpsected instance. |
void |
run()
|
void |
setHistoryLength(int length)
Define the amount of recorded states of the Object to inspect that remain in memory. |
void |
setInterval(long sleeptime)
Sets the interval for inpection of the instance to inspect in ms. |
String |
toString()
|
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final boolean VERBOSE
protected IRingBuffer m_buffer
protected EventListenerList m_changeListeners
protected Field[] m_fields
protected long m_interval
protected Object m_toinspect
Constructor Detail |
---|
public ObjectRecorder(Object toinspect, long interval)
toinspect
- the instance to inspect.interval
- the interval of inspection in ms.Method Detail |
---|
public void addChangeListener(ChangeListener x)
x
- the change listener that will be informed about new recordings of
the inpected instances.protected void fireChange()
public TimeStampedValue[] getAttributeHistory(String attributeName) throws NoSuchAttributeException
attributeName
- field name of the internal instance to inspect.
NoSuchAttributeException
- if the attribute / field described by the given argument does not
exist on the internal Object to instpect.getInspected()
public String[] getAttributeNames()
public Object getInspected()
public TimeStampedValue getLastValue(String fieldname) throws NoSuchAttributeException
fieldname
- the field whose value was recorded.
NoSuchAttributeException
- if no such field exists on the Object to inspect.public IRingBuffer getRingBuffer()
ObjectRecorder.ObjectInspection
instances that have been done.
ObjectRecorder.ObjectInspection
instances that have been
done.public void inspect()
public void removeChangeListener(ChangeListener x)
x
- the listener to remove.public void run()
run
in interface Runnable
run
in class Thread
Runnable.run()
public void setHistoryLength(int length)
Default value is 100.
length
- the amount of recorded states of the Object to inspect that remain
in memory.public void setInterval(long sleeptime)
sleeptime
- the interval for inpection of the instance to inspect in ms.ObjectRecorder(Object, long)
public String toString()
toString
in class Thread
Object.toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |