Skip to content

Instantly share code, notes, and snippets.

@zeroows
Created February 17, 2015 07:42
Show Gist options
  • Save zeroows/c38da313121c3843892d to your computer and use it in GitHub Desktop.
Save zeroows/c38da313121c3843892d to your computer and use it in GitHub Desktop.
Extension to tell Akka how to create beans via Spring.
package tk.aalkhodiry.client.akka;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import akka.actor.Extension;
import akka.actor.Props;
/**
* Extension to tell Akka how to create beans via Spring.
*/
@Component
public class SpringExtension implements Extension {
private ApplicationContext applicationContext;
/**
* Used to initialize the Spring application context for the extension.
*/
public void initialize(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
/**
* Create a Props for the specified actorBeanName using the
* SpringActorProducer class.
*/
public Props props(String actorBeanName) {
return Props.create(SpringActorProducer.class, applicationContext, actorBeanName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment