The following sample will use the three concepts by providing a DataSource that reads from a classpath resource, a Converter that converts JSON into objects and a DataProvider that combines the DataSource with the Converter to get access to GluonObservable objects.
Inside the repository, look for the folder named gluon-connect-basic-usage. Retrieving an object looks somewhat similar to retrieving a list. Below we have the user. As you can see, we use JavaFX properties here instead of native Java types. To retrieve the object from the JSON file, we use the following code:. Gluon CloudLink enables enterprise and mobile developers to easily connect their disparate services and applications together, enabling bi-directional communications between mobile apps, enterprise infrastructure, and cloud systems.
Data storage, synchronization to the back-end or across devices and connectors to other back-ends. If you already have a Gluon CloudLink subscription you can safely skip this part.
If not, go to the Gluon CloudLink Product page and choose a subscription that matches your needs. There is also an option to sign up for a day trial account.
Enter your billing information or login with your existing account when you have signed up for one of our other products before. Once you are successfully signed up, a Gluon CloudLink application will be created for you automatically. You will also receive an email that contains a link to access the Gluon Dashboard.
The Gluon Dashboard is a web application from which you can configure and monitor your Gluon CloudLink application. The chapters that follow below will describe all the functional components that are provided by Gluon CloudLink.
Each component talks about the required steps on how to set up, configure and use them from the perspective of your enterprise application as well as from the mobile client application.
To be able to use Gluon CloudLink you will need to make sure everything is set up correctly. Each of these endpoints is described in the appropriate sections below.
For your convenience, we also provide a Java Client that calls on these same endpoints. The Java Client currently has two implementations that you can choose from. The Spring client is more suited for enterprise applications that are running inside the Spring framework.
This is the only encoding that is supported by Gluon CloudLink. If your data you sent looks garbled, please verify that you correctly applied UTF-8 encoding. Note that the Eclipse Yasson dependency is only required when you are running inside a Java EE 7 container. The value of the Authorization header is as follows:. When using the Java Client, authentication is done by providing the server key when you create an instance of the Java Client:.
Alternatively, when running inside a CDI aware environment, you can inject an instance of the JavaEE client as follows:. When you are using Spring Boot, you can make use of autowiring to inject an instance of the Spring Client. An application property is then required that contains the server key of your Gluon CloudLink Application. It is automatically added as a dependency to the main Gluon Mobile artifact, but can also be added separately. We recommend using Maven as the build tool for building and provisioning a Gluon Mobile application.
Maven project can make use of the GluonFX plugin , and the associated pom. Gluon Mobile uses the application specific credentials to sign all requests that are made to Gluon CloudLink. This allows Gluon CloudLink to know on behalf of which application the request is initiated. This file will automatically be picked up by Gluon Mobile when needed. Insert the content below, making sure that you replace the values for the applicationKey and applicationSecret with the correct credentials for your application:.
From the Gluon Dashboard, select the Credentials item from the menu on the left. You will find the key and secret tokens of your Gluon CloudLink application inside the Client tab. You can either manually copy and paste them in the configuration file or you can directly download the configuration file by clicking the download button. Applications often use data that needs to be stored. Some data is only relevant to a specific instance of the application i.
Gluon CloudLink Client is the component that manages data on the client. It provides an API that allows users to store and synchronize data and provides a number of options for developers to choose from for each data entity:. Gluon CloudLink provides a scalable and persistent data store that is used to store data and to update clients when data changes.
In addition, Gluon CloudLink provides the ability to link your Gluon Mobile application with another back-end or cloud infrastructure by configuring one or more Connectors. Gluon CloudLink makes sure your data is consistent across the different devices. Depending on your preferences, changes on one device propagate immediately to other devices. Or they might only be stored in Gluon CloudLink and the devices will manually request the latest version whenever they want.
The DataClient class is the access point to the Data Storage. You can configure the DataClient to link data with an authenticated user. The following authentication methods are currently available:. Email and Password: authenticate users by letting them sign up and sign in with their personally chosen email address and password. See the documentation on User Management to read more about configuring user authentication.
To enable user authentication on the client, you need to provide a UserClient instance when building the DataClient. The provided UserClient will ensure that an authenticated user is present when the DataClient tries to access underlying data. Authentication is done by presenting the user with an authentication view from which one of the configured login methods can be chosen.
Once you have a DataClient reference, you can start storing and retrieving data. There are two different types of data that can be managed in Gluon CloudLink:. Because these objects and lists are maintained remotely, we will call them remote entities. Every remote entity is identified by a unique string identifier.
For example, retrieving a remote list with the identifier notes can be done with the following code:. In its simplest form the createListDataReader method returns an instance of GluonObservableList without any synchronization flags. That is because a Gluon CloudLink list always exists. When a list is retrieved the first time, an empty list will automatically be created for you. A remote object works a bit differently than a list, because in contrast to a list, an object does have the notion of existence.
All the operations on the DataProvider are asynchronous in nature and are executed in a separate background thread. You can listen for changes on the stateProperty of the returned GluonObservable object to monitor the progress of the background operation.
To know when your object or list is ready to be used, you can also listen for the initializedProperty instead. When retrieving an object from Gluon CloudLink, you can detect if this object was already stored previously by using the following pattern:.
When you retrieve a list for the first time, an empty list will be created for you by the Gluon CloudLink service. Sometimes you wish to populate this empty list with default objects. You can do that with the following pattern:. You can check the exceptionProperty on the GluonObservable object to see what exactly went wrong. Gluon CloudLink supports three different data types: String , Map and custom classes. Inside a Map and for the fields of a custom class, the following field types can be used:.
String and StringProperty. See the Data Synchronization section for more information on these flags. The String data type is the most basic of the three supported types.
It simply stores and retrieves instances of string. It is the most flexible data type, but is less type safe. The keys of the map must be strings, while the value can be any of the supported field types that are listed above. If the map contains a value that is not supported, those values will be ignored when storing or retrieving data. As a final option, you can define your data structure inside a Custom Class.
The DataClient will inspect the provided class for all declared fields of which the type matches any of the supported field types. Note that only non-static fields and non-final primitive fields will be considered. All other field declarations will be ignored when storing or retrieving data. By default, no synchronization flags are configured when calling any of the methods we mentioned above.
To enable synchronization, you can pass any of the SyncFlag enum constants to the method. There are four different types of SyncFlag :. As an example, the code snippet below retrieves an instance of GluonObservableList that is configured with the list read through and list write through synchronization flags. This means that any changes that are done on the client, either adding or removing items, are propagated back to Gluon CloudLink.
The reverse is true as well: all changes that occur in Gluon CloudLink will be reflected back to the local list on the device. One of the features of Gluon CloudLink is to link it with an existing back end infrastructure. There are two main ways for linking Gluon CloudLink with such a back end infrastructure.
The body of the request must be a UTF-8 encoded JSON string and will be used as the payload for the object that is being added into the list. The body of the request must be a UTF-8 encoded JSON string and will be used as the payload for the object that is being updated in the list. A Connector can be used for automatic pushing and pulling of data from Gluon CloudLink to an enterprise back end system.
Different connector implementations are provided by Gluon CloudLink out of the box. Depending on the configured Connector, some extra code will be required on the back end application as well. The following Connectors are available for use within Gluon CloudLink. If you have a specific requirement for a custom Connector, please let us know. This is the most generic connector and allows synchronization data to any enterprise or cloud system that can talk REST.
This connector invokes a remote function that is defined in your CloudLink application. This connector specifically synchronizes data from and to your Couchbase server. Ideally suited if you have an existing Couchbase installation that you want to unlock to mobile devices. Each of them should be implemented on the back end application to be able to handle the request. JSON payload of the new object. If the object is a String , the payload will use a key named v.
A new object is added to Gluon CloudLink. The objectIdentifier is the identifier that is passed in from the application client when retrieving or storing the object. An existing object is updated in Gluon CloudLink. An existing object is removed from Gluon CloudLink.
A new object is added to a list. The objectIdentifier is an identifier that is assigned to the object specific to Gluon CloudLink, i. This is in contrast to the listIdentifier , which is the identifier that is passed in from the application client when retrieving the list.
An existing object in the list is updated. An existing object is removed from a list. When a client application requests an object or a list that is not yet known inside Gluon CloudLink, Gluon CloudLink calls one of the following two endpoints on the back end application to retrieve the initial object or list information.
A new object is being requested from the client application with the specified objectIdentifier. JSON payload of the list to retrieve. A new list is being requested from the client application with the specified listIdentifier. When a client application requests data to be added, updated or removed from Gluon CloudLink, those requests will be provided with the remote function invocation as a JSON string. The Couchbase Connector is able to send data to an existing Couchbase Server.
When activating the Couchbase Connector inside the Dashboard, you will need to provide the following information to let Gluon CloudLink be able to setup a connection with the Couchbase Server:. You can specify more than one node, by separating them with a semicolon.
An example of such an object can be seen below:. For each object in the list, the document will contain a key that matches the identifier of the object.
Below is an example of a list that contains two objects:. The format of the documents stored inside the Couchbase bucket must also follow the same format as described in the previous section. Almost all mobile applications that exist today interact with a back end infrastructure for managing their data. In theory, an application can directly make requests to these back ends, but there are a number of drawbacks for doing this:.
Mobile devices are not always connected to the internet. It takes lots of boilerplate code to check connectivity and handle rescheduling of requests when connectivity is restored. Applications on mobile devices have specific lifecycles and need to behave according to specific policies. Some resources are conditionally available.
The battery might be low, the application might be running in the background, the device is connected with a paid cellular network, etc. Depending on those conditions, an application must behave differently. Mobile devices have less resources than the regular server, and those resources need to shared with other applications.
CloudLink provides Remote Functions to give the application a reliable and secure way for linking with existing back end systems.
Each remote function is uniquely identified by a name. This name will be used in the client application when it makes a call to the defined remote function. You will find the following sections:. Authentication: in here different authentication schemes can be created that are used when authentication is required by a remote function.
A dialog will be shown where the following components can be configured:. The function name is a unique identifier for the remote function. The name is used in the client application when a call needs to be triggered to the remote function. Mock responses can be enabled for testing purposes. When mocking is enabled, a call to the remote function will not create a request to the actual configured endpoint, but respond directly with the data that is defined for the mock response.
The method defines what HTTP method to use when creating the request. Specify the timeout, in milliseconds, for reading from the remote function endpoint. If the value is zero, the default timeout will be used. Specify the timeout, in milliseconds, for connecting to the remote function endpoint. Specifies the authentication method that must be used when executing the request to the remote function. The authentication method can be selected from a list of authentication methods that are configured in the Authentication section.
The body type defines what kind of data will be sent to the remote function. The following types are supported:. When the raw body type is chosen, two extra fields will be available to specify the data and the media type of the raw body content.
If caching is enabled, CloudLink caches each successful response from invocations to the remote function for one hour. In closer detail, two HTTP response headers are currently inspected:. ETag: if an entity tag is provided, it will be used in any subsequent request to the configured endpoint for cache validation. Cache-Control: if cache control contains the words private or no-store , the response is not cached. If it contains public default value or a max-age value, the response is cached for the specified duration.
Navigate to the Credentials section in Gluon Dashboard and choose the Customer tab. Enter the required information. An optional specific version of the AWS Lambda function that must be executed.
An optional payload that should be sent along when executing the AWS Lambda function. When the selected payload type is string or byte array , you can specify the variable name of the payload. When the payload type is string , the value mapped with the key will be the JSON value that is loaded from the Payload string that can be specified in the text area below. If the payload type is byte array , then the JSON value will be a Base64 encoded string of the passed in array of bytes.
When the string payload type is chosen, an extra text area will be available to specify the data for the string content. The resulting data string must be valid JSON. If this is not the case, the request to the remote function will be aborted with a Bad Request status. Defines the expected media type of the response from the AWS Lambda function.
Configure a remote function that can invoke a Microsoft Azure function with an http trigger. A dialog will be shown in which the following components can be configured:. Define the Function Key to use for authorizing the invocation to the Azure function. The key is passed down to the function using the x-functions-key HTTP header. Make sure that you copy the value of the Function Key and not its name. Azure functions using Anonymous authorization can leave this field empty.
These are remote functions that are configured to run on the Fn Project platform. Your Fn function must be available from a public registry on Docker Hub. The name of the docker image as it has been pushed to Docker Hub. When input is enabled, two extra fields will be available to specify the data and the media type of the input.
The content of the text area will be passed down to the Fn Function during invocation. Specify the timeout, in seconds, for executing the remote function on the Fn Project platform. Gluon Functions allow you to run Java functions inside a serverless platform that is managed by Gluon CloudLink itself. All you need is a zip file that bundles all the runtime jar files that are needed for running the function.
The entrypoint defines what method should be invoked when the Gluon Function is triggered. The syntax consists of the fully qualified class name and the method name to be invoked, separated with a double colon, i. Specify the Java Runtime environment that must be used for running the Gluon Function. You can choose between Java 8 and Java 9.
Define the maximum amount of memory that should be provided when running the Gluon Function. The bundle contains the actual classes that are needed for executing the Gluon Function.
The bundle is a zip file containing one or more jar files that will be added to the classpath of the Gluon Function. Each remote function can be configured with additional parameters. Each parameter consists of a type, a name and optional default and test values.
The name is used by the client application to define the value for the parameter that will be passed on when building the request for the remote function. In the image below, a query parameter is configured with the name tagged. A query parameter will be sent as part of the query string. The query string is the part of the URI that comes after the question mark.
A form parameter can be chosen for remote functions that are configured with the POST method. Form parameters are sent as form url encoded parameters in the body of the request. A header parameter can be used to send custom HTTP request headers when building the request for the remote function. Variable parameters can be used to add custom variables to certain fields of a remote function.
The variable will be replaced with the value that was passed on by the client application, before the actual request is executed. The endpoint of a remote function sometimes requires that the request is authenticated. The Authentication section provides three different authentication mechanisms that can be used together with a remote function. The username and password are both required. See the OAuth 1.
A token key and secret can be provided as well when necessary, but can be left empty if the endpoint only requires that the request must be signed with consumer credentials. This authentication method will apply the Resource Owner Password Credentials authorization grant as defined in the OAuth 2.
When making a request to the defined endpoint of the remote function, it will first try to get an access token using the configuration details of the authentication method. The access token will then be passed along with the actual request to the endpoint of the remote function. Each remote function can be tested from within Gluon Dashboard to ensure the configuration is valid.
Each configured parameter has an optional test value that will be used when testing the remote function. When no test value is provided, the default value will be used instead. When testing the remote function, the response of the endpoint will be printed so it can be verified against the expected value. Useful information from each call that is being invoked by a remote function is stored in the Call Log and can be accessed in Gluon Dashboard.
Each request records the response code, the request and response timestamps and the body of the request and response. The body is capped at 8k. For calling a remote function from the client application we use the RemoteFunctionBuilder. The RemoteFunctionBuilder can generate three different implementations of a RemoteFunction , each handling the response of the call to the remote function in their own way:.
RemoteFunctionList: the response is converted into a list of objects, contained in a GluonObservableList. RemoteFunctionChunkedList: the response of the function is a continuous stream of chunks, where each chunk is converted and added to a GluonObservableList. To start calling remote functions, we first need to build an instance by using the RemoteFunctionBuilder builder class.
Each built RemoteFunction instance can then be triggered by calling the call method. Every response that is returned by a call to a remote function will by default be cached locally in the private storage of the device. The next time the remote function is called, it will first load and return the cached data before making the actual call to the remote function in Gluon CloudLink.
This allows the application to already present the user with data from the last time the remote function was called. When the response from the call to the actual remote function in Gluon CloudLink is completed, it will overwrite the cached data with the data from the new response.
By default, Gluon CloudLink will close the call to the endpoint that is configured for a remote function after 60 seconds. However, the connection will be kept open when the remote function uses chunked transfer encoding.
This is handled automatically, when the remote function specifies the Transfer-Encoding response header with the value chunked in its response. In other words, there is nothing special that needs to be configured in your Remote Function definition on Gluon Dashboard. At the client side, you do need to use a different implementation of RemoteFunction that is able to handle chunked encoding: RemoteFunctionChunkedList.
Writing binary data with a remote function can be done by defining the remote function in Gluon Dashboard with the raw body type. In the client application, a byte array is provided as the raw body when building the remote function. You can find end to end guides on working with different cloud servers with Gluon Cloudlink below:.
Create Remote Functions using Microsoft Azure. The User Management service enables user authentication in your Gluon Mobile application. It supports email and password based authentication and signing in with most popular identity providers like Facebook, Google and more. Enabling the login methods that should be available for your application can be done from the Gluon Dashboard. Navigate to the User Management link, and select the Login Methods tab. From here you can add and configure one or more login methods.
The login methods for identity providers all need a key and a secret from an application that is created on the respective identity provider. We provide a step-by-step guide to creating and configuring an application for each of the supported identity providers.
The UserClient class is the access point to the User Management service. It contains various methods for managing the authentication process. When a new instance is constructed, it will load the Login Methods that are enabled for the Gluon Mobile application and present them to the user when the authentication process is started. Based on your article, I think we must give special attention to Atom, it is really easy to use.
Thanks for a wonderful read. Keep writing! Indeed a great article with nice collection. Thank you so much for sharing the list! Your content will surely help our develpers community. Keep up the good work. Thanks for Sharing! My coder is trying to persuade me to move to. I have always disliked the idea because of thhe costs. But he's tryiong none the less. I've been using Movable-type on various websites for about a year and am anxious about switching to another platform.
I have heard very good things about blogengine. Is there a way I can import all my wordpress posts into it? Any help would be really appreciated!
The blog is absolutely fantastic! Lot of great information which can be helpful about benefits of developing website. Keep updating the blogs. Home Blog PHP. Jan 25, PHP. Previous Insights.
View All Insights. Next Insights. Comments Leave a message Email Address. Lauren Silva. Few technologies have the potential to change the nature of work and how we live as artificial intelligence AI and machine learning ML. Everything from new organizational structures and payment schemes to new expectations, skills, and tools will shape the future of the firm. Self-Driving Car Engineer. Data Analyst Nanodegree.
Android Basics Nanodegree. Intro to Programming Nanodegree. AI for Trading. Predictive Analytics for Business Nanodegree. AI For Business Leaders. School of Artificial Intelligence. School of Cyber Security. School of Data Science. School of Business. School of Autonomous Systems. School of Executive Leadership. School of Programming and Development. Related Articles. Python Serialization: Getting Started The internet accumulates mind-boggling amounts of data daily — amounts in the petabytes, exabytes and zettabytes.
0コメント