WildFly CLI Implementation Details

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

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 Command Line Loop below.

Authentication

The CLI client loads implementations of the interface javax.security.sasl.SaslClientFactory:

package org.xnio.sasl;

public final class SaslUtils {
   ...
   private static <T> Iterator<T> getFactories(Class<T> type, ClassLoader classLoader, boolean includeGlobal) {
        Set<T> factories = new LinkedHashSet<T>();
        final ServiceLoader<T> loader = ServiceLoader.load(type, classLoader);
        for (T factory : loader) {
            factories.add(factory);
        }
       ...
}

Local user authentication will be available to CLI is org.jboss.sasl.localuser.LocalUserClientFactory is present in the class path.

This materializes if ${JBOSS_HOME}/bin/client/jboss-cli-client.jar is in the class path.

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.