我如何在java中使用自定义构造函数创建actor?我搜索了文档,但没有找到它。
这是我的演员:
public class ResizePhotoActor extends UntypedActor {
private int width;
private int height;
private String caption;
public ResizePhotoActor(int width, int height, String caption) {
this.height = height;
this.width = width;
this.caption = caption;
}
public void onReceive(Object message) throws Exception {
}
}
我试过这个:
ActorRef imageActorRef = system.actorOf(
Props.create(new ResizePhotoActor(1, 2, "")));
但它不起作用。
谢谢
答案 0 :(得分:19)
ActorRef imageActorRef = system.actorOf(Props.create(ResizePhotoActor.class, 1, 2, ""));
文档:http://doc.akka.io/docs/akka/current/java/actors.html#Props