Oyunun web sitesindeki documentation'u izleyerek Aktörüm şu şekilde yapılandırılmıştır;Bir Aktöre Yapılandırma ve Hizmeti Enjekte Etme
public class SuggestionActor extends UntypedActor {
public static Props props = Props.create(SuggestionActor.class);
private DAOService service;
private Configuration config;
@Inject
public SuggestionActor(DAOService service, Configuration config) {
this.service = service;
this.config = config;
}
@Override
public void onReceive(Object msg) throws Exception {
if(msg instanceof SayHello) {
// check if msg comes
Logger.info(((SayHello) msg).name + config.getString("dao.mode"));
}
}
}
- (dosyasına koyarak etkinleştirilmiş)
public class ActorProtocols {
public static class SayHello{
public final String name;
public SayHello(String name) {
this.name = name;
}
}
}
MyModule
public class MyModule extends AbstractModule implements AkkaGuiceSupport {
@Override
protected void configure() {
bindActor(SuggestionActor.class, "suggestion-actor");
}
}
Benim Kontrolör
@Singleton
public class SuggestionController extends Controller {
private static Logger.ALogger LOGGER = Logger.of(SuggestionController.class);
@Inject @Named("suggestion-actor")
private ActorRef suggestionActor;
public Result suggest(String message) {
ask(suggestionActor, new SayHello(message), 10000);
}
}
Ben aracılığıyla benim DAO nesne ve Yapılandırma enjekte çalışırsanız SuggestionActor, Pl şirketinde constructor injection ay a Atılarak neden: java.lang.IllegalArgumentException: sınıf aktörleri üzerinde eşleşen bir kurucu bulunamadı.Örnekler için hata: []
Fikirler?