Class Adapter

java.lang.Object
org.apache.pekko.actor.typed.javadsl.Adapter

public class Adapter extends Object
Adapters between typed and classic actors and actor systems. The underlying ActorSystem is the classic pekko.actor.ActorSystem which runs Akka pekko.actor.typed.Behavior on an emulation layer. In this system typed and classic actors can coexist.

These methods make it possible to create a child actor from classic parent actor, and the opposite classic child from typed parent. watch is also supported in both directions.

There are also converters (toTyped, toClassic) between classic pekko.actor.ActorRef and pekko.actor.typed.ActorRef, and between classic pekko.actor.ActorSystem and pekko.actor.typed.ActorSystem.

  • Constructor Details

    • Adapter

      public Adapter()
  • Method Details

    • spawnAnonymous

      public static <T> ActorRef<T> spawnAnonymous(ActorSystem sys, Behavior<T> behavior)
      Spawn the given behavior as a child of the user actor in a classic ActorSystem. Actor default supervision strategy is to stop. Can be overridden with Behaviors.supervise.
    • spawnAnonymous

      public static <T> ActorRef<T> spawnAnonymous(ActorSystem sys, Behavior<T> behavior, Props props)
      Spawn the given behavior as a child of the user actor in a classic ActorSystem. Actor default supervision strategy is to stop. Can be overridden with Behaviors.supervise.
    • spawn

      public static <T> ActorRef<T> spawn(ActorSystem sys, Behavior<T> behavior, String name)
      Spawn the given behavior as a child of the user actor in a classic ActorSystem. Actor default supervision strategy is to stop. Can be overridden with Behaviors.supervise.
    • spawn

      public static <T> ActorRef<T> spawn(ActorSystem sys, Behavior<T> behavior, String name, Props props)
      Spawn the given behavior as a child of the user actor in a classic ActorSystem. Actor default supervision strategy is to stop. Can be overridden with Behaviors.supervise.
    • spawnAnonymous

      public static <T> ActorRef<T> spawnAnonymous(ActorContext ctx, Behavior<T> behavior)
      Spawn the given behavior as a child of the user actor in a classic ActorContext. Actor default supervision strategy is to stop. Can be overridden with Behaviors.supervise.
    • spawnAnonymous

      public static <T> ActorRef<T> spawnAnonymous(ActorContext ctx, Behavior<T> behavior, Props props)
      Spawn the given behavior as a child of the user actor in a classic ActorContext. Actor default supervision strategy is to stop. Can be overridden with Behaviors.supervise.
    • spawn

      public static <T> ActorRef<T> spawn(ActorContext ctx, Behavior<T> behavior, String name)
      Spawn the given behavior as a child of the user actor in a classic ActorContext. Actor default supervision strategy is to stop. Can be overridden with Behaviors.supervise.
    • spawn

      public static <T> ActorRef<T> spawn(ActorContext ctx, Behavior<T> behavior, String name, Props props)
      Spawn the given behavior as a child of the user actor in a classic ActorContext. Actor default supervision strategy is to stop. Can be overridden with Behaviors.supervise.
    • toTyped

      public static ActorSystem<Void> toTyped(ActorSystem sys)
    • toClassic

      public static ActorSystem toClassic(ActorSystem<?> sys)
    • toClassic

      public static ActorContext toClassic(ActorContext<?> ctx)
    • watch

      public static <U> void watch(ActorContext ctx, ActorRef<U> other)
    • unwatch

      public static <U> void unwatch(ActorContext ctx, ActorRef<U> other)
    • stop

      public static void stop(ActorContext ctx, ActorRef<?> child)
    • watch

      public static <U> void watch(ActorContext<?> ctx, ActorRef other)
    • unwatch

      public static <U> void unwatch(ActorContext<?> ctx, ActorRef other)
    • stop

      public static void stop(ActorContext<?> ctx, ActorRef child)
    • actorOf

      public static ActorRef actorOf(ActorContext<?> ctx, Props props)
    • actorOf

      public static ActorRef actorOf(ActorContext<?> ctx, Props props, String name)
    • toClassic

      public static ActorRef toClassic(ActorRef<?> ref)
    • toTyped

      public static <T> ActorRef<T> toTyped(ActorRef ref)
    • props

      public static <T> Props props(Creator<Behavior<T>> behavior, Props deploy)
      Wrap pekko.actor.typed.Behavior in a classic pekko.actor.Props, i.e. when spawning a typed child actor from a classic parent actor. This is normally not needed because you can use the extension methods spawn and spawnAnonymous with a classic ActorContext, but it's needed when using typed actors with an existing library/tool that provides an API that takes a classic pekko.actor.Props parameter. Cluster Sharding is an example of that.
    • props

      public static <T> Props props(Creator<Behavior<T>> behavior)
      Wrap pekko.actor.typed.Behavior in a classic pekko.actor.Props, i.e. when spawning a typed child actor from a classic parent actor. This is normally not needed because you can use the extension methods spawn and spawnAnonymous with a classic ActorContext, but it's needed when using typed actors with an existing library/tool that provides an API that takes a classic pekko.actor.Props parameter. Cluster Sharding is an example of that.
    • toClassic

      public static Scheduler toClassic(Scheduler scheduler)
    • toTyped

      public static <T> Scheduler toTyped(Scheduler scheduler)