How can I use a TypedActor in a Java application?

梦想的初衷 提交于 2019-12-06 08:43:11

Your code is correct, as far as I can see. To instantiate a TypedActor in Java with a non default constructor, you should use:

BaseService service = TypedActor.newInstance(BaseService.class,
                                                     new TypedActorFactory() {
            public TypedActor create() {
                return new BaseActor("someString", 12);
            }
        });

Indeed, the official doc contains a typo.

Can you try to use aspectwerkz-2.2.3? I have tried your code and it does work for me. The only difference is the version of aspectwerkz I'm using.

Also, please note that these are the dependencies for akka-typed-actor 1.1-M1:

<dependency org="org.codehaus.aspectwerkz" name="aspectwerkz" rev="2.2.3" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
<dependency org="aopalliance" name="aopalliance" rev="1.0" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
<dependency org="org.guiceyfruit" name="guice-all" rev="2.0" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
<dependency org="se.scalablesolutions.akka" name="akka-stm" rev="1.1-M1" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
<dependency org="org.scala-lang" name="scala-library" rev="2.9.0.RC1" force="true" conf="compile->compile(*),master(*);runtime->runtime(*)"/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!