コード例 #1
0
 /**
  * Create a new SysAdminUtilsImpl
  *
  * @param lifecycle the play application lifecycle listener
  * @param configuration the play application configuration
  * @param databaseDependencyService the service which secure the availability of the database
  * @param actorSystem the Akka actor system
  */
 @Inject
 public SysAdminUtilsImpl(
     ApplicationLifecycle lifecycle,
     Configuration configuration,
     IDatabaseDependencyService databaseDependencyService,
     ActorSystem actorSystem) {
   log.info("SERVICE>>> SysAdminUtilsImpl starting...");
   this.actorSystem = actorSystem;
   this.configuration = configuration;
   initAutomatedSystemStatus();
   lifecycle.addStopHook(
       () -> {
         log.info("SERVICE>>> SysAdminUtilsImpl stopping...");
         if (automaticSystemStatus != null) {
           try {
             getAutomaticSystemStatus().cancel();
           } catch (Exception e) {
             log.error("Unable to stop the automatic system status", e);
           }
         }
         log.info("SERVICE>>> SysAdminUtilsImpl stopped");
         return Promise.pure(null);
       });
   log.info("SERVICE>>> SysAdminUtilsImpl started");
 }
コード例 #2
0
 @Inject
 public JPAApiProvider(JPAConfig jpaConfig, DBApi dbApi, ApplicationLifecycle lifecycle) {
   // dependency on db api ensures that the databases are initialised
   jpaApi = new DefaultJPAApi(jpaConfig);
   lifecycle.addStopHook(
       () -> {
         jpaApi.shutdown();
         return CompletableFuture.completedFuture(null);
       });
   jpaApi.start();
 }
コード例 #3
0
 @Inject
 public EbeanDynamicEvolutions(
     EbeanConfig config, Environment environment, ApplicationLifecycle lifecycle) {
   this.config = config;
   this.environment = environment;
   start();
   lifecycle.addStopHook(
       () -> {
         servers.forEach((database, server) -> server.shutdown(false, false));
         return CompletableFuture.completedFuture(null);
       });
 }
コード例 #4
0
  @Inject
  public MorphiumConnection(ApplicationLifecycle lifecycle, Configuration configuration) {
    final String dbName = configuration.getString("mongodb.name");
    final String dbHostName = configuration.getString("mongodb.host.name");
    final Integer dbHostPort = configuration.getInt("mongodb.host.port");

    final String username = configuration.getString("mongodb.username");
    final String password = configuration.getString("mongodb.password");

    Logger.info(
        "Mong db name: "
            + dbName
            + ", host : "
            + dbHostName
            + ", port : "
            + dbHostPort
            + ", username:"******", passsword:"
            + password);

    cfg = new MorphiumConfig();
    cfg.setDatabase(dbName);
    try {
      cfg.addHost(dbHostName, dbHostPort);
      if (StringUtils.isNotEmpty(username)) {
        cfg.setMongoLogin(username);
      }
      if (StringUtils.isNotEmpty(password)) {
        cfg.setMongoPassword(password);
      }
      m = new Morphium(cfg);

    } catch (UnknownHostException e) {
      e.printStackTrace();
      m = null;
      cfg = null;
    }

    lifecycle.addStopHook(
        () -> {
          if (m != null) {
            m.close();
          }
          return F.Promise.pure(null);
        });
  }