sofya.ed.structural
Interface SocketProcessingStrategy

All Superinterfaces:
ActiveComponent
All Known Implementing Classes:
AbstractSocketProcessingStrategy, BlockCoverageProcessingStrategy, BlockSequenceProcessingStrategy, BranchCoverageProcessingStrategy, BranchSequenceProcessingStrategy

public interface SocketProcessingStrategy
extends ActiveComponent

A socket processing strategy implements a strategy to be used by a ProgramEventDispatcher to receive probes received from a subject communicating using a socket connection and dispatch them as events.

Version:
04/24/2006
Author:
Alex Kinneer

Method Summary
 void dispatcherStarting()
          Message sent by the event dispatcher to indicate that it is about to start receiving data to publish its event stream.
 void dispatcherStopped()
          Message sent by the event dispatcher to indicate that it has stopped receiving data used to publish its event stream.
 void doHandshake(java.net.Socket sbjSocket)
          Executes the handshake procedure with the socket probe.
 void processProbes(java.net.Socket sbjSocket, ControlData cntrl)
          The standard trace processing loop, used for all subjects except other event dispatchers.
 void processProbesSynchronized(java.net.Socket sbjSocket, ControlData cntrl)
          The synchronized trace processing loop.
 
Methods inherited from interface sofya.ed.structural.ActiveComponent
configure, isReady, register, release, reset
 

Method Detail

dispatcherStarting

void dispatcherStarting()
Message sent by the event dispatcher to indicate that it is about to start receiving data to publish its event stream.

This message provides the processing strategy an opportunity to take some action prior to handling the event stream, such as issuing a message to listeners.


dispatcherStopped

void dispatcherStopped()
Message sent by the event dispatcher to indicate that it has stopped receiving data used to publish its event stream.

This message provides the processing strategy an opportunity to take some action after handling the event stream, such as issuing a message to listeners.


doHandshake

void doHandshake(java.net.Socket sbjSocket)
                 throws AbstractEventDispatcher.ExecException,
                        java.io.IOException
Executes the handshake procedure with the socket probe.

This method should check whether the type of instrumentation indicated by the socket probe is appropriate for this processing strategy. If it is not, an error response should be sent to the socket probe and an exception thrown. Otherwise, the integer code for the form of instrumentation to be processed should be returned.

Parameters:
sbjSocket - Main communications socket which is connected to the socket probe.
Throws:
AbstractEventDispatcher.ExecException - If the instrumentation in the subject is not appropriate for this type of filter.
java.io.IOException - If there is any error communicating through the socket.

processProbes

void processProbes(java.net.Socket sbjSocket,
                   ControlData cntrl)
The standard trace processing loop, used for all subjects except other event dispatchers.

The run loop waits for the subject to negotiate a socket connection and then begins processing trace messages until the socket stream is closed. If the subject is not instrumented, this loop will be killed while waiting for the subject to connect when the main thread calls ProgramEventDispatcher.stopServer().

A standard trace processing loop is provided distinct from the synchronized version so that the cost of synchronization is not incurred for all subjects. This also avoids complications related to determining when to strip timestamps from trace messages. The cost of this implementation is that you must remember to update both this method and processProbesSynchronized(java.net.Socket, sofya.ed.structural.ControlData) when making changes to how trace messages are processed.


processProbesSynchronized

void processProbesSynchronized(java.net.Socket sbjSocket,
                               ControlData cntrl)
The synchronized trace processing loop.

The processing performed by this run loop should be functionally equivalent to that of processProbes(java.net.Socket, sofya.ed.structural.ControlData). The only difference is that this loop should synchronize access to the listeners.

Note: This method is only expected to synchronize two threads. The event dispatcher will never execute this method from more than two threads, as there is no reason to do so.