Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 初始化Akka中的演员,播放2.4.2_Java_Playframework 2.0_Akka - Fatal编程技术网

Java 初始化Akka中的演员,播放2.4.2

Java 初始化Akka中的演员,播放2.4.2,java,playframework-2.0,akka,Java,Playframework 2.0,Akka,我的应用程序有一个组件,Processor.java,它监听来自外部源的事件。我想使用参与者将这些事件传递到套接字中。我有一类处理这些事件的演员: public class EventProcessor extends UntypedActor { static ActorRef channel = Akka.system().actorOf(Props.create(EventProcessor.class)); public void onReceive(Object m

我的应用程序有一个组件,
Processor.java
,它监听来自外部源的事件。我想使用参与者将这些事件传递到套接字中。我有一类处理这些事件的演员:

public class EventProcessor extends UntypedActor {

    static ActorRef channel = Akka.system().actorOf(Props.create(EventProcessor.class));

    public void onReceive(Object message) throws Exception {
        // do stuff here
    }

    public void handleMessage(String event) {
         // tell another actor to do stuff here
    }
}
我希望能够在
Process.java
中实例化
EventProcessor
类型的参与者。现在,我有这个:

ActorRef act = Akka.system().actorOf(new Props(EventProcessor.class), null);
act.handleMessage(str);
我收到一个编译错误:

constructor Props in class akka.actor.Props cannot be applied to given types;
  required: akka.actor.Deploy,java.lang.Class<?>,scala.collection.immutable.Seq<java.lang.Object>
  found: java.lang.Class<models.EventProcessor>
  reason: actual and formal argument lists differ in length
akka.actor.Props类中的构造函数Props不能应用于给定类型; 必需:akka.actor.Deploy、java.lang.Class、scala.collection.immutable.Seq 找到:java.lang.Class 原因:实际参数列表和正式参数列表长度不同 在我的例子中,在Akka中实例化演员的正确方法是什么

Props.create(Actor.class)
替换
新道具(YourActor.class)
。 我有同样的编译错误,它对我有效。 看

final Props props = Props.create(MyActor.class, arg1, arg2);