Skip to content

Instantly share code, notes, and snippets.

@legatoo
Created February 27, 2018 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save legatoo/74588362e9e16b58ea85edc4ba12c967 to your computer and use it in GitHub Desktop.
Save legatoo/74588362e9e16b58ea85edc4ba12c967 to your computer and use it in GitHub Desktop.
SpringActorProducer.java
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