public abstract class ClientBuilder
extends java.lang.Object
ProcessBuilder instance. A special small tools are designed for
Linux / Windows OS in order to spawn the process on the OS user account.
Both tools are written in C using specific OS API and are build as executable
using ant native target. The source code and the make file for this tools are
available in the /src/native process directory.
The password is provided vis stdin redirection on both platforms.
The command line parameters for the spawned process are constructed from default
parameters stored in directory and some specific parameters stored inside a
ClientBuilderParameters structure.| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<java.lang.String> |
command
A collection of command line tokens
|
private static CentralLogger |
LOG
Logger
|
private java.lang.ProcessBuilder |
pb
The ProcessBuilder instance
|
private static java.util.Map<java.lang.String,java.lang.String[]> |
pendingCmds
Pending spawn commands to be retrieved by remote clients.
|
protected boolean |
remote
Indicate a remote or local spawn
|
| Constructor and Description |
|---|
ClientBuilder() |
| Modifier and Type | Method and Description |
|---|---|
private void |
addClasspath()
Add Java CLASSPATH and the main class.
|
protected abstract void |
addClientOptions()
Add custom client options to the
command. |
private void |
addConfigFile()
Add client configuration file if exists.
|
private boolean |
addConfigIfExisting(BootstrapConfig config,
ConfigItem<java.lang.Integer> clientConfig)
Get a key value form configuration file.
|
private void |
addServerOptions(boolean secure)
Add server properties.
|
private <T> void |
addToCommand(ConfigItem<T> clientConfig,
T value)
Adds a config option name : value to the command.
|
private void |
buildCommand()
Build command for spawned process.
|
static java.lang.String[] |
getCommand(java.lang.String uuid)
Get the spawn command registered for this UUID.
|
abstract ClientBuilderParameters |
getParams()
Returns the
ClientBuilderParameters used for building the client. |
protected abstract java.util.List<java.lang.String> |
getSpawnArguments()
Get the spawn arguments for a specific implementation.
|
(package private) void |
initNativeSecureConnection(java.util.List<java.lang.String> cmd)
Initialize the command line parameters for a native secure connection, which is the
secure authentication method used for non-interactive clients and those interactive clients
which cannot be launched using a password.
|
java.lang.Process |
localStart(java.util.Map<java.lang.String,java.lang.String> env)
Spawn's new local Java process.
|
private java.util.List<java.lang.String> |
prepareToLaunch()
Prepare command line arguments for spawned process before to start.
|
BrokerSpawnResult |
remoteStart(java.lang.String dedicatedUser,
Brokers brokers,
java.util.Map<java.lang.String,java.lang.String> env)
Spawn's new remote Java process.
|
BrokerSpawnResult |
remoteStart(java.lang.String dedicatedUser,
Brokers brokers,
java.util.Map<java.lang.String,java.lang.String> env,
WebClientAllocator allocator,
java.lang.String[] requestParameters)
Spawn's new remote Java process.
|
static void |
removeCommand(java.lang.String uuid)
Remove the spawn command registered for this UUID.
|
private static final CentralLogger LOG
private static final java.util.Map<java.lang.String,java.lang.String[]> pendingCmds
protected final java.util.List<java.lang.String> command
protected boolean remote
private java.lang.ProcessBuilder pb
public abstract ClientBuilderParameters getParams()
ClientBuilderParameters used for building the client.public static java.lang.String[] getCommand(java.lang.String uuid)
uuid - The UUID.public static void removeCommand(java.lang.String uuid)
uuid - The UUID.protected abstract void addClientOptions()
command. Don't use for options critical for initial
client configuration.protected abstract java.util.List<java.lang.String> getSpawnArguments()
public java.lang.Process localStart(java.util.Map<java.lang.String,java.lang.String> env)
throws java.io.IOException
env - A map with environment variables for temporary account.java.io.IOException - If something goes wrong.public BrokerSpawnResult remoteStart(java.lang.String dedicatedUser, Brokers brokers, java.util.Map<java.lang.String,java.lang.String> env)
dedicatedUser - The dedicated user associated with the host on which the spawned client
will be runbrokers - List of brokers.env - A map with environment variables for temporary account.public BrokerSpawnResult remoteStart(java.lang.String dedicatedUser, Brokers brokers, java.util.Map<java.lang.String,java.lang.String> env, WebClientAllocator allocator, java.lang.String[] requestParameters)
dedicatedUser - The dedicated user associated with the host on which the spawned client
will be runbrokers - List of brokers.env - A map with environment variables for temporary account.allocator - The web client allocatorrequestParameters - The given requests parametersvoid initNativeSecureConnection(java.util.List<java.lang.String> cmd)
spawn
tool using the spawn 0 <secure-port> <server-hostname> <server-alias> <uuid>
syntax.cmd - The data structure to initialize with the parametes for the native secure
connection.private java.util.List<java.lang.String> prepareToLaunch()
private void addServerOptions(boolean secure)
secure - Indicating to setup a secure true
or an insecure false connection.private boolean addConfigIfExisting(BootstrapConfig config, ConfigItem<java.lang.Integer> clientConfig)
config - Configuration file.clientConfig - The client config to be read and added.true if successfully added, false otherwise.private <T> void addToCommand(ConfigItem<T> clientConfig, T value)
clientConfig - The client config to be read and added.value - The value to be added.private void addClasspath()
private void addConfigFile()
private void buildCommand()