Class NonUIClient
- java.lang.Object
- com.iizix.test.client.NonUIClient
 
- All Implemented Interfaces:
- GManagementConstants,- ISessionStatistics,- ISessionTransMgr,- TransactionCommListener,- EventListener,- GConstants,- IPropMgrOwner
 - public class NonUIClient extends java.lang.Object implements IPropMgrOwner, EventListener, ISessionTransMgr, TransactionCommListener, GConstants, GManagementConstants Class emulating a non-UI client. Subclasses can extend this class to provide some UI to display or to interact with.- Author:
- Christopher Mindus
 
- Field Summary- Fields inherited from interface com.iizix.GConstants- TRANS_ATOM, TRANS_BINARY_DATA, TRANS_BUSY, TRANS_CLIENT_LOCK, TRANS_CREATE, TRANS_DISPLAYTERMINAL, TRANS_DOWNLOAD_RESOURCES, TRANS_HOSTPRINT, TRANS_INIT, TRANS_INSTALL_RESOURCE, TRANS_LOG, TRANS_MANAGEMENT, TRANS_MESSAGE, TRANS_RELOAD, TRANS_REMOTE_CALL, TRANS_REMOTE_EVENT, TRANS_REMOTE_REPLY, TRANS_REMOVETERMINAL, TRANS_TERMINALUPDATE, TRANS_UPDATE
 - Fields inherited from interface com.iizix.comm.GManagementConstants- MT_CONNECTION, MT_DISPOSE_WHEN_CLOSED, MT_NEXT_SERIAL, MT_PING, MT_PONG, MT_PW, MT_RECONNECTION, MT_RESEND_TRANS
 
 - Constructor Summary- Constructors - Constructor - Description - NonUIClient(ClientManager manager, java.lang.String name, DestinationServer... destinations)Constructor.
 - Method Summary- All Methods Instance Methods Concrete Methods - Modifier and Type - Method - Description - boolean- addDestination(DestinationServer destination)Adds a new destination server.- protected void- configureSSLProps(SSLCommProps sslProps, DestinationServer destination)Configures the SSL properties for the destination server.- void- connect()Connects to one of the destination servers in turn.- protected SSLCommProps- createSSLProps(DestinationServer destination)The SSL properties, null for plain communication.- void- dispose()Disposes of the client manager.- void- doDispose(boolean doAbort)Called when the session ID has been disposed of by a call to its dispose method.- BusyState- getBusyState()Gets the client busy state.- java.lang.String- getClientContextMenuReference(UIContextMenu contextMenu)Gets the reference to use for a context menu.- DestinationServer[]- getDestinations()Gets the destination servers.- PropCnr- getRootProp()Gets the root property.- SessionMode- getSessionMode()Gets the session mode.- SessionStatistics- getSessionStatistics()Gets the statistics instance of the session.- protected SSLCommProps- getSSLProperties()Gets the SSL properties for this instance.- boolean- isDisposed()Checks if client is disposed of.- boolean- isVerbose()Gets the verbose flag.- protected void- log(int level, java.lang.String msg, java.lang.Object... params)Called to perform verbose logging.- protected void- onBusyChanged(BusyState busy)Perform a client lock/unlock.- void- onCommClosed(TransactionComm comm, int code, java.lang.String reason)Called when the communication link is closed.- void- onCommClosing(TransactionComm comm)Called when the communication link is closing.- void- onCommConnected(TransactionComm comm)Called when the communication link is connected.- void- onCommData(TransactionComm comm, ReadTransaction trans, int size)Called when the communication link has received data.- void- onCommError(TransactionComm comm, java.lang.Throwable e)Called when the communication link is closed.- void- onCommHeartBeat(TransactionComm comm, long duration)Called when the communication link has received data.- void- onCommTimeout(TransactionComm comm, boolean isReadTimeout)Called when the communication link has timed out on a read or write operation.- void- onEvent(GEvent event)Called to process an event due to a change in the some property in the UI root tree.- protected void- onPaused(long remainingTime)Called when the session enters pause mode.- protected void- onPong(long received, long duration)Pong transaction received.- void- onRemoteEventQueued()Called when a RemoteEvent has been added and needs sending (along with all properties, etc).- protected void- onSessionModeChanged(SessionMode mode)Called to inform a subclass that the session mode has changed.- protected void- processDisplayMessage(int severity, java.lang.String head, java.lang.String msg)Displays a message, or removes it.- protected void- processDownloadResources(ReadTransaction trans)Processes "download resources": only for iiziApp, but only performed for iiziRun.- protected void- processInstallResource(ReadTransaction trans)Processes "install resource".- protected void- processReloadPage()Processes "reload page".- void- reconnect()Connects to the last connected destination server.- boolean- requestPingPong()Requests a ping transaction.- void- setRequestedApp(java.lang.String appID, java.lang.String language, java.lang.String userID, java.lang.String password)Sets the Application ID to run, the User ID and Password to use for the connection.- protected void- setSSLProperties(SSLCommProps sslProps)Assigns the SSL properties.- void- setVerbose(boolean isVerbose)Sets the verbose flag, also used for new clients.- void- setWriteCacheParams(int minLength, int maxLength, int cacheCount)Sets the parameters for the write cache: minLength, maxLength, cacheCount.- protected void- triggerPostEventProcessing()Triggers a remote event to check checked for e.g.- Methods inherited from class java.lang.Object- clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - Methods inherited from interface com.iizix.comm.session.ISessionStatistics- getLastConnectionTime, getProperties, getProperty, setProperty
 
 
