Package org.wildfly.plugin.tools.cli

## Class CLIWrapper

- java.lang.Object
- - org.wildfly.plugin.tools.cli.CLIWrapper

- All Implemented Interfaces:
    `AutoCloseable`

      public class CLIWrapper
      extends Object
      implements AutoCloseable

  A CLI executor, resolving CLI classes from the provided Classloader. We can't have cli/embedded/jboss modules in plugin classpath, it causes issue because we are sharing the same jboss module classes between execution run inside the same JVM.

  > CLI dependencies are retrieved from provisioned server artifacts list and resolved using maven. In addition jboss-modules.jar located in the provisioned server is added.

  Author:
    jdenise, James R. Perkins

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CLIWrapper​(Path jbossHome, boolean resolveExpression, ClassLoader loader)` | Creates a new CLIWrapper with a `null` `BootLoggingConfiguration`.
    `CLIWrapper​(Path jbossHome, boolean resolveExpression, ClassLoader loader, BootLoggingConfiguration bootLoggingConfiguration)` | Creates a new CLIWrapper with a `null` `BootLoggingConfiguration`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `bindClient​(org.jboss.as.controller.client.ModelControllerClient client)` | Binds the client to the CLI context.
    `void` | `close()` |
    `void` | `generateBootLoggingConfig()` | Generate boot logging.
    `String` | `getOutput()` | Returns the output from the CLI context.
    `void` | `handle​(String command)` | Handles invoking the command.
    `void` | `handleSafe​(String command)` | Safely handle invoking the command.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CLIWrapper

          public CLIWrapper​(Path jbossHome,
                            boolean resolveExpression,
                            ClassLoader loader)

      Creates a new CLIWrapper with a `null` `BootLoggingConfiguration`.

      Note, when this constructor is used, the `generateBootLoggingConfig()` cannot be invoked.

      Parameters:
        `jbossHome` - the servers home directory
        `resolveExpression` - `true` if parameters in commands should be resolved before sending the command to the server
        `loader` - the class loader to use for loading the CLI context
      Throws:
        `RuntimeException` - if an error occurs creating the CLI context

    - #### CLIWrapper

          public CLIWrapper​(Path jbossHome,
                            boolean resolveExpression,
                            ClassLoader loader,
                            BootLoggingConfiguration bootLoggingConfiguration)

      Creates a new CLIWrapper with a `null` `BootLoggingConfiguration`.

      Note, if the `bootLoggingConfiguration` is `null`, the `generateBootLoggingConfig()` cannot be invoked.

      Parameters:
        `jbossHome` - the servers home directory
        `resolveExpression` - `true` if parameters in commands should be resolved before sending the command to the server
        `loader` - the class loader to use for loading the CLI context
        `bootLoggingConfiguration` - the boot logging configuration generator, or `null` to not allow boot logging configuration
      Throws:
        `RuntimeException` - if an error occurs creating the CLI context

  - ### Method Detail

    - #### handle

          public void handle​(String command)
                      throws Exception

      Handles invoking the command.
      Parameters:
        `command` - the command to invoke
      Throws:
        `Exception` - if an error occurs handling the command

    - #### handleSafe

          public void handleSafe​(String command)

      Safely handle invoking the command.
      Parameters:
        `command` - the command to invoke

    - #### bindClient

          public void bindClient​(org.jboss.as.controller.client.ModelControllerClient client)
                          throws Exception

      Binds the client to the CLI context.
      Parameters:
        `client` - the client to bind
      Throws:
        `Exception` - if an error occurs binding the client to the context

    - #### getOutput

          public String getOutput()

      Returns the output from the CLI context.
      Returns:
        the CLI output

    - #### close

          public void close()
                     throws Exception

      Specified by:
        `close` in interface `AutoCloseable`
      Throws:
        `Exception`

    - #### generateBootLoggingConfig

          public void generateBootLoggingConfig()

      Generate boot logging. The `CLIWrapper(Path, boolean, ClassLoader, BootLoggingConfiguration)` constructor must have been used with a non-null `BootLoggingConfiguration`.
      Throws:
        `RuntimeException` - if an error occurs generated the boot logging configuration