WildFly CLI Implementation Details
Internal
Client Connection
org.jboss.as.cli.CommandLineMain.main(…) is executed first. This invokes org.jboss.as.cli.impl. CliLauncher.main(…).
This one creates a command context and initializes it as follows:
CommandContext cmdCtx = CommandContextFactory.getInstance().newCommandContext(defaultHost, defaultPort, username, password, disableLocalAuth, initConsole, connect, connectionTimeout);
Connection to the CLI server is implemented by invoking:
cmdCtx.connectController();
CommandContextImpl.connectController() creates the client, which is a ModelControllerClient instance, authenticates and installs the client.
The command line loop is implemented in cmdCtx.interact(), see below: Command Line Loop
org.jboss.as.cli.impl.CommandContextImpl.interact()
Interactions with the model controller consists in sending ModelNode instances. For example, a ModelNode associated with :read-attribute(name=release-version) is:
{
"address" => [], "operation" => "read-attribute", "name" => "release-version"
}
The CommandContextImpl instance has just one “operation request”, which is a ModelNode instance. As part of the sequence of being sent to the server, the ModelInstance is installed in the CommandContextImpl instance map, under the “OP_REQ” key.
Then, the operationHandler.handle() is invoked on the CommandContextImpl instance (CommandContextImpl.java line 638).
OperationRequestHandler instance handle(): • gets the ModelControllerClient instance from the context • validates the request • “executes” the request by invoking client.execute(request)
If the result is a success, it is simply displayed.