Following are descriptions of the custom datasource fields:
- Data Source Type: Custom
- Custom Data Source Type: Specify whether the data is in a table or accessed through a query as described below
- Name: Enter a unique name for this datasource
- Description: Description of the datasource
- Configuration: XML configuration of the datasource
Custom datasource type
When creating a custom datasource, you specify whether the datasource type is DS_CUSTOM_TABULAR (the data is stored in tables) or DS_CUSTOM_QUERY (non-tabular data accessed through a query). Following is more information about each type.
Custom tabular datasources
Tabular datasources are used for accessing tabular data, that is, the data is stored in rows in named tables that can be queried later. To implement tabular datasources, the interface
org.wso2.carbon.dataservices.core.custom.datasource.TabularDataBasedDS is used. You can see a sample implementation of a tabular custom datasource at
A tabular datasource is typically associated with a SQL data services query. WSO2 products use an internal SQL parser to execute SQL against the custom datasource. You can see a sample data service descriptor at
InMemoryDSSample. Carbon datasources also support tabular data with the datasource reader implementation
org.wso2.carbon.dataservices.core.custom.datasource.CustomTabularDataSourceReader. If you have Data Services Server installed, you can see a sample Carbon datasource configuration file at
Custom query datasources
Custom query-based datasources are used for accessing non-tabular data through a query expression. To implement query-based datasources, the interface
org.wso2.carbon.dataservices.core.custom.datasource.CustomQueryBasedDS is used. You can create any non-tabular datasource using the query-based approach. Even if the target datasource does not have a query expression format, you can create and use your own. For example, you can support any NoSQL type datasource using this type of a datasource.
You can see a sample implementation of a custom query-based datasource at
EchoDataSource. You can see a sample data service descriptor with custom query datasources in
InMemoryDSSample. Carbon datasources also support query-based data with the datasource reader implementation
org.wso2.carbon.dataservices.core.custom.datasource.CustomQueryDataSourceReader. If you have Data Services Server installed, you can see a sample Carbon datasource configuration file at
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, such as 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'.
After creating datasources, they appear on the Data Sources page. You canas needed by clicking their Edit or Delete links.