How gideonlegrange/mikrotik-java works
mikrotik-java is a Java client for connecting to MikroTik RouterOS and issuing API commands. The main workflow is to open a socket-backed connection, log in, send a command, and receive result maps or asynchronous listener callbacks; commands support parameters, filtering, and selected return fields, while the API also supports configuration changes, cancellation, and TLS via a caller-supplied socket factory. The implementation excerpts show parsing, wire encoding/decoding, and response dispatch. Some connection-processing code was omitted, so internal response links are limited to documented or visible behavior.
Main entry points: ApiConnectionImpl.java Connection implementation · ApiConnection.java Connection API · Parser.java Command parser · Util.java Wire codec
Components 12
Client API
- Connection API
src/main/java/me/legrange/mikrotik/ApiConnection.java - API exceptions
src/main/java/me/legrange/mikrotik/MikrotikApiException.java
Command Processing
- Command scanner
src/main/java/me/legrange/mikrotik/impl/Scanner.java - Command parser
src/main/java/me/legrange/mikrotik/impl/Parser.java - Command model
src/main/java/me/legrange/mikrotik/impl/Command.java
RouterOS Transport
- Connection implementation
src/main/java/me/legrange/mikrotik/impl/ApiConnectionImpl.java - Wire codec
src/main/java/me/legrange/mikrotik/impl/Util.java
Results and Errors
- Result listener
src/main/java/me/legrange/mikrotik/ResultListener.java - Result map
src/main/java/me/legrange/mikrotik/impl/Result.java - Command error
src/main/java/me/legrange/mikrotik/impl/ApiCommandException.java
Other components
- Java application
- RouterOS router
Connections 16
- Java application → Connection API: opens and invokes
- Connection API → Connection implementation: delegates connection
- Connection implementation → RouterOS router: connects and sends
- RouterOS router → Connection implementation: returns sentences
- Connection implementation → Command parser: parses commands
- Command parser → Command scanner: requests tokens
- Command parser → Command model: builds command
- Connection implementation → Wire codec: encodes commands
- Wire codec → RouterOS router: writes protocol data
- Connection implementation → Wire codec: decodes input
- Connection implementation → Result listener: dispatches updates
- Connection implementation → Result map: assembles result maps
- Connection implementation → Command error: wraps router errors
- Command error → API exceptions: extends
- Connection implementation → Connection API: returns results
- Connection API → Java application: returns or reports