public class ProcessClientSpawner extends ClientSpawner
This class is tricky to understand because the main part of it runs on the server while the
TemporaryClientTask
inner class is serialized and sent down to execute on the
client side. That client side code then calls methods which are implemented as a remote
object with the Spawner
interface, which the server portions of this class implement.
The spawner process will connect to the server using a secure socket and temporary credentials to establish a secure session. If that works, it will lookup the credentials to use for spawning the client based on a unique UUID for this spawning session. Using those credentials it will start the client and notify the server about success or failure.
This notification must not be treated as the client process authenticated successfully; it needs to be interpreted as a signal that the temporary connection has finished successfully.
Modifier and Type | Class and Description |
---|---|
private static class |
ProcessClientSpawner.TemporaryClientTask
On P2J client side, it will do custom work after authenticating using the temporary
credentials.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
process
The P2J process ID being spawned by this instance.
|
cb, cfg
Constructor and Description |
---|
ProcessClientSpawner(java.lang.String process)
Create a new spawner for P2J processes.
|
Modifier and Type | Method and Description |
---|---|
java.io.Serializable |
allocateClient(java.lang.String host)
Allocates the system resources for the spawned client if it is necessarily.
|
protected ClientBuilder |
getBuilder(ClientBuilderParameters cfg)
Get a
ProcessClientBuilder used to spawn P2J clients for the target process . |
java.lang.Object |
getServerData()
Get a map containing the P2J process secure credentials: the serialized process keystore and
trust store and other details, like target aliases in the keystore and truststore.
|
TemporaryClient |
getTemporaryClient()
Get a
TemporaryClient worker which will do the work after authenticating on the P2J
server using the temporary credentials. |
static void |
launch(java.lang.String batchProcess)
Launch the specified batch process.
|
void |
releaseClient()
Releases the system resources for this spawned client.
|
clientIsReady, getExitCode, spawn
private java.lang.String process
public ProcessClientSpawner(java.lang.String process)
process
- The P2J process ID.public static void launch(java.lang.String batchProcess)
If the P2J process is linked with an appserver, it will delegate the launching to
AppServerLauncher.launch(java.lang.String)
. Else, it will use the spawner
infrastructure to start a P2J client.
batchProcess
- The name of the batch process to be launched.public java.lang.Object getServerData()
protected ClientBuilder getBuilder(ClientBuilderParameters cfg)
ProcessClientBuilder
used to spawn P2J clients for the target process
.getBuilder
in class ClientSpawner
cfg
- The P2J web client configuration.public TemporaryClient getTemporaryClient()
TemporaryClient
worker which will do the work after authenticating on the P2J
server using the temporary credentials.public java.io.Serializable allocateClient(java.lang.String host) throws Spawner.OutOfResources
host
- The remote host for the spawned clientSpawner.OutOfResources
- If the required resources can't be allocated.public void releaseClient()
SpawnerListener