[Download] | [Documentation Home] | [Release Note]

Custom Data Source Support

Introduction

WSO2 Data Services Server features custom data source support to interface data services with any type of data sources available. There are two options in writing a custom data source:

  • Tabular Based Data Sources
  • Custom Query Based Data Sources

Tabular Data Based Data Sources

The tabular data based data sources are meant to be created, when you have a data source which represents its data using tables. Where a set a named tables contains data rows that can be queried later. To implement these type of data sources, the interface org.wso2.carbon.dataservices.core.custom.datasource.TabularDataBasedDS has to be implemented. A sample implementation of this type of a custom data source can be seen at InMemoryDataSource. When a tabular data based data source is created, it will be associated with a data services query which has an SQL query, this is done by internally using our own SQL parser to execute SQL against the custom data source. A sample data service descriptor on how this is done can be found at InMemoryDSSample. Also this is also supported with Carbon data sources, with the data source reader implementation org.wso2.carbon.dataservices.core.custom.datasource.CustomTabularDataSourceReader. A sample of a Carbon data source configuration file can be found at custom-datasources.xml, which ships as a sample with WSO2 DSS.

Custom Query Based Data Sources

The custom query based data sources are meant to be created, when you have a data source which has some form of a query expression support. Also, basically any non-tabular data based data source can be created with this type. Even if the target data source do not have query expression format, you can create your own one and use that. So for example, any NoSQL type data source can be supported using this type of a data source. To implement these type of data sources, the interface org.wso2.carbon.dataservices.core.custom.datasource.CustomQueryBasedDS has to be implemented. A sample implementation of this type of a custom data source can be seen at EchoDataSource. A sample data service descriptor with custom query data sources in action can be found at InMemoryDSSample. This is supported in Carbon data sources, with the data source reader implementation org.wso2.carbon.dataservices.core.custom.datasource.CustomQueryDataSourceReader. A sample of a Carbon data source configuration file can be found at custom-datasources.xml.

NOTE:-
All the custom data sources, in its implementation "init" method, the user supplied properties will be parsed in to initialize the data source accordingly, also a specific property named "__DATASOURCE_ID__" will be parsed in, which contains an UUID to uniquely identify the current data source. This can be used by custom data source authors for any required functionality to identify the data sources accordingly, for example, scenarios like, data source instances communicating within a server cluster for data synchronization.