Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Another utility actor used in unit testing. Use this when you need to refer to the actor being tested by its path, but don't want to create all the actor parent actors.
package com.turbo.akka;
import akka.event.Logging;
import akka.event.LoggingAdapter;
* Utility actor that does nothing but take a Props and create
* whatever actor the Props points to
public class ChildCreationActor extends UntypedActor {
private final LoggingAdapter LOG = Logging.getLogger(getContext().system(), this);
public void onReceive(Object o) throws Exception {
if (o instanceof ChildArgs) {
ChildArgs childArgs = (ChildArgs)o;
ActorRef child = getContext().actorOf(childArgs.props, childArgs.actorName);"Created child actor: " + child.path().toString());
else {
* The only usable msg to ChildCreationActor. Defines the child actor to create
public static class ChildArgs {
public final String actorName;
public final Props props;
public ChildArgs(Props props, String actorName) {
this.actorName = actorName;
this.props = props;

This comment has been minimized.

Copy link

@SerialCoderer SerialCoderer commented May 22, 2014

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment