public class CliCommandBuilder extends Object implements CommandBuilder
This builder is not thread safe and the same instance should not be used in multiple threads.
Modifier and Type | Method and Description |
---|---|
CliCommandBuilder |
addCliArgument(String arg)
Adds an argument to be passed to the CLI command ignore the argument if
null . |
CliCommandBuilder |
addCliArguments(Iterable<String> args)
Adds the arguments to the collection of arguments that will be passed to the CLI command ignoring any
null arguments. |
CliCommandBuilder |
addCliArguments(String... args)
Adds the arguments to the collection of arguments that will be passed to the CLI command ignoring any
null arguments. |
CliCommandBuilder |
addJavaOption(String jvmArg)
Adds a JVM argument to the command ignoring
null arguments. |
CliCommandBuilder |
addJavaOptions(Iterable<String> javaOpts)
Adds the collection of JVM arguments to the command.
|
CliCommandBuilder |
addJavaOptions(String... javaOpts)
Adds the array of JVM arguments to the command.
|
CliCommandBuilder |
addModuleDir(String moduleDir)
Adds a directory to the collection of module paths.
|
CliCommandBuilder |
addModuleDirs(Iterable<String> moduleDirs)
Adds all the module directories to the collection of module paths.
|
CliCommandBuilder |
addModuleDirs(String... moduleDirs)
Adds all the module directories to the collection of module paths.
|
List<String> |
build()
A list of commands, including a
java executable, required to launch WildFly
instance. |
List<String> |
buildArguments()
A list of command arguments required to launch WildFly instance.
|
Path |
getJavaHome()
Returns the Java home directory where the java executable command can be found.
|
List<String> |
getJavaOptions()
Returns the JVM arguments.
|
String |
getModulePaths()
Returns the modules paths used on the command line.
|
static CliCommandBuilder |
of(Path wildflyHome)
Creates a command builder for a CLI instance.
|
static CliCommandBuilder |
of(String wildflyHome)
Creates a command builder for a CLI instance.
|
CliCommandBuilder |
setCommand(String command)
Sets the command to execute.
|
CliCommandBuilder |
setCommands(Iterable<String> commands)
Sets the commands to execute.
|
CliCommandBuilder |
setCommands(String... commands)
Sets the commands to execute.
|
CliCommandBuilder |
setConnection(String controller)
Sets the hostname and port to connect to.
|
CliCommandBuilder |
setConnection(String hostname,
int port)
Sets the hostname and port to connect to.
|
CliCommandBuilder |
setConnection(String protocol,
String hostname,
int port)
Sets the protocol, hostname and port to connect to.
|
CliCommandBuilder |
setController(String controller)
Sets the hostname and port to connect to.
|
CliCommandBuilder |
setController(String hostname,
int port)
Sets the hostname and port to connect to.
|
CliCommandBuilder |
setController(String protocol,
String hostname,
int port)
Sets the protocol, hostname and port to connect to.
|
CliCommandBuilder |
setJavaHome(Path javaHome)
Sets the Java home where the Java executable can be found.
|
CliCommandBuilder |
setJavaHome(String javaHome)
Sets the Java home where the Java executable can be found.
|
CliCommandBuilder |
setJavaOptions(Iterable<String> javaOpts)
Sets the JVM arguments to use.
|
CliCommandBuilder |
setJavaOptions(String... javaOpts)
Sets the JVM arguments to use.
|
CliCommandBuilder |
setModuleDirs(Iterable<String> moduleDirs)
Replaces any previously set module directories with the collection of module directories.
|
CliCommandBuilder |
setModuleDirs(String... moduleDirs)
Replaces any previously set module directories with the array of module directories.
|
CliCommandBuilder |
setPassword(String password)
Sets the password to use when establishing a connection.
|
CliCommandBuilder |
setScriptFile(Path path)
Sets the path to the script file to execute.
|
CliCommandBuilder |
setScriptFile(String path)
Sets the path to the script file to execute.
|
CliCommandBuilder |
setTimeout(int timeout)
Sets the timeout used when connecting to the server.
|
CliCommandBuilder |
setUseGui()
Sets the command argument to use the GUI CLI client.
|
CliCommandBuilder |
setUser(String user)
Sets the user to use when establishing a connection.
|
public static CliCommandBuilder of(Path wildflyHome)
wildflyHome
- the path to the WildFly home directorypublic static CliCommandBuilder of(String wildflyHome)
wildflyHome
- the path to the WildFly home directorypublic CliCommandBuilder setConnection(String controller)
This sets both the --connect
and --controller
arguments.
controller
- the controller argument to usepublic CliCommandBuilder setConnection(String hostname, int port)
This sets both the --connect
and --controller
arguments.
hostname
- the host nameport
- the portpublic CliCommandBuilder setConnection(String protocol, String hostname, int port)
This sets both the --connect
and --controller
arguments.
protocol
- the protocol to usehostname
- the host nameport
- the portpublic CliCommandBuilder setController(String controller)
controller
- the controller argument to usepublic CliCommandBuilder setController(String hostname, int port)
hostname
- the host nameport
- the portpublic CliCommandBuilder setController(String protocol, String hostname, int port)
protocol
- the protocol to usehostname
- the host nameport
- the portpublic CliCommandBuilder setUser(String user)
user
- the user to usepublic CliCommandBuilder setPassword(String password)
password
- the password to usepublic CliCommandBuilder setScriptFile(String path)
path
- the path to the script file to executepublic CliCommandBuilder setScriptFile(Path path)
path
- the path to the script file to executepublic CliCommandBuilder setCommand(String command)
command
- the command to executepublic CliCommandBuilder setCommands(String... commands)
commands
- the commands to executepublic CliCommandBuilder setCommands(Iterable<String> commands)
commands
- the commands to executepublic CliCommandBuilder setTimeout(int timeout)
timeout
- the time out to usepublic CliCommandBuilder setUseGui()
public CliCommandBuilder addJavaOption(String jvmArg)
null
arguments.jvmArg
- the JVM argument to addpublic CliCommandBuilder addJavaOptions(String... javaOpts)
javaOpts
- the array of JVM arguments to add, null
arguments are ignoredpublic CliCommandBuilder addJavaOptions(Iterable<String> javaOpts)
javaOpts
- the collection of JVM arguments to add, null
arguments are ignoredpublic CliCommandBuilder setJavaOptions(Iterable<String> javaOpts)
null
values in the collection.
If the collection is null
the JVM arguments will be cleared and no new arguments will be added.javaOpts
- the JVM arguments to usepublic CliCommandBuilder setJavaOptions(String... javaOpts)
null
values in the array.
If the array is null
the JVM arguments will be cleared and no new arguments will be added.javaOpts
- the JVM arguments to usepublic List<String> getJavaOptions()
public CliCommandBuilder addCliArgument(String arg)
null
.arg
- the argument to passpublic CliCommandBuilder addCliArguments(String... args)
null
arguments.args
- the arguments to addpublic CliCommandBuilder addCliArguments(Iterable<String> args)
null
arguments.args
- the arguments to addpublic CliCommandBuilder addModuleDir(String moduleDir)
moduleDir
- the module directory to addIllegalArgumentException
- if the path is null
public CliCommandBuilder addModuleDirs(String... moduleDirs)
moduleDirs
- an array of module paths to addIllegalArgumentException
- if any of the module paths are invalid or null
public CliCommandBuilder addModuleDirs(Iterable<String> moduleDirs)
moduleDirs
- a collection of module paths to addIllegalArgumentException
- if any of the module paths are invalid or null
public CliCommandBuilder setModuleDirs(Iterable<String> moduleDirs)
moduleDirs
- the collection of module directories to useIllegalArgumentException
- if any of the module paths are invalid or null
public CliCommandBuilder setModuleDirs(String... moduleDirs)
moduleDirs
- the array of module directories to useIllegalArgumentException
- if any of the module paths are invalid or null
public String getModulePaths()
path separator
public CliCommandBuilder setJavaHome(String javaHome)
javaHome
- the Java home or null
to use te system property java.home
public CliCommandBuilder setJavaHome(Path javaHome)
javaHome
- the Java home or null
to use te system property java.home
public Path getJavaHome()
java.home
, should be used.public List<String> buildArguments()
CommandBuilder
java
executable command.buildArguments
in interface CommandBuilder
public List<String> build()
CommandBuilder
java
executable, required to launch WildFly
instance.build
in interface CommandBuilder
Copyright © 2023 JBoss by Red Hat. All rights reserved.