Project

General

Profile

1 29078 michele.ar
package eu.dnetlib.functionality.index.client;
2
3
import java.util.List;
4
5
import javax.annotation.Resource;
6
7 29686 sandro.lab
/**
8
 * The Class GlobalIndexClientFactory.
9
 */
10
11
/**
12
 * The Class ResolvingIndexClientFactory.
13
 */
14
public class ResolvingIndexClientFactory {
15
16
	/** The index client factories. */
17 29078 michele.ar
	@Resource
18 29686 sandro.lab
	private List<IndexClientFactory> indexClientFactories;
19
20
	/**
21
	 * Gets the client.
22 32572 michele.ar
	 *
23 29686 sandro.lab
	 * @param format
24
	 *            the format
25
	 * @param layout
26
	 *            the layout
27
	 * @param interpretation
28
	 *            the interpretation
29
	 * @param backendId
30
	 *            the backend id
31
	 * @return the client
32
	 * @throws IndexClientException
33
	 *             the index client exception
34
	 */
35
	public IndexClient getClient(final String format, final String layout, final String interpretation, final String backendId) throws IndexClientException {
36
		for (IndexClientFactory factory : indexClientFactories) {
37 32572 michele.ar
			if (factory.getBackendId().equalsIgnoreCase(backendId)) { return factory.getClient(format, layout, interpretation); }
38 29078 michele.ar
		}
39 29686 sandro.lab
		throw new IndexClientException("No client for bakendId: " + backendId);
40 29078 michele.ar
	}
41
42
}