WildFly CLI Implementation Details: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * WildFly CLI")
 
No edit summary
Line 2: Line 2:


* [[WildFly CLI#Subjects|WildFly CLI]]
* [[WildFly CLI#Subjects|WildFly CLI]]
=Client Connection=
<tt>org.jboss.as.cli.CommandLineMain.main(…)</tt> is executed first. This invokes <tt>org.jboss.as.cli.impl. CliLauncher.main(…)</tt>.
This one creates a command context and initializes it as follows:
<pre>
CommandContext cmdCtx =  CommandContextFactory.getInstance().newCommandContext(defaultHost,
                                                                                                                                              defaultPort,
                                                                                                                                              username,
                                                                                                                                              password,
                                                                                                                                              disableLocalAuth,
                                                                                                                                              initConsole,
                                                                                                                                              connect,
                                                                                                                                              connectionTimeout);
</pre>
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.

Revision as of 22:07, 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.