class DataSourceMapSetter {

    @SuppressWarnings("unchecked")
    public static Map<String, DataSource> getDataSourceMap(final Environment environment) {
        Map<String, DataSource> result = new LinkedHashMap<>();
        Map<String, Object> dataSourceCommonProps = PropertyUtil.handle(environment, COMMON_PREFIX, Map.class);
        for (String each : getDataSourceNames(environment, PREFIX)) {
            try {
                result.put(each, getDataSource(environment, PREFIX, each, dataSourceCommonProps));
            } catch (final ReflectiveOperationException ex) {
                throw new ShardingSphereException("Can't find data source type.", ex);
            } catch (final NamingException ex) {
                throw new ShardingSphereException("Can't find JNDI data source.", ex);
            }
        }
        return result;
    }

}