Package: io.vertx.groovy.servicediscovery

## [Groovy] Class ServiceReference

- io.vertx.groovy.servicediscovery.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 ServiceReference.get method * release the reference - so the binding between the consumer and the provider is removed

- - ### Constructor Summary

    Constructors
    Constructor and description
    `ServiceReference (java.lang.Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `T` | `cached()` Gets the service object if already retrieved.
    `T` | `get()` Gets the object to access the service.
    `java.lang.Object` | `getDelegate()`
    `java.util.Map<java.lang.String, java.lang.Object>` | `record()` Returns: the service record.
    `void` | `release()` Releases the reference.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### ServiceReference(java.lang.Object delegate)

  - ### Method Detail

    - #### T cached()

      Gets the service object if already retrieved. It won't try to acquire the service object if not retrieved yet.

      Returns:
        the object, `null` if not yet retrieved

    - #### 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.

      Returns:
        the object to access the service

    - #### java.lang.Object getDelegate()

    - #### java.util.Map<java.lang.String, java.lang.Object> record()

      Returns:
        the service record. (see Record)

    - #### 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.