org.jactr.tools.async.shadow
Class ShadowController

java.lang.Object
  extended by org.jactr.tools.async.common.MINAEndpoint
      extended by org.jactr.tools.async.shadow.ShadowController
All Implemented Interfaces:
org.jactr.core.utils.parameter.IParameterized

public class ShadowController
extends MINAEndpoint

a mock controller that is to be used to interface with the real one controller.NetworkedDebugController

Author:
developer

Field Summary
 
Fields inherited from class org.jactr.tools.async.common.MINAEndpoint
ADDRESS, CRED_CLASS, CREDENTAILS, PROTOCOL_CLASS, SERVICE_CLASS, TRANSPORT_CLASS
 
Constructor Summary
ShadowController()
           
 
Method Summary
 void addBreakpoint(org.jactr.core.runtime.controller.debug.BreakpointType type, java.lang.String modelName, java.lang.String details)
           
 void attach()
          start up the service
 void clearBreakpoints()
           
 void detach(boolean force)
           
 org.antlr.runtime.tree.CommonTree getBreakpointData(java.lang.String modelName)
           
 ShadowIOHandler getHandler()
           
 BaseIOHandler getIOHandler()
          return the io handler that handles all the communications
 org.antlr.runtime.tree.CommonTree getModelDescriptor(java.lang.String modelName)
           
 java.util.Collection<java.lang.String> getModelNames()
           
 java.util.Collection<java.lang.String> getRunningModels()
           
 java.util.Collection<java.lang.String> getSuspendedModels()
           
 java.util.Collection<java.lang.String> getTerminatedModels()
           
 boolean isConnected()
           
 boolean isRunning()
           
 boolean isRunning(java.lang.String modelName)
           
 boolean isSuspended()
           
 boolean isSuspended(java.lang.String modelName)
           
 void removeBreakpoint(org.jactr.core.runtime.controller.debug.BreakpointType type, java.lang.String modelName, java.lang.String details)
           
 void reset()
           
 void resume()
           
 void resume(java.lang.String modelName)
           
 void resumed(java.lang.String modelName)
          called by the io handler only when the actual runtime has resumed.
 void setBreakpointData(java.lang.String modelName, org.antlr.runtime.tree.CommonTree breakpointData)
           
 void setModelDescriptor(java.lang.String modelName, org.antlr.runtime.tree.CommonTree modelDescriptor)
           
 void setProductionEnabled(java.lang.String modelName, java.lang.String productionName, boolean enabled)
           
 void start()
           
 void start(boolean suspendImmediately)
           
 void started(java.util.Collection<java.lang.String> modelNames)
          called by the io handler only when the runtime has actually started.
 void stop()
           
 void stop(java.lang.String modelName)
           
 void stopped(java.lang.String modelName)
          called by the io handler only when the runtime has stopped.
 void suspend()
           
 void suspend(java.lang.String modelName)
           
 void suspended(java.lang.String modelName)
          called by the io handler only to signal that the runtime (where ever it is) has been suspended.
 boolean waitForCompletion()
           
 boolean waitForCompletion(long maxWait)
           
 boolean waitForConnection(long timeout)
          after attach is called (which will start the configured service) you will often need to wait for the connection to be completed (established with the remote)
 boolean waitForResumption()
           
 boolean waitForResumption(long maxWait)
          Will wait until one of three things happens: the state is now resumed, the state has changed otherwise, or maxWait milliseconds have elapsed
 boolean waitForStart()
           
 boolean waitForStart(long maxWait)
          Will wait until one of three things happens: the state is now running, the state has changed otherwise, or maxWait milliseconds have elapsed
 long waitForStateChange()
           
 long waitForStateChange(long maxWait)
          wait at most maxWait milliseconds for some change of state in the system.
 boolean waitForSuspension()
           
 boolean waitForSuspension(long maxWait)
          Will wait until one of three things happens: the state is now suspended, the state has changed otherwise, or maxWait milliseconds have elapsed
 
Methods inherited from class org.jactr.tools.async.common.MINAEndpoint
getActualAddress, getActualCredentials, getExecutorService, getParameter, getPossibleParameters, getSetableParameters, setAddressInfo, setCredentialInformation, setCredentialsClass, setExecutorService, setParameter, setProtocol, setService, setTransportProvider
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShadowController

public ShadowController()
Method Detail

getModelNames

public java.util.Collection<java.lang.String> getModelNames()

getRunningModels

public java.util.Collection<java.lang.String> getRunningModels()

getTerminatedModels

public java.util.Collection<java.lang.String> getTerminatedModels()

getSuspendedModels

public java.util.Collection<java.lang.String> getSuspendedModels()

getModelDescriptor

public org.antlr.runtime.tree.CommonTree getModelDescriptor(java.lang.String modelName)

setModelDescriptor

public void setModelDescriptor(java.lang.String modelName,
                               org.antlr.runtime.tree.CommonTree modelDescriptor)

getBreakpointData

public org.antlr.runtime.tree.CommonTree getBreakpointData(java.lang.String modelName)

setBreakpointData

