Skip to content

Commit

Permalink
Merge pull request #27 from GoodforGod/dev
Browse files Browse the repository at this point in the history
[5.0.0]
  • Loading branch information
GoodforGod authored Aug 13, 2023
2 parents 027962e + 0d156d0 commit dbd4cf8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ArangoAccessorFactory {
ArangoDB getAccessor(ArangoConfiguration configuration,
SSLContextProvider sslContextProvider,
@Nullable ArangoSerde serde) {
return getAccessorPrototype(configuration, sslContextProvider, serde);
return createAccessor(configuration, sslContextProvider, serde);
}

/**
Expand All @@ -46,6 +46,12 @@ ArangoDB getAccessor(ArangoConfiguration configuration,
ArangoDB getAccessorPrototype(ArangoConfiguration configuration,
SSLContextProvider sslContextProvider,
@Nullable ArangoSerde serde) {
return createAccessor(configuration, sslContextProvider, serde);
}

private ArangoDB createAccessor(ArangoConfiguration configuration,
SSLContextProvider sslContextProvider,
@Nullable ArangoSerde serde) {
final ArangoSSLConfiguration sslConfiguration = configuration.getSslConfiguration();

final ArangoDB.Builder builder = new ArangoDB.Builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
* @author Anton Kurako (GoodforGod)
* @since 29.2.2020
*/
@Requires(beans = ArangoConfiguration.class)
@Requires(beans = { ArangoDB.class, ArangoConfiguration.class })
@Factory
public class ArangoClientFactory {

@Refreshable(ArangoSettings.PREFIX)
@Bean(preDestroy = "close")
@Singleton
ArangoClient getClient(ArangoDB accessor, ArangoConfiguration configuration) {
return getClientPrototype(accessor, configuration);
return new ArangoClientImpl(accessor, configuration);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.arangodb.ArangoDBException;
import io.micronaut.context.annotation.Context;
import io.micronaut.context.annotation.Parallel;
import io.micronaut.context.annotation.Requires;
import io.micronaut.core.annotation.Internal;
import io.micronaut.runtime.exceptions.ApplicationStartupException;
Expand All @@ -19,15 +20,24 @@
* @since 16.3.2020
*/
@Requires(property = ArangoSettings.PREFIX + ".create-database-if-not-exist", value = "true", defaultValue = "false")
@Requires(beans = ArangoConfiguration.class)
@Requires(beans = { ArangoClient.class, ArangoConfiguration.class })
@Context
@Internal
@Parallel
public class ArangoDatabaseInitializer {

private final Logger logger = LoggerFactory.getLogger(getClass());

private final ArangoClient client;
private final ArangoConfiguration configuration;

public ArangoDatabaseInitializer(ArangoClient client, ArangoConfiguration configuration) {
this.client = client;
this.configuration = configuration;
}

@PostConstruct
public void setupDatabase(ArangoClient client, ArangoConfiguration configuration) {
public void setupDatabase() {
final String database = configuration.getDatabase();
if (ArangoSettings.SYSTEM_DATABASE.equals(database)) {
logger.debug("ArangoDB is configured to use System Database, skipping initialization");
Expand Down

0 comments on commit dbd4cf8

Please sign in to comment.