Search in sources :

Example 6 with SynapseCommonsException

use of org.apache.synapse.commons.SynapseCommonsException in project wso2-synapse by wso2.

the class InMemoryDataSourceRepository method register.

/**
 * Keep DataSource in the Local store.
 *
 * @param dataSourceInformation the information describing a data source
 * @see DataSourceRepository#register(DataSourceInformation)
 */
public void register(DataSourceInformation dataSourceInformation) {
    if (dataSourceInformation == null) {
        throw new SynapseCommonsException("DataSourceInformation cannot be found.", log);
    }
    DataSource dataSource = DataSourceFactory.createDataSource(dataSourceInformation);
    if (dataSource == null) {
        if (log.isDebugEnabled()) {
            log.debug("DataSource cannot be created or" + " found for DataSource Information " + dataSourceInformation);
        }
        return;
    }
    String name = dataSourceInformation.getDatasourceName();
    if (log.isDebugEnabled()) {
        log.debug("Registering a DatSource with name : " + name + " in Local Pool");
    }
    REPOSITORY.addMBean(name, new DBPoolView(name));
    dataSources.put(name, dataSource);
}
Also used : SynapseCommonsException(org.apache.synapse.commons.SynapseCommonsException) DataSource(javax.sql.DataSource)

Example 7 with SynapseCommonsException

use of org.apache.synapse.commons.SynapseCommonsException in project wso2-synapse by wso2.

the class JNDIBasedDataSourceRepository method unRegister.

public void unRegister(String name) {
    InitialContext context = getCachedInitialContext(name);
    try {
        context.unbind(name);
    } catch (NamingException e) {
        throw new SynapseCommonsException("Error removing a Datasource with name : " + name + " from the JNDI context : " + initialContext, e);
    }
    cachedNameList.remove(name);
}
Also used : SynapseCommonsException(org.apache.synapse.commons.SynapseCommonsException)

Aggregations

SynapseCommonsException (org.apache.synapse.commons.SynapseCommonsException)7 Properties (java.util.Properties)1 DataSource (javax.sql.DataSource)1 DataSourceInformation (org.apache.synapse.commons.datasource.DataSourceInformation)1 SecretInformation (org.wso2.securevault.secret.SecretInformation)1