io.vertx.servicediscovery

## Interface ServiceReference

- All Known Implementing Classes:
    AbstractServiceReference

      public interface ServiceReference

  Once a consumer has chosen a service, it builds a `ServiceReference` managing the binding with the chosen service provider.

  The reference lets the consumer: * access the service (via a proxy or a client) with the `get()` method * release the reference - so the binding between the consumer and the provider is removed

  Author:
    Clement Escoffier

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> T` | `cached()` Gets the service object if already retrieved.
    `<T> T` | `get()` Gets the object to access the service.
    `Record` | `record()`
    `void` | `release()` Releases the reference.

- - ### Method Detail

    - #### record

          Record record()

      Returns:
        the service record.

    - #### get

          <T> T get()

      Gets the object to access the service. It can be a proxy, a client or whatever object. The type depends on the service type and the server itself.
      Type Parameters:
        `T` - the type
      Returns:
        the object to access the service

    - #### cached

          <T> T cached()

      Gets the service object if already retrieved. It won't try to acquire the service object if not retrieved yet.
      Type Parameters:
        `T` - the type
      Returns:
        the object, `null` if not yet retrieved

    - #### release

          void release()

      Releases the reference. Once released, the consumer must not use the reference anymore. This method must be idempotent and defensive, as multiple call may happen.

Copyright © 2016. All rights reserved.