/** * Create a provider for an actor implemented by the given class, with the given name. * * This will instantiate the actor using Play's injector, allowing it to be dependency injected itself. The returned * provider will provide the ActorRef for the actor, allowing it to be injected into other components. * * Typically, you will want to use this in combination with a named qualifier, so that multiple ActorRefs can be * bound, and the scope should be set to singleton or eager singleton. * * @param actorClass The class that implements the actor. * @param name The name of the actor. * @return A provider for the actor. */ public static <T extends Actor> Provider<ActorRef> providerOf(Class<T> actorClass, String name) { return providerOf(actorClass, name, Function.identity()); } }
@Override public void onStart(Application app) { Logger.info("Application has started"); Akka.system().scheduler().schedule( Duration.create(1, TimeUnit.MINUTES), //Initial delay of 1 min Duration.create(1, TimeUnit.HOURS), //Refresh every hour new Runnable() { @Override public void run() { final HerculesPatternService patternService = INJECTOR.getInstance(HerculesPatternService.class); patternService.synchronizeAllSources(); } }, Akka.system().dispatcher() ); }
play.libs.Akka.asPromise(ask(actorRef,msg, timeout)).map( new play.libs.F.Function<java.lang.Object, play.mvc.Result>() { public play.mvc.Result apply(java.lang.Object response){
/** * Create a provider for an actor implemented by the given class, with the given name. * * This will instantiate the actor using Play's injector, allowing it to be dependency injected itself. The returned * provider will provide the ActorRef for the actor, allowing it to be injected into other components. * * Typically, you will want to use this in combination with a named qualifier, so that multiple ActorRefs can be * bound, and the scope should be set to singleton or eager singleton. * * @param <T> the type of the actor * @param actorClass The class that implements the actor. * @param name The name of the actor. * @return A provider for the actor. */ public static <T extends Actor> Provider<ActorRef> providerOf(Class<T> actorClass, String name) { return providerOf(actorClass, name, Function.identity()); } }
/** * Create a provider for an actor implemented by the given class, with the given name. * * This will instantiate the actor using Play's injector, allowing it to be dependency injected itself. The returned * provider will provide the ActorRef for the actor, allowing it to be injected into other components. * * Typically, you will want to use this in combination with a named qualifier, so that multiple ActorRefs can be * bound, and the scope should be set to singleton or eager singleton. * * @param <T> the type of the actor * @param actorClass The class that implements the actor. * @param name The name of the actor. * @return A provider for the actor. */ public static <T extends Actor> Provider<ActorRef> providerOf(Class<T> actorClass, String name) { return providerOf(actorClass, name, Function.identity()); } }
/** * Create a provider for an actor implemented by the given class, with the given name. * * This will instantiate the actor using Play's injector, allowing it to be dependency injected itself. The returned * provider will provide the ActorRef for the actor, allowing it to be injected into other components. * * Typically, you will want to use this in combination with a named qualifier, so that multiple ActorRefs can be * bound, and the scope should be set to singleton or eager singleton. * * @param <T> the type of the actor * @param actorClass The class that implements the actor. * @param name The name of the actor. * @return A provider for the actor. */ public static <T extends Actor> Provider<ActorRef> providerOf(Class<T> actorClass, String name) { return providerOf(actorClass, 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. * @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(); }
/** * 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(); }