Class RemoteFunction

  • Direct Known Subclasses:
    RemoteFunctionChunkedList, RemoteFunctionList, RemoteFunctionObject

    public abstract class RemoteFunction
    extends Object
    A RemoteFunction contains the information that is required for triggering a request to a remote function that is configured in Gluon CloudLink. Remote functions are constructed with a RemoteFunctionBuilder. The builder class can generate either a remote function that returns a single object or a remote function that returns a list of objects. These are implemented by RemoteFunctionObject, RemoteFunctionList and RemoteFunctionChunkedList respectively.

    The following code demonstrates how to call a remote function and populate the result into an observable list:

         RemoteFunctionList queryItemsFunction = RemoteFunctionBuilder.create("queryItems")
                 .param("customer", customerIdentifier)
                 .param("queryString", txtQuery.getText())
                 .list();
    
         GluonObservableList<Item> queryResults = queryItemsFunction.call(Item.class);
     
    • Method Detail

      • getFunctionName

        public String getFunctionName()
        The name that uniquely identifies the remote function that should be called when this RemoteFunction instance is used.
        Returns:
        the name of the remote function to call
      • isCachingEnabled

        public boolean isCachingEnabled()
        Returns whether the remote function has local caching enabled or not.

        When caching is enabled, calling a remote function will cause the locally cached values to be returned before the actual call to the remote function is triggered. This might for instance help in quickly populating a list with the already cached objects. When the call to the remote function has completed, the cached values will be cleared and completely overwritten with the new values that are loaded from the response of the remote function.

        Returns:
        true if local caching is enabled or false if it is disabled.
      • getParams

        public Map<String,​String> getParams()
        A Map of function parameters that are sent along with the request when calling the RemoteFunction.
        Returns:
        the function parameters to pass together with the call to the remote function
      • getRawBody

        public byte[] getRawBody()
        The bytes that are sent to the remote function as the raw body.
        Returns:
        the bytes to send as the raw body for the remote function call
      • setRawBody

        public void setRawBody​(byte[] rawBody)
        Sets the bytes that are sent to the remote function as the raw body.
        Parameters:
        rawBody - the bytes to send as the raw body for the remote function call
      • clearCache

        public void clearCache()
        Clear the locally cached values of the responses that are returned by previous calls to the remote function.