我如何在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 {
}
}
Run Code Online (Sandbox Code Playgroud)
我试过这个:
ActorRef imageActorRef = system.actorOf(
Props.create(new ResizePhotoActor(1, 2, "")));
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
谢谢
Inf*_*ity 20
ActorRef imageActorRef = system.actorOf(Props.create(ResizePhotoActor.class, 1, 2, ""));
Run Code Online (Sandbox Code Playgroud)
文件:http://doc.akka.io/docs/akka/current/java/actors.html#Props