Package com.gargoylesoftware.base.trace
Class TraceItemDispatcher
java.lang.Object
com.gargoylesoftware.base.trace.TraceItemDispatcher
- All Implemented Interfaces:
Runnable
Internal use only.
.A dispatcher for TraceItems
- Version:
- $Revision: 1.8 $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate static final intprivate static intprivate intprivate TraceItemQueueprivate static final Formatprivate final TraceItemQueue -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidassertNotNull(String fieldName, Object fieldValue) Verify that the specified value is not null.private static voiddefaultTraceWriter(TraceItem item) Provide default behaviourvoidAdd an item to the trace queue.voiddisposeTraceItem(TraceItem item) Dispose of a trace item.private voiddumpTraceElement(TraceItem item) Format an item and print it to standard out.voidflush()Return a trace itemGet the queue.booleanReturn true if buffering is enabled.voidrun()voidsetBufferingEnabled(boolean enabled) Set whether or not to buffer the output of the trace calls.private void
-
Field Details
-
TIMESTAMP_FORMAT
-
BUFFER_ENABLED
private static final int BUFFER_ENABLED- See Also:
-
BUFFER_SHUTTING_DOWN
private static final int BUFFER_SHUTTING_DOWN- See Also:
-
BUFFER_DISABLED
private static final int BUFFER_DISABLED- See Also:
-
bufferStatus_
private static int bufferStatus_ -
traceQueue_
-
cacheTraceItemQueue_
-
cacheMaxSize_
private int cacheMaxSize_
-
-
Constructor Details
-
TraceItemDispatcher
public TraceItemDispatcher()
-
-
Method Details
-
run
public void run() -
dumpTraceElement
Format an item and print it to standard out.- Parameters:
item- the item to print.
-
defaultTraceWriter
Provide default behaviour- Parameters:
item- The item to print
-
getTraceItemQueue
Get the queue.- Returns:
- The queue.
-
dispatch
Add an item to the trace queue.- Parameters:
item- The item to add.
-
waitForQueueToEmpty
private void waitForQueueToEmpty() -
setBufferingEnabled
public void setBufferingEnabled(boolean enabled) Set whether or not to buffer the output of the trace calls. Buffering will increase perceived performance significantly.- Parameters:
enabled- True if buffering should be enabled
-
isBufferingEnabled
public boolean isBufferingEnabled()Return true if buffering is enabled.- Returns:
- true if buffering is enabled.
-
flush
public void flush() -
getNewTraceItem
Return a trace item- Returns:
- The new trace item.
-
disposeTraceItem
Dispose of a trace item. Disposing will put the trace item back on a queue for reuse.- Parameters:
item- The item to dispose.
-
assertNotNull
protected final void assertNotNull(String fieldName, Object fieldValue) throws DetailedNullPointerException Verify that the specified value is not null. If it is then throw an exception- Parameters:
fieldName- The name of the field to checkfieldValue- The value of the field to check- Throws:
DetailedNullPointerException- If fieldValue is null
-