Registry Drivers
Creating Registry Drivers

Registry drivers are normally bundled with scopes drivers (see Scopes Drivers).  Normally, before a registry driver is accessed, the user should authenticate the corresponding scope  (e.g., the "https://​www​.googleapis​.com​/auth​/spreadsheets" scope in the "google_scopes" driver).

After the scope is authenticated and the correspoding credentials stored (in the registry or in some other place), the corresponding remote registry can be mounted.  After mounting, a virtual registry branch (subkey) within the "users/[login]" branch will become available (we call this branch a mount point).

To mount a remote file system, the registry key "users/[login]/registry_mount_points/[path/to/mount/point]" with the value equal to the remote location string must be created.  The location string must start with the driver-specific prefix, e.g., "gspreadsheet:", followed by the driver-specific remote location.

The prefix will be used by webAppOS Registry to determine the driver implementation.  Normally, the driver should implement server-side Registry API.  However, to support serverless webAppOS applications, the registry driver can also provide a client-side implementation of Registry API.

The driver must check occasionally the registry key mentioned above as well as the credentials used to connect to the remote registry.  In case the registry key is not present or credentials have changed, the driver must consider that the mount point has been unmounted.

Server-Side implementation

The server-side implementation must implement the org.webappos.registry.IRegistry interface (see webAppOS Registry API) and specify the corresponding implementation class in service.properties:

registry_driver=some.java.package.JavaClassImplementingIRegistry
# extends org.webappos.registry.IRegistry
registry_prefix="gspreadsheet:"
# some prefix used by webAppOS Registry to choose the registry driver

The class constructor must take two string arguments: the location of the remote database/spreadsheet and the options string.  User's credentials (access tokens) must be taken from the registry (or where the corresponding scopes driver saved them).  If the scopes driver authenticated multiple accounts, the options string can specify the account name to use.

Client-Side implementation

The client-side implementation (for serverless access) must be accessible via services/[scopes_driver_name]/[registry_prefix]_registry_driver.js

The [registry_prefix]_registry_driver.js must define an asynchronous (AMD) module that returns a JavaScript constructor function implementing webAppOS Registry API.

The constructor function must take two arguments: the location of the remote registry and the options.  It must return a JavaScript object implementing methods from org.webappos.registry.IRegistry.

define(function(){
var ...; // private properties
return function(location, options) {
this.getValue = async function(key) {
...
};
this.setValue = async function(key, value) {
...
};

return this;
};
})