// Path: src/main/java/com/codefork/refine/Config.java
// @Component
// public class Config {
// 
//     public static final String PROP_CACHE_ENABLED = "cache.enabled";
//     public static final String PROP_CACHE_TTL = "cache.ttl";
//     public static final String PROP_CACHE_SIZE = "cache.size";
// 
//     private static final String CONFIG_FILENAME = "conciliator.properties";
// 
//     private Log log = LogFactory.getLog(Config.class);
//     private Properties properties = new Properties();
// 
//     public Config() {
//         properties.put(PROP_CACHE_ENABLED, "true");
//         properties.put(PROP_CACHE_TTL, "3600");
//         properties.put(PROP_CACHE_SIZE, "64MB");
// 
//         properties.put("datasource.orcid.name", "ORCID");
//         properties.put("datasource.orcidsmartnames.name", "ORCID - Smart Names Mode");
//         properties.put("datasource.openlibrary.name", "OpenLibrary");
//         loadFromFile();
//     }
// 
//     public void loadFromFile() {
//         if(new File(CONFIG_FILENAME).exists()) {
//             try {
//                 log.info("Loading configuration from " + CONFIG_FILENAME);
//                 Properties p = new Properties();
//                 p.load(new FileInputStream(CONFIG_FILENAME));
//                 merge(p);
//             } catch (IOException ex) {
//                 log.error("Error reading config file, skipping it: " + ex);
//             }
//         }
//     }
// 
//     public void merge(Properties properties) {
//         this.properties.putAll(properties);
//     }
// 
//     public Properties getProperties() {
//         return properties;
//     }
// 
//     /**
//      * Returns the properties relevant to a given data source name,
//      * with the datasource.NAME prefix stripped off.
//      *
//      * e.g.
//      * datasource.mysource.timeout=2000
//      *
//      * the Properties object returned will have key "timeout" with value "2000"
//      *
//      * @param name
//      * @return
//      */
//     public Properties getDataSourceProperties(String name) {
//         Properties props = new Properties();
//         for(String key : getProperties().stringPropertyNames()) {
//             String prefix = "datasource." + name;
//             if(key.startsWith(prefix)) {
//                 String shortenedKey = key.substring(prefix.length()).replaceAll("^\\.+", "");
//                 if(shortenedKey.length() > 0) {
//                     props.setProperty(shortenedKey, getProperties().getProperty(key));
//                 }
//             }
//         }
//         return props;
//     }
// 
// }
// 
// Path: src/main/java/com/codefork/refine/ThreadPoolFactory.java
// @Component
// public class ThreadPoolFactory {
// 
//     private Map<String, ThreadPool> sharedThreadPools = new HashMap<>();
// 
//     public ThreadPool createThreadPool() {
//         return new ThreadPool();
//     }
// 
//     public ThreadPool getSharedThreadPool(String key) {
//         if(!sharedThreadPools.containsKey(key)) {
//             sharedThreadPools.put(key, new ThreadPool());
//         }
//         return sharedThreadPools.get(key);
//     }
// 
//     public void releaseThreadPool(ThreadPool pool) {
//         for(ThreadPool p: sharedThreadPools.values()) {
//             if(p.equals(pool)) {
//                 // we never shut down shared thread pools.
//                 // TODO: keep a count of how many things use
//                 // a shared thread pool and release when 0.
//                 return;
//             }
//         }
//         pool.shutdown();
//     }
// 
// }
// 
// Path: src/main/java/com/codefork/refine/datasource/ConnectionFactory.java
// public interface ConnectionFactory {
// 
//     HttpURLConnection createConnection(String url) throws IOException;
// 
// }


import com.codefork.refine.Config;
import com.codefork.refine.ThreadPoolFactory;
import com.codefork.refine.datasource.ConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Component;
package com.codefork.refine.solr;


/**
 * Example of a second Solr data source. You can create as many solr data sources
 * as you want, by copying/renaming this file.
 *
 * The name of this class doesn't actually matter, as long as it's unique and matches
 * the .java filename.
 *
 * @Component specifies the name that Spring uses for injection; it should match the
 * string in the @Qualifier annotation on DataSourceController.setDataSource().
 *
 * getConfigName() should return a name used for the keys in the conciliator.properties file.
 */
@Component("anothersolr")
public class AnotherSolr extends Solr {

