org.eclipse.emf.mwe.internal.core.debug.processing.handlers
Class CommandRuntimeHandler

java.lang.Object
  extended by org.eclipse.emf.mwe.internal.core.debug.processing.handlers.CommandRuntimeHandler
All Implemented Interfaces:
java.lang.Runnable, EventHandler, CommandListener, ProcessHandler, RuntimeHandler

public class CommandRuntimeHandler
extends java.lang.Object
implements RuntimeHandler, CommandListener, ProcessHandler, EventHandler, java.lang.Runnable

This class handles the communication of debug commands on the runtime side.
It listens in an extra thread for commands and sets state values accordingly.

The DebugMonitor uses this class to react according to the process state settings when it needs to.
The ICommandListener and IProcessHandler methods are the active ones that communicate with the debug server.
The IEventHandler methods react only internally on events.


Field Summary
static int RESUME
           
static int STEP_INTO
           
static int STEP_OVER
           
static int STEP_RETURN
           
static int SUSPEND
           
static int TERMINATE
           
 
Fields inherited from interface org.eclipse.emf.mwe.internal.core.debug.processing.ProcessHandler
INTERRUPT, POP, PUSH, SHALL_HANDLE
 
Fields inherited from interface org.eclipse.emf.mwe.core.debug.processing.EventHandler
END_FRAME, NORMAL_FRAME
 
Constructor Summary
CommandRuntimeHandler()
           
 
Method Summary
 void init(DebugMonitor monitor, Connection connection)
          initiate the instantiated handler.
 boolean isLastCall()
          the CommandRuntimeHandler shall have the last call
 void listenCommand()
          listen for the next regular process command.
 void postTask(java.lang.Object context)
          decrement the iteration level
 void preTask(java.lang.Object element, java.lang.Object context, int state)
          increment the iteration level
 void resumed()
          no contribution here
 void run()
           
 boolean shallHandle(boolean lastState, java.lang.Object element, int flag)
          ask the suitable element adapter if the element shall be handled.
 boolean shallInterrupt(boolean lastState)
          return true in case of a user's terminate event or if the socket connection is no longer open
 boolean shallSuspend(boolean lastState, java.lang.Object element, int flag)
          return true in case of a user's suspend request or dependend on the current iteration level.
 void started()
          no contribution here
 void startListener()
          start the listening process in an extra thread, if required
 void suspended()
          reset a potential forceSuspend request
 void terminated()
          no contribution here
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STEP_INTO

public static final int STEP_INTO
See Also:
Constant Field Values

STEP_OVER

public static final int STEP_OVER
See Also:
Constant Field Values

STEP_RETURN

public static final int STEP_RETURN
See Also:
Constant Field Values

RESUME

public static final int RESUME
See Also:
Constant Field Values

SUSPEND

public static final int SUSPEND
See Also:
Constant Field Values

TERMINATE

public static final int TERMINATE
See Also:
Constant Field Values
Constructor Detail

CommandRuntimeHandler

public CommandRuntimeHandler()
Method Detail

init

public void init(DebugMonitor monitor,
                 Connection connection)
Description copied from interface: RuntimeHandler
initiate the instantiated handler. It gets the DebugMonitor and Connection instances that may be needed for the handler to do it's work
the handler may be registered at the DebugMonitor dependent on the type of handler.

Specified by:
init in interface RuntimeHandler
Parameters:
monitor - the DebugMonitor
connection - the connection to the debugger framework
See Also:
RuntimeHandler.init(org.eclipse.emf.mwe.internal.core.debug.processing.DebugMonitor, org.eclipse.emf.mwe.internal.core.debug.communication.Connection)

startListener

public void startListener()
Description copied from interface: RuntimeHandler
start the listening process in an extra thread, if required

Specified by:
startListener in interface RuntimeHandler
See Also:
RuntimeHandler.startListener()

run

public void run()
Specified by:
run in interface java.lang.Runnable
See Also:
Runnable.run()

isLastCall

public boolean isLastCall()
the CommandRuntimeHandler shall have the last call

Specified by:
isLastCall in interface ProcessHandler
Returns:
whether or not
See Also:
ProcessHandler.isLastCall()

shallHandle

public boolean shallHandle(boolean lastState,
                           java.lang.Object element,
                           int flag)
ask the suitable element adapter if the element shall be handled. Remember that information for the pop call.

Specified by:
shallHandle in interface ProcessHandler
Parameters:
lastState - the consolidated decisions of previously asked listeners
element - the element that is questioned
flag - one of the values IProcessHandler.PUSH or IProcessHandler.POP
Returns:
See Also:
ProcessHandler.shallHandle(boolean, java.lang.Object, int)

shallSuspend

public boolean shallSuspend(boolean lastState,
                            java.lang.Object element,
                            int flag)
return true in case of a user's suspend request or dependend on the current iteration level.

Specified by:
shallSuspend in interface ProcessHandler
Parameters:
lastState - the consolidated decisions of previously asked listeners
element - the element that is questioned
flag - one of the values IEventHandler.NORMAL_FRAME or IEventHandler.END_FRAME
Returns:
if the process shall suspend based on the last state and the evaluation of the current element
See Also:
ProcessHandler.shallSuspend(boolean, java.lang.Object, int)

shallInterrupt

public boolean shallInterrupt(boolean lastState)
return true in case of a user's terminate event or if the socket connection is no longer open

Specified by:
shallInterrupt in interface ProcessHandler
Parameters:
lastState - the consolidated decisions of previously asked listeners
Returns:
if the process shall be interrupted based on the last state and the evaluation of the current element
See Also:
ProcessHandler.shallInterrupt(boolean)

started

public void started()
no contribution here

Specified by:
started in interface EventHandler
See Also:
org.eclipse.emf.mwe.internal.core.debug.processing.EventHandler#started()

preTask

public void preTask(java.lang.Object element,
                    java.lang.Object context,
                    int state)
increment the iteration level

Specified by:
preTask in interface EventHandler
See Also:
org.eclipse.emf.mwe.internal.core.debug.processing.EventHandler#preTask(java.lang.Object, int)

postTask

public void postTask(java.lang.Object context)
decrement the iteration level

Specified by:
postTask in interface EventHandler
See Also:
org.eclipse.emf.mwe.internal.core.debug.processing.EventHandler#preTask(java.lang.Object, int)

suspended

public void suspended()
reset a potential forceSuspend request

Specified by:
suspended in interface EventHandler
See Also:
org.eclipse.emf.mwe.internal.core.debug.processing.EventHandler#suspended()

resumed

public void resumed()
no contribution here

Specified by:
resumed in interface EventHandler
See Also:
org.eclipse.emf.mwe.internal.core.debug.processing.EventHandler#started()

terminated

public void terminated()
no contribution here

Specified by:
terminated in interface EventHandler
See Also:
org.eclipse.emf.mwe.internal.core.debug.processing.EventHandler#started()

listenCommand

public void listenCommand()
Description copied from interface: CommandListener
listen for the next regular process command. This method could be a long running one that waits until the user starts the next debug action.

Specified by:
listenCommand in interface CommandListener