Class NonUIClient

java.lang.Object
com.iizix.test.client.NonUIClient
All Implemented Interfaces:
GManagementConstants, ISessionStatistics, ISessionTransMgr, TransactionCommListener, EventListener, GConstants, IPropMgrOwner

Class emulating a non-UI client. Subclasses can extend this class to provide some UI to display or to interact with.
Author:
Christopher Mindus
  • Constructor Details

  • Method Details

    • 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 ClientManager instance 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:
      doDispose in interface ISessionTransMgr
      Parameters:
      doAbort - Abort-flag, if true pending transaction are not sent.
    • log

      protected void log(int level, String msg, 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:
      getSessionStatistics in 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 ClientManager instance 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.
    • 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:
      IllegalArgumentException - If the SocketCommProps cannot be found.
    • setRequestedApp

      public 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.
      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.
    • 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

      Connects 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.
    • reconnect

      Connects 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.
    • 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:
      onEvent in interface EventListener
      Parameters:
      event - The event.
    • getRootProp

      public final PropCnr getRootProp()
      Gets the root property.
      Returns:
      The root property, or null if 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:
      onRemoteEventQueued in interface IPropMgrOwner
    • getClientContextMenuReference

      public String getClientContextMenuReference(UIContextMenu contextMenu)
      Gets the reference to use for a context menu.
      Specified by:
      getClientContextMenuReference in 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:
      onCommConnected in 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:
      onCommData in 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:
      onCommHeartBeat in interface TransactionCommListener
      Parameters:
      comm - The transaction communication instance.
      duration - The duration of the heart-beat in nanoseconds.
    • 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:
      onCommTimeout in 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, Throwable e)
      Called when the communication link is closed.
      Specified by:
      onCommError in 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:
      onCommClosing in interface TransactionCommListener
      Parameters:
      comm - The transaction communication instance.
    • onCommClosed

      public final void onCommClosed(TransactionComm comm, int code, String reason)
      Called when the communication link is closed.
      Specified by:
      onCommClosed in 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, String head, 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.