WSO2 Carbon Data Sources [Documentation Index]

WSO2 Carbon Data Sources

This guide describes how WSO2 Carbon Data Sources can be used, configured and its improvements over the previous Data Source implementation. WSO2Carbon 4.0.0 is shipped with WSO2 Carbon Data Source implementation which can be used to create global and local data sources.

Contents

Introduction to WSO2 Carbon Data Sources

WSO2 Carbon Core is added with new Data Source implementation support. This functionality is to be used by registry / user manager in looking up data sources using JNDI. Therefore it has been added to Carbon Core.

Improvements of Carbon Data Source over older Data Source implementation

  • The connection pooling implementation has been changed to jdbc-pool, from DBCP. All of jdbc-pool properties are supported.

  • Carbon Secure Vault support.

  • Database provider given DataSource support, i.e. that implements javax.sql.DataSource, javax.sql.XADataSource. For example if someone need to use Oracle supplied poolable DataSource implementation, it is possible to do so, and also required for creating data sources to be used in distributed transactions.

  • Automatic sync of data sources in a clustered environment using the coordination component.

  • Pluggable data source types, so other than RDBMS data sources can be registered using this (for in-memory, JNDI access).

Carbon Data Source Configuration

Data Sources are defined inside a separate directory at /repository/conf/datasources/. Inside this directory there is a single file 'master-datasources.xml' that is coming from Carbon Core. It contains the data source definition for registry/user-manager database. A single file can contain multiple data sources. If more data sources need to be added, a new file with the pattern *-datasources.xml can be created and it will be loaded. This was done for easy addition of data sources. For example, bps-datasources.xml can be maintained seperately without maintaining one global datasource file. This means it has to maintain data sources used in Carbon Core in their product.

Using Carbon Data Source Implementation

Carbon Data Source Implementation can be used in two ways.

1. Creating Local Data sources

Carbon Data Sources provide an API for creating DataSource objects to create connections. This will be creating your own data sources locally in your app, without registering it in a global way. For that we need to simply use the "org.wso2.carbon.ndatasource.rdbms.RDBMSDataSource", where we can give it the properties like connection URL, User, Password, etc and create the connections.

2. Creating Gloabal Data Sources

In this case Data Sources are registered globally, using the *-datasources.xml files in the file system or in the registry by using the UI. In this way, you can do a JNDI lookup or use the OSGi service that is provided to do an in-memory lookup to get the data sources. The advantage of this is, the connection pools are centrally handled. Also this provide automatic sync of data sources within a cluster, where if you update/delete a data source in one node it will be reflected by all the nodes in the cluster.