Akka Java : 创建一个带有参数的构造函数的actor
Akka Java : create an actor with constructor taking parameters
如何在 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, "")));
但是没用。
谢谢
ActorRef imageActorRef = system.actorOf(Props.create(ResizePhotoActor.class, 1, 2, ""));
文档:http://doc.akka.io/docs/akka/current/java/actors.html#Props
如何在 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, "")));
但是没用。
谢谢
ActorRef imageActorRef = system.actorOf(Props.create(ResizePhotoActor.class, 1, 2, ""));
文档:http://doc.akka.io/docs/akka/current/java/actors.html#Props