- Constructor Detail- NonUIClient- public NonUIClient(ClientManager manager, java.lang.String name, DestinationServer... destinations) throws java.io.IOException Constructor.- Parameters:
- manager- The client manager.
- name- The name of the client, null for default.
- Throws:
- java.io.IOException- If the worker cannot be created.
 
 
 - Method Detail- isVerbose- public final boolean isVerbose() Gets the verbose flag.- Returns:
- The verbose output flag on console.
 
 - setVerbose- public final void setVerbose(boolean isVerbose) Sets the verbose flag, also used for new clients.- By default, these settings are taken from the - ClientManagerinstance when the client session is created.- Parameters:
- isVerbose- The verbose output flag on console.
 
 - isDisposed- public final boolean isDisposed() Checks if client is disposed of.- Returns:
- true if disposed of, false otherwise.
 
 - dispose- public final void dispose() Disposes of the client manager. Calling this method will cause all client connections to be disposed of.- This method is the equivalent of calling - doDispose(false).
 - doDispose- public final void doDispose(boolean doAbort) Called when the session ID has been disposed of by a call to its dispose method.- Specified by:
- doDisposein interface- ISessionTransMgr
- Parameters:
- doAbort- Abort-flag, if true pending transaction are not sent.
 
 - log- protected void log(int level, java.lang.String msg, java.lang.Object... params)Called to perform verbose logging. This method can be overridden to e.g. store the output in separate files. Note that the method is called regardless of the verbose setting.- Parameters:
