Class Messages

java.lang.Object
com.northconcepts.datapipeline.core.Messages

public class Messages extends Object
Thread-local container for messages and exceptions originating in asynchronous operations.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addDebug(String message, boolean recordStackTrace)
    Adds a debug message, optionally capturing the caller's current stack trace.
    void
    addDebug(String message, Throwable exception)
    Adds a debug message that carries the given exception.
    void
     
    void
    addWarning(String message, boolean recordStackTrace)
    Adds a warning, optionally capturing the caller's current stack trace.
    void
    addWarning(String message, Throwable exception)
    Adds a warning that carries the given exception.
    static final void
    Removes the thread-local instance if one exists.
    static final Messages
    Returns the current thread's container, creating it if needed (a discarding container while collection is disabled).
    static final Messages
    getCurrent(boolean create)
    Returns the current thread's container, creating it only if create is true (otherwise null when there is none); returns a discarding container while collection is disabled.
    getMessage(int index)
     
    int
     
    static boolean
    Indicates if messages are collected, for all threads; when false, getCurrent() returns a container that discards them (defaults to true).
    static final void
    pop()
    Restores the current thread's container saved by the matching push().
    static final void
    Saves the current thread's container on a stack and starts a new, empty one; restore it with pop().
    static final void
    setCurrent(Messages messages)
    Replaces the current thread's container (ignored while collection is disabled); not intended for application use.
    static void
    setEnabled(boolean enabled)
    Indicates if messages are collected, for all threads; when false, getCurrent() returns a container that discards them (defaults to true).
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Messages

      public Messages()
  • Method Details

    • isEnabled

      public static boolean isEnabled()
      Indicates if messages are collected, for all threads; when false, getCurrent() returns a container that discards them (defaults to true).
    • setEnabled

      public static void setEnabled(boolean enabled)
      Indicates if messages are collected, for all threads; when false, getCurrent() returns a container that discards them (defaults to true).
    • getCurrent

      public static final Messages getCurrent(boolean create)
      Returns the current thread's container, creating it only if create is true (otherwise null when there is none); returns a discarding container while collection is disabled.
    • getCurrent

      public static final Messages getCurrent()
      Returns the current thread's container, creating it if needed (a discarding container while collection is disabled).
    • setCurrent

      public static final void setCurrent(Messages messages)
      Replaces the current thread's container (ignored while collection is disabled); not intended for application use.
    • clearCurrent

      public static final void clearCurrent()
      Removes the thread-local instance if one exists.
    • push

      public static final void push()
      Saves the current thread's container on a stack and starts a new, empty one; restore it with pop().
    • pop

      public static final void pop()
      Restores the current thread's container saved by the matching push().
    • addMessage

      public void addMessage(Message message)
    • getMessageCount

      public int getMessageCount()
    • getMessage

      public Message getMessage(int index)
    • addWarning

      public void addWarning(String message, boolean recordStackTrace)
      Adds a warning, optionally capturing the caller's current stack trace.
    • addDebug

      public void addDebug(String message, boolean recordStackTrace)
      Adds a debug message, optionally capturing the caller's current stack trace.
    • addWarning

      public void addWarning(String message, Throwable exception)
      Adds a warning that carries the given exception.
    • addDebug

      public void addDebug(String message, Throwable exception)
      Adds a debug message that carries the given exception.
    • toString

      public String toString()
      Overrides:
      toString in class Object