public class ObjectRecorder
extends java.lang.Thread
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 succeed: 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.
| Modifier and Type | Class | Description |
|---|---|---|
class |
ObjectRecorder.ObjectInspection |
Data container for the inspection of the internal intance.
|
| Modifier and Type | Field | Description |
|---|---|---|
protected IRingBuffer<ObjectRecorder.ObjectInspection> |
m_buffer |
Fast buffer to store recorded fiels.
|
protected javax.swing.event.EventListenerList |
m_changeListeners |
The listeners on this recorder.
|
protected java.lang.reflect.Field[] |
m_fields |
The fields to inspect on the instance.
|
protected long |
m_interval |
The time - interval between to inspections of the Object.
|
protected java.lang.Object |
m_toinspect |
The instance to inspect.
|
protected static boolean |
VERBOSE |
Verbosity constant.
|
| Constructor | Description |
|---|---|
ObjectRecorder(java.lang.Object toinspect,
long interval) |
Creates an instance that will inspect the given Object in the given time
interval.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addChangeListener(javax.swing.event.ChangeListener x) |
Adds a change listener that will be informed about new recordings of the
inspected instances.
|
boolean |
equals(java.lang.Object obj) |
|
protected void |
fireChange() |
Informs the listeners about a change of this instance.
|
TimeStampedValue[] |
getAttributeHistory(java.lang.String attributeName) |
The History returned by this Method represents the past of the field
specified by attributeName.
|
java.lang.String[] |
getAttributeNames() |
Returns the names of the fields to inspect.
|
java.lang.Object |
getInspected() |
Returns the inspected instance.
|
TimeStampedValue |
getLastValue(java.lang.String fieldname) |
Returns the last recorded value taken from the given field along with the
time stamp identifying the time this value was recored.
|
IRingBuffer<ObjectRecorder.ObjectInspection> |
getRingBuffer() |
Returns the internal fifo buffer that stores the
ObjectRecorder.ObjectInspection instances that have been done. |
int |
hashCode() |
|
void |
inspect() |
Makes a record of the state of the object specified in the constructor.
|
void |
removeChangeListener(javax.swing.event.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.
|
java.lang.String |
toString() |
finalize, getClass, notify, notifyAll, wait, wait, waitactiveCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yieldprotected static final boolean VERBOSE
protected IRingBuffer<ObjectRecorder.ObjectInspection> m_buffer
protected javax.swing.event.EventListenerList m_changeListeners
protected java.lang.reflect.Field[] m_fields
protected long m_interval
protected java.lang.Object m_toinspect
public ObjectRecorder(java.lang.Object toinspect,
long interval)
toinspect - the instance to inspect.interval - the interval of inspection in ms.public void addChangeListener(javax.swing.event.ChangeListener x)
x - the change listener that will be informed about new recordings of
the inspected instances.public boolean equals(java.lang.Object obj)
equals in class java.lang.ObjectObject.equals(java.lang.Object)protected void fireChange()
public TimeStampedValue[] getAttributeHistory(java.lang.String attributeName) throws javax.naming.directory.NoSuchAttributeException
attributeName - field name of the internal instance to inspect.javax.naming.directory.NoSuchAttributeException - if the attribute / field described by the given argument does not
exist on the internal Object to instpect.getInspected()public java.lang.String[] getAttributeNames()
public java.lang.Object getInspected()
public TimeStampedValue getLastValue(java.lang.String fieldname) throws javax.naming.directory.NoSuchAttributeException
fieldname - the field whose value was recorded.javax.naming.directory.NoSuchAttributeException - if no such field exists on the Object to inspect.public IRingBuffer<ObjectRecorder.ObjectInspection> getRingBuffer()
ObjectRecorder.ObjectInspection instances that have been done.
ObjectRecorder.ObjectInspection instances that have been
done.public int hashCode()
hashCode in class java.lang.ObjectObject.hashCode()public void inspect()
public void removeChangeListener(javax.swing.event.ChangeListener x)
x - the listener to remove.public void run()
run in class java.lang.ThreadRunnable.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 java.lang.String toString()
toString in class java.lang.ThreadObject.toString()Copyright © 2001 - 2010 LGPL, All Rights Footloose.