Created
December 4, 2018 06:34
-
-
Save gupta-himanshu/86d0565f2026027a9dda664103300cbe to your computer and use it in GitHub Desktop.
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 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