Search in sources :

Example 1 with TDataBaseConfig

use of org.wso2.carbon.bpel.config.TDataBaseConfig in project carbon-business-process by wso2.

the class BPELServerConfiguration method populateDataSourceConfigFields.

private void populateDataSourceConfigFields() {
    TDataBaseConfig databaseConfig = bpsConfigDocument.getWSO2BPS().getDataBaseConfig();
    if (databaseConfig != null) {
        // Now we do not have concept called EMBEDDED. All the DBs are configured as EXTERNAL.
        // This way users can modify the default db config as well. And also support the
        // -Dsetup
        dsType = DataSourceType.EXTERNAL;
        if (databaseConfig.getDataSource().getName() != null && databaseConfig.getDataSource().getName().length() > 0) {
            dataSourceName = databaseConfig.getDataSource().getName();
        } else {
            throw new RuntimeException("Data Source name cannot be null, " + "when data source mode is external.");
        }
        if (databaseConfig.getDataSource().isSetJNDI()) {
            TDataBaseConfig.DataSource.JNDI jndiConfig = databaseConfig.getDataSource().getJNDI();
            if (jndiConfig.getContextFactory() != null && jndiConfig.getContextFactory().length() > 0 && jndiConfig.getProviderURL() != null && jndiConfig.getProviderURL().length() > 0) {
                dataSourceJNDIRepoInitialContextFactory = jndiConfig.getContextFactory().trim();
                dataSourceJNDIRepoProviderURL = jndiConfig.getProviderURL().trim();
                // Read Port Offset
                int portOffset = readPortOffset();
                // applying port offset operation
                String urlWithoutPort = dataSourceJNDIRepoProviderURL.substring(0, dataSourceJNDIRepoProviderURL.lastIndexOf(':') + 1);
                int dataSourceJNDIRepoProviderPort = Integer.parseInt(dataSourceJNDIRepoProviderURL.substring(urlWithoutPort.length())) + portOffset;
                dataSourceJNDIRepoProviderURL = urlWithoutPort + dataSourceJNDIRepoProviderPort;
            }
        }
    }
}
Also used : TDataBaseConfig(org.wso2.carbon.bpel.config.TDataBaseConfig)

Aggregations

TDataBaseConfig (org.wso2.carbon.bpel.config.TDataBaseConfig)1