- 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 protectedJBossModulesCommandBuilder(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 JBossModulesCommandBuilderaddJavaOption(String jvmArg)Adds a JVM argument to the command ignoringnullarguments.JBossModulesCommandBuilderaddJavaOptions(Iterable<String> javaOpts)Adds the collection of JVM arguments to the command.JBossModulesCommandBuilderaddJavaOptions(String... javaOpts)Adds the array of JVM arguments to the command.JBossModulesCommandBuilderaddModuleDir(String moduleDir)Adds a directory to the collection of module paths.JBossModulesCommandBuilderaddModuleDirs(Iterable<String> moduleDirs)Adds all the module directories to the collection of module paths.JBossModulesCommandBuilderaddModuleDirs(String... moduleDirs)Adds all the module directories to the collection of module paths.JBossModulesCommandBuilderaddModuleOption(String arg)Adds an option which will be passed to JBoss Modules.JBossModulesCommandBuilderaddModuleOptions(Iterable<String> args)Adds the options which will be passed to JBoss Modules.JBossModulesCommandBuilderaddModuleOptions(String... args)Adds the options which will be passed to JBoss Modules.protected voidaddServerArg(String key, String value)JBossModulesCommandBuilderaddServerArgument(String arg)Adds an argument to be passed to the server ignore the argument ifnull.JBossModulesCommandBuilderaddServerArguments(Iterable<String> args)Adds the arguments to the collection of arguments that will be passed to the server ignoring anynullarguments.JBossModulesCommandBuilderaddServerArguments(String... args)Adds the arguments to the collection of arguments that will be passed to the server ignoring anynullarguments.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.StringgetModulesJarName()Returns the normalized path to thejboss-modules.jarfor launching the server.protected StringgetServerArg(String key)Returns the first argument from the server arguments.List<String>getServerArguments()A collection of server command line arguments.PathgetWildFlyHome()Returns the home directory used.static JBossModulesCommandBuilderof(String wildflyHome, String moduleName)Creates a command builder for a launching JBoss Modules module.static JBossModulesCommandBuilderof(Path wildflyHome, String moduleName)Creates a command builder for a launching JBoss Modules module.JBossModulesCommandBuildersetJavaHome(String javaHome)Sets the Java home where the Java executable can be found.JBossModulesCommandBuildersetJavaHome(Path javaHome)Sets the Java home where the Java executable can be found.JBossModulesCommandBuildersetJavaOptions(Iterable<String> javaOpts)Sets the JVM arguments to use.JBossModulesCommandBuildersetJavaOptions(String... javaOpts)Sets the JVM arguments to use.JBossModulesCommandBuildersetModuleDirs(Iterable<String> moduleDirs)Replaces any previously set module directories with the collection of module directories.JBossModulesCommandBuildersetModuleDirs(String... moduleDirs)Replaces any previously set module directories with the array of module directories.JBossModulesCommandBuildersetModuleOptions(Iterable<String> args)Clears the current module options and adds the options which will be passed to JBoss Modules.JBossModulesCommandBuildersetModuleOptions(String... args)Clears the current module options and adds the options which will be passed to JBoss Modules.JBossModulesCommandBuildersetModulesLockless(boolean b)Set totrueto use JBoss Modules lockless mode.JBossModulesCommandBuildersetModulesMetrics(boolean b)Set totrueto gather metrics for JBoss Modules.protected voidsetSingleServerArg(String key, String value)JBossModulesCommandBuildersetUseSecurityManager(boolean useSecMgr)Sets whether or not the security manager option,-secmgr, should be used.booleanuseSecurityManager()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 thewildflyHomeandjavaHomeare not validated using the constructor. The staticof(Path, String)is preferred.- Parameters:
wildflyHome- the path to WildFly, cannot benullmoduleName- 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 benullmoduleName- 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 benullmoduleName- 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-trueto 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:
trueif 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 anynullarguments.- 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 anynullarguments.- 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.jarfor 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 ignoringnullarguments.- 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,nullarguments 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,nullarguments 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 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 JBossModulesCommandBuilder 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
-
addModuleOption
public JBossModulesCommandBuilder addModuleOption(String arg)
Adds an option which will be passed to JBoss Modules.Note that
-mpor--modulepathis 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
-mpor--modulepathis 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
-mpor--modulepathis 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
-mpor--modulepathis 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
-mpor--modulepathis 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 ornullto 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 ornullto use te system propertyjava.home- Returns:
- the builder
-
setModulesLockless
public JBossModulesCommandBuilder setModulesLockless(boolean b)
Set totrueto use JBoss Modules lockless mode.- Parameters:
b-trueto use lockless mode- Returns:
- the builder
-
setModulesMetrics
public JBossModulesCommandBuilder setModulesMetrics(boolean b)
Set totrueto gather metrics for JBoss Modules.- Parameters:
b-trueto gather metrics for JBoss Modules.- Returns:
- this builder
-
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
-
-