Skip to content

Instantly share code, notes, and snippets.

@gupta-himanshu
Created December 4, 2018 06:34
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 gupta-himanshu/86d0565f2026027a9dda664103300cbe to your computer and use it in GitHub Desktop.
Save gupta-himanshu/86d0565f2026027a9dda664103300cbe to your computer and use it in GitHub Desktop.
package com.knoldus.lagom.sample.restaurant.menu.impl;
import akka.actor.ActorSystem;
import akka.management.AkkaManagement$;
import akka.management.cluster.bootstrap.ClusterBootstrap$;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.knoldus.lagom.sample.restaurant.menu.api.MenuService;
import com.lightbend.lagom.javadsl.server.ServiceGuiceSupport;
import com.typesafe.config.Config;
import play.Application;
import play.Environment;
public final class MenuModule extends AbstractModule implements ServiceGuiceSupport {
private final Environment environment;
private final Config config;
public MenuModule(final Environment environment, final Config config) {
this.environment = environment;
this.config = config;
}
@Override
protected void configure() {
if (environment.isProd()) {
bind(AkkaManagerAndClusterStarter.class).asEagerSingleton();
}
bindService(MenuService.class, MenuServiceImpl.class);
}
static class AkkaManagerAndClusterStarter {
@Inject
AkkaManagerAndClusterStarter(final Application application, final ActorSystem actorSystem) {
if (application.isProd()) {
AkkaManagement$.MODULE$.get(actorSystem).start();
ClusterBootstrap$.MODULE$.get(actorSystem).start();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment