Created
February 27, 2018 02:18
-
-
Save legatoo/74588362e9e16b58ea85edc4ba12c967 to your computer and use it in GitHub Desktop.
SpringActorProducer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.actor.Actor; | |
import akka.actor.IndirectActorProducer; | |
import org.springframework.context.ApplicationContext; | |
/** | |
* An actor producer that lets Spring create the Actor instances. | |
*/ | |
public class SpringActorProducer implements IndirectActorProducer { | |
final ApplicationContext applicationContext; | |
final String actorBeanName; | |
public SpringActorProducer(ApplicationContext applicationContext, | |
String actorBeanName) { | |
this.applicationContext = applicationContext; | |
this.actorBeanName = actorBeanName; | |
} | |
@Override | |
public Actor produce() { | |
return (Actor) applicationContext.getBean(actorBeanName); | |
} | |
@Override | |
public Class<? extends Actor> actorClass() { | |
return (Class<? extends Actor>) applicationContext.getType(actorBeanName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment