|
6 | 6 | import com.codefork.refine.ThreadPool; |
7 | 7 | import com.codefork.refine.ThreadPoolFactory; |
8 | 8 | import com.codefork.refine.datasource.ConnectionFactory; |
| 9 | +import com.codefork.refine.datasource.SearchTask; |
| 10 | +import com.codefork.refine.datasource.WebServiceSearchTask; |
9 | 11 | import com.codefork.refine.datasource.stats.Stats; |
10 | 12 | import com.codefork.refine.datasource.WebServiceDataSource; |
11 | 13 | import com.codefork.refine.resources.NameType; |
@@ -47,15 +49,39 @@ public class VIAF extends WebServiceDataSource { |
47 | 49 | private VIAFSource viafSource = null; |
48 | 50 | private Map<String, NonVIAFSource> nonViafSources = new HashMap<>(); |
49 | 51 |
|
| 52 | + private int delay = 0; |
| 53 | + |
50 | 54 | @Autowired |
51 | 55 | public VIAF(Config config, CacheManager cacheManager, ThreadPoolFactory threadPoolFactory, ConnectionFactory connectionFactory, Stats stats) { |
52 | 56 | super(config, cacheManager, threadPoolFactory, connectionFactory, stats); |
53 | 57 |
|
54 | 58 | setCacheEnabled(true); |
55 | 59 |
|
| 60 | + var dataSourceProperties = config.getDataSourceProperties("viaf"); |
| 61 | + |
| 62 | + var threadPoolSize = dataSourceProperties.getProperty("threadpool.size"); |
| 63 | + if(threadPoolSize != null) { |
| 64 | + getLog().info("Setting pool size for VIAF to " + threadPoolSize); |
| 65 | + getThreadPool().setPoolSize(Integer.parseInt(threadPoolSize.strip())); |
| 66 | + } |
| 67 | + |
| 68 | + var delay = dataSourceProperties.getProperty("delay"); |
| 69 | + if(delay != null) { |
| 70 | + getLog().info("Setting delay to " + delay); |
| 71 | + setDelay(Integer.parseInt(delay.strip())); |
| 72 | + } |
| 73 | + |
56 | 74 | spf = SAXParserFactory.newInstance(); |
57 | 75 | } |
58 | 76 |
|
| 77 | + public int getDelay() { |
| 78 | + return delay; |
| 79 | + } |
| 80 | + |
| 81 | + public void setDelay(int delay) { |
| 82 | + this.delay = delay; |
| 83 | + } |
| 84 | + |
59 | 85 | /** |
60 | 86 | * Factory method for getting a NonVIAFSource object |
61 | 87 | */ |
@@ -115,6 +141,14 @@ public static String createCqlQueryString(SearchQuery searchQuery) { |
115 | 141 | return cql; |
116 | 142 | } |
117 | 143 |
|
| 144 | + /** |
| 145 | + * Override so we can add an optional delay to the task |
| 146 | + **/ |
| 147 | + @Override |
| 148 | + public SearchTask createSearchTask(String key, SearchQuery searchQuery) { |
| 149 | + return new WebServiceSearchTask(this, key, searchQuery, getDelay()); |
| 150 | + } |
| 151 | + |
118 | 152 | /** |
119 | 153 | * Does actual work of performing a search and parsing the XML. |
120 | 154 | * @param query |
|
0 commit comments