Class ConnectionChecker

    • Method Detail

      • getInstance

        public static ConnectionChecker getInstance()
        Returns singleton instance
        Returns:
      • isStarted

        public boolean isStarted()
        Returns checker state

        Checker is started automatically when util module is loaded

        Returns:
        checker state
      • start

        public void start()
        Starting checker.

        Checking timer starts immediately, with default period 2000 ms.

      • stop

        public void stop()
        Stopping checker
      • isOnline

        public boolean isOnline()
        Returns online status

        Boolean type is used to be able to return answer "I don't know" in case the checker is not running

        First testing if there is a connection. This should be quite fast. If connection is available, then return result of test in timer.

        NOTE: Displable fast check since this could be blocking in case of slow dns server method just returns online state now.
        Returns:
        online status
      • addPropertyChangeListener

        public void addPropertyChangeListener​(PropertyChangeListener listener)
        Add property change listener

        Listener is fired with property name status in case status changes (online->offline, offline->online)

        Parameters:
        listener -
      • removePropertyChangeListener

        public void removePropertyChangeListener​(PropertyChangeListener listener)
        Remove property change listener
        Parameters:
        listener -
      • getCheckPeriod

        public long getCheckPeriod()
        Return time in milliseconds between two checks
        Returns:
      • setCheckPeriod

        public void setCheckPeriod​(long checkPeriod)
        Set time in milliseconds between two checks

        To apply new settings call restart()

        Parameters:
        checkPeriod -
      • getHostName

        public String getHostName()
        Return hostname, that is used to checked online status
        Returns:
      • setHostName

        public void setHostName​(String hostName)
        Set hostname to check online status

        To apply new settings call restart()

        Parameters:
        hostName -
      • getPortNumber

        public int getPortNumber()
        Return checked port number
        Returns:
      • setPortNumber

        public void setPortNumber​(int portNumber)
        Set port number

        To apply new settings call restart()

        Parameters:
        portNumber -
      • restart

        public void restart()
        Restart checker to apply new settings.

        Actually calling stop() and start()