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);
}
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);
}
Aggregations