T
- the type of service objectpublic abstract class AbstractServiceReference<T> extends Object implements ServiceReference
Modifier and Type | Field and Description |
---|---|
protected T |
service |
protected Vertx |
vertx |
Constructor and Description |
---|
AbstractServiceReference(Vertx vertx,
ServiceDiscovery discovery,
Record record)
Creates a new instance of
AbstractServiceReference . |
Modifier and Type | Method and Description |
---|---|
<X> X |
cached()
Returns the service object.
|
<X> X |
cachedAs(Class<X> x)
GGets the service object if already retrieved.
|
void |
close()
Same as
release() , here to implement AutoCloseable . |
<X> X |
get()
Gets the service object.
|
<X> X |
getAs(Class<X> x)
Gets the service object.
|
boolean |
isHolding(Object object)
Checks whether or not the service reference has the given service object.
|
protected void |
onClose()
Callback that let you cleanup the service object.
|
Record |
record() |
void |
release()
If the service object has been retrieved, calls
onClose() and release the reference. |
protected abstract T |
retrieve()
Method to implement to retrieve the service object.
|
public AbstractServiceReference(Vertx vertx, ServiceDiscovery discovery, Record record)
AbstractServiceReference
.vertx
- the vert.x instancerecord
- the service recordpublic <X> X cached()
null
.cached
in interface ServiceReference
null
if nonepublic <X> X get()
retrieve()
, otherwise returned the cached value.get
in interface ServiceReference
public <X> X getAs(Class<X> x)
get()
this method let you configure the type of object you want to retrieve. This parameter must match
the expected service type, and must pass the "polyglot" version of the class.getAs
in interface ServiceReference
X
- the type of objectx
- thepublic <X> X cachedAs(Class<X> x)
cached()
this method let you configure the type of object you want to retrieve. This parameter must match
the expected service type, and must pass the "polyglot" version of the class.cachedAs
in interface ServiceReference
X
- the type of objectx
- theprotected abstract T retrieve()
protected void onClose()
public Record record()
record
in interface ServiceReference
public void release()
onClose()
and release the reference. Otherwise, does nothing.release
in interface ServiceReference
public void close()
release()
, here to implement AutoCloseable
.close
in interface AutoCloseable
public boolean isHolding(Object object)
ServiceReference
isHolding
in interface ServiceReference
object
- the service object, must not be null
true
if the service reference service object is equal to the given object, false
otherwise.Copyright © 2023 Eclipse. All rights reserved.