Package org.wildfly.core.launcher
Class CliCommandBuilder
- 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 CliCommandBuilderaddCliArgument(String arg)Adds an argument to be passed to the CLI command ignore the argument ifnull.CliCommandBuilderaddCliArguments(Iterable<String> args)Adds the arguments to the collection of arguments that will be passed to the CLI command ignoring anynullarguments.CliCommandBuilderaddCliArguments(String... args)Adds the arguments to the collection of arguments that will be passed to the CLI command ignoring anynullarguments.CliCommandBuilderaddJavaOption(String jvmArg)Adds a JVM argument to the command ignoringnullarguments.CliCommandBuilderaddJavaOptions(Iterable<String> javaOpts)Adds the collection of JVM arguments to the command.CliCommandBuilderaddJavaOptions(String... javaOpts)Adds the array of JVM arguments to the command.CliCommandBuilderaddModuleDir(String moduleDir)Adds a directory to the collection of module paths.CliCommandBuilderaddModuleDirs(Iterable<String> moduleDirs)Adds all the module directories to the collection of module paths.CliCommandBuilderaddModuleDirs(String... moduleDirs)Adds all the module directories to the collection of module paths.static CliCommandBuilderasJarLauncher(String wildflyHome)Creates a command builder for a non-modular CLI instance launched from wildflyHome/bin/client/jboss-client.jar.static CliCommandBuilderasJarLauncher(Path wildflyHome)Creates a command builder for a non-modular CLI instance launched from wildflyHome/bin/client/jboss-client.jar.static CliCommandBuilderasModularLauncher(String wildflyHome)Creates a command builder for a CLI instance.static CliCommandBuilderasModularLauncher(Path wildflyHome)Creates a command builder for a CLI instance.List<String>build()A list of commands, including ajavaexecutable, required to launch WildFly instance.List<String>buildArguments()A list of command arguments required to launch WildFly instance.PathgetJavaHome()Returns the Java home directory where the java executable command can be found.List<String>getJavaOptions()Returns the JVM arguments.StringgetModulePaths()Returns the modules paths used on the command line.CliCommandBuildersetCommand(String command)Sets the command to execute.CliCommandBuildersetCommands(Iterable<String> commands)Sets the commands to execute.CliCommandBuildersetCommands(String... commands)Sets the commands to execute.CliCommandBuildersetConnection(String controller)Sets the hostname and port to connect to.CliCommandBuildersetConnection(String hostname, int port)Sets the hostname and port to connect to.CliCommandBuildersetConnection(String protocol, String hostname, int port)Sets the protocol, hostname and port to connect to.CliCommandBuildersetController(String controller)Sets the hostname and port to connect to.CliCommandBuildersetController(String hostname, int port)Sets the hostname and port to connect to.CliCommandBuildersetController(String protocol, String hostname, int port)Sets the protocol, hostname and port to connect to.CliCommandBuildersetJavaHome(String javaHome)Sets the Java home where the Java executable can be found.CliCommandBuildersetJavaHome(Path javaHome)Sets the Java home where the Java executable can be found.CliCommandBuildersetJavaOptions(Iterable<String> javaOpts)Sets the JVM arguments to use.CliCommandBuildersetJavaOptions(String... javaOpts)Sets the JVM arguments to use.CliCommandBuildersetModuleDirs(Iterable<String> moduleDirs)Replaces any previously set module directories with the collection of module directories.CliCommandBuildersetModuleDirs(String... moduleDirs)Replaces any previously set module directories with the array of module directories.CliCommandBuildersetPassword(String password)Sets the password to use when establishing a connection.CliCommandBuildersetScriptFile(String path)Sets the path to the script file to execute.CliCommandBuildersetScriptFile(Path path)Sets the path to the script file to execute.CliCommandBuildersetTimeout(int timeout)Sets the timeout used when connecting to the server.CliCommandBuildersetUseGui()Sets the command argument to use the GUI CLI client.CliCommandBuildersetUser(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
-
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
--connectand--controllerarguments.- 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
--connectand--controllerarguments.- 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
--connectand--controllerarguments.- 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 ignoringnullarguments.- 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,nullarguments 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,nullarguments 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 ignoresnullvalues in the collection. If the collection isnullthe 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 ignoresnullvalues in the array. If the array isnullthe 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 anynullarguments.- 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 anynullarguments.- 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 ornullto 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 ornullto 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:CommandBuilderA list of command arguments required to launch WildFly instance. These are the arguments the follow ajavaexecutable command.- Specified by:
buildArgumentsin interfaceCommandBuilder- Returns:
- the list of arguments required to launch WildFly
-
build
public List<String> build()
Description copied from interface:CommandBuilderA list of commands, including ajavaexecutable, required to launch WildFly instance.- Specified by:
buildin interfaceCommandBuilder- Returns:
- the list of arguments required to launch WildFly
-
-