I am trying to implement TypedActorin Java following the examples of Typed Actors (Java) . But I am afraid. I said akka-actor-1.1-M1.jar, akka-typed-actor-1.1-M1.jar, scala-library.jarbut it was not enough. I got an error in Eclipse, so I added aspectwerkz-2.0.jar, and aspectwerkz-core-2.0.jarin their way of assembly.
I am trying to use TypedActor with a custom constructor.
But now I get a compilation error:
Exception in thread "main" java.lang.NoSuchMethodError: org.codehaus.aspectwerkz.proxy.Proxy.newInstance([Ljava/lang/Class;[Ljava/lang/Object;ZZ)Ljava/lang/Object;
at akka.actor.TypedActor$.newInstance(TypedActor.scala:596)
at akka.actor.TypedActor$.newInstance(TypedActor.scala:634)
at akka.actor.TypedActor.newInstance(TypedActor.scala)
at com.example.actor.ActorTest.main(ActorTest.java:12)
Here is my code for BaseActor:
import akka.actor.TypedActor;
public class BaseActor extends TypedActor implements BaseService {
private String str;
private int num;
public BaseActor(String str, int num) {
this.str = str;
this.num = num;
System.out.println("booted");
}
public void testData(String str, int num) {
System.out.println(this.str + " " + this.num);
System.out.println(str + " " + num);
}
}
My interfacefor service:
public interface BaseService {
public void testData(String str, int num);
}
And the test class:
import akka.actor.TypedActor;
import akka.actor.TypedActorFactory;
public class ActorTest {
public static void main(String[] args) {
BaseService service = TypedActor.newInstance(BaseService.class,
new TypedActorFactory() {
public TypedActor create() {
return new BaseActor("someString", 12);
}
});
service.testData("Hello", 6);
}
}
In this example, they write:
Service service = TypedActor.newInstance(classOf[Service],
new TypedActorFactory() {
public TypedActor create() {
return new ServiceWithConstructorArgsImpl("someString", 500L));
});
But I don’t think classOf[Service]Java is, it is more like Scala.
How can I implement TypedActorusing a special constructor?