@Test public void mustGetTheTypedActorExtension() { try { // #typed-actor-extension-tools // Returns the Typed Actor Extension TypedActorExtension extension = TypedActor.get(system); // system is an instance of ActorSystem // Returns whether the reference is a Typed Actor Proxy or not TypedActor.get(system).isTypedActor(someReference); // Returns the backing Akka Actor behind an external Typed Actor Proxy TypedActor.get(system).getActorRefFor(someReference); // Returns the current ActorContext, // method only valid within methods of a TypedActor implementation ActorContext context = TypedActor.context(); // Returns the external proxy of the current Typed Actor, // method only valid within methods of a TypedActor implementation Squarer sq = TypedActor.<Squarer>self(); // Returns a contextual instance of the Typed Actor Extension // this means that if you create other Typed Actors with this, // they will become children to the current Typed Actor. TypedActor.get(TypedActor.context()); // #typed-actor-extension-tools } catch (Exception e) { // dun care } }
@Test public void createHierarchies() { try { // #typed-actor-hierarchy Squarer childSquarer = TypedActor.get(TypedActor.context()) .typedActorOf(new TypedProps<SquarerImpl>(Squarer.class, SquarerImpl.class)); // Use "childSquarer" as a Squarer // #typed-actor-hierarchy } catch (Exception e) { // dun care } }