Class NonUIClient
- All Implemented Interfaces:
- GManagementConstants,- ISessionStatistics,- ISessionTransMgr,- TransactionCommListener,- EventListener,- GConstants,- IPropMgrOwner
- 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 SummaryConstructorsConstructorDescription- NonUIClient- (ClientManager manager, String name, DestinationServer... destinations) Constructor.
- Method SummaryModifier and TypeMethodDescription- final boolean- addDestination- (DestinationServer destination) Adds a new destination server.- protected void- configureSSLProps- (SSLCommProps sslProps, DestinationServer destination) Configures the SSL properties for the destination server.- final void- connect()Connects to one of the destination servers in turn.- protected SSLCommProps- createSSLProps- (DestinationServer destination) The SSL properties, null for plain communication.- final void- dispose()Disposes of the client manager.- final void- doDispose- (boolean doAbort) Called when the session ID has been disposed of by a call to its dispose method.- final BusyStateGets the client busy state.- getClientContextMenuReference- (UIContextMenu contextMenu) Gets the reference to use for a context menu.- final DestinationServer[]Gets the destination servers.- final PropCnrGets the root property.- final SessionModeGets the session mode.- final SessionStatisticsGets the statistics instance of the session.- protected final SSLCommPropsGets the SSL properties for this instance.- final booleanChecks if client is disposed of.- final booleanGets the verbose flag.- protected voidCalled to perform verbose logging.- protected void- onBusyChanged- (BusyState busy) Perform a client lock/unlock.- final void- onCommClosed- (TransactionComm comm, int code, String reason) Called when the communication link is closed.- final void- onCommClosing- (TransactionComm comm) Called when the communication link is closing.- final voidCalled when the communication link is connected.- final void- onCommData- (TransactionComm comm, ReadTransaction trans, int size) Called when the communication link has received data.- final void- onCommError- (TransactionComm comm, Throwable e) Called when the communication link is closed.- final void- onCommHeartBeat- (TransactionComm comm, long duration) Called when the communication link has received data.- final void- onCommTimeout- (TransactionComm comm, boolean isReadTimeout) Called when the communication link has timed out on a read or write operation.- final voidCalled 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.- final voidCalled when a RemoteEvent has been added and needs sending (along with all properties, etc).- protected voidCalled to inform a subclass that the session mode has changed.- protected void- processDisplayMessage- (int severity, String head, String msg) Displays a message, or removes it.- protected voidProcesses "download resources": only for iiziApp, but only performed for iiziRun.- protected voidProcesses "install resource".- protected voidProcesses "reload page".- final voidConnects to the last connected destination server.- booleanRequests a ping transaction.- final void- setRequestedApp- (String appID, String language, String userID, String password) Sets the Application ID to run, the User ID and Password to use for the connection.- protected final void- setSSLProperties- (SSLCommProps sslProps) Assigns the SSL properties.- final void- setVerbose- (boolean isVerbose) Sets the verbose flag, also used for new clients.- final void- setWriteCacheParams- (int minLength, int maxLength, int cacheCount) Sets the parameters for the write cache: minLength, maxLength, cacheCount.- protected final voidTriggers 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 Details- NonUIClientpublic NonUIClient- (ClientManager manager, String name, DestinationServer... destinations) throws IOException Constructor.- Parameters:
- manager- The client manager.
- name- The name of the client, null for default.
- Throws:
- IOException- If the worker cannot be created.
 
 
- Method Details- isVerbosepublic final boolean isVerbose()Gets the verbose flag.- Returns:
- The verbose output flag on console.
 
- setVerbosepublic 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.
 
- isDisposedpublic final boolean isDisposed()Checks if client is disposed of.- Returns:
- true if disposed of, false otherwise.
 
- disposepublic 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).
- doDisposepublic 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.
 
- logCalled 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.).
 
- onPausedprotected 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.
 
- getSessionStatisticsGets the statistics instance of the session.- Specified by:
- getSessionStatisticsin interface- ISessionStatistics
- Returns:
- The SessionStatistics instance.
 
- getDestinationsGets the destination servers.- Returns:
- The destination servers.
 
- addDestinationAdds a new destination server.- Parameters:
- destination- The destination.
- Returns:
- true if added, false if destination was already present.
 
- setWriteCacheParamspublic 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:
- IllegalArgumentException- If arguments are not valid.
 
- setSSLPropertiesAssigns the SSL properties.- Parameters:
- sslProps- The SSL properties, null for defaults or for plain connection.
 
