public final class TelnetConsole extends Console
Console connected to a telnet client via a Socket.
This class can be used to implement an embedded CLI console within an application, accessed via telnet. For example:
// Accept a new connection
final Socket socket = ...
// Set up telnet CLI console
final TelnetConsole console = TelnetConsole.create(database, socket);
console.getSession().loadFunctionsFromClasspath();
console.getSession().loadCommandsFromClasspath();
// Run the console
console.run();
| Modifier and Type | Class and Description |
|---|---|
static class |
TelnetConsole.ForwardingTerminal
Wrapper class for a JLine
Terminal that forwards all methods to the wrapped delegate. |
static class |
TelnetConsole.TelnetTerminal
JLine
Terminal that gets window size information from an associated nvt4j Terminal. |
| Modifier and Type | Method and Description |
|---|---|
static TelnetConsole |
create(Database db,
Socket socket)
Simplified factory method for
SessionMode.CORE_API mode. |
static TelnetConsole |
create(JSimpleDB jdb,
Socket socket)
Simplified factory method for
SessionMode.JSIMPLEDB mode. |
static TelnetConsole |
create(KVDatabase kvdb,
Database db,
JSimpleDB jdb,
InputStream input,
OutputStream output,
String encoding,
String appName)
Generic factory method.
|
static TelnetConsole |
create(KVDatabase kvdb,
Socket socket)
Simplified factory method for
SessionMode.KEY_VALUE mode. |
getConsoleReader, getSession, getTerminal, parseCommand, run, runNonInteractive, setHistoryFilepublic static TelnetConsole create(KVDatabase kvdb, Socket socket) throws IOException
SessionMode.KEY_VALUE mode.kvdb - key/value KVDatabasesocket - socket connected to telnet clientIOException - if an I/O error occurspublic static TelnetConsole create(Database db, Socket socket) throws IOException
SessionMode.CORE_API mode.db - core API Databasesocket - socket connected to telnet clientIOException - if an I/O error occurspublic static TelnetConsole create(JSimpleDB jdb, Socket socket) throws IOException
SessionMode.JSIMPLEDB mode.jdb - JSimpleDB databasesocket - socket connected to telnet clientIOException - if an I/O error occurspublic static TelnetConsole create(KVDatabase kvdb, Database db, JSimpleDB jdb, InputStream input, OutputStream output, String encoding, String appName) throws IOException
kvdb - KVDatabase for SessionMode.KEY_VALUE (otherwise must be null)db - Database for SessionMode.CORE_API (otherwise must be null)jdb - JSimpleDB for SessionMode.JSIMPLEDB (otherwise must be null)input - console inputoutput - console outputencoding - character encoding for terminal, or null for defaultappName - JLine application name, or null for noneIOException - if an I/O error occursIllegalArgumentException - if not exactly one of kvdb, db or jdb is not nullCopyright © 2016. All rights reserved.