try {
Map<String, Object> aConfig = new HashMap<String, Object>(mConfig);
aConfig.putAll(theMap);
DataSource aSource = mDataSourceFactoryProvider.create(aConfig);
if (!(aSource instanceof MutableDataSource)) {
throw new IllegalArgumentException("Cannot use Empire with a non-mutable Data source");
}
if (isUseEmpireTransactions() && !(aSource instanceof SupportsTransactions)) {
aSource = new TransactionalDataSource((MutableDataSource) aSource);
}
aSource.connect();
return new EntityManagerImpl( (MutableDataSource) aSource);
}
catch (ConnectException e) {
throw new IllegalStateException("Could not connect to the data source", e);