Class Tracer

  • All Implemented Interfaces:
    java.lang.Cloneable

    public final class Tracer
    extends java.lang.Object
    implements java.lang.Cloneable
    Central control point of Aspectrace tracing.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addMessageStreamFilter​(MessageStreamFilter messageStreamFilter)
      Adds a filter through which all of the tracing will go.
      void addProcessor​(TraceProcessorManager manager)
      Adds a trace in a TraceToProcessor.
      void addTracing​(Tracer.Channel chn)
      Adds a trace random configuration with the default properties.
      void addTracing​(Tracer.Channel chn, java.util.Properties props)
      Adds a trace random configuration and starts it.
      void addTracing​(Tracer.Formatter frm, Tracer.Writer wrt)
      Adds a trace standard configuration with the default properties.
      void addTracing​(Tracer.Formatter frm, Tracer.Writer wrt, java.util.Properties props)
      Adds a trace standard configuration.
      void addXmlTrace​(java.io.File file)
      Adds a trace in a XML-file with the default coding.
      void addXmlTrace​(java.io.File file, java.lang.String encoding)
      Adds a trace in a XML-file with a given coding.
      void addXmlTrace​(java.lang.String pattern)
      Adds a trace in a template XML-file with the default coding.
      void addXmlTrace​(java.lang.String pattern, java.lang.String encoding)
      Adds a trace in a template XML-file with a given coding.
      static java.lang.String allocateChannelId()  
      void endTrace()
      Ends a trace.
      protected void finalize()  
      java.lang.String get_channel()
      Gets a channel ID which is processed by the current tracer.
      static java.lang.String getChannel()
      Gets a channel ID for the current process/stream/etc.
      static Tracer getInstance()
      Gets a tracer instance for the current process/stream/etc.
      void removeMessageStreamFilter​(MessageStreamFilter messageStreamFilter)
      Removes a trace filter.
      static void setChannel​(java.lang.String ch)  
      static void setMasterTracer()
      Sets the tracer of the current stream as master.
      void trace_debug​(java.lang.String text)
      Traces a debug message.
      void trace_message​(AbstractTraceMessage msg)
      Traces a message.
      void trace_sync_tag​(java.lang.String aspect, java.lang.String name)
      Traces a synchronized tag message.
      void trace_tag_end​(java.lang.String aspect, java.lang.String tag, java.lang.String parent)
      Traces a close tag message.
      void trace_tag_start​(java.lang.String aspect, java.lang.String tag, java.lang.String parent)
      Traces an open tag message.
      static void traceDebug​(java.lang.String text)
      Traces a debug message via the default instance.
      static void traceMessage​(AbstractTraceMessage msg)
      Traces a message via the default instance.
      static void traceSyncTag​(java.lang.String aspect, java.lang.String name)
      Traces a synchronized tag message via the default instance.
      static void traceTagEnd​(java.lang.String aspect, java.lang.String tag, java.lang.String parent)
      Traces a close tag message via the default instance.
      static void traceTagStart​(java.lang.String aspect, java.lang.String tag, java.lang.String parent)
      Traces an open tag message via the default instance.
      static void tracingError​(java.lang.Throwable exception)
      Traces an error in trace procedures.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static Tracer getInstance()
        Gets a tracer instance for the current process/stream/etc.
        See Also:
        endTrace()
      • setMasterTracer

        public static void setMasterTracer()
        Sets the tracer of the current stream as master. In this case tracer instances from other streams which tracer channels haven't been explicitly set will use the channels from this tracer.

        If there has been made a call in a thread manually then endTrace() call must be made manually afterwards as well.

      • finalize

        protected void finalize()
        Overrides:
        finalize in class java.lang.Object
      • getChannel

        public static java.lang.String getChannel()
        Gets a channel ID for the current process/stream/etc.
      • get_channel

        public java.lang.String get_channel()
        Gets a channel ID which is processed by the current tracer.
      • setChannel

        public static void setChannel​(java.lang.String ch)
      • allocateChannelId

        public static java.lang.String allocateChannelId()
      • addTracing

        public void addTracing​(Tracer.Formatter frm,
                               Tracer.Writer wrt,
                               java.util.Properties props)
                        throws java.lang.IllegalStateException,
                               java.lang.IllegalArgumentException,
                               java.io.IOException
        Adds a trace standard configuration.
        Throws:
        java.lang.IllegalStateException
        java.lang.IllegalArgumentException
        java.io.IOException
      • addTracing

        public void addTracing​(Tracer.Formatter frm,
                               Tracer.Writer wrt)
                        throws java.lang.IllegalStateException,
                               java.lang.IllegalArgumentException,
                               java.io.IOException
        Adds a trace standard configuration with the default properties.
        Throws:
        java.lang.IllegalStateException
        java.lang.IllegalArgumentException
        java.io.IOException
      • addTracing

        public void addTracing​(Tracer.Channel chn)
                        throws java.lang.IllegalStateException,
                               java.lang.IllegalArgumentException,
                               java.io.IOException
        Adds a trace random configuration with the default properties.
        Throws:
        java.lang.IllegalStateException
        java.lang.IllegalArgumentException
        java.io.IOException
      • addTracing

        public void addTracing​(Tracer.Channel chn,
                               java.util.Properties props)
                        throws java.lang.IllegalStateException,
                               java.lang.IllegalArgumentException,
                               java.io.IOException
        Adds a trace random configuration and starts it.
        Throws:
        java.lang.IllegalStateException
        java.lang.IllegalArgumentException
        java.io.IOException
      • addXmlTrace

        public void addXmlTrace​(java.io.File file)
                         throws java.io.IOException,
                                java.lang.IllegalStateException,
                                java.lang.IllegalArgumentException
        Adds a trace in a XML-file with the default coding.
        Throws:
        java.io.IOException
        java.lang.IllegalStateException
        java.lang.IllegalArgumentException
      • addXmlTrace

        public void addXmlTrace​(java.io.File file,
                                java.lang.String encoding)
                         throws java.io.IOException,
                                java.lang.IllegalStateException,
                                java.lang.IllegalArgumentException
        Adds a trace in a XML-file with a given coding.
        Throws:
        java.io.IOException
        java.lang.IllegalStateException
        java.lang.IllegalArgumentException
      • addXmlTrace

        public void addXmlTrace​(java.lang.String pattern)
                         throws java.io.IOException,
                                java.lang.IllegalStateException,
                                java.lang.IllegalArgumentException
        Adds a trace in a template XML-file with the default coding.
        Throws:
        java.io.IOException
        java.lang.IllegalStateException
        java.lang.IllegalArgumentException
      • addXmlTrace

        public void addXmlTrace​(java.lang.String pattern,
                                java.lang.String encoding)
                         throws java.io.IOException,
                                java.lang.IllegalStateException,
                                java.lang.IllegalArgumentException
        Adds a trace in a template XML-file with a given coding.
        Throws:
        java.io.IOException
        java.lang.IllegalStateException
        java.lang.IllegalArgumentException
      • addProcessor

        public void addProcessor​(TraceProcessorManager manager)
                          throws java.lang.IllegalArgumentException,
                                 java.lang.IllegalStateException,
                                 java.io.IOException
        Adds a trace in a TraceToProcessor.
        Parameters:
        manager - Defined configuration of handlers. All necessary handlers and adapters must be configured and connected before calling this method.
        Throws:
        java.lang.IllegalArgumentException - Manager error.
        java.lang.IllegalStateException - Invalid state of manager or tracer.
        java.io.IOException
      • addMessageStreamFilter

        public void addMessageStreamFilter​(MessageStreamFilter messageStreamFilter)
        Adds a filter through which all of the tracing will go. Filters may be more than one - in that case messages will go through all of them in the order of filter adding.
      • trace_tag_start

        public void trace_tag_start​(java.lang.String aspect,
                                    java.lang.String tag,
                                    java.lang.String parent)
        Traces an open tag message.
      • trace_tag_end

        public void trace_tag_end​(java.lang.String aspect,
                                  java.lang.String tag,
                                  java.lang.String parent)
        Traces a close tag message.
      • trace_sync_tag

        public void trace_sync_tag​(java.lang.String aspect,
                                   java.lang.String name)
        Traces a synchronized tag message.
      • trace_debug

        public void trace_debug​(java.lang.String text)
        Traces a debug message.
      • endTrace

        public void endTrace()
        Ends a trace. All errors in channels are ignored.

        This method is recommended to call in the threads which are doing tracing before their end. If it hasn't been done then the tracing system will try to do so automatically via JVM garbage collector and before the program end but this is not so safe.

      • traceMessage

        public static void traceMessage​(AbstractTraceMessage msg)
        Traces a message via the default instance.
      • traceDebug

        public static void traceDebug​(java.lang.String text)
        Traces a debug message via the default instance.
      • traceTagStart

        public static void traceTagStart​(java.lang.String aspect,
                                         java.lang.String tag,
                                         java.lang.String parent)
        Traces an open tag message via the default instance.
      • traceTagEnd

        public static void traceTagEnd​(java.lang.String aspect,
                                       java.lang.String tag,
                                       java.lang.String parent)
        Traces a close tag message via the default instance.
      • traceSyncTag

        public static void traceSyncTag​(java.lang.String aspect,
                                        java.lang.String name)
        Traces a synchronized tag message via the default instance.
      • tracingError

        public static void tracingError​(java.lang.Throwable exception)
        Traces an error in trace procedures.