public abstract class ClientSpawner<R extends java.io.Serializable> extends java.lang.Object implements SpawnerListener<R>
Actual implementations of this class will need to provide the following info:
ClientBuilder
instance, to spawn the P2J client process.ClientBuilderParameters
instance, to configure the P2J client.SpawnerListener.getServerData()
, to send custom data
back to the P2J client.SpawnerListener.getTemporaryClient()
, with the work
needed to be done after authenticating with the temporary credentials.Modifier and Type | Field and Description |
---|---|
protected ClientBuilder |
cb
The
ClientBuilder used to spawn the P2J client process. |
protected ClientBuilderParameters |
cfg
The configuration for this spawner.
|
private int |
exitCode
Spawner exit code
|
private java.util.concurrent.CountDownLatch |
latch
Synchronize
|
private static java.util.logging.Logger |
LOG
Logger.
|
private boolean |
ready
Flag indicating the P2J client has been started.
|
private static int |
TIME_OUT
Timeout
|
Constructor and Description |
---|
ClientSpawner(ClientBuilderParameters cfg)
Configure a new client spawner.
|
Modifier and Type | Method and Description |
---|---|
void |
clientIsReady(java.lang.Object data)
Notify when the client has started.
|
protected abstract ClientBuilder |
getBuilder(ClientBuilderParameters cfg)
Get a
ClientBuilder used to spawn P2J clients. |
int |
getExitCode()
Return spawner exit code
|
void |
spawn(java.lang.String userName,
java.lang.String password,
java.util.Map<java.lang.String,java.lang.String> envVars)
Launch a P2J client local or remote.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
allocateClient, getServerData, getTemporaryClient, releaseClient
private static final java.util.logging.Logger LOG
private static final int TIME_OUT
protected ClientBuilder cb
ClientBuilder
used to spawn the P2J client process.protected final ClientBuilderParameters cfg
private int exitCode
private java.util.concurrent.CountDownLatch latch
private volatile boolean ready
public ClientSpawner(ClientBuilderParameters cfg)
cfg
- The spawner configuration.protected abstract ClientBuilder getBuilder(ClientBuilderParameters cfg)
ClientBuilder
used to spawn P2J clients.cfg
- The P2J client configuration.public void spawn(java.lang.String userName, java.lang.String password, java.util.Map<java.lang.String,java.lang.String> envVars)
userName
- User name.password
- User password.envVars
- Environment variables to set. May be null
.public int getExitCode()
public void clientIsReady(java.lang.Object data)
clientIsReady
in interface SpawnerListener<R extends java.io.Serializable>
data
- Custom data sent by the P2J client back to the server.