@@ -0,0 +1,1070 @@
+package cz.cuni.mff.d3s.spl.core.data;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0Aimport java.util.NoSuchElementException;%0A%0A%0Apublic class DataSourceRegister %7B%0A%0A%09private static Map%3CString, DataSource%3E register = new HashMap%3C%3E();%0A%09%0A%09public static void put(String id, DataSource source) %7B%0A%09%09if ((id == null) %7C%7C (source == null)) %7B%0A%09%09%09throw new IllegalArgumentException(%22Parameter cannot be null.%22);%0A%09%09%7D%0A%09%09synchronized (register) %7B%0A%09%09%09register.put(id, source);%09%09%09%0A%09%09%7D%0A%09%7D%0A%09%0A%09/** Retrieve previously stored data source.%0A%09 * %0A%09 * This function always returns a valid data source (or throws an%0A%09 * exception).%0A%09 * %0A%09 * @param id Data source id.%0A%09 * @return Data source bound with given id.%0A%09 * @throw NoSuchElementException No data source with given id was stored.%0A%09 */%0A%09public static synchronized DataSource get(String id) %7B%0A%09%09DataSource source;%0A%09%09synchronized (register) %7B%0A%09%09%09source = register.get(id);%09%0A%09%09%7D%0A%09%09if (source == null) %7B%0A%09%09%09String msg = String.format(%22No data source %60%25s' registered.%22, id);%0A%09%09%09throw new NoSuchElementException(msg);%0A%09%09%7D%0A%09%09return source;%0A%09%7D%0A%7D%0A

Add a global storage for data sources