Package ej.net

Class HttpPollerConnectivityManager


  • public class HttpPollerConnectivityManager
    extends PollerConnectivityManager
    Basic full java implementation. Consider the network is connected when there is at least one NetworkInterface which address is not 0.0.0.0. It uses an HTTP request to check if it is connected to internet.
    • Constructor Detail

      • HttpPollerConnectivityManager

        public HttpPollerConnectivityManager()
        Instantiates an HttpPollerConnectivityManager with System properties values. It uses the system properties:
        • connectivity.http.host
        • connectivity.http.port (optional default value is 80)
        • connectivity.http.payload (optional default value will do a get at the root of the host)
        See Also:
        PollerConnectivityManager()
      • HttpPollerConnectivityManager

        public HttpPollerConnectivityManager​(Timer timer)
        Instantiates an HttpPollerConnectivityManager with System properties values. It uses the system properties:
        • connectivity.http.host
        • connectivity.http.port (optional default value is 80)
        • connectivity.http.payload (optional default value will do a get at the root of the host)
        Parameters:
        timer - the timer to use, cannot be null.
        See Also:
        PollerConnectivityManager()
      • HttpPollerConnectivityManager

        public HttpPollerConnectivityManager​(Timer timer,
                                             long delay,
                                             long periodWhenAvaialble,
                                             long periodWhenLost,
                                             long periodWhenInternet)
        Instantiates an HttpPollerConnectivityManager with arguments values.
        Parameters:
        timer - the timer to use, cannot be null.
        delay - the delay before the start.
        periodWhenAvaialble - the period for the polling when at least one interface is available.
        periodWhenLost - the period for the polling when all the interface are down.
        periodWhenInternet - the period for the polling when there is internet access.
    • Method Detail

      • setHttpValues

        public void setHttpValues​(@Nullable
                                  String host,
                                  @Nullable
                                  String payload,
                                  int port)
        Sets the http values.
        Parameters:
        host - the host to use, cannot be null.
        payload - the payload to send, if null a simple get request at the root will be used.
        port - the port to use.