public void setBreakpointData(java.lang.String modelName,
                              org.antlr.runtime.tree.CommonTree breakpointData)

isConnected

public boolean isConnected()

waitForConnection

public boolean waitForConnection(long timeout)
                          throws java.lang.InterruptedException
after attach is called (which will start the configured service) you will often need to wait for the connection to be completed (established with the remote)

Parameters:
timeout - milliseconds to wait
Returns:
Throws:
java.lang.InterruptedException

attach

public void attach()
start up the service

See Also:
IController.attach()

getHandler

public ShadowIOHandler getHandler()

getIOHandler

public BaseIOHandler getIOHandler()
Description copied from class: MINAEndpoint
return the io handler that handles all the communications

Specified by:
getIOHandler in class MINAEndpoint
Returns:

detach

public void detach(boolean force)

isRunning

public boolean isRunning()
See Also:
IController.isRunning()

isRunning

public boolean isRunning(java.lang.String modelName)

isSuspended

public boolean isSuspended()
See Also:
IController.isSuspended()

isSuspended

public boolean isSuspended(java.lang.String modelName)

addBreakpoint

public void addBreakpoint(org.jactr.core.runtime.controller.debug.BreakpointType type,
                          java.lang.String modelName,
                          java.lang.String details)

removeBreakpoint

public void removeBreakpoint(org.jactr.core.runtime.controller.debug.BreakpointType type,
                             java.lang.String modelName,
                             java.lang.String details)

clearBreakpoints

public void clearBreakpoints()

setProductionEnabled

public void setProductionEnabled(java.lang.String modelName,
                                 java.lang.String productionName,
                                 boolean enabled)

reset

public void reset()
See Also:
org.jactr.core.runtime.controller.IController#reset()

resume

public void resume()
See Also:
IController.resume()

resume

public void resume(java.lang.String modelName)

start

public void start()
See Also:
IController.start()

start

public void start(boolean suspendImmediately)
See Also:
IController.start(boolean)

stop

public void stop()
See Also:
IController.stop()

stop

public void stop(java.lang.String modelName)

suspend

public void suspend()
See Also:
IController.suspend()

suspend

public void suspend(java.lang.String modelName)

waitForStateChange

public long waitForStateChange()
                        throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

waitForStateChange

public long waitForStateChange(long maxWait)
                        throws java.lang.InterruptedException
wait at most maxWait milliseconds for some change of state in the system. This is much safer than waitForResumption() and waitForSuspension() as they may miss events if the notifications are coming in faster than ShadowController can respond to them.

Parameters:
maxWait -
Returns:
the number of state changes that have elapsed since start of wait
Throws:
java.lang.InterruptedException

waitForCompletion

public boolean waitForCompletion()
                          throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

waitForCompletion

public boolean waitForCompletion(long maxWait)
                          throws java.lang.InterruptedException
Returns:
if the runtime is running
Throws:
java.lang.InterruptedException
See Also:
IController.waitForCompletion()

resumed

public void resumed(java.lang.String modelName)
called by the io handler only when the actual runtime has resumed.


waitForResumption

public boolean waitForResumption()
                          throws java.lang.InterruptedException
Returns:
Throws:
java.lang.InterruptedException
See Also:
waitForResumption(long)

waitForResumption

public boolean waitForResumption(long maxWait)
                          throws java.lang.InterruptedException
Will wait until one of three things happens: the state is now resumed, the state has changed otherwise, or maxWait milliseconds have elapsed

Parameters:
maxWait - milliseconds to block, 0 is indefinite
Returns:
if the runtime has resumed, if false, you should explicitly check the state
Throws:
java.lang.InterruptedException
See Also:
waitForStateChange(long)

suspended

public void suspended(java.lang.String modelName)
called by the io handler only to signal that the runtime (where ever it is) has been suspended.


waitForSuspension

public boolean waitForSuspension()
                          throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException
See Also:
waitForSuspension(long)

waitForSuspension

public boolean waitForSuspension(long maxWait)
                          throws java.lang.InterruptedException
Will wait until one of three things happens: the state is now suspended, the state has changed otherwise, or maxWait milliseconds have elapsed

Parameters:
maxWait - milliseconds to block, 0 is indefinite
Returns:
if the runtime has suspended, if false, you should explicitly check the state
Throws:
java.lang.InterruptedException
See Also:
waitForStateChange(long)

waitForStart

public boolean waitForStart()
                     throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException
See Also:
IController.waitForStart()

waitForStart

public boolean waitForStart(long maxWait)
                     throws java.lang.InterruptedException
Will wait until one of three things happens: the state is now running, the state has changed otherwise, or maxWait milliseconds have elapsed

Parameters:
maxWait - milliseconds to block, 0 is indefinite
Returns:
if the runtime has started, if false, you should explicitly check the state
Throws:
java.lang.InterruptedException
See Also:
waitForStateChange(long)

started

public void started(java.util.Collection<java.lang.String> modelNames)
called by the io handler only when the runtime has actually started.


stopped

public void stopped(java.lang.String modelName)
called by the io handler only when the runtime has stopped.