- level- The level of the event:- {@link ILog#SEVERE}to- {@link ILog#FINEST}.
- msg- The message.
- params- Optional parameters (could be a- Throwable, an- Array, a- Collection, etc.).
 
 - onPaused- protected void onPaused(long remainingTime) Called when the session enters pause mode. Subclasses can override this method to perform reconnection at some point in time...- Parameters:
- remainingTime- Time that remains to reconnect in milliseconds.
 
 - getSessionStatistics- public final SessionStatistics getSessionStatistics() Gets the statistics instance of the session.- Specified by:
- getSessionStatisticsin interface- ISessionStatistics
- Returns:
- The SessionStatistics instance.
 
 - getDestinations- public final DestinationServer[] getDestinations() Gets the destination servers.- Returns:
- The destination servers.
 
 - addDestination- public final boolean addDestination(DestinationServer destination) Adds a new destination server.- Parameters:
- destination- The destination.
- Returns:
- true if added, false if destination was already present.
 
 - setWriteCacheParams- public final void setWriteCacheParams(int minLength, int maxLength, int cacheCount)Sets the parameters for the write cache: minLength, maxLength, cacheCount. This call must be done prior to connecting the client.- By default, these settings are taken from the - ClientManagerinstance when the client session is created.- Parameters:
- minLength- The minimum length for caching, 7 is the smallest value.
- maxLength- The maximum length for caching, normally 80 or so (maximum 1024).
- cacheCount- The count should normally be larger than 200 and smaller than 1000 (maximum 2048), if zero, cache is disabled.
- Throws:
- java.lang.IllegalArgumentException- If arguments are not valid.
 
 - setSSLProperties- protected final void setSSLProperties(SSLCommProps sslProps) Assigns the SSL properties.- Parameters:
- sslProps- The SSL properties, null for defaults or for plain connection.
 
 - getSSLProperties- protected final SSLCommProps getSSLProperties() Gets the SSL properties for this instance.- Returns:
- The SSL properties, or null for plain connections or defaults.
 
 - createSSLProps- protected SSLCommProps createSSLProps(DestinationServer destination) The SSL properties, null for plain communication.- Parameters:
- destination- The destination server.
- Returns:
- The initialized SSL communication properties.
 
 - configureSSLProps- protected void configureSSLProps(SSLCommProps sslProps, DestinationServer destination) Configures the SSL properties for the destination server.- Parameters:
- sslProps- The SSL properties to reconfigure.
- destination- The destination server.
- Throws:
- java.lang.IllegalArgumentException- If the SocketCommProps cannot be found.
 
 - setRequestedApp- public final void setRequestedApp(java.lang.String appID, java.lang.String language, java.lang.String userID, java.lang.String password)Sets the Application ID to run, the User ID and Password to use for the connection.- Parameters:
- appID- The application ID (leading and trailing whitespaces are removed).
- language- The language code (or null for none). Must be a valid language code. Please note that the language code used for the client session is changed using- Locale.forLanguageTag(language).getDisplayLanguage().replace('_','-').
- userID- The user ID (leading and trailing whitespaces are removed).
- password- The password.
- Throws:
- java.lang.NullPointerException- If any parameter is null.
- java.lang.IllegalArgumentException- If any string is empty.
 
 - onSessionModeChanged- protected void onSessionModeChanged(SessionMode mode) Called to inform a subclass that the session mode has changed.- Subclasses can override this method to process it. - Parameters:
- mode- The new mode.
 
 - getSessionMode- public final SessionMode getSessionMode() Gets the session mode.- Returns:
- The current mode.
 
 - onBusyChanged- protected void onBusyChanged(BusyState busy) Perform a client lock/unlock. When client is unlocked, the component focus is set.- Subclasses can override this method to process it. - Parameters:
- busy- The busy state, or null for none. Note that the busy state may contain a progress indicator value in percent (0-100%).
 
 - getBusyState- public final BusyState getBusyState() Gets the client busy state. This state can also contain a progress indicator value.- Returns:
- The busy state, or null if not busy.
 
 - processReloadPage- protected void processReloadPage() Processes "reload page".- Subclasses can override this method to process it. - This would mean to reset and reload session entirely, skipping reconnect! - The current processing is to log a warning message: "Reload page requested from server". 
 - connect- public final void connect() throws java.security.UnrecoverableKeyException, java.security.KeyManagementException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.security.KeyStoreException, java.security.NoSuchProviderException, java.io.IOExceptionConnects to one of the destination servers in turn.- Throws:
- java.security.KeyStoreException- If no Provider supports a KeyStoreSpi implementation for the PKCS#12 type.
- java.security.NoSuchAlgorithmException- If the algorithm used to check the integrity of the key store cannot be found.
- java.security.cert.CertificateException- If any of the certificates in the key store could not be loaded.
- java.security.UnrecoverableKeyException- If the key cannot be recovered (e.g. the given password is wrong).
- java.security.NoSuchProviderException- TLS provider not found.
- java.security.KeyManagementException- Key management problems.
- java.io.IOException- If there is an I/O or format problem with the key store data, if a password is required but not given, or if the given password was incorrect. If the error is due to a wrong password, the cause of the IOException should be an UnrecoverableKeyException.
- java.lang.IllegalStateException- If no destination servers are not defined, or if disposed of, or the client manager is disposed of, or if the session already is connected.
 
 - reconnect- public final void reconnect() throws java.security.UnrecoverableKeyException, java.security.KeyManagementException, java.security.NoSuchAlgorithmException, java.security.cert.CertificateException, java.security.KeyStoreException, java.security.NoSuchProviderException, java.io.IOExceptionConnects to the last connected destination server.- Throws:
- java.security.KeyStoreException- If no Provider supports a KeyStoreSpi implementation for the PKCS#12 type.
- java.security.NoSuchAlgorithmException- If the algorithm used to check the integrity of the key store cannot be found.
- java.security.cert.CertificateException- If any of the certificates in the key store could not be loaded.
- java.security.UnrecoverableKeyException- If the key cannot be recovered (e.g. the given password is wrong).
- java.security.NoSuchProviderException- TLS provider not found.
- java.security.KeyManagementException- Key management problems.
- java.io.IOException- If there is an I/O or format problem with the key store data, if a password is required but not given, or if the given password was incorrect. If the error is due to a wrong password, the cause of the IOException should be an UnrecoverableKeyException.
- java.lang.IllegalStateException- If reconnection is not possible because the session is disposed of or is not in reconnectable state.
 
 - onEvent- public final void onEvent(GEvent event) Called to process an event due to a change in the some property in the UI root tree.- Specified by:
- onEventin interface- EventListener
- Parameters:
- event- The event.
 
 - getRootProp- public final PropCnr getRootProp() Gets the root property.- Returns:
- The root property, or nullif not yet created.
 
 - triggerPostEventProcessing- protected final void triggerPostEventProcessing() Triggers a remote event to check checked for e.g. new data or queued events. This method is called from- onEvent(GEvent)when the event is locally induced (i.e. not remote induced).
 - onRemoteEventQueued- public final void onRemoteEventQueued() Called when a RemoteEvent has been added and needs sending (along with all properties, etc).- Specified by:
- onRemoteEventQueuedin interface- IPropMgrOwner
 
 - getClientContextMenuReference- public java.lang.String getClientContextMenuReference(UIContextMenu contextMenu) Gets the reference to use for a context menu.- Specified by:
- getClientContextMenuReferencein interface- IPropMgrOwner
- Parameters:
- contextMenu- The context menu.
- Returns:
- The reference to use, empty string for none (never null).
 
 - onCommConnected- public final void onCommConnected(TransactionComm comm) Called when the communication link is connected.- Specified by:
- onCommConnectedin interface- TransactionCommListener
- Parameters:
- comm- The transaction communication instance.
 
 - onCommData- public final void onCommData(TransactionComm comm, ReadTransaction trans, int size) Called when the communication link has received data.- Specified by:
- onCommDatain interface- TransactionCommListener
- Parameters:
- comm- The transaction communication instance.
- trans- The transaction received.
- size- The size of the data received, as it may have been uncompressed.
 
 - onCommHeartBeat- public final void onCommHeartBeat(TransactionComm comm, long duration) Called when the communication link has received data.- Specified by:
- onCommHeartBeatin interface- TransactionCommListener
- Parameters:
- comm- The transaction communication instance.
- duration- The duration of the heart-beat in milliseconds.
 
 - onCommTimeout- public final void onCommTimeout(TransactionComm comm, boolean isReadTimeout) Called when the communication link has timed out on a read or write operation.- Specified by:
- onCommTimeoutin interface- TransactionCommListener
- Parameters:
- comm- The transaction communication instance.
- isReadTimeout- Flag indicating read timeout when true, false indicates write timeout.
 
 - onCommError- public final void onCommError(TransactionComm comm, java.lang.Throwable e) Called when the communication link is closed.- Specified by:
- onCommErrorin interface- TransactionCommListener
- Parameters:
- comm- The transaction communication instance.
- e- The exception.
 
 - onCommClosing- public final void onCommClosing(TransactionComm comm) Called when the communication link is closing.- Specified by:
- onCommClosingin interface- TransactionCommListener
- Parameters:
- comm- The transaction communication instance.
 
 - onCommClosed- public final void onCommClosed(TransactionComm comm, int code, java.lang.String reason) Called when the communication link is closed.- Specified by:
- onCommClosedin interface- TransactionCommListener
- Parameters:
- comm- The transaction communication instance.
 
 - requestPingPong- public boolean requestPingPong() Requests a ping transaction. When this is sent, the other party will reply with a pong transaction, and the start time will be used to measure the duration of the round-trip. Please note a potential logging overhead.- Returns:
- true for success, false for failure.
 
 - onPong- protected void onPong(long received, long duration)Pong transaction received.- Subclasses can override this method to process it. - Parameters:
- received- The time the transaction was received, milliseconds since the epoch.
- duration- Milliseconds it took to send PING and receive back PONG.
 
 - processInstallResource- protected void processInstallResource(ReadTransaction trans) Processes "install resource".- Subclasses can override this method to process it. - Parameters:
- trans- The read transaction.
 
 - processDownloadResources- protected void processDownloadResources(ReadTransaction trans) Processes "download resources": only for iiziApp, but only performed for iiziRun.- Subclasses can override this method to process it. - Parameters:
- trans- The read transaction.
 
 - processDisplayMessage- protected void processDisplayMessage(int severity, java.lang.String head, java.lang.String msg)Displays a message, or removes it.- Subclasses can override this method to process it. - Parameters:
- severity- The message severity:- 0: INFORMATION
- 1: WARNING
- 2: ERROR
- 255: "None"
 
- head- Message heading, could be empty string.
- msg- The message: if empty string, the message is removed on the client side.