- getSSLPropertiesGets the SSL properties for this instance.- Returns:
- The SSL properties, or null for plain connections or defaults.
 
- createSSLPropsThe SSL properties, null for plain communication.- Parameters:
- destination- The destination server.
- Returns:
- The initialized SSL communication properties.
 
- configureSSLPropsConfigures the SSL properties for the destination server.- Parameters:
- sslProps- The SSL properties to reconfigure.
- destination- The destination server.
- Throws:
- IllegalArgumentException- If the SocketCommProps cannot be found.
 
- setRequestedAppSets 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:
- NullPointerException- If any parameter is null.
- IllegalArgumentException- If any string is empty.
 
- onSessionModeChangedCalled to inform a subclass that the session mode has changed.- Subclasses can override this method to process it. - Parameters:
- mode- The new mode.
 
- getSessionModeGets the session mode.- Returns:
- The current mode.
 
- onBusyChangedPerform 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%).
 
- getBusyStateGets the client busy state. This state can also contain a progress indicator value.- Returns:
- The busy state, or null if not busy.
 
- processReloadPageprotected 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". 
- connectpublic final void connect() throws UnrecoverableKeyException, KeyManagementException, NoSuchAlgorithmException, CertificateException, KeyStoreException, NoSuchProviderException, IOExceptionConnects to one of the destination servers in turn.- Throws:
- KeyStoreException- If no Provider supports a KeyStoreSpi implementation for the PKCS#12 type.
- NoSuchAlgorithmException- If the algorithm used to check the integrity of the key store cannot be found.
- CertificateException- If any of the certificates in the key store could not be loaded.
- UnrecoverableKeyException- If the key cannot be recovered (e.g. the given password is wrong).
- NoSuchProviderException- TLS provider not found.
- KeyManagementException- Key management problems.
- 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.
- 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.
 
- reconnectpublic final void reconnect() throws UnrecoverableKeyException, KeyManagementException, NoSuchAlgorithmException, CertificateException, KeyStoreException, NoSuchProviderException, IOExceptionConnects to the last connected destination server.- Throws:
- KeyStoreException- If no Provider supports a KeyStoreSpi implementation for the PKCS#12 type.
- NoSuchAlgorithmException- If the algorithm used to check the integrity of the key store cannot be found.
- CertificateException- If any of the certificates in the key store could not be loaded.
- UnrecoverableKeyException- If the key cannot be recovered (e.g. the given password is wrong).
- NoSuchProviderException- TLS provider not found.
- KeyManagementException- Key management problems.
- 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.
- IllegalStateException- If reconnection is not possible because the session is disposed of or is not in reconnectable state.
 
- onEventCalled 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.
 
- getRootPropGets the root property.- Returns:
- The root property, or nullif not yet created.
 
- triggerPostEventProcessingprotected 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).
- onRemoteEventQueuedpublic final void onRemoteEventQueued()Called when a RemoteEvent has been added and needs sending (along with all properties, etc).- Specified by:
- onRemoteEventQueuedin interface- IPropMgrOwner
 
- getClientContextMenuReferenceGets 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).
 
- onCommConnectedCalled when the communication link is connected.- Specified by:
- onCommConnectedin interface- TransactionCommListener
- Parameters:
- comm- The transaction communication instance.
 
- onCommDataCalled 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.
 
- onCommHeartBeatCalled 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.
 
- onCommTimeoutCalled 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.
 
- onCommErrorCalled when the communication link is closed.- Specified by:
- onCommErrorin interface- TransactionCommListener
- Parameters:
- comm- The transaction communication instance.
- e- The exception.
 
- onCommClosingCalled when the communication link is closing.- Specified by:
- onCommClosingin interface- TransactionCommListener
- Parameters:
- comm- The transaction communication instance.
 
- onCommClosedCalled when the communication link is closed.- Specified by:
- onCommClosedin interface- TransactionCommListener
- Parameters:
- comm- The transaction communication instance.
 
- requestPingPongpublic 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.
 
- onPongprotected 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.
 
- processInstallResourceProcesses "install resource".- Subclasses can override this method to process it. - Parameters:
- trans- The read transaction.
 
- processDownloadResourcesProcesses "download resources": only for iiziApp, but only performed for iiziRun.- Subclasses can override this method to process it. - Parameters:
- trans- The read transaction.
 
- processDisplayMessageDisplays 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.