Package com.gargoylesoftware.base.trace
Class TraceItemDispatcher
- java.lang.Object
-
- com.gargoylesoftware.base.trace.TraceItemDispatcher
-
- All Implemented Interfaces:
java.lang.Runnable
public class TraceItemDispatcher extends java.lang.Object implements java.lang.Runnable
Internal use only.
.A dispatcher for TraceItems
- Version:
- $Revision: 1.8 $
-
-
Field Summary
Fields Modifier and Type Field Description private static int
BUFFER_DISABLED
private static int
BUFFER_ENABLED
private static int
BUFFER_SHUTTING_DOWN
private static int
bufferStatus_
private int
cacheMaxSize_
private TraceItemQueue
cacheTraceItemQueue_
private static java.text.Format
TIMESTAMP_FORMAT
private TraceItemQueue
traceQueue_
-
Constructor Summary
Constructors Constructor Description TraceItemDispatcher()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
assertNotNull(java.lang.String fieldName, java.lang.Object fieldValue)
Verify that the specified value is not null.private static void
defaultTraceWriter(TraceItem item)
Provide default behaviourvoid
dispatch(TraceItem item)
Add an item to the trace queue.void
disposeTraceItem(TraceItem item)
Dispose of a trace item.private void
dumpTraceElement(TraceItem item)
Format an item and print it to standard out.void
flush()
TraceItem
getNewTraceItem()
Return a trace itemTraceItemQueue
getTraceItemQueue()
Get the queue.boolean
isBufferingEnabled()
Return true if buffering is enabled.void
run()
void
setBufferingEnabled(boolean enabled)
Set whether or not to buffer the output of the trace calls.private void
waitForQueueToEmpty()
-
-
-
Field Detail
-
TIMESTAMP_FORMAT
private static final java.text.Format TIMESTAMP_FORMAT
-
BUFFER_ENABLED
private static final int BUFFER_ENABLED
- See Also:
- Constant Field Values
-
BUFFER_SHUTTING_DOWN
private static final int BUFFER_SHUTTING_DOWN
- See Also:
- Constant Field Values
-
BUFFER_DISABLED
private static final int BUFFER_DISABLED
- See Also:
- Constant Field Values
-
bufferStatus_
private static int bufferStatus_
-
traceQueue_
private final TraceItemQueue traceQueue_
-
cacheTraceItemQueue_
private TraceItemQueue cacheTraceItemQueue_
-
cacheMaxSize_
private int cacheMaxSize_
-
-
Method Detail
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
dumpTraceElement
private void dumpTraceElement(TraceItem item)
Format an item and print it to standard out.- Parameters:
item
- the item to print.
-
defaultTraceWriter
private static void defaultTraceWriter(TraceItem item)
Provide default behaviour- Parameters:
item
- The item to print
-
getTraceItemQueue
public TraceItemQueue getTraceItemQueue()
Get the queue.- Returns:
- The queue.
-
dispatch
public void dispatch(TraceItem item)
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
public TraceItem getNewTraceItem()
Return a trace item- Returns:
- The new trace item.
-
disposeTraceItem
public void disposeTraceItem(TraceItem item)
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(java.lang.String fieldName, java.lang.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
-
-