@PostConstruct public void init() { Collection<ICustomerContext> customers = customerContextHolder.getCustomerContexts(); for (ICustomerContext customerContext : customers) { try { DataSource dataSource = configurableDataSourceFactory.createDataSource(customerContext); resolvedDataSources.put(customerContext.getCustomerId(), dataSource); } catch (Exception e) { logger.error( "Unable to create DataSource for customer [" + customerContext.getCustomerId() + "]", e); } } }
protected DataSource resolveSpecifiedDataSource(ICustomerContext customerContext) throws IllegalArgumentException { try { DataSource dataSource = null; synchronized (customerContext) { dataSource = configurableDataSourceFactory.createDataSource(customerContext); this.resolvedDataSources.put(customerContext.getCustomerId(), dataSource); } return dataSource; } catch (Exception e) { String msg = "Unable to create DataSource for customer [" + customerContext.getCustomerId() + "]"; logger.error(msg, e); throw new IllegalArgumentException(msg, e); } }