Package java8guide.akka.ask

Source Code of java8guide.akka.ask.Application

/*
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
*/
package java8guide.akka.ask;

import javaguide.akka.HelloActor;
import javaguide.akka.HelloActorProtocol.SayHello;

//#ask
import akka.actor.*;
import play.mvc.*;
import play.libs.F.*;
import javax.inject.*;

import static akka.pattern.Patterns.ask;

@Singleton
public class Application extends Controller {

    final ActorRef helloActor;

    @Inject public Application(ActorSystem system) {
        helloActor = system.actorOf(HelloActor.props);
    }

    public Promise<Result> sayHello(String name) {
        return Promise.wrap(ask(helloActor, new SayHello(name), 1000))
            .map(response -> ok((String) response));
    }
}
//#ask
TOP

Related Classes of java8guide.akka.ask.Application

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.