...
- Log in to the product's management console and select Datasources sub menu from the Configure menu.
- Click Add Datasource.
- The New Datasource page opens. Select 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 as the datasource type, provide a unique name, a description and configure the rest of the fields using the information below:
- Custom Datasource Type : See below
- Configuration : XML configuration of the datasource
Custom datasource type AnchorCusDSType CusDSType
CusDSType | |
CusDSType |
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 to connect to a source that represents its data using tables, where a set of named tables contains data rows that can be queried later. To implement tabular datasources, Tabular datasources are implemented using the interface org.wso2.carbon.dataservices.core.custom.datasource.TabularDataBasedDS
is used. A . See InMemoryDataSource
for a sample implementation of tabular custom datasource can be found at InMemoryDataSource.
datasources.
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
.See InMemoryDSSample
for a sample implementation.
An example configuration of a custom datasource of type DS_CUSTOM_TABULAR
is shown below:
Custom query datasources
Custom query
baseddatasources 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. used to connect to a source of non-tabular data that has query expression support. Even if the target
datasourcedata source does not have a query expression format,
usersyou can create
theiryour own and add it.
For example, any NoSQL type datasource can be supported using thisThis type of a datasource supports any NoSQL source of data.
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 Custom query datasources are implemented using the interface 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
.CustomQueryBasedDS
. See EchoDataSource
for a sample implementation. See InMemoryDSSample
for a sample data service descriptor with custom query datasources.
In the "init
" methods of all custom datasources, user-supplied specified properties will be are parsed to initialize the datasource datasources accordingly. AlsoIn addition, a property named "__DATASOURCE_ID__
", which contains a UUID to uniquely identify the current datasource, will be is passed. This can be used by custom Custom datasource authors use this property to identify the datasources accordingly. For example, scenarios like in situations where datasource instances communicating communicate within a server cluster for data synchronization.Shown below is an example configuration of a custom datasource of type 'DS_CUSTOM_TABULAR'.