This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Custom Datasource Sample
Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:<PRODUCT_HOME>/
repository/samples/
directory that includes all Data Integration samples is changed to <EI_HOME>/
samples/data-services/
.<PRODUCT_HOME>/
repository/samples/resources/
directory that includes all artifacts related to the Data Integration samples is changed to <EI_HOME>/
samples/data-services/resources/
.
This sample demonstrates the use of custom datasources in a data service, using WSO2 EI.
About the data service
The InMemoryDSSample used here consists of the following custom datasource implementations:
- org.wso2.carbon.dataservices.core.custom.datasource.InMemoryDataSource (custom tabular datasource) implemented using the org.wso2.carbon.dataservices.core.custom.datasource.TabularDataBasedDS interface.
- org.wso2.carbon.dataservices.core.custom.datasource.EchoDataSource(custom query datasource) implemented using the org.wso2.carbon.dataservices.core.custom.datasource.CustomQueryBasedDS interface.
Building the sample
The sample data service InMemoryDSSample should be deployed using the instructions in Samples Setup section.
Running the sample
The sample service can be run using the TryIt tool, which is bundled with WSO2 EI, or a code-generated java client sample as discussed in the Data Services Clients section.
Follow the steps below to demonstrate this functionality using the TryIt tool:
- Log in to the management console of your server and click List under Services in the navigator.
- The InMemoryDSSample should be listed.
- Click Try this service to open the TryIt tool for the InMemoryDSSample.
- Select the relevant operation and click Send to execute the command. The service contains the following operations:
- "addVehicle": This operation adds a new vehicle to the datasource.
- "getOldVehicles": This gives all the vehicles added with the year greater than 1970.
- "getAllVehicles": This operation returns all the vehicles added in the datasource.
- "getVehicleById": This operation gives the vehicle information which matches with the provided id.
- "getAllUsers": This operation returns the user information stored in the datasource.
- "echo1" and "echo2": This operation returns the entered values.
- "addVehicle": This operation adds a new vehicle to the datasource.