1
|
package eu.dnetlib.index.actors;
|
2
|
|
3
|
import java.util.Map;
|
4
|
|
5
|
import com.google.common.collect.Maps;
|
6
|
import eu.dnetlib.rmi.provision.IndexServiceException;
|
7
|
|
8
|
// TODO: Auto-generated Javadoc
|
9
|
|
10
|
/**
|
11
|
* The Class ActorMap.
|
12
|
*/
|
13
|
public class ActorMap {
|
14
|
|
15
|
/**
|
16
|
* Map of Index actors.
|
17
|
*/
|
18
|
private transient Map<String, IndexFeedActor> actorMap = Maps.newConcurrentMap();
|
19
|
|
20
|
/**
|
21
|
* Checks for actor.
|
22
|
*
|
23
|
* @param backendId the backend Identifier
|
24
|
* @return true, if successful
|
25
|
*/
|
26
|
public boolean hasActor(final String backendId) {
|
27
|
return actorMap.containsKey(backendId);
|
28
|
}
|
29
|
|
30
|
/**
|
31
|
* Gets the actor.
|
32
|
*
|
33
|
* @param backendId the backend Identifier
|
34
|
* @return the actor
|
35
|
* @throws IndexServiceException the index service exception
|
36
|
*/
|
37
|
public IndexFeedActor getActor(final String backendId) throws IndexServiceException {
|
38
|
if (!hasActor(backendId)) throw new IndexServiceException("Actor not found for protocol ID " + backendId);
|
39
|
return actorMap.get(backendId);
|
40
|
}
|
41
|
|
42
|
/**
|
43
|
* Adds the actor.
|
44
|
*
|
45
|
* @param backendId the backend Identifier
|
46
|
* @param actor the actor
|
47
|
*/
|
48
|
public void addActor(final String backendId, final IndexFeedActor actor) {
|
49
|
actorMap.put(backendId, actor);
|
50
|
}
|
51
|
|
52
|
}
|