Class TraceProvider

  • Direct Known Subclasses:
    StreamTraceProvider, TraceToProcessor, XmlSocketServer, XmlStreamParser

    public abstract class TraceProvider
    extends java.lang.Object
    Trace provider. Represents a stream of aspect messages, distributed between corresponding adapters in the following way:
    • Begin/end trace messages are directed to an empty aspect ("").
    • Tag messages are directed to an empty aspect and to a parent aspect via corresponding adapters аспекту и породившему их аспекту, after that are distributed between listeners via methods CommonListener.processGlobalTagChange(TagMessage) and AspectListener.processTagChange(TagMessage).
    • All aspect-dependent messages (including messages from a base aspect) are directed to the corresponding adapter.
      Note: Error messages and coverage messages independently of a logically connected aspect belong to "error" aspect and "coverage" aspect respectively.

    If a trace provider realization suggests a work in it's own active control stream in which messages are pulled from external sources (model PULL) then method process() is redefined in the corresponding class. In this scenario the base struct of the class provider is the following:

     public void process() { // Called from TraceProcessorManager.process()
       fireTraceStart(...);
       while(messages) {
         fireMessage(...); or fireTagMessage(...);
       }
       fireTraceEnd(...);
     }
     

    If a trace provider realization suggests a work in the other's active control stream in which messages are pushed by external sources (model PUSH) then the base struct of the class is the following:

     TraceProcessorManager tpm; // Gets from the outside
     stream_start_event_handler() {
       attachToManager(tpm);
       fireTraceStart(...);
     }
     next_external_event_handler() {
       fireMessage(...); or fireTagMessage(...);
     }
     end_stream_event_handler() {
       fireTraceEnd(...);
     }
     

    Note: The class TraceProvider has the realizations of methods fireTraceStart(String), fireMessage(TraceMessage), fireTagMessage(TagMessage) and fireTraceEnd(String, boolean) which are synchronized but not final.

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected TraceProvider()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addProcessorTag​(java.lang.String aspect, java.lang.String channel, java.lang.String tag, java.lang.String parent)
      Adds a user tag.
      protected void addProviderTag​(java.lang.String aspect, java.lang.String channel, java.lang.String tag, java.lang.String parent)
      Adds a tag from a trace.
      protected void attachToManager​(TraceProcessorManager tpm)
      Connects all adapters from a specified trace handler manager to itself.
      protected void fireMessage​(TraceMessage msg)
      Distributes a trace message via the corresponding adapter.
      protected void fireMessage​(java.lang.String aspect, java.lang.String channel, TraceNode tn)  
      protected void fireSyncMessage​(java.lang.String aspect, java.lang.String channel, java.lang.String name)  
      protected void fireTagMessage​(TagMessage msg)
      Distributes a tag change message or a synchronized message via adapters.
      protected void fireTraceEnd​(java.lang.String traceDesc, boolean verdict)
      Notifies empty aspect handlers about the trace handle end.
      protected void fireTraceStart​(java.lang.String traceDesc)
      Notifies empty aspect handlers about the trace handle start.
      AspectAdapter getAdapter​(java.lang.String aspect)
      Gets an adapter for an aspect.
      protected java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> getAllTags()
      Gets all tags.
      protected java.util.Set<java.lang.String> getTags​(java.lang.String aspect)
      Gets tags for an aspect.
      void process()
      Begins message handling loop if this is an active trace source (model PULL).
      void removeAdapter​(java.lang.String aspect)
      Removes aspect adapter.
      protected void removeProcessorTag​(java.lang.String aspect, java.lang.String channel, java.lang.String tag, java.lang.String parent)
      Deletes a user tag.
      protected void removeProviderTag​(java.lang.String aspect, java.lang.String channel, java.lang.String tag, java.lang.String parent)
      Deletes a tag from a trace.
      protected void setAdapter​(java.lang.String aspect, AspectAdapter adapter)
      Sets an adapter for an aspect.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TraceProvider

        protected TraceProvider()
    • Method Detail

      • process

        public void process()
                     throws java.io.IOException,
                            java.lang.IllegalStateException,
                            java.lang.IllegalArgumentException
        Begins message handling loop if this is an active trace source (model PULL). If this trace source doesn't get messages in his own active stream but works as a message converter from the others' active (PUSH) sources then - empty realization by default.
        Throws:
        java.io.IOException - Input-Output error
        java.lang.IllegalStateException - The handling has already begun
        java.lang.IllegalArgumentException - Trace error (casted by a trace source, by an aspect adapter or by a trace handler)
      • attachToManager

        protected void attachToManager​(TraceProcessorManager tpm)
        Connects all adapters from a specified trace handler manager to itself. Calls tpm.attachAdapters(this). This method calls providers which DON'T work in an active stream of the corresponding trace handle manager in the beginning of a trace.
        See Also:
        fireTraceStart(String)
      • setAdapter

        protected final void setAdapter​(java.lang.String aspect,
                                        AspectAdapter adapter)
                                 throws java.lang.IllegalArgumentException,
                                        java.lang.IllegalStateException
        Sets an adapter for an aspect. The adapter can be used multiple times.
        Throws:
        java.lang.IllegalArgumentException - Incorrect adapter or this aspect has got already a different adapter instance.
        java.lang.IllegalStateException - The handling has already begun
      • removeAdapter

        public final void removeAdapter​(java.lang.String aspect)
        Removes aspect adapter.
      • fireTraceStart

        protected void fireTraceStart​(java.lang.String traceDesc)
        Notifies empty aspect handlers about the trace handle start.
      • fireTraceEnd

        protected void fireTraceEnd​(java.lang.String traceDesc,
                                    boolean verdict)
        Notifies empty aspect handlers about the trace handle end.
      • fireMessage

        protected final void fireMessage​(java.lang.String aspect,
                                         java.lang.String channel,
                                         TraceNode tn)
                                  throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • fireMessage

        protected void fireMessage​(TraceMessage msg)
                            throws java.lang.IllegalArgumentException
        Distributes a trace message via the corresponding adapter. change tag messages must be distributed via fireTagMessage(TagMessage) method.
        Throws:
        java.lang.IllegalArgumentException - Aspect adapter has found an error in message.
      • fireTagMessage

        protected void fireTagMessage​(TagMessage msg)
                               throws java.lang.IllegalArgumentException
        Distributes a tag change message or a synchronized message via adapters. Message is distributed via an empty aspect adapter and via an adapter corresponding aspect tag. If this method is called during other's message handling then the corresponding tag message is delayed until current handling end.
        Throws:
        java.lang.IllegalArgumentException
      • fireSyncMessage

        protected final void fireSyncMessage​(java.lang.String aspect,
                                             java.lang.String channel,
                                             java.lang.String name)
                                      throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • addProviderTag

        protected final void addProviderTag​(java.lang.String aspect,
                                            java.lang.String channel,
                                            java.lang.String tag,
                                            java.lang.String parent)
        Adds a tag from a trace. Message is distributed in the standard way via method fireTagMessage(TagMessage)
      • removeProviderTag

        protected final void removeProviderTag​(java.lang.String aspect,
                                               java.lang.String channel,
                                               java.lang.String tag,
                                               java.lang.String parent)
        Deletes a tag from a trace. Message is distributed in the standard way via method fireTagMessage(TagMessage)
      • addProcessorTag

        protected final void addProcessorTag​(java.lang.String aspect,
                                             java.lang.String channel,
                                             java.lang.String tag,
                                             java.lang.String parent)
        Adds a user tag. The method is usually called by a trace handler. A change tag message with the flag isUser=true is distributed in the standard way via method fireTagMessage(TagMessage)
      • removeProcessorTag

        protected final void removeProcessorTag​(java.lang.String aspect,
                                                java.lang.String channel,
                                                java.lang.String tag,
                                                java.lang.String parent)
        Deletes a user tag. The method is usually called by a trace handler. A change tag message with the flag isUser=true is distributed in the standard way via method fireTagMessage(TagMessage)
      • getTags

        protected java.util.Set<java.lang.String> getTags​(java.lang.String aspect)
        Gets tags for an aspect.
        Returns:
        A set of tags. A return value directly refers to the current provider state.
      • getAllTags

        protected java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> getAllTags()
        Gets all tags.
        Returns:
        A copy of the complete tag set for all aspects. Mapping values are class LinkedHashSet instances which guarantees the order of iteration corresponding with the order of tag creation (in trace). In case of a inner tag outer tag appears first.