...
- Go to the Configure tab on the management console and click Data Sources to open the Data Sources screen.
- Then click Add Data Source. The following screen will open:
- Enter "Custom" as the datasource type.
- In the Custom Data Source Type field, enter "DS_CUSTOM_TABULAR" (to store data in tables) or "DS_CUSTOM_QUERY" (to store non-tabular data accessed through a query).
- In the Name and Description fields, enter a unique name for the datasource.
- In the Configuration section, specify the xml configuration of the datasource. See the examples given below.
XML configuration for a custom tabular datasource (DS_CUSTOM_TABULAR type):
Code Block <configuration> <customDataSourceClass>org.wso2.carbon.dataservices.core.custom.datasource.InMemoryDataSource</customDataSourceClass> <customDataSourceProps> <property name="inmemory_datasource_schema">{Vehicles:[ID,Model,Classification,Year]}</property> <property name="inmemory_datasource_records"> {Vehicles:[["S10_1678","Harley Davidson Ultimate Chopper","Motorcycles","1969"], ["S10_1949","Alpine Renault 1300","Classic Cars","1952"], ["S10_2016","Moto Guzzi 1100i","Motorcycles","1996"], ["S10_4698","Harley-Davidson Eagle Drag Bike","Motorcycles","2003"], ["S10_4757","Alfa Romeo GTA","Classic Cars","1972"], ["S10_4962","LanciaA Delta 16V","Classic Cars","1962"], ["S12_1099","Ford Mustang","Classic Cars","1968"], ["S12_1108","Ferrari Enzo","Classic Cars","2001"]]} </property> </customDataSourceProps> </configuration>
XML configuration for a custom query datasource (DS_CUSTOM_QUERY):
Code Block <configuration> <customDataSourceClass>org.wso2.carbon.dataservices.core.custom.datasource.EchoDataSource</customDataSourceClass> <customDataSourceProps> <property name="p1">val1</property> <property name="p2">val2</property> </customDataSourceProps> </configuration>
...