Class BootableJarCommandBuilder

  • All Implemented Interfaces:
    CommandBuilder

    public class BootableJarCommandBuilder
    extends Object
    implements CommandBuilder
    Builds a list of commands used to launch a bootable jar instance of WildFly.

    This builder is not thread safe and the same instance should not be used in multiple threads.

    Author:
    JF Denise
    • Method Detail

      • setInstallDir

        public BootableJarCommandBuilder setInstallDir​(Path installDir)
        Set the directory to install the server.
        Parameters:
        installDir - Installation directory.
        Returns:
        This builder.
      • getServerArguments

        public List<String> getServerArguments()
        A collection of server command line arguments.
        Returns:
        the server arguments
      • addServerArguments

        public BootableJarCommandBuilder addServerArguments​(String... args)
        Adds the arguments to the collection of arguments that will be passed to the server ignoring any null arguments.
        Parameters:
        args - the arguments to add
        Returns:
        the builder
      • addServerArguments

        public BootableJarCommandBuilder addServerArguments​(Iterable<String> args)
        Adds the arguments to the collection of arguments that will be passed to the server ignoring any null arguments.
        Parameters:
        args - the arguments to add
        Returns:
        the builder
      • addServerArgument

        public BootableJarCommandBuilder addServerArgument​(String arg)
        Adds an argument to be passed to the server ignore the argument if null.
        Parameters:
        arg - the argument to pass
        Returns:
        the builder
      • setBindAddressHint

        public BootableJarCommandBuilder setBindAddressHint​(String address)
        Sets the system property jboss.bind.address to the address given.

        This will override any previous value set via addServerArgument(String).

        Note: This option only works if the standard system property has not been removed from the interface. If the system property was removed the address provided has no effect.

        Parameters:
        address - the address to set the bind address to
        Returns:
        the builder
      • setBindAddressHint

        public BootableJarCommandBuilder setBindAddressHint​(String interfaceName,
                                                            String address)
        Sets the system property jboss.bind.address.$INTERFACE to the address given where $INTERFACE is the interfaceName parameter. For example in the default configuration passing management for the interfaceName parameter would result in the system property jboss.bind.address.management being set to the address provided.

        This will override any previous value set via addServerArgument(String).

        Note: This option only works if the standard system property has not been removed from the interface. If the system property was removed the address provided has no effect.

        Parameters:
        interfaceName - the name of the interface of the binding address
        address - the address to bind the management interface to
        Returns:
        the builder
      • setMulticastAddressHint

        public BootableJarCommandBuilder setMulticastAddressHint​(String address)
        Sets the system property jboss.default.multicast.address to the address given.

        This will override any previous value set via addServerArgument(String).

        Note: This option only works if the standard system property has not been removed from the interface. If the system property was removed the address provided has no effect.

        Parameters:
        address - the address to set the multicast system property to
        Returns:
        the builder
      • of

        public static BootableJarCommandBuilder of​(Path bootableJar)
        Creates a command builder for a bootable instance of WildFly.
        Parameters:
        bootableJar - the path to the bootable jar
        Returns:
        a new builder
      • of

        public static BootableJarCommandBuilder of​(String bootableJar)
        Creates a command builder for a bootable instance of WildFly.
        Parameters:
        bootableJar - the path to the WildFly home directory
        Returns:
        a new builder
      • addJavaOption

        public BootableJarCommandBuilder addJavaOption​(String jvmArg)
        Adds a JVM argument to the command ignoring null arguments.
        Parameters:
        jvmArg - the JVM argument to add
        Returns:
        the builder
      • setYamlFiles

        public BootableJarCommandBuilder setYamlFiles​(Path... yamlFiles)
        Adds the YAML configuration file argument with the given YAML configuration files.
        Parameters:
        yamlFiles - the files to add
        Returns:
        the builder
      • setYamlFiles

        public BootableJarCommandBuilder setYamlFiles​(Collection<Path> yamlFiles)
        Adds the YAML configuration file argument with the given YAML configuration files.
        Parameters:
        yamlFiles - the files to add
        Returns:
        the builder
      • addJavaOptions

        public BootableJarCommandBuilder 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 BootableJarCommandBuilder 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 BootableJarCommandBuilder setJavaOptions​(Iterable<String> javaOpts)
        Sets the JVM arguments to use. This overrides any default JVM arguments that would normally be added and ignores null values in the collection.

        If the collection is null 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 BootableJarCommandBuilder setJavaOptions​(String... javaOpts)
        Sets the JVM arguments to use. This overrides any default JVM arguments that would normally be added and ignores null values in the array.

        If the array is null 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
      • setDebug

        public BootableJarCommandBuilder setDebug()
        Sets the debug argument for the JVM with a default port of 8787.
        Returns:
        the builder
      • setDebug

        public BootableJarCommandBuilder setDebug​(int port)
        Sets the debug argument for the JVM.
        Parameters:
        port - the port to listen on
        Returns:
        the builder
      • setDebug

        public BootableJarCommandBuilder setDebug​(boolean suspend,
                                                  int port)
        Sets the debug JPDA remote socket debugging argument.
        Parameters:
        suspend - true to suspend otherwise false
        port - the port to listen on
        Returns:
        the builder
      • setJavaHome

        public BootableJarCommandBuilder setJavaHome​(String javaHome)
        Sets the Java home where the Java executable can be found.
        Parameters:
        javaHome - the Java home or null to use te system property java.home
        Returns:
        the builder
      • setJavaHome

        public BootableJarCommandBuilder setJavaHome​(Path javaHome)
        Sets the Java home where the Java executable can be found.
        Parameters:
        javaHome - the Java home or null to use te system property java.home
        Returns:
        the builder
      • setModulesLockless

        public BootableJarCommandBuilder setModulesLockless​(boolean b)
        Set to true to use JBoss Modules lockless mode.
        Parameters:
        b - true to use lockless mode
        Returns:
        the builder
      • setModulesMetrics

        public BootableJarCommandBuilder setModulesMetrics​(boolean b)
        Set to true to gather metrics for JBoss Modules.
        Parameters:
        b - true to gather metrics for JBoss Modules.
        Returns:
        this builder
      • addSecurityProperty

        public BootableJarCommandBuilder addSecurityProperty​(String key)
        Adds a security property to be passed to the server with a null value.
        Parameters:
        key - the property key
        Returns:
        the builder
      • addSecurityProperty

        public BootableJarCommandBuilder addSecurityProperty​(String key,
                                                             String value)
        Adds a security property to be passed to the server.
        Parameters:
        key - the property key
        value - the property value
        Returns:
        the builder
      • addSecurityProperties

        public BootableJarCommandBuilder addSecurityProperties​(Map<String,​String> properties)
        Adds all the security properties to be passed to the server.
        Parameters:
        properties - a map of the properties to add, null values are allowed in the map
        Returns:
        the 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 a java executable command.

        Specified by:
        buildArguments in interface CommandBuilder
        Returns:
        the list of arguments required to launch WildFly
      • build

        public List<String> build()
        Description copied from interface: CommandBuilder
        A list of commands, including a java executable, required to launch WildFly instance.
        Specified by:
        build in interface CommandBuilder
        Returns:
        the list of arguments required to launch WildFly
      • 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