Class EpsilonDebugServer

java.lang.Object
org.eclipse.epsilon.eol.dap.EpsilonDebugServer
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
ReusableEpsilonDebugServer

public class EpsilonDebugServer extends Object implements Runnable

Network-based server for the debug adapter protocol, which listens via TCP at a given host and port, and exposes a given IEolModule.

The module should be fully configured the first time that someone connects to this server. The server will automatically call IEolModule.execute() the first time that anyone connects to it.

An instance of this class can only be run() once. If you need to restart the server, you will need to create another instance. After run() completes, the result of executing the module will be available via getResult().

  • Field Details

  • Constructor Details

    • EpsilonDebugServer

      public EpsilonDebugServer(IEolModule module, int port)
      Convenience version of EpsilonDebugServer(IEolModule, String, int) for listening at the loopback address (i.e. localhost).
    • EpsilonDebugServer

      public EpsilonDebugServer(IEolModule module, String host, int port)
      Creates a new instance, without starting the server.
      Parameters:
      module - Module to be debugged.
      port - Port to listen on, or 0 to use an available port from an ephemeral range.
  • Method Details

    • run

      public void run()
      Runs the server in the current thread. In the absence of server errors, this method will block until a DAP client has attached to the module, and the module has completed its execution.
      Specified by:
      run in interface Runnable
    • onAttach

      protected void onAttach()
      Starts the module in a background thread upon first attachment. Needed because modules don't track the fact that they are running themselves.
    • runModule

      protected void runModule()
      Runs the module, and shuts down the server when execution completes (whether successfully or unsuccessfully).
    • isStarted

      public Future<Boolean> isStarted()
      Returns a Future that can be used to check if the server has started and if it has started successfully, or wait until that moment.
    • shutdown

      public void shutdown()
      Shuts down the server, if it was listening. Will not do anything if the server is not listening or has already been shut down.
    • getDebugAdapter

      public EpsilonDebugAdapter getDebugAdapter()
    • getHost

      public String getHost()
    • getPort

      public int getPort()
    • getModule

      public IEolModule getModule()
    • getOnStart

      public Runnable getOnStart()
      Returns the Runnable to be executed in its own thread once the server is started.
    • setOnStart

      public void setOnStart(Runnable onStart)
      Sets the Runnable to be executed in its own thread once the server is started.
    • getResult

      public Future<Object> getResult()
      Returns a Future which will contain the result of running the Epsilon script. This result may be a regular object (equivalent to the value returned by IEolModule.execute()), or an exception thrown by it.