Class QueueTracer<T extends AbstractTracer>

  • 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
    • Constructor Detail

      • 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 Detail

      • 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
      • isOnline

        public boolean isOnline()
        Returns the configured online value. Will be used by the parameterless initCurrentTracingContext() method.
        Returns:
        the configured online value
      • getLevel

        public int getLevel()
        Returns the configured debuglevel. Will be used by the parameterless initCurrentTracingContext() method.
        Returns:
        the configured debug level
      • 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.