    @Autowired
// Path: src/main/java/com/codefork/refine/Config.java
// @Component
// public class Config {
// 
//     public static final String PROP_CACHE_ENABLED = "cache.enabled";
//     public static final String PROP_CACHE_TTL = "cache.ttl";
//     public static final String PROP_CACHE_SIZE = "cache.size";
// 
//     private static final String CONFIG_FILENAME = "conciliator.properties";
// 
//     private Log log = LogFactory.getLog(Config.class);
//     private Properties properties = new Properties();
// 
//     public Config() {
//         properties.put(PROP_CACHE_ENABLED, "true");
//         properties.put(PROP_CACHE_TTL, "3600");
//         properties.put(PROP_CACHE_SIZE, "64MB");
// 
//         properties.put("datasource.orcid.name", "ORCID");
//         properties.put("datasource.orcidsmartnames.name", "ORCID - Smart Names Mode");
//         properties.put("datasource.openlibrary.name", "OpenLibrary");
//         loadFromFile();
//     }
// 
//     public void loadFromFile() {
//         if(new File(CONFIG_FILENAME).exists()) {
//             try {
//                 log.info("Loading configuration from " + CONFIG_FILENAME);
//                 Properties p = new Properties();
//                 p.load(new FileInputStream(CONFIG_FILENAME));
//                 merge(p);
//             } catch (IOException ex) {
//                 log.error("Error reading config file, skipping it: " + ex);
//             }
//         }
//     }
// 
//     public void merge(Properties properties) {
//         this.properties.putAll(properties);
//     }
// 
//     public Properties getProperties() {
//         return properties;
//     }
// 
//     /**
//      * Returns the properties relevant to a given data source name,
//      * with the datasource.NAME prefix stripped off.
//      *
//      * e.g.
//      * datasource.mysource.timeout=2000
//      *
//      * the Properties object returned will have key "timeout" with value "2000"
//      *
//      * @param name
//      * @return
//      */
//     public Properties getDataSourceProperties(String name) {
//         Properties props = new Properties();
//         for(String key : getProperties().stringPropertyNames()) {
//             String prefix = "datasource." + name;
//             if(key.startsWith(prefix)) {
//                 String shortenedKey = key.substring(prefix.length()).replaceAll("^\\.+", "");
//                 if(shortenedKey.length() > 0) {
//                     props.setProperty(shortenedKey, getProperties().getProperty(key));
//                 }
//             }
//         }
//         return props;
//     }
// 
// }
// 
// Path: src/main/java/com/codefork/refine/ThreadPoolFactory.java
// @Component
// public class ThreadPoolFactory {
// 
//     private Map<String, ThreadPool> sharedThreadPools = new HashMap<>();
// 
//     public ThreadPool createThreadPool() {
//         return new ThreadPool();
//     }
// 
//     public ThreadPool getSharedThreadPool(String key) {
//         if(!sharedThreadPools.containsKey(key)) {
//             sharedThreadPools.put(key, new ThreadPool());
//         }
//         return sharedThreadPools.get(key);
//     }
// 
//     public void releaseThreadPool(ThreadPool pool) {
//         for(ThreadPool p: sharedThreadPools.values()) {
//             if(p.equals(pool)) {
//                 // we never shut down shared thread pools.
//                 // TODO: keep a count of how many things use
//                 // a shared thread pool and release when 0.
//                 return;
//             }
//         }
//         pool.shutdown();
//     }
// 
// }
// 
// Path: src/main/java/com/codefork/refine/datasource/ConnectionFactory.java
// public interface ConnectionFactory {
// 
//     HttpURLConnection createConnection(String url) throws IOException;
// 
// }


// Path: src/main/java/com/codefork/refine/solr/AnotherSolr.java
import com.codefork.refine.Config;
import com.codefork.refine.ThreadPoolFactory;
import com.codefork.refine.datasource.ConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Component;

package com.codefork.refine.solr;


/**
 * Example of a second Solr data source. You can create as many solr data sources
 * as you want, by copying/renaming this file.
 *
 * The name of this class doesn't actually matter, as long as it's unique and matches
 * the .java filename.
 *
 * @Component specifies the name that Spring uses for injection; it should match the
 * string in the @Qualifier annotation on DataSourceController.setDataSource().
 *
 * getConfigName() should return a name used for the keys in the conciliator.properties file.
 */
@Component("anothersolr")
public class AnotherSolr extends Solr {

    @Autowired
    public AnotherSolr(Config config, CacheManager cacheManager, ThreadPoolFactory threadPoolFactory, ConnectionFactory connectionFactory) {