Project

General

Profile

1
package eu.dnetlib.index.actors;
2

    
3
import akka.actor.ActorSystem;
4
import akka.actor.TypedActor;
5
import akka.actor.TypedProps;
6
import akka.japi.Creator;
7
import eu.dnetlib.clients.index.utils.ServiceTools;
8
import eu.dnetlib.index.IndexServerDAOMap;
9
import eu.dnetlib.cql.CqlTranslator;
10
import eu.dnetlib.miscutils.factory.Factory;
11
import org.springframework.beans.factory.annotation.Autowired;
12
import org.springframework.beans.factory.annotation.Required;
13

    
14
// TODO: Auto-generated Javadoc
15
// TODO springify actor parameter with a prototype bean
16

    
17
/**
18
 * A factory for creating IndexFeedActor objects.
19
 */
20
public class IndexFeedActorFactory implements Factory<IndexFeedActor> {
21

    
22
	/**
23
	 * The index server dao map.
24
	 */
25
	private IndexServerDAOMap indexServerDAOMap;
26

    
27
	/**
28
	 * The service tools.
29
	 */
30
	@Autowired
31
	private ServiceTools serviceTools;
32

    
33
	/**
34
	 * The actor system.
35
	 */
36
	private ActorSystem actorSystem;
37

    
38
	/**
39
	 * CqlTranslator.
40
	 */
41
	@Autowired
42
	private CqlTranslator translator;
43

    
44
	/**
45
	 * {@inheritDoc}
46
	 *
47
	 * @see Factory#newInstance()
48
	 */
49
	@Override
50
	public IndexFeedActor newInstance() {
51
		return TypedActor.get(getActorSystem()).typedActorOf(new TypedProps<>(IndexFeedActor.class, (Creator<IndexFeedActorImpl>) () ->
52
				new IndexFeedActorImpl(getIndexServerDAOMap(), getServiceTools(), translator)));
53
	}
54

    
55
	/**
56
	 * Gets the service tools.
57
	 *
58
	 * @return the service tools
59
	 */
60
	public ServiceTools getServiceTools() {
61
		return serviceTools;
62
	}
63

    
64
	/**
65
	 * Sets the service tools.
66
	 *
67
	 * @param serviceTools the new service tools
68
	 */
69
	public void setServiceTools(final ServiceTools serviceTools) {
70
		this.serviceTools = serviceTools;
71
	}
72

    
73
	/**
74
	 * Gets the actor system.
75
	 *
76
	 * @return the actor system
77
	 */
78
	public ActorSystem getActorSystem() {
79
		return actorSystem;
80
	}
81

    
82
	/**
83
	 * Sets the actor system.
84
	 *
85
	 * @param actorSystem the new actor system
86
	 */
87
	@Required
88
	public void setActorSystem(final ActorSystem actorSystem) {
89
		this.actorSystem = actorSystem;
90
	}
91

    
92
	/**
93
	 * Gets the index server dao map.
94
	 *
95
	 * @return the indexServerDAOMap
96
	 */
97
	public IndexServerDAOMap getIndexServerDAOMap() {
98
		return indexServerDAOMap;
99
	}
100

    
101
	/**
102
	 * Sets the index server dao map.
103
	 *
104
	 * @param indexServerDAOMap the indexServerDAOMap to set
105
	 */
106
	@Required
107
	public void setIndexServerDAOMap(final IndexServerDAOMap indexServerDAOMap) {
108
		this.indexServerDAOMap = indexServerDAOMap;
109
	}
110

    
111
}
(5-5/8)