io.vertx.reactivex.servicediscovery

## Class ServiceReference

- java.lang.Object
- - io.vertx.reactivex.servicediscovery.ServiceReference

-     public class ServiceReference
      extends Object

  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

  NOTE: This class has been automatically generated from the `original` non RX-ified interface using Vert.x codegen.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static io.vertx.lang.rx.TypeArg<ServiceReference>` | `__TYPE_ARG`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServiceReference(Object delegate)`
    `ServiceReference(ServiceReference delegate)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> T` | `cached()` Gets the service object if already retrieved.
    `<X> X` | `cachedAs(Class<X> x)` Gets the service object if already retrieved.
    `boolean` | `equals(Object o)`
    `<T> T` | `get()` Gets the object to access the service.
    `<X> X` | `getAs(Class<X> x)` Gets the object to access the service.
    `ServiceReference` | `getDelegate()`
    `int` | `hashCode()`
    `boolean` | `isHolding(Object object)` Checks whether or not the service reference has the given service object.
    `static ServiceReference` | `newInstance(ServiceReference arg)`
    `Record` | `record()`
    `void` | `release()` Releases the reference.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### __TYPE_ARG

          public static final io.vertx.lang.rx.TypeArg<ServiceReference> __TYPE_ARG

  - ### Constructor Detail

    - #### ServiceReference

          public ServiceReference(ServiceReference delegate)

    - #### ServiceReference

          public ServiceReference(Object delegate)

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### getDelegate

          public ServiceReference getDelegate()

    - #### record

          public Record record()

      Returns:
        the service record.

    - #### get

          public <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. This method returns the Java version and primary facet of the object, use `getAs(java.lang.Class<X>)` to retrieve the polyglot instance of the object or another facet..
      Returns:
        the object to access the service

    - #### getAs

          public <X> X getAs(Class<X> x)

      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. This method wraps the service object into the desired type.
      Parameters:
        `x` - the type of object
      Returns:
        the object to access the service wrapped to the given type

    - #### cachedAs

          public <X> X cachedAs(Class<X> x)

      Gets the service object if already retrieved. It won't try to acquire the service object if not retrieved yet. Unlike `cached()`, this method return the warpped object to the desired (given) type.
      Parameters:
        `x` - the type of object
      Returns:
        the object, `null` if not yet retrieved

    - #### cached

          public <T> 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

    - #### release

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

    - #### isHolding

          public boolean isHolding(Object object)

      Checks whether or not the service reference has the given service object.
      Parameters:
        `object` - the service object, must not be `null`
      Returns:
        `true` if the service reference service object is equal to the given object, `false` otherwise.

    - #### newInstance

          public static ServiceReference newInstance(ServiceReference arg)

Copyright © 2024 Eclipse. All rights reserved.