/** * Create an injected child actor. * * @param create A function to create the actor. * @param name The name of the actor. * @return An ActorRef for the created actor. */ default ActorRef injectedChild(Supplier<Actor> create, String name) { return injectedChild(create, name, Function.identity()); }
/** * Bind an actor. * * This will cause the actor to be instantiated by Guice, allowing it to be dependency injected itself. It will * bind the returned ActorRef for the actor will be bound, qualified with the passed in name, so that it can be * injected into other components. * * @param actorClass The class that implements the actor. * @param name The name of the actor. */ default <T extends Actor> void bindActor(Class<T> actorClass, String name) { bindActor(actorClass, name, Function.identity()); }
/** * Create an injected child actor. * * @param create A function to create the actor. * @param name The name of the actor. * @param props A function to provide props for the actor. The props passed in will just describe how to create the * actor, this function can be used to provide additional configuration such as router and dispatcher * configuration. * @return An ActorRef for the created actor. */ default ActorRef injectedChild(Supplier<Actor> create, String name, Function<Props, Props> props) { return context().actorOf(props.apply(Props.create(Actor.class, create::get)), name); }
/** * Bind an actor. * * This will cause the actor to be instantiated by Guice, allowing it to be dependency injected itself. It will * bind the returned ActorRef for the actor will be bound, qualified with the passed in name, so that it can be * injected into other components. * * @param actorClass The class that implements the actor. * @param name The name of the actor. * @param props A function to provide props for the actor. The props passed in will just describe how to create the * actor, this function can be used to provide additional configuration such as router and dispatcher * configuration. */ default <T extends Actor> void bindActor(Class<T> actorClass, String name, Function<Props, Props> props) { BinderAccessor.binder(this).bind(ActorRef.class) .annotatedWith(Names.named(name)) .toProvider(Providers.guicify(Akka.providerOf(actorClass, name, props))) .asEagerSingleton(); }
/** * Create an injected child actor. * * @param create A function to create the actor. * @param name The name of the actor. * @return An ActorRef for the created actor. */ default ActorRef injectedChild(Supplier<Actor> create, String name) { return injectedChild(create, name, Function.identity()); }
/** * Create an injected child actor. * * @param create A function to create the actor. * @param name The name of the actor. * @param props A function to provide props for the actor. The props passed in will just describe how to create the * actor, this function can be used to provide additional configuration such as router and dispatcher * configuration. * @return An ActorRef for the created actor. */ default ActorRef injectedChild(Supplier<Actor> create, String name, Function<Props, Props> props) { return context().actorOf(props.apply(Props.create(Actor.class, create::get)), name); }
BinderAccessor.binder(this).install( new FactoryModuleBuilder() .implement(Actor.class, actorClass)
/** * Bind an actor. * * This will cause the actor to be instantiated by Guice, allowing it to be dependency injected itself. It will * bind the returned ActorRef for the actor will be bound, qualified with the passed in name, so that it can be * injected into other components. * * @param <T> the actor type. * @param actorClass The class that implements the actor. * @param name The name of the actor. */ default <T extends Actor> void bindActor(Class<T> actorClass, String name) { bindActor(actorClass, name, Function.identity()); }
/** * Create an injected child actor. * * @param create A function to create the actor. * @param name The name of the actor. * @return An ActorRef for the created actor. */ default ActorRef injectedChild(Supplier<Actor> create, String name) { return injectedChild(create, name, Function.identity()); }
/** * Create an injected child actor. * * @param create A function to create the actor. * @param name The name of the actor. * @param props A function to provide props for the actor. The props passed in will just describe how to create the * actor, this function can be used to provide additional configuration such as router and dispatcher * configuration. * @return An ActorRef for the created actor. */ default ActorRef injectedChild(Supplier<Actor> create, String name, Function<Props, Props> props) { return context().actorOf(props.apply(Props.create(Actor.class, create::get)), name); }
/** * Bind an actor factory. * * This is useful for when you want to have child actors injected, and want to pass parameters into them, as well as * have Guice provide some of the parameters. It is intended to be used with Guice's AssistedInject feature. * * See <a href="https://www.playframework.com/documentation/2.6.x/JavaAkka#Dependency-injecting-child-actors">Dependency-injecting-child-actors</a> * * @param <T> the actor type. * @param actorClass The class that implements the actor. * @param factoryClass The factory interface for creating the actor. */ default <T extends Actor> void bindActorFactory(Class<T> actorClass, Class<?> factoryClass) { BinderAccessor.binder(this).install( new FactoryModuleBuilder() .implement(Actor.class, actorClass) .build(factoryClass) ); } }
/** * Bind an actor. * * This will cause the actor to be instantiated by Guice, allowing it to be dependency injected itself. It will * bind the returned ActorRef for the actor will be bound, qualified with the passed in name, so that it can be * injected into other components. * * @param <T> the actor type. * @param actorClass The class that implements the actor. * @param name The name of the actor. */ default <T extends Actor> void bindActor(Class<T> actorClass, String name) { bindActor(actorClass, name, Function.identity()); }
/** * Create an injected child actor. * * @param create A function to create the actor. * @param name The name of the actor. * @return An ActorRef for the created actor. */ default ActorRef injectedChild(Supplier<Actor> create, String name) { return injectedChild(create, name, Function.identity()); }
/** * Create an injected child actor. * * @param create A function to create the actor. * @param name The name of the actor. * @param props A function to provide props for the actor. The props passed in will just describe how to create the * actor, this function can be used to provide additional configuration such as router and dispatcher * configuration. * @return An ActorRef for the created actor. */ default ActorRef injectedChild(Supplier<Actor> create, String name, Function<Props, Props> props) { return context().actorOf(props.apply(Props.create(Actor.class, create::get)), name); }
/** * Bind an actor factory. * * This is useful for when you want to have child actors injected, and want to pass parameters into them, as well as * have Guice provide some of the parameters. It is intended to be used with Guice's AssistedInject feature. * * See <a href="https://www.playframework.com/documentation/2.6.x/JavaAkka#Dependency-injecting-child-actors">Dependency-injecting-child-actors</a> * * @param <T> the actor type. * @param actorClass The class that implements the actor. * @param factoryClass The factory interface for creating the actor. */ default <T extends Actor> void bindActorFactory(Class<T> actorClass, Class<?> factoryClass) { BinderAccessor.binder(this).install( new FactoryModuleBuilder() .implement(Actor.class, actorClass) .build(factoryClass) ); } }
/** * Bind an actor. * * This will cause the actor to be instantiated by Guice, allowing it to be dependency injected itself. It will * bind the returned ActorRef for the actor will be bound, qualified with the passed in name, so that it can be * injected into other components. * * @param <T> the actor type. * @param actorClass The class that implements the actor. * @param name The name of the actor. * @param props A function to provide props for the actor. The props passed in will just describe how to create the * actor, this function can be used to provide additional configuration such as router and dispatcher * configuration. */ default <T extends Actor> void bindActor(Class<T> actorClass, String name, Function<Props, Props> props) { BinderAccessor.binder(this).bind(ActorRef.class) .annotatedWith(Names.named(name)) .toProvider(Providers.guicify(Akka.providerOf(actorClass, name, props))) .asEagerSingleton(); }
/** * Bind an actor. * * This will cause the actor to be instantiated by Guice, allowing it to be dependency injected itself. It will * bind the returned ActorRef for the actor will be bound, qualified with the passed in name, so that it can be * injected into other components. * * @param <T> the actor type. * @param actorClass The class that implements the actor. * @param name The name of the actor. * @param props A function to provide props for the actor. The props passed in will just describe how to create the * actor, this function can be used to provide additional configuration such as router and dispatcher * configuration. */ default <T extends Actor> void bindActor(Class<T> actorClass, String name, Function<Props, Props> props) { BinderAccessor.binder(this).bind(ActorRef.class) .annotatedWith(Names.named(name)) .toProvider(Providers.guicify(Akka.providerOf(actorClass, name, props))) .asEagerSingleton(); }