# Interface RouteService

All Known Implementing Classes:
  `OsrmRouteService`

public interface RouteService

A backend that turns a `RouteRequest` into road-following `Route`s.

Codename One ships `OsrmRouteService`, which needs no API key, and `Routing` uses it unless you install another. Implement this interface to route through a different provider (Google Directions, Mapbox Directions, GraphHopper, your own server) and install it with `Routing.setService(RouteService)` -- application code that calls `Routing` keeps working unchanged.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `findRoutes(RouteRequest request, RouteCallback callback)`
  Routes `request` and reports the outcome to `callback`.
  `String`
  `getId()`
  A short identifier for this backend, for example `"osrm"`.
  `boolean`
  `isAvailable()`
  Whether this service can route right now.

- ## Method Details

  - ### getId

    String getId()
    A short identifier for this backend, for example `"osrm"`. Used in log messages and to tell services apart.

  - ### isAvailable

    boolean isAvailable()
    Whether this service can route right now. A service that needs an API key returns false until one is configured, letting callers fail fast with a clear message instead of a network error.

  - ### findRoutes

    void findRoutes(RouteRequest request, RouteCallback callback)

    Routes `request` and reports the outcome to `callback`.

    The call returns immediately; the work happens off the event dispatch thread and the callback is invoked back on it. Implementations must invoke exactly one callback method for every request, including when the request is rejected outright.

    `callback` is required -- an asynchronous call with nowhere to report its result is a mistake, not a fire-and-forget mode, so implementations reject a `null` one with `IllegalArgumentException` rather than returning quietly and leaving the caller to wonder.