public class ClientCore
extends java.lang.Object
This code provides supports the startup of a client session within the same process as the server. This can be used to duplicate the traditional Progress 4GL fat client approach (a "single process" mode). It can also be used to implement multiple client sessions within a true server process which would be used to support web-based clients.
| Modifier and Type | Class and Description |
|---|---|
static class |
ClientCore.InitStruct
Structure used for passing several values to and from
initialize(InitStruct, BootstrapConfig, String)
method. |
| Modifier and Type | Field and Description |
|---|---|
private static CentralLogger |
LOG
Logger.
|
private static boolean |
nativeLayerInitialized
Flag to prevent multiple native library loading.
|
| Constructor and Description |
|---|
ClientCore() |
| Modifier and Type | Method and Description |
|---|---|
private static BootstrapConfig |
buildTemporaryClientConfig(BootstrapConfig config)
Build a separate BootstrapConfig for temporary clients.
|
private static int |
getLinuxScreenColorDepth()
Returns the found screen color depth in Linux.
|
private static java.lang.String |
getOsDeviceId()
Returns the OS specific device ID.
|
static long |
getPid()
Native call to read the operating system pid for the current JVM process.
|
static java.lang.String |
getUserName()
Native call to read the operating system user name for the current JVM process.
|
static void |
initialize(ClientCore.InitStruct is,
BootstrapConfig config,
java.lang.String uuid)
Initialize client.
|
static boolean |
isCauseStop(java.lang.Throwable chained)
Inspect the chain of exceptions and report if any of them are STOP
conditions.
|
static boolean |
isNativeLayerInitialized()
Returns a flag to indicate if native library has loaded.
|
static void |
loadNativeLibrary()
Loads native library and performs required initial steps for P2J library to working.
|
(package private) static void |
outputDiagnostics(BootstrapConfig config,
java.util.function.Supplier<java.lang.String> diagnostics)
Render the diagnostics as text and output this to the log.
|
private static ClientParameters |
processClientParams(ScreenDriver<?> driver,
BootstrapConfig config)
Pull the client parameters from the driver and bootstrap configuration and initialize
a parameters object with the resulting data.
|
static void |
processInit()
Native call to set up and redefine signal processing handlers.
|
static ScreenDriver<?> |
processTemporaryClient(java.lang.String uuid,
BootstrapConfig config,
java.util.function.Supplier<java.lang.String> diag)
Establish a direct connection using the temporary credentials and perform custom work,
depending on the
TemporaryClient implementation returned by
Spawner.getTemporaryClient(java.lang.String, java.lang.String). |
static void |
setOutputToFile(BootstrapConfig config)
Reads server:clientConfig:outputToFile config from BootstrapConfig,
replaces the placeholder %pid% with the current process id
and redirects stdout to the file path defined as outputToFile.
|
static void |
start(BootstrapConfig config,
java.util.function.Supplier<java.lang.String> diag)
Start the client loop.
|
private static final CentralLogger LOG
private static boolean nativeLayerInitialized
public static boolean isNativeLayerInitialized()
public static void initialize(ClientCore.InitStruct is, BootstrapConfig config, java.lang.String uuid)
is - initialization structure in/out.config - The configuration to use for setup of the client and for the
server connection.uuid - server:spawner:uuid configuration valuepublic static void start(BootstrapConfig config, java.util.function.Supplier<java.lang.String> diag) throws java.lang.Exception
config - The configuration to use for setup of the client and for the
server connection.diag - Details about the driver state that can help diagnose server startup issues.java.lang.Exceptionpublic static boolean isCauseStop(java.lang.Throwable chained)
chained - The top of the chain of exceptions.true if any of the exceptions in the chain are
STOP conditions.public static void setOutputToFile(BootstrapConfig config)
config - Reference to the configuration reader.public static void loadNativeLibrary()
public static void processInit()
public static long getPid()
public static java.lang.String getUserName()
static void outputDiagnostics(BootstrapConfig config, java.util.function.Supplier<java.lang.String> diagnostics)
config - The bootstrap configuration for this client.diagnostics - Details about the client process.private static BootstrapConfig buildTemporaryClientConfig(BootstrapConfig config)
config - Client bootstrap configuration.private static ClientParameters processClientParams(ScreenDriver<?> driver, BootstrapConfig config)
driver - The primary UI driver for this client session.config - The bootstrap configuration for this session (this must have been previously
merged with any command line overrides).public static ScreenDriver<?> processTemporaryClient(java.lang.String uuid, BootstrapConfig config, java.util.function.Supplier<java.lang.String> diag) throws java.lang.Exception
TemporaryClient implementation returned by
Spawner.getTemporaryClient(java.lang.String, java.lang.String).uuid - Remote client identifier uuid.config - The configuration to use for setup of the client and for the server connection.diag - Details about the driver state that can help diagnose server startup issues.TemporaryClient.doWork(com.goldencode.p2j.main.Spawner, com.goldencode.p2j.cfg.BootstrapConfig, java.util.function.Supplier<java.lang.String>).java.lang.Exception - If something goes wrong.private static java.lang.String getOsDeviceId()
private static int getLinuxScreenColorDepth()