Class SshEngine

java.lang.Object
com.sshtools.synergy.nio.SshEngine

public class SshEngine extends Object
This class provides an abstract daemon for servicing any number of protocol contexts.
  • Field Details

    • hexArray

      protected static final char[] hexArray
  • Constructor Details

    • SshEngine

      public SshEngine()
      Constructs the Daemon.
  • Method Details

    • getContext

      public SshEngineContext getContext()
      Get the context for this Daemon.
      Returns:
      DaemonContext
    • getLastError

      public Throwable getLastError()
    • addListener

      public void addListener(SshEngineListener listener)
    • removeListener

      public void removeListener(SshEngineListener listener)
    • getVersion

      public static String getVersion()
      Returns the current version of the API.
    • getReleaseDate

      public static Date getReleaseDate()
      Returns the release date of the current version.
    • isStarting

      public boolean isStarting()
    • addShutdownHook

      public void addShutdownHook(Runnable r)
    • getIntValue

      protected int getIntValue(Properties properties, String overrideKey, int defaultValue)
    • getBooleanValue

      protected boolean getBooleanValue(Properties properties, String overrideKey, boolean defaultValue)
    • getLongValue

      protected long getLongValue(Properties properties, String overrideKey, long defaultValue)
    • startup

      public boolean startup() throws IOException
      Starts the daemon, first calling the #configure(ConfigurationContext) method to allow your server to configure itself.
      Returns:
      true if at least one interface started, otherwise false.
      Throws:
      IOException
    • startup

      public boolean startup(Properties properties) throws IOException
      Throws:
      IOException
    • startListeningInterface

      protected boolean startListeningInterface(ListeningInterface li)
    • removeAcceptor

      public void removeAcceptor(ListeningInterface li)
    • isStarted

      public boolean isStarted()
      Get whether the daemon is currently started
      Returns:
      started
    • shutdownAsync

      public void shutdownAsync(boolean graceful, long forceAfterMs)
      Shutdown the server. This does not exit the JVM
    • shutdownNow

      public void shutdownNow(boolean graceful, long forceAfterMs)
      This method should be used to shutdown the server from your main thread. If you need to shutdown the server from within a session that is running on a transfer thread use {@link shutdownAsync().}
    • shutdownAndExit

      public void shutdownAndExit()
    • restart

      public void restart() throws IOException
      Throws:
      IOException
    • restart

      public void restart(boolean graceful, long forceAfterMs) throws IOException
      Throws:
      IOException
    • connect

      public <K extends ProtocolContext> ConnectRequestFuture connect(String hostToConnect, int portToConnect, K protocolContext) throws SshException, IOException
      Throws:
      SshException
      IOException
    • processOpenSocket

      protected SocketChannel processOpenSocket(SocketChannel socketChannel, ProtocolContext protocolContext, String hostToConnect, int portToConnect) throws UnsupportedEncodingException, IOException
      Throws:
      UnsupportedEncodingException
      IOException
    • isStartupRequiresListeningInterfaces

      public boolean isStartupRequiresListeningInterfaces()
    • setStartupRequiresListeningInterfaces

      public void setStartupRequiresListeningInterfaces(boolean startupRequiresListeningInterfaces)
    • registerConnector

      public void registerConnector(ClientConnector connector, SocketChannel socketChannel) throws IOException
      Register a client connector with the daemon.
      Parameters:
      connector - ClientConnector
      socketChannel - SocketChannel
      Throws:
      IOException
    • registerAcceptor

      public void registerAcceptor(ClientAcceptor acceptor, ServerSocketChannel socketChannel) throws IOException
      Register a client acceptor with the daemon.
      Parameters:
      acceptor - ClientAcceptor
      socketChannel - ServerSocketChannel
      Throws:
      IOException
    • registerHandler

      public void registerHandler(SocketHandler handler, SelectableChannel channel) throws IOException
      Register a socket handler with the daemon.
      Parameters:
      handler - SocketHandler
      channel - SelectableChannel
      Throws:
      IOException
    • registerHandler

      public void registerHandler(SocketHandler handler, SelectableChannel channel, SelectorThread thread) throws IOException
      Register a socket handler with the daemon.
      Parameters:
      handler - SocketHandler
      channel - SelectableChannel
      thread - SelectorThread
      Throws:
      IOException
    • getDefaultInstance

      public static SshEngine getDefaultInstance() throws IOException
      Throws:
      IOException
    • getShutdownFuture

      public AbstractRequestFuture getShutdownFuture()