Class QueueTracer<T extends AbstractTracer>

java.lang.Object
de.christofreichardt.diagnosis.AbstractTracer
de.christofreichardt.diagnosis.QueueTracer<T>
Type Parameters:
T - the wrapped tracer
Direct Known Subclasses:
OueueNetTracer, QueueFileTracer, QueueNullTracer

public abstract class QueueTracer<T extends AbstractTracer> extends AbstractTracer
A special tracer intended for the use by a bounded blocking queue. This is an option to retrieve tracer within a multi-threaded environment when we cannot control the creation of the threads. An example would be applications within a container that manages a thread pool. This tracer honors the contract of an AbstractTracer but does so by wrapping and delegating to another AbstractTracer. In particular the current tracing context will be automatically cleared when calling wayout() and the method stack remains empty afterwards. Thus the tracer can be reused for another thread's tracing context without any danger to create a memory leak.
Author:
Christof Reichardt
  • Field Details

  • Constructor Details

    • QueueTracer

      public QueueTracer(String name, T tracer)
      Constructor expects the tracer name and the to be wrapped tracer instance.
      Parameters:
      name - the name of the tracer
      tracer - the to be wrapped tracer
  • Method Details

    • getSyncObject

      public Object getSyncObject()
      Delegates to the corresponding method of the wrapped tracer.
      Overrides:
      getSyncObject in class AbstractTracer
      Returns:
      the sync object of the wrapped tracer
    • getBufferSize

      public int getBufferSize()
      Delegates to the corresponding method of the wrapped tracer.
      Overrides:
      getBufferSize in class AbstractTracer
      Returns:
      the buffer size of the wrapped tracer
    • isAutoflush

      public boolean isAutoflush()
      Delegates to the corresponding method of the wrapped tracer.
      Overrides:
      isAutoflush in class AbstractTracer
      Returns:
      indicates the autoflush mode of the wrapped tracer
    • isOpened

      public boolean isOpened()
      Delegates to the corresponding method of the wrapped tracer.
      Overrides:
      isOpened in class AbstractTracer
      Returns:
      indicates if the wrapped tracer is openend
    • setBufferSize

      public void setBufferSize(int bufferSize)
      Sets the buffer size of the wrapped tracer.
      Overrides:
      setBufferSize in class AbstractTracer
      Parameters:
      bufferSize - the bufferSize to set
    • setAutoflush

      protected void setAutoflush(boolean autoflush)
      Sets the autoflush mode of the wrapped tracer
      Overrides:
      setAutoflush in class AbstractTracer
      Parameters:
      autoflush - the autoflush to set
    • readConfiguration

      protected void readConfiguration(XPath xpath, Node node) throws XPathExpressionException, AbstractTracer.Exception
      Description copied from class: AbstractTracer
      Reads the configuration for this particular tracer instance by evaluating the given node with the given xpath engine.
      Overrides:
      readConfiguration in class AbstractTracer
      Parameters:
      xpath - the xpath engine
      node - the config node
      Throws:
      XPathExpressionException - indicates xpath problems
      AbstractTracer.Exception - indicates problems when configuring certain tracer instances
    • open

      public void open()
      Opens the wrapped tracer.
      Specified by:
      open in class AbstractTracer
    • close

      public void close()
      Closes the wrapped tracer.
      Specified by:
      close in class AbstractTracer
    • initCurrentTracingContext

      public void initCurrentTracingContext()
      Delegates to the corresponding method of the wrapped tracer by using the config parameter global to all queued tracer.
      Overrides:
      initCurrentTracingContext in class AbstractTracer
    • initCurrentTracingContext

      public void initCurrentTracingContext(int debugLevel, boolean online)
      Delegates to the corresponding method of the wrapped tracer.
      Overrides:
      initCurrentTracingContext in class AbstractTracer
      Parameters:
      debugLevel - controls the extent of the output
      online - a value of false delivers no output of the current thread at all whereas a value of true delivers output controlled by debugLevel
    • entry

      public TraceMethod entry(String returnType, Class clazz, String methodSignature)
      Delegates to the corresponding method of the wrapped tracer.
      Overrides:
      entry in class AbstractTracer
      Parameters:
      returnType - the return type of the method as string representation
      clazz - the class to which that method belong
      methodSignature - the remaining method signature (without return type) inclusive parameter as string representation
      Returns:
      the TraceMethod which has been put onto the stack - a mere data object for internal use primarily. May be null.
    • entry

      public TraceMethod entry(String returnType, Object object, String methodSignature)
      Delegates to the corresponding method of the wrapped tracer.
      Overrides:
      entry in class AbstractTracer
      Parameters:
      returnType - the return type of the method as string representation
      object - the object that owns the method
      methodSignature - the remaining method signature (without return type) inclusive parameter as string representation
      Returns:
      the TraceMethod which has been put onto the stack - a mere data object for internal use primarily. May be null.
    • logMessage

      public void logMessage(LogLevel logLevel, String message, Class clazz, String methodName)
      Delegates to the corresponding method of the wrapped tracer.
      Overrides:
      logMessage in class AbstractTracer
      Parameters:
      logLevel - one of the predefined levels INFO, WARNING, ERROR, FATAL and SEVERE
      message - the to be logged message
      clazz - the originating class
      methodName - the originating method
    • logException

      public void logException(LogLevel logLevel, Throwable throwable, Class clazz, String methodName)
      Delegates to the corresponding method of the wrapped tracer.
      Overrides:
      logException in class AbstractTracer
      Parameters:
      logLevel - one of the predefined levels INFO, WARNING, ERROR, FATAL and SEVERE
      throwable - the to be logged throwable
      clazz - the originating class
      methodName - the name of the relevant method
    • getThreadMap

      protected AbstractThreadMap getThreadMap()
      Delegates to the corresponding method of the wrapped tracer.
      Overrides:
      getThreadMap in class AbstractTracer
      Returns:
      the thread map of the wrapped tracer
    • wayout

      public TraceMethod wayout()
      Delegates to the corresponding method of the wrapped tracer. Besides it checks if the stack size of the current tracing context has decreased to zero. If so then the current tracing context will be cleared.
      Overrides:
      wayout in class AbstractTracer
      Returns:
      the TraceMethod which has been popped from the stack - a mere data object for internal use primarily. May be null.
    • out

      public IndentablePrintStream out()
      Delegates to the corresponding method of the wrapped tracer.
      Overrides:
      out in class AbstractTracer
      Returns:
      an IndentablePrintStream
    • out

      protected IndentablePrintStream out(int level)
      Delegates to the corresponding method of the wrapped tracer.
      Overrides:
      out in class AbstractTracer
      Parameters:
      level - the level of the to be printed data
      Returns:
      an IndentablePrintStream
    • clearCurrentTracingContext

      public void clearCurrentTracingContext()
      Delegates to the corresponding method of the wrapped tracer.
      Overrides:
      clearCurrentTracingContext in class AbstractTracer