Project

General

Profile

1
package eu.dnetlib.functionality.index.client;
2

    
3
import java.util.List;
4

    
5
import javax.annotation.Resource;
6

    
7
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
8
import eu.dnetlib.enabling.tools.ServiceLocator;
9

    
10
/**
11
 * The Class GlobalIndexClientFactory.
12
 */
13

    
14
/**
15
 * The Class ResolvingIndexClientFactory.
16
 */
17
public class ResolvingIndexClientFactory {
18

    
19
	/** The index client factories. */
20
	@Resource
21
	private List<IndexClientFactory> indexClientFactories;
22

    
23
	/** The lookup locator. */
24
	@Resource(name = "lookupLocator")
25
	private ServiceLocator<ISLookUpService> lookupLocator;
26

    
27
	/**
28
	 * Gets the client.
29
	 *
30
	 * @param format
31
	 *            the format
32
	 * @param layout
33
	 *            the layout
34
	 * @param interpretation
35
	 *            the interpretation
36
	 * @param backendId
37
	 *            the backend id
38
	 * @return the client
39
	 * @throws IndexClientException
40
	 *             the index client exception
41
	 */
42
	public IndexClient getClient(final String format, final String layout, final String interpretation, final String backendId) throws IndexClientException {
43
		for (IndexClientFactory factory : indexClientFactories) {
44
			if (factory.getBackendId().equalsIgnoreCase(backendId)) return factory.getClient(format, layout, interpretation);
45
		}
46
		throw new IndexClientException("No client for bakendId: " + backendId);
47
	}
48

    
49
}
(6-6/6)