- java.lang.Object
-
- org.wildfly.core.launcher.CliCommandBuilder
-
- All Implemented Interfaces:
CommandBuilder
public class CliCommandBuilder extends Object implements CommandBuilder
Builds a list of commands to create a new process for a CLI instance.This builder is not thread safe and the same instance should not be used in multiple threads.
- Author:
- James R. Perkins
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CliCommandBuilder
addCliArgument(String arg)
Adds an argument to be passed to the CLI command ignore the argument ifnull
.CliCommandBuilder
addCliArguments(Iterable<String> args)
Adds the arguments to the collection of arguments that will be passed to the CLI command ignoring anynull
arguments.CliCommandBuilder
addCliArguments(String... args)
Adds the arguments to the collection of arguments that will be passed to the CLI command ignoring anynull
arguments.CliCommandBuilder
addJavaOption(String jvmArg)
Adds a JVM argument to the command ignoringnull
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.static CliCommandBuilder
asJarLauncher(String wildflyHome)
Creates a command builder for a non-modular CLI instance launched from wildflyHome/bin/client/jboss-client.jar.static CliCommandBuilder
asJarLauncher(Path wildflyHome)
Creates a command builder for a non-modular CLI instance launched from wildflyHome/bin/client/jboss-client.jar.static CliCommandBuilder
asModularLauncher(String wildflyHome)
Creates a command builder for a CLI instance.static CliCommandBuilder
asModularLauncher(Path wildflyHome)
Creates a command builder for a CLI instance.List<String>
build()
A list of commands, including ajava
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(String wildflyHome)
Creates a command builder for a modular CLI instance.static CliCommandBuilder
of(Path wildflyHome)
Creates a command builder for a modular 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(String javaHome)
Sets the Java home where the Java executable can be found.CliCommandBuilder
setJavaHome(Path 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(String path)
Sets the path to the script file to execute.CliCommandBuilder
setScriptFile(Path 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.
-
-
-
Method Detail
-
asModularLauncher
public static CliCommandBuilder asModularLauncher(Path wildflyHome)
Creates a command builder for a CLI instance.- Parameters:
wildflyHome
- the path to the WildFly home directory- Returns:
- a new builder
-
asModularLauncher
public static CliCommandBuilder asModularLauncher(String wildflyHome)
Creates a command builder for a CLI instance.- Parameters:
wildflyHome
- the path to the WildFly home directory- Returns:
- a new builder
-
of
public static CliCommandBuilder of(Path wildflyHome)
Creates a command builder for a modular CLI instance.- Parameters:
wildflyHome
- the path to the WildFly home directory- Returns:
- a new builder
-
of
public static CliCommandBuilder of(String wildflyHome)
Creates a command builder for a modular CLI instance.- Parameters:
wildflyHome
- the path to the WildFly home directory- Returns:
- a new builder
-
asJarLauncher
public static CliCommandBuilder asJarLauncher(Path wildflyHome)
Creates a command builder for a non-modular CLI instance launched from wildflyHome/bin/client/jboss-client.jar.- Parameters:
wildflyHome
- the path to the WildFly home directory- Returns:
- a new builder
-
asJarLauncher
public static CliCommandBuilder asJarLauncher(String wildflyHome)
Creates a command builder for a non-modular CLI instance launched from wildflyHome/bin/client/jboss-client.jar.- Parameters:
wildflyHome
- the path to the WildFly home directory- Returns:
- a new builder
-
setConnection
public CliCommandBuilder setConnection(String controller)
Sets the hostname and port to connect to.This sets both the
--connect
and--controller
arguments.- Parameters:
controller
- the controller argument to use- Returns:
- the builder
-
setConnection
public CliCommandBuilder setConnection(String hostname, int port)
Sets the hostname and port to connect to.This sets both the
--connect
and--controller
arguments.- Parameters:
hostname
- the host nameport
- the port- Returns:
- the builder
-
setConnection
public CliCommandBuilder setConnection(String protocol, String hostname, int port)
Sets the protocol, hostname and port to connect to.This sets both the
--connect
and--controller
arguments.- Parameters:
protocol
- the protocol to usehostname
- the host nameport
- the port- Returns:
- the builder
-
setController
public CliCommandBuilder setController(String controller)
Sets the hostname and port to connect to.- Parameters:
controller
- the controller argument to use- Returns:
- the builder
-
setController
public CliCommandBuilder setController(String hostname, int port)
Sets the hostname and port to connect to.- Parameters:
hostname
- the host nameport
- the port- Returns:
- the builder
-
setController
public CliCommandBuilder setController(String protocol, String hostname, int port)
Sets the protocol, hostname and port to connect to.- Parameters:
protocol
- the protocol to usehostname
- the host nameport
- the port- Returns:
- the builder
-
setUser
public CliCommandBuilder setUser(String user)
Sets the user to use when establishing a connection.- Parameters:
user
- the user to use- Returns:
- the builder
-
setPassword
public CliCommandBuilder setPassword(String password)
Sets the password to use when establishing a connection.- Parameters:
password
- the password to use- Returns:
- the builder
-
setScriptFile
public CliCommandBuilder setScriptFile(String path)
Sets the path to the script file to execute.- Parameters:
path
- the path to the script file to execute- Returns:
- the builder
-
setScriptFile
public CliCommandBuilder setScriptFile(Path path)
Sets the path to the script file to execute.- Parameters:
path
- the path to the script file to execute- Returns:
- the builder
-
setCommand
public CliCommandBuilder setCommand(String command)
Sets the command to execute.- Parameters:
command
- the command to execute- Returns:
- the builder
-
setCommands
public CliCommandBuilder setCommands(String... commands)
Sets the commands to execute.- Parameters:
commands
- the commands to execute- Returns:
- the builder
-
setCommands
public CliCommandBuilder setCommands(Iterable<String> commands)
Sets the commands to execute.- Parameters:
commands
- the commands to execute- Returns:
- the builder
-
setTimeout
public CliCommandBuilder setTimeout(int timeout)
Sets the timeout used when connecting to the server.- Parameters:
timeout
- the time out to use- Returns:
- the builder
-
setUseGui
public CliCommandBuilder setUseGui()
Sets the command argument to use the GUI CLI client.- Returns:
- the builder
-
addJavaOption
public CliCommandBuilder addJavaOption(String jvmArg)
Adds a JVM argument to the command ignoringnull
arguments.- Parameters:
jvmArg
- the JVM argument to add- Returns:
- the builder
-
addJavaOptions
public CliCommandBuilder addJavaOptions(String... javaOpts)
Adds the array of JVM arguments to the command.- Parameters:
javaOpts
- the array of JVM arguments to add,null
arguments are ignored- Returns:
- the builder
-
addJavaOptions
public CliCommandBuilder addJavaOptions(Iterable<String> javaOpts)
Adds the collection of JVM arguments to the command.- Parameters:
javaOpts
- the collection of JVM arguments to add,null
arguments are ignored- Returns:
- the builder
-
setJavaOptions
public CliCommandBuilder setJavaOptions(Iterable<String> javaOpts)
Sets the JVM arguments to use. This overrides any default JVM arguments that would normally be added and ignoresnull
values in the collection. If the collection isnull
the JVM arguments will be cleared and no new arguments will be added.- Parameters:
javaOpts
- the JVM arguments to use- Returns:
- the builder
-
setJavaOptions
public CliCommandBuilder setJavaOptions(String... javaOpts)
Sets the JVM arguments to use. This overrides any default JVM arguments that would normally be added and ignoresnull
values in the array. If the array isnull
the JVM arguments will be cleared and no new arguments will be added.- Parameters:
javaOpts
- the JVM arguments to use- Returns:
- the builder
-
getJavaOptions
public List<String> getJavaOptions()
Returns the JVM arguments.- Returns:
- the JVM arguments
-
addCliArgument
public CliCommandBuilder addCliArgument(String arg)
Adds an argument to be passed to the CLI command ignore the argument ifnull
.- Parameters:
arg
- the argument to pass- Returns:
- the builder
-
addCliArguments
public CliCommandBuilder addCliArguments(String... args)
Adds the arguments to the collection of arguments that will be passed to the CLI command ignoring anynull
arguments.- Parameters:
args
- the arguments to add- Returns:
- the builder
-
addCliArguments
public CliCommandBuilder addCliArguments(Iterable<String> args)
Adds the arguments to the collection of arguments that will be passed to the CLI command ignoring anynull
arguments.- Parameters:
args
- the arguments to add- Returns:
- the builder
-
addModuleDir
public CliCommandBuilder addModuleDir(String moduleDir)
Adds a directory to the collection of module paths.- Parameters:
moduleDir
- the module directory to add- Returns:
- the builder
- Throws:
IllegalArgumentException
- if the path isnull
-
addModuleDirs
public CliCommandBuilder addModuleDirs(String... moduleDirs)
Adds all the module directories to the collection of module paths.- Parameters:
moduleDirs
- an array of module paths to add- Returns:
- the builder
- Throws:
IllegalArgumentException
- if any of the module paths are invalid ornull
-
addModuleDirs
public CliCommandBuilder addModuleDirs(Iterable<String> moduleDirs)
Adds all the module directories to the collection of module paths.- Parameters:
moduleDirs
- a collection of module paths to add- Returns:
- the builder
- Throws:
IllegalArgumentException
- if any of the module paths are invalid ornull
-
setModuleDirs
public CliCommandBuilder setModuleDirs(Iterable<String> moduleDirs)
Replaces any previously set module directories with the collection of module directories. The default module directory will NOT be used if this method is invoked.- Parameters:
moduleDirs
- the collection of module directories to use- Returns:
- the builder
- Throws:
IllegalArgumentException
- if any of the module paths are invalid ornull
-
setModuleDirs
public CliCommandBuilder setModuleDirs(String... moduleDirs)
Replaces any previously set module directories with the array of module directories. The default module directory will NOT be used if this method is invoked.- Parameters:
moduleDirs
- the array of module directories to use- Returns:
- the builder
- Throws:
IllegalArgumentException
- if any of the module paths are invalid ornull
-
getModulePaths
public String getModulePaths()
Returns the modules paths used on the command line.- Returns:
- the paths separated by the
path separator
-
setJavaHome
public CliCommandBuilder setJavaHome(String javaHome)
Sets the Java home where the Java executable can be found.- Parameters:
javaHome
- the Java home ornull
to use te system propertyjava.home
- Returns:
- the builder
-
setJavaHome
public CliCommandBuilder setJavaHome(Path javaHome)
Sets the Java home where the Java executable can be found.- Parameters:
javaHome
- the Java home ornull
to use te system propertyjava.home
- Returns:
- the builder
-
getJavaHome
public Path getJavaHome()
Returns the Java home directory where the java executable command can be found. If the directory was not set the system property value,java.home
, should be used.- Returns:
- the path to the Java home directory
-
buildArguments
public List<String> buildArguments()
Description copied from interface:CommandBuilder
A list of command arguments required to launch WildFly instance. These are the arguments the follow ajava
executable command.- Specified by:
buildArguments
in interfaceCommandBuilder
- Returns:
- the list of arguments required to launch WildFly
-
build
public List<String> build()
Description copied from interface:CommandBuilder
A list of commands, including ajava
executable, required to launch WildFly instance.- Specified by:
build
in interfaceCommandBuilder
- Returns:
- the list of arguments required to launch WildFly
-
-