Package com.sshtools.synergy.nio
Class SshEngine
java.lang.Object
com.sshtools.synergy.nio.SshEngine
This class provides an abstract daemon for servicing any number of protocol
contexts.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(SshEngineListener listener) void<K extends ProtocolContext>
ConnectRequestFutureprotected booleangetBooleanValue(Properties properties, String overrideKey, boolean defaultValue) Get the context for this Daemon.static SshEngineprotected intgetIntValue(Properties properties, String overrideKey, int defaultValue) protected longgetLongValue(Properties properties, String overrideKey, long defaultValue) static DateReturns the release date of the current version.static StringReturns the current version of the API.booleanGet whether the daemon is currently startedbooleanbooleanprotected SocketChannelprocessOpenSocket(SocketChannel socketChannel, ProtocolContext protocolContext, String hostToConnect, int portToConnect) voidregisterAcceptor(ClientAcceptor acceptor, ServerSocketChannel socketChannel) Register a client acceptor with the daemon.voidregisterConnector(ClientConnector connector, SocketChannel socketChannel) Register a client connector with the daemon.voidregisterHandler(SocketHandler handler, SelectableChannel channel) Register a socket handler with the daemon.voidregisterHandler(SocketHandler handler, SelectableChannel channel, SelectorThread thread) Register a socket handler with the daemon.voidvoidremoveListener(SshEngineListener listener) voidrestart()voidrestart(boolean graceful, long forceAfterMs) voidsetStartupRequiresListeningInterfaces(boolean startupRequiresListeningInterfaces) voidvoidshutdownAsync(boolean graceful, long forceAfterMs) Shutdown the server.voidshutdownNow(boolean graceful, long forceAfterMs) This method should be used to shutdown the server from your main thread.protected booleanbooleanstartup()Starts the daemon, first calling the#configure(ConfigurationContext)method to allow your server to configure itself.booleanstartup(Properties properties)
-
Field Details
-
hexArray
protected static final char[] hexArray
-
-
Constructor Details
-
SshEngine
public SshEngine()Constructs the Daemon.
-
-
Method Details
-
getContext
Get the context for this Daemon.- Returns:
- DaemonContext
-
getLastError
-
addListener
-
removeListener
-
getVersion
Returns the current version of the API. -
getReleaseDate
Returns the release date of the current version. -
isStarting
public boolean isStarting() -
addShutdownHook
-
getIntValue
-
getBooleanValue
-
getLongValue
-
startup
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
- Throws:
IOException
-
startListeningInterface
-
removeAcceptor
-
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
- Throws:
IOException
-
restart
- Throws:
IOException
-
connect
public <K extends ProtocolContext> ConnectRequestFuture connect(String hostToConnect, int portToConnect, K protocolContext) throws SshException, IOException - Throws:
SshExceptionIOException
-
processOpenSocket
protected SocketChannel processOpenSocket(SocketChannel socketChannel, ProtocolContext protocolContext, String hostToConnect, int portToConnect) 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- ClientConnectorsocketChannel- SocketChannel- Throws:
IOException
-
registerAcceptor
public void registerAcceptor(ClientAcceptor acceptor, ServerSocketChannel socketChannel) throws IOException Register a client acceptor with the daemon.- Parameters:
acceptor- ClientAcceptorsocketChannel- ServerSocketChannel- Throws:
IOException
-
registerHandler
Register a socket handler with the daemon.- Parameters:
handler- SocketHandlerchannel- SelectableChannel- Throws:
IOException
-
registerHandler
public void registerHandler(SocketHandler handler, SelectableChannel channel, SelectorThread thread) throws IOException Register a socket handler with the daemon.- Parameters:
handler- SocketHandlerchannel- SelectableChannelthread- SelectorThread- Throws:
IOException
-
getDefaultInstance
- Throws:
IOException
-
getShutdownFuture
-