Created
February 17, 2015 07:43
-
-
Save zeroows/ef200055e5d281393f6b to your computer and use it in GitHub Desktop.
An actor producer that lets Spring create the Actor instances.
This file contains 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
package tk.aalkhodiry.client.akka; | |
import org.springframework.context.ApplicationContext; | |
import akka.actor.Actor; | |
import akka.actor.IndirectActorProducer; | |
/** | |
* An actor producer that lets Spring create the Actor instances. | |
*/ | |
public class SpringActorProducer implements IndirectActorProducer { | |
private final ApplicationContext applicationContext; | |
private final String actorBeanName; | |
public SpringActorProducer(ApplicationContext applicationContext, | |
String actorBeanName) { | |
this.applicationContext = applicationContext; | |
this.actorBeanName = actorBeanName; | |
} | |
@Override | |
public Actor produce() { | |
return (Actor) applicationContext.getBean(actorBeanName); | |
} | |
@SuppressWarnings("unchecked") | |
@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