Class SwitchableMasterUriProvider

java.lang.Object
org.ros.master.uri.SwitchableMasterUriProvider
All Implemented Interfaces:
MasterUriProvider

public class SwitchableMasterUriProvider extends Object implements MasterUriProvider
A proxying MasterUriProvider which can be switched between providers.

This class is thread-safe.

Author:
Keith M. Hughes
  • Constructor Details

    • SwitchableMasterUriProvider

      public SwitchableMasterUriProvider(MasterUriProvider provider)
      Parameters:
      provider - the initial provider to use
  • Method Details

    • getMasterUri

      public URI getMasterUri() throws RosRuntimeException
      Description copied from interface: MasterUriProvider
      Get a master URI.

      There is no guarantee that calling this class twice will provide the same URI.

      This call may or may not block until a URI is available.

      Specified by:
      getMasterUri in interface MasterUriProvider
      Returns:
      a master URI
      Throws:
      RosRuntimeException - this exception may or may not be thrown if there is no master URI available
    • getMasterUri

      public URI getMasterUri(long timeout, TimeUnit unit)
      Description copied from interface: MasterUriProvider
      Get a master URI within a given amount of time.

      There is no guarantee that calling this class twice will provide the same URI.

      This call may or may not block until a URI is available.

      Specified by:
      getMasterUri in interface MasterUriProvider
      Parameters:
      timeout - the amount of time to wait for a URI
      unit - the time unit for the wait time
      Returns:
      a master URI or null if none could be obtained within the timeout
    • switchProvider

      public void switchProvider(SwitchableMasterUriProvider.MasterUriProviderSwitcher switcher)
      Switch between providers.
      Parameters:
      switcher - the new provider