- java.lang.Object
-
- org.wildfly.core.launcher.JBossModulesCommandBuilder
-
- All Implemented Interfaces:
CommandBuilder
- Direct Known Subclasses:
DomainCommandBuilder
,StandaloneCommandBuilder
public class JBossModulesCommandBuilder extends Object implements CommandBuilder
Builds a list of commands used to launch JBoss Modules module. This builder is not thread safe and the same instance should not be used in multiple threads.- Author:
- James R. Perkins
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
JBossModulesCommandBuilder(Path wildflyHome, String moduleName)
Creates a command builder for a launching JBoss Modules module.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JBossModulesCommandBuilder
addJavaOption(String jvmArg)
Adds a JVM argument to the command ignoringnull
arguments.JBossModulesCommandBuilder
addJavaOptions(Iterable<String> javaOpts)
Adds the collection of JVM arguments to the command.JBossModulesCommandBuilder
addJavaOptions(String... javaOpts)
Adds the array of JVM arguments to the command.JBossModulesCommandBuilder
addModuleDir(String moduleDir)
Adds a directory to the collection of module paths.JBossModulesCommandBuilder
addModuleDirs(Iterable<String> moduleDirs)
Adds all the module directories to the collection of module paths.JBossModulesCommandBuilder
addModuleDirs(String... moduleDirs)
Adds all the module directories to the collection of module paths.JBossModulesCommandBuilder
addModuleOption(String arg)
Adds an option which will be passed to JBoss Modules.JBossModulesCommandBuilder
addModuleOptions(Iterable<String> args)
Adds the options which will be passed to JBoss Modules.JBossModulesCommandBuilder
addModuleOptions(String... args)
Adds the options which will be passed to JBoss Modules.protected void
addServerArg(String key, String value)
JBossModulesCommandBuilder
addServerArgument(String arg)
Adds an argument to be passed to the server ignore the argument ifnull
.JBossModulesCommandBuilder
addServerArguments(Iterable<String> args)
Adds the arguments to the collection of arguments that will be passed to the server ignoring anynull
arguments.JBossModulesCommandBuilder
addServerArguments(String... args)
Adds the arguments to the collection of arguments that will be passed to the server ignoring anynull
arguments.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.String
getModulesJarName()
Returns the normalized path to thejboss-modules.jar
for launching the server.protected String
getServerArg(String key)
Returns the first argument from the server arguments.List<String>
getServerArguments()
A collection of server command line arguments.Path
getWildFlyHome()
Returns the home directory used.static JBossModulesCommandBuilder
of(String wildflyHome, String moduleName)
Creates a command builder for a launching JBoss Modules module.static JBossModulesCommandBuilder
of(Path wildflyHome, String moduleName)
Creates a command builder for a launching JBoss Modules module.JBossModulesCommandBuilder
setJavaHome(String javaHome)
Sets the Java home where the Java executable can be found.JBossModulesCommandBuilder
setJavaHome(Path javaHome)
Sets the Java home where the Java executable can be found.JBossModulesCommandBuilder
setJavaOptions(Iterable<String> javaOpts)
Sets the JVM arguments to use.JBossModulesCommandBuilder
setJavaOptions(String... javaOpts)
Sets the JVM arguments to use.JBossModulesCommandBuilder
setModuleDirs(Iterable<String> moduleDirs)
Replaces any previously set module directories with the collection of module directories.JBossModulesCommandBuilder
setModuleDirs(String... moduleDirs)
Replaces any previously set module directories with the array of module directories.JBossModulesCommandBuilder
setModuleOptions(Iterable<String> args)
Clears the current module options and adds the options which will be passed to JBoss Modules.JBossModulesCommandBuilder
setModuleOptions(String... args)
Clears the current module options and adds the options which will be passed to JBoss Modules.JBossModulesCommandBuilder
setModulesLockless(boolean b)
Set totrue
to use JBoss Modules lockless mode.JBossModulesCommandBuilder
setModulesMetrics(boolean b)
Set totrue
to gather metrics for JBoss Modules.protected void
setSingleServerArg(String key, String value)
JBossModulesCommandBuilder
setUseSecurityManager(boolean useSecMgr)
Sets whether or not the security manager option,-secmgr
, should be used.boolean
useSecurityManager()
Indicates whether or no a security manager should be used for the server launched.
-
-
-
Constructor Detail
-
JBossModulesCommandBuilder
protected JBossModulesCommandBuilder(Path wildflyHome, String moduleName)
Creates a command builder for a launching JBoss Modules module. Note thewildflyHome
andjavaHome
are not validated using the constructor. The staticof(Path, String)
is preferred.- Parameters:
wildflyHome
- the path to WildFly, cannot benull
moduleName
- the name of the entry module, cannot benull
-
-
Method Detail
-
of
public static JBossModulesCommandBuilder of(Path wildflyHome, String moduleName)
Creates a command builder for a launching JBoss Modules module.- Parameters:
wildflyHome
- the path to the WildFly home directory, cannot benull
moduleName
- the name of the entry module, cannot benull
- Returns:
- a new builder
-
of
public static JBossModulesCommandBuilder of(String wildflyHome, String moduleName)
Creates a command builder for a launching JBoss Modules module.- Parameters:
wildflyHome
- the path to the WildFly home directory, cannot benull
moduleName
- the name of the entry module, cannot benull
- Returns:
- a new builder
-
setUseSecurityManager
public JBossModulesCommandBuilder setUseSecurityManager(boolean useSecMgr)
Sets whether or not the security manager option,-secmgr
, should be used.- Parameters:
useSecMgr
-true
to use the a security manager, otherwisefalse
- Returns:
- the builder
-
useSecurityManager
public boolean useSecurityManager()
Indicates whether or no a security manager should be used for the server launched.- Returns:
true
if a security manager should be used, otherwisefalse
-
addModuleDir
public JBossModulesCommandBuilder 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 JBossModulesCommandBuilder 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 JBossModulesCommandBuilder 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 JBossModulesCommandBuilder 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 JBossModulesCommandBuilder 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
-
addServerArgument
public JBossModulesCommandBuilder addServerArgument(String arg)
Adds an argument to be passed to the server ignore the argument ifnull
.- Parameters:
arg
- the argument to pass- Returns:
- the builder
-
addServerArguments
public JBossModulesCommandBuilder addServerArguments(String... args)
Adds the arguments to the collection of arguments that will be passed to the server ignoring anynull
arguments.- Parameters:
args
- the arguments to add- Returns:
- the builder
-
addServerArguments
public JBossModulesCommandBuilder addServerArguments(Iterable<String> args)
Adds the arguments to the collection of arguments that will be passed to the server ignoring anynull
arguments.- Parameters:
args
- the arguments to add- Returns:
- the builder
-
getWildFlyHome
public Path getWildFlyHome()
Returns the home directory used.- Returns:
- the home directory
-
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
-
getModulesJarName
public String getModulesJarName()
Returns the normalized path to thejboss-modules.jar
for launching the server.- Returns:
- the path to
jboss-modules.jar
-
getServerArguments
public List<String> getServerArguments()
A collection of server command line arguments.- Returns:
- the server arguments
-
addJavaOption
public JBossModulesCommandBuilder addJavaOption(String jvmArg)
Adds a JVM argument to the command ignoringnull
arguments.- Parameters:
jvmArg
- the JVM argument to add- Returns:
- the builder
-
addJavaOptions
public JBossModulesCommandBuilder 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 JBossModulesCommandBuilder 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 JBossModulesCommandBuilder 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 JBossModulesCommandBuilder 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
-
addModuleOption
public JBossModulesCommandBuilder addModuleOption(String arg)
Adds an option which will be passed to JBoss Modules.Note that
-mp
or--modulepath
is not supported. UseaddModuleDir(String)
to add a module directory.- Parameters:
arg
- the argument to add- Returns:
- the builder
-
addModuleOptions
public JBossModulesCommandBuilder addModuleOptions(String... args)
Adds the options which will be passed to JBoss Modules.Note that
-mp
or--modulepath
is not supported. UseaddModuleDirs(String...)
to add a module directory.- Parameters:
args
- the argument to add- Returns:
- the builder
-
addModuleOptions
public JBossModulesCommandBuilder addModuleOptions(Iterable<String> args)
Adds the options which will be passed to JBoss Modules.Note that
-mp
or--modulepath
is not supported. UseaddModuleDirs(Iterable)
to add a module directory.- Parameters:
args
- the argument to add- Returns:
- the builder
-
setModuleOptions
public JBossModulesCommandBuilder setModuleOptions(String... args)
Clears the current module options and adds the options which will be passed to JBoss Modules.Note that
-mp
or--modulepath
is not supported. UseaddModuleDirs(String...)
to add a module directory.- Parameters:
args
- the argument to use- Returns:
- the builder
-
setModuleOptions
public JBossModulesCommandBuilder setModuleOptions(Iterable<String> args)
Clears the current module options and adds the options which will be passed to JBoss Modules.Note that
-mp
or--modulepath
is not supported. UseaddModuleDirs(Iterable)
to add a module directory.- Parameters:
args
- the argument to use- Returns:
- the builder
-
setJavaHome
public JBossModulesCommandBuilder 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 JBossModulesCommandBuilder 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
-
setModulesLockless
public JBossModulesCommandBuilder setModulesLockless(boolean b)
Set totrue
to use JBoss Modules lockless mode.- Parameters:
b
-true
to use lockless mode- Returns:
- the builder
-
setModulesMetrics
public JBossModulesCommandBuilder setModulesMetrics(boolean b)
Set totrue
to gather metrics for JBoss Modules.- Parameters:
b
-true
to gather metrics for JBoss Modules.- Returns:
- this builder
-
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
-
-