View Javadoc
1   package de.dlr.shepard;
2   
3   import de.dlr.shepard.influxDB.InfluxDBConnector;
4   import de.dlr.shepard.neo4j.MigrationsRunner;
5   import de.dlr.shepard.neo4j.NeoConnector;
6   import de.dlr.shepard.util.IConnector;
7   import de.dlr.shepard.util.PKIHelper;
8   import io.quarkus.logging.Log;
9   import io.quarkus.runtime.Shutdown;
10  import io.quarkus.runtime.Startup;
11  import jakarta.enterprise.context.ApplicationScoped;
12  import jakarta.inject.Inject;
13  
14  @ApplicationScoped
15  public class QuarkusApplication {
16  
17    @Inject
18    InfluxDBConnector influxdb;
19  
20    private static IConnector neo4j = NeoConnector.getInstance();
21  
22    @Startup
23    void init() {
24      Log.info("Starting shepard backend");
25  
26      var pkiHelper = new PKIHelper();
27      var migrationRunner = new MigrationsRunner();
28      pkiHelper.init();
29  
30      Log.info("Waiting for databases");
31      migrationRunner.waitForConnection();
32  
33      Log.info("Run database migrations");
34      migrationRunner.apply();
35  
36      Log.info("Initialize databases");
37      neo4j.connect();
38      Log.info("Connection established to neo4j database.");
39      influxdb.connect();
40      Log.info(("Connection established to influx database."));
41    }
42  
43    @Shutdown
44    void shutdown() {
45      neo4j.disconnect();
46      influxdb.disconnect();
47    }
48  }