Unknown macro: {next_previous_link3}
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

A datasource is a connection set up to a storage of data, such as a database or a data file, from a server. You can create a custom datasource as follows.

  1. Log in to the product's management console and select Datasources sub menu from the Configure menu.
  2. Click Add Datasource.  
  3. The New Datasource page opens. Select Custom from the Datasource Type drop-down list and a set of fields appear as follows for configuration:

    • Datasource Type : Custom 
    • Custom Datasource Type : Described below
    • Name : Name of the datasource (this value should be unique)
    • Description : Description of the datasource
    • Configuration : XML configuration of the datasource
     

Custom datasource type

The actual type of the custom datasource can be either DS_CUSTOM_TABULAR or DS_CUSTOM_QUERY. There are two options cover most of the common business use cases.  

Custom tabular datasources  

Tabular datasources are used when there is a datasource which represents its data using tables, where a set of named tables contains data rows that can be queried later.  

To implement tabular datasources, the interface org.wso2.carbon.dataservices.core.custom.datasource.TabularDataBasedDS is used. A sample implementation of tabular custom datasource can be found at InMemoryDataSource.  

A tabular datasource is typically associated with an SQL data services query. This is done by internally using our own SQL parser to execute SQL against the custom datasource. A sample data service descriptor on how this is done can be found at InMemoryDSSample . Also, this is supported in Carbon datasources, with the datasource reader implementation org.wso2.carbon.dataservices.core.custom.datasource.CustomTabularDataSourceReader. A sample Carbon datasource configuration file can be found at <DSS_HOME>/repository/conf/datasources/custom-datasources.xml.

Custom query datasources  

Custom query based datasources are created when there is a datasource which has some form of a query expression support.

To implement , the interface org.wso2.carbon.dataservices.core.custom.datasource.CustomQueryBasedDS is used. Any non-tabular datasource can be created using the query-based approach. Even if the target datasource does not have a query expression format, users can create their own and it. For example, any NoSQL type datasource can be supported using this type of a datasource.  

A sample implementation of a query-based custom datasource can be seen at EchoDataSource . A sample data service descriptor with custom query datasources can be found in action in InMemoryDSSample . This is supported in Carbon datasources, with the datasource reader implementation org.wso2.carbon.dataservices.core.custom.datasource.CustomQueryDataSourceReader. A sample of a Carbon datasource configuration file can be found at <DSS_HOME>/repository/conf/datasources/custom-datasources.xml.  

In the "init" methods of all custom datasources, user-supplied properties will be parsed to initialize the datasource accordingly. Also, a property named "__DATASOURCE_ID__", which contains a UUID to uniquely identify the current datasource, will be passed. This can be used by custom datasource authors to identify the datasources accordingly. For example, scenarios like datasource instances communicating within a server cluster for data synchronization.

Shown below is an example configuration of a custom datasource of type 'DS_CUSTOM_TABULAR'.

  • No labels