private DataSource connectDataSource(Map<String, String> content) throws BaseException { String typeKey = content.get(Helper.Keys.DataBuilderId); String dataSourceId = content.get(Helper.Keys.SourceId); if (typeKey == null) throw new MissingArgumentException( String.format("Argument %s is missing.", Helper.Keys.DataBuilderId)); if (dataSourceId == null) throw new MissingArgumentException( String.format("Argument %s is missing.", Helper.Keys.SourceId)); DataSourceBuilder connection = dataSourceBuilderListener.getInstance(typeKey); DataSource source = connection.createInstance(dataSourceId, content); source.setState(DataInformation.DataState.CONNECTING); Thread thread = new Thread() { public void run() { try { source.connect(); source.setState(DataInformation.DataState.READY); threads.remove(source.getId()); } catch (BaseException e) { e.printStackTrace(); threads.remove(source.getId()); dataSources.remove(source.getId()); } } }; threads.put(dataSourceId, thread); thread.start(); return source; }