Class ClientManager

  • public class ClientManager
    extends java.lang.Object
    Class to manage clients connections.
    Christopher Mindus
    • Method Detail

      • getInstance

        public static ClientManager getInstance()
        Gets the client manager singleton instance.
        The client manager instance.
      • getCurrentNonUIClient

        public static NonUIClient getCurrentNonUIClient()
        Gets the NonUIClient instance or its subclass from the current thread.
        The NonUIClient instance or null if thread does not belong to the any client instance.
      • getPropFactory

        public PropFactory getPropFactory()
        Gets the property factory.
        The PropFactory instance initialized as CLIENT.
      • isVerbose

        public boolean isVerbose()
        Gets the verbose flag.
        The verbose output flag on console.
      • setVerbose

        public void setVerbose​(boolean isVerbose)
        Sets the verbose flag, also used for new clients.
        isVerbose - The verbose output flag on console.
      • setWriteCacheParams

        public void setWriteCacheParams​(int minLength,
                                        int maxLength,
                                        int cacheCount)
        Sets the parameters for the write cache: minLength, maxLength, cacheCount. This call must be done creating a new client.
        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 (range is 10 to 2048), if zero, cache is disabled.
        java.lang.IllegalArgumentException - If arguments are not valid.
      • getCacheMinLength

        public int getCacheMinLength()
        Gets the minimum length for string caching.
        The minimum length.
      • getCacheMaxLength

        public int getCacheMaxLength()
        Gets the maximum length for string caching.
        The maximum length.
      • getCacheCount

        public int getCacheCount()
        Gets the count for the write cache.
        The count of cached strings in the write cache.
      • setMaxTransactionQueueSize

        public void setMaxTransactionQueueSize​(int size)
        Sets the maximum queued transaction to keep. This method must be called prior to creating a client.
        size - The size, default is 10.
        java.lang.IllegalArgumentException - If less than 2 and more than 100.
      • getMaxTransactionQueueSize

        public int getMaxTransactionQueueSize()
        Gets the maximum queued transactions to keep.
        The size, range between 2 and 100, default is 10.
      • setRequestedApp

        public 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.
        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.
        java.lang.NullPointerException - If any parameter is null.
        java.lang.IllegalArgumentException - If any string is empty.
      • createDefaultClient

        public NonUIClient createDefaultClient​(DestinationServer... destinations)
        Creates a new DefaultClient.
        destinations - The destinations.
        Throws: - If the worker cannot be created.
        java.lang.IllegalStateException - If client manager is disposed of.
      • getClients

        public NonUIClient[] getClients()
        Gets all the clients.
        The clients array.
      • isDisposed

        public boolean isDisposed()
        Checks if client manager is disposed of.
        true if disposed of, false otherwise.
      • dispose

        public int dispose​(long timeout)
        Disposes of the client manager. Calling this method will cause all client connections to be disposed of.
        timeout - The maximum time to wait for clients to complete, -1L for indefinite timeout. The timeout wait can be interrupted if you call the thread's interrupt() method.
        zero for success, otherwise the remaining disposed but still not terminated client sessions. If called when already disposed of, -1 is returned.