public class GluonClient
extends java.lang.Object
The GluonClient is the access point to the Gluon CloudLink
infrastructure. It assists in using the DataProvider
with data stored on Gluon CloudLink as the data source.
For instance, to retrieve a list from Gluon CloudLink, you can use the following code:
GluonClient gluonClient = GluonClientBuilder.create() .credentials(new GluonCredentials(APP_KEY, APP_SECRET)) .build(); GluonObservableList<Item> items = DataProvider.retrieveList(gluonClient.createListDataReader("items", Item.class));
Type | Property and Description |
---|---|
javafx.beans.property.ReadOnlyObjectProperty<User> |
authenticatedUser
A property that holds the currently authenticated user.
|
Modifier and Type | Method and Description |
---|---|
<V> void |
authenticate(java.util.concurrent.Callable<V> callable)
Start the authentication flow.
|
<O> void |
authenticate(java.util.function.Consumer<O> consumer,
O acceptable)
Start the authentication flow.
|
void |
authenticate(java.lang.Runnable runnable)
Start the authentication flow.
|
javafx.beans.property.ReadOnlyObjectProperty<User> |
authenticatedUserProperty()
A property that holds the currently authenticated user.
|
<E> ListDataReader<E> |
createListDataReader(java.lang.String identifier,
java.lang.Class<E> objectClass)
Creates an instance of
ListDataReader that can be passed directly in the
DataProvider.retrieveList(ListDataReader) method. |
<E> ListDataReader<E> |
createListDataReader(java.lang.String identifier,
java.lang.Class<E> objectClass,
SyncFlag... syncFlags)
Creates an instance of
ListDataReader that can be passed directly in the
DataProvider.retrieveList(ListDataReader) method. |
<T> ObjectDataReader<T> |
createObjectDataReader(java.lang.String identifier,
java.lang.Class<T> objectClass,
SyncFlag... syncFlags)
Creates an instance of
ObjectDataReader that can be passed directly in the
DataProvider.retrieveObject(ObjectDataReader) method. |
<T> ObjectDataRemover<T> |
createObjectDataRemover()
Creates an instance of
ObjectDataRemover that can be passed directly in the
DataProvider.removeObject(GluonObservableObject, ObjectDataRemover) method. |
<T> ObjectDataWriter<T> |
createObjectDataWriter(java.lang.String identifier,
java.lang.Class<T> objectClass,
SyncFlag... syncFlags)
Creates an instance of
ObjectDataWriter that can be passed directly in the
DataProvider.storeObject(Object, ObjectDataWriter) method. |
User |
getAuthenticatedUser()
Gets the value of the property authenticatedUser.
|
AuthenticationMode |
getAuthenticationMode()
Get the authentication mode to use when storing or retrieving data with this GluonClient instance.
|
GluonCredentials |
getCredentials()
Get the application credentials that are used to authorize the application when connecting with Gluon CloudLink.
|
java.lang.String |
getHost()
Get the name of the host that is used for connecting to Gluon CloudLink.
|
java.lang.String |
getHost(java.lang.String service)
Gets the name of the host that is used for connecting to Gluon CloudLink, appending the provided
service . |
OperationMode |
getOperationMode()
Get the operation mode to use when storing or retrieving data with this GluonClient instance.
|
boolean |
isAuthenticated()
Check whether the application is successfully authenticated with a user.
|
<E> void |
push(GluonObservableList<E> list)
Push any changes made to the list to Gluon CloudLink.
|
<E> void |
push(GluonObservableList<E> list,
boolean fully)
Push any changes made to the list to Gluon CloudLink.
|
<T> void |
push(GluonObservableObject<T> object)
Push any changes made to the object to Gluon CloudLink.
|
java.lang.String |
toString() |
public javafx.beans.property.ReadOnlyObjectProperty<User> authenticatedUserProperty
null
value if no
user is currently authenticated.getAuthenticatedUser()
public java.lang.String getHost()
public java.lang.String getHost(java.lang.String service)
service
.service
- the string to append to the base host name.service
string.java.lang.NullPointerException
- when the service
parameter is null
public GluonCredentials getCredentials()
public AuthenticationMode getAuthenticationMode()
public OperationMode getOperationMode()
public boolean isAuthenticated()
AuthenticationMode.PUBLIC
, this method will always return true
.true
when an authenticated user is available, false
otherwise.public User getAuthenticatedUser()
null
when no user is
currently authenticated.null
if no user is authenticated.public javafx.beans.property.ReadOnlyObjectProperty<User> authenticatedUserProperty()
null
value if no
user is currently authenticated.getAuthenticatedUser()
public void authenticate(java.lang.Runnable runnable)
runnable
- a runnable that will be called when authentication has completed successfullypublic <V> void authenticate(java.util.concurrent.Callable<V> callable)
V
- the type of the object that is returned from the provided callablecallable
- a callable that will be called when authentication has completed successfullypublic <O> void authenticate(java.util.function.Consumer<O> consumer, O acceptable)
acceptable
object. If a user was already authenticated
when making this call, the consumer will be called immediately.O
- The type of the acceptable object that will be accepted by the consumer.consumer
- a consumer that will be called when authentication has completed successfullyacceptable
- the object to pass to the consumer's accept method, can be null
public <T> ObjectDataReader<T> createObjectDataReader(java.lang.String identifier, java.lang.Class<T> objectClass, SyncFlag... syncFlags)
ObjectDataReader
that can be passed directly in the
DataProvider.retrieveObject(ObjectDataReader)
method. The object data reader will read the object with
the specified identifier
from Gluon CloudLink.
Any of the following synchronization flags can be passed in with the syncFlags
parameter:
SyncFlag.OBJECT_READ_THROUGH
and SyncFlag.OBJECT_WRITE_THROUGH
. All other values will be silently
ignored.
T
- the type of the object that is retrievedidentifier
- the identifier of the object to retrieve from Gluon CloudLinkobjectClass
- the class of the object to retrievesyncFlags
- an optional list of synchronization flagspublic <T> ObjectDataWriter<T> createObjectDataWriter(java.lang.String identifier, java.lang.Class<T> objectClass, SyncFlag... syncFlags)
ObjectDataWriter
that can be passed directly in the
DataProvider.storeObject(Object, ObjectDataWriter)
method. The object data writer will send the object
with the specified identifier
to Gluon CloudLink.
Any of the following synchronization flags can be passed in with the syncFlags
parameter:
SyncFlag.OBJECT_READ_THROUGH
and SyncFlag.OBJECT_WRITE_THROUGH
. All other values will be silently
ignored.
T
- the type of the object that is storedidentifier
- the identifier of the object to store in Gluon CloudLinkobjectClass
- the class of the object to storesyncFlags
- an optional list of synchronization flagspublic <T> ObjectDataRemover<T> createObjectDataRemover()
ObjectDataRemover
that can be passed directly in the
DataProvider.removeObject(GluonObservableObject, ObjectDataRemover)
method. The observable object that is
passed in with the removeObject method will be used to get information about which object needs to be removed
from Gluon CloudLink.
Note: this method can only be used for removing observable objects that were either retrieved using an ObjectDataReader created by a GluonClient instance or stored using an ObjectDataWriter created by a GluonClient instance.
T
- the type of the object to removepublic <E> ListDataReader<E> createListDataReader(java.lang.String identifier, java.lang.Class<E> objectClass)
ListDataReader
that can be passed directly in the
DataProvider.retrieveList(ListDataReader)
method. This method is the same as calling createListDataReader(String, Class, SyncFlag...)
with the following two synchronization flags: SyncFlag.LIST_READ_THROUGH
and SyncFlag.LIST_WRITE_THROUGH
.E
- the type of the objects contained in the list to readidentifier
- the identifier of the list to retrieve from Gluon CloudLinkobjectClass
- the class of the objects contained in the list to readpublic <E> ListDataReader<E> createListDataReader(java.lang.String identifier, java.lang.Class<E> objectClass, SyncFlag... syncFlags)
ListDataReader
that can be passed directly in the
DataProvider.retrieveList(ListDataReader)
method. The list data reader will read the list with the
specified identifier
together with the objects it contains from Gluon CloudLink.E
- the type of the objects contained in the list to readidentifier
- the identifier of the list to retrieve from Gluon CloudLinkobjectClass
- the class of the objects contained in the list to readsyncFlags
- an optional list of synchronization flagspublic <E> void push(GluonObservableList<E> list)
push(GluonObservableList, boolean)
with a value of true
for the fully
parameter.E
- the type of the objects contained in the list to pushlist
- the observable list to push to Gluon CloudLinkpush(GluonObservableList, boolean)
public <E> void push(GluonObservableList<E> list, boolean fully)
When the fully
parameter is set to true
, all items in the list will be considered as
marked for update. Otherwise, only items that were removed or added or updated manually will be updated on Gluon
CloudLink. Again, note that when using fully
with a value of true
, items that were
marked for removal will still be removed because the removal marker takes precedence over the update marker.
E
- the type of the objects contained in the list to pushlist
- the observable list to push to Gluon CloudLinkfully
- when true
all items in the list are considered as marked for updatepublic <T> void push(GluonObservableObject<T> object)
write through flag
.
A push can be used as a convenient way to store updates to an observable object that was already retrieved. Consider the following code, to see an example of the push method:
GluonObservableObject<Sample> sample = DataProvider.retrieveObject(gluonClient.createObjectDataReader("sample", Sample.class)); // somewhere the object gets updated and you want to store the updates gluonClient.push(sample);
Actually, the push method is a simple alternative to the storeObject
method that is available in DataProvider. Using that method, updating the object in Gluon CloudLink can be done
as follows, which is more cumbersome to write and you need to pass in the object identifier again:
DataProvider.storeObject(sample.get(), gluonClient.createObjectDataWriter("sample", Sample.class));
Note: this method can only be used with observable objects that were either retrieved using an ObjectDataReader created by a GluonClient instance or stored using an ObjectDataWriter created by a GluonClient instance.
T
- the type of the object to pushobject
- the observable object to push to Gluon CloudLinkpublic java.lang.String toString()
toString
in class java.lang.Object