Class TraceItemDispatcher

java.lang.Object
com.gargoylesoftware.base.trace.TraceItemDispatcher
All Implemented Interfaces:
Runnable

public class TraceItemDispatcher extends Object implements Runnable

Internal use only.

.

A dispatcher for TraceItems

Version:
$Revision: 1.8 $
  • Field Details

    • TIMESTAMP_FORMAT

      private static final Format 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_

      private final TraceItemQueue traceQueue_
    • cacheTraceItemQueue_

      private TraceItemQueue cacheTraceItemQueue_
    • cacheMaxSize_

      private int cacheMaxSize_
  • Constructor Details

    • TraceItemDispatcher

      public TraceItemDispatcher()
  • Method Details

    • run

      public void run()
      Specified by:
      run in interface 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(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 check
      fieldValue - The value of the field to check
      Throws:
      DetailedNullPointerException - If fieldValue is null