Package org.wildfly.plugin.tools.server
Class Configuration<T extends Configuration<T>>
- java.lang.Object
-
- org.wildfly.plugin.tools.server.Configuration<T>
-
- Direct Known Subclasses:
DomainConfiguration
,StandaloneConfiguration
public abstract class Configuration<T extends Configuration<T>> extends Object
The configuration used when starting a server.- Since:
- 1.2
- Author:
- James R. Perkins
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
Configuration.LaunchType
-
Constructor Summary
Constructors Modifier Constructor Description protected
Configuration(org.wildfly.core.launcher.CommandBuilder commandBuilder)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
addEnvironmentVariable(String key, String value)
Adds an environment variable to the process being created.T
addEnvironmentVariables(Map<String,String> env)
Adds the environment variables to the process being created.protected org.jboss.as.controller.client.ModelControllerClient
client()
The client set on the configuration or a new client.T
client(org.jboss.as.controller.client.ModelControllerClient client)
Sets the client to use for the server manager.protected org.wildfly.core.launcher.CommandBuilder
commandBuilder()
The command builder used to create the launcher.protected boolean
consumeStderr()
Checks if the error stream (stderr
) needs to be consumed.protected boolean
consumeStdout()
Checks if the output stream (stdout
) needs to be consumed.static StandaloneConfiguration
create(org.wildfly.core.launcher.BootableJarCommandBuilder commandBuilder)
Creates a standalone configuration to launch a standalone server via the bootable JAR.static DomainConfiguration
create(org.wildfly.core.launcher.DomainCommandBuilder commandBuilder)
Creates a domain configuration to launch a domain serverstatic StandaloneConfiguration
create(org.wildfly.core.launcher.StandaloneCommandBuilder commandBuilder)
Creates a standalone configuration to launch a standalone server.T
directory(File dir)
Sets the working directory for the process created.T
directory(String dir)
Sets the working directory for the process created.T
directory(Path path)
Sets the working directory for the process created.protected org.wildfly.core.launcher.Launcher
launcher()
A configured launcher for create the server process.protected abstract Configuration.LaunchType
launchType()
The type of the server to launch.protected String
managementAddress()
The management address set or127.0.0.1
if not set.T
managementAddress(String managementAddress)
The management address to use for the client if the client has not been set.protected int
managementPort()
The management port or9990
if set to 0 or less.T
managementPort(int managementPort)
The management port to use for the client if the client has not been set.T
redirectError(File file)
Redirects the error stream of the process to a file.T
redirectError(ProcessBuilder.Redirect destination)
Redirects the error stream of the process to the destination provided.T
redirectErrorStream(boolean redirectErrorStream)
Set totrue
if the error stream should be redirected to the output stream.T
redirectOutput(File file)
Redirects the output of the process to a file.T
redirectOutput(ProcessBuilder.Redirect destination)
Redirects the output of the process to the destination provided.T
redirectOutput(Path path)
Redirects the output of the process to a file.protected abstract T
self()
This instance.protected boolean
shutdownOnClose()
Indicates if the server should be shutdown when theServerManager
is closed.T
shutdownOnClose(boolean shutdownOnClose)
-
-
-
Method Detail
-
create
public static StandaloneConfiguration create(org.wildfly.core.launcher.StandaloneCommandBuilder commandBuilder)
Creates a standalone configuration to launch a standalone server.- Parameters:
commandBuilder
- the standalone command builder used to launch the server- Returns:
- a new standalone configuration
-
create
public static StandaloneConfiguration create(org.wildfly.core.launcher.BootableJarCommandBuilder commandBuilder)
Creates a standalone configuration to launch a standalone server via the bootable JAR.- Parameters:
commandBuilder
- the bootable JAR command builder used to launch the server- Returns:
- a new standalone configuration
-
create
public static DomainConfiguration create(org.wildfly.core.launcher.DomainCommandBuilder commandBuilder)
Creates a domain configuration to launch a domain server- Parameters:
commandBuilder
- the domain command builder used to launch the server- Returns:
- a new domain configuration
-
client
public T client(org.jboss.as.controller.client.ModelControllerClient client)
Sets the client to use for the server manager.If the the server manager is closed, the client will also be closed.
- Parameters:
client
- the client to use to communicate with the server- Returns:
- this configuration
-
client
protected org.jboss.as.controller.client.ModelControllerClient client()
The client set on the configuration or a new client.- Returns:
- the client to use
-
managementAddress
public T managementAddress(String managementAddress)
The management address to use for the client if the client has not been set.- Parameters:
managementAddress
- the management address, default islocalhost
- Returns:
- this configuration
-
managementAddress
protected String managementAddress()
The management address set or127.0.0.1
if not set.- Returns:
- the management address
-
managementPort
public T managementPort(int managementPort)
The management port to use for the client if the client has not been set.- Parameters:
managementPort
- the management port, default is9990
- Returns:
- this configuration
-
managementPort
protected int managementPort()
The management port or9990
if set to 0 or less.- Returns:
- the management port
-
shutdownOnClose
public T shutdownOnClose(boolean shutdownOnClose)
- Parameters:
shutdownOnClose
-true
to shutdown the server when the server manager is closed- Returns:
- this configuration
-
shutdownOnClose
protected boolean shutdownOnClose()
Indicates if the server should be shutdown when theServerManager
is closed.- Returns:
true
to shutdown the server when the is closed
-
redirectErrorStream
public T redirectErrorStream(boolean redirectErrorStream)
Set totrue
if the error stream should be redirected to the output stream.- Parameters:
redirectErrorStream
-true
to merge the error stream into the output stream, otherwisefalse
to keep the streams separate- Returns:
- the Configuration
-
redirectOutput
public T redirectOutput(File file)
Redirects the output of the process to a file.- Parameters:
file
- the file to redirect the output to- Returns:
- the Configuration
- See Also:
ProcessBuilder.Redirect.to(java.io.File)
-
redirectOutput
public T redirectOutput(Path path)
Redirects the output of the process to a file.- Parameters:
path
- the path to redirect the output to- Returns:
- the Configuration
- See Also:
ProcessBuilder.Redirect.to(java.io.File)
-
redirectOutput
public T redirectOutput(ProcessBuilder.Redirect destination)
Redirects the output of the process to the destination provided.- Parameters:
destination
- the output destination- Returns:
- the Configuration
- See Also:
ProcessBuilder.redirectOutput(Redirect)
-
consumeStdout
protected boolean consumeStdout()
Checks if the output stream (stdout
) needs to be consumed.- Returns:
true
if the output stream should be consumed, otherwisefalse
-
redirectError
public T redirectError(File file)
Redirects the error stream of the process to a file.- Parameters:
file
- the file to redirect the error stream to- Returns:
- the Configuration
- See Also:
ProcessBuilder.Redirect.to(java.io.File)
-
redirectError
public T redirectError(ProcessBuilder.Redirect destination)
Redirects the error stream of the process to the destination provided.- Parameters:
destination
- the error stream destination- Returns:
- the Configuration
- See Also:
ProcessBuilder.redirectError(Redirect)
-
consumeStderr
protected boolean consumeStderr()
Checks if the error stream (stderr
) needs to be consumed.- Returns:
true
if the error stream should be consumed, otherwisefalse
-
directory
public T directory(Path path)
Sets the working directory for the process created.- Parameters:
path
- the path to the working directory- Returns:
- the Configuration
- See Also:
ProcessBuilder.directory(java.io.File)
-
directory
public T directory(File dir)
Sets the working directory for the process created.- Parameters:
dir
- the working directory- Returns:
- the Configuration
- See Also:
ProcessBuilder.directory(java.io.File)
-
directory
public T directory(String dir)
Sets the working directory for the process created.- Parameters:
dir
- the working directory- Returns:
- the Configuration
- See Also:
ProcessBuilder.directory(java.io.File)
-
addEnvironmentVariable
public T addEnvironmentVariable(String key, String value)
Adds an environment variable to the process being created. If the key or value isnull
, the environment variable will not be added.- Parameters:
key
- they key for the variablevalue
- the value for the variable- Returns:
- the Configuration
- See Also:
ProcessBuilder.environment()
-
addEnvironmentVariables
public T addEnvironmentVariables(Map<String,String> env)
Adds the environment variables to the process being created. Note thatnull
keys or values will not be added.- Parameters:
env
- the environment variables to add- Returns:
- the Configuration
- See Also:
ProcessBuilder.environment()
-
commandBuilder
protected org.wildfly.core.launcher.CommandBuilder commandBuilder()
The command builder used to create the launcher.- Returns:
- the command builder
-
launcher
protected org.wildfly.core.launcher.Launcher launcher()
A configured launcher for create the server process.- Returns:
- the configured launcher
-
launchType
protected abstract Configuration.LaunchType launchType()
The type of the server to launch.- Returns:
- the type of the server
-
self
protected abstract T self()
This instance.- Returns:
- this instance
-
-