WildFly CLI Implementation Details: Difference between revisions
No edit summary |
No edit summary |
||
Line 23: | Line 23: | ||
Connection to the CLI server is implemented by invoking: | Connection to the CLI server is implemented by invoking: | ||
<pre> | |||
cmdCtx.connectController(); | cmdCtx.connectController(); | ||
</pre> | |||
CommandContextImpl.connectController() creates the client, which is a ModelControllerClient instance, authenticates and installs the client. | <tt>CommandContextImpl.connectController()</tt> creates the client, which is a <tt>ModelControllerClient</tt> instance, authenticates and installs the client. | ||
The command line loop is implemented in cmdCtx.interact(), see below: | The command line loop is implemented in <tt>cmdCtx.interact()</tt>, see below: | ||
=Command Line Loop= | |||
<pre> | |||
org.jboss.as.cli.impl.CommandContextImpl.interact() | org.jboss.as.cli.impl.CommandContextImpl.interact() | ||
</pre> | |||
Interactions with the model controller consists in sending ModelNode instances. For example, a ModelNode associated with :read-attribute(name=release-version) is: | Interactions with the model controller consists in sending ModelNode instances. For example, a ModelNode associated with <tt>:read-attribute(name=release-version)</tt> is: | ||
{ | { |
Revision as of 22:10, 27 August 2016
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.