io.quarkus.amazon.dynamodb.runtime.DynamodbClientProducer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-amazon-dynamodb Show documentation
Show all versions of quarkus-amazon-dynamodb Show documentation
Connect to Amazon DynamoDB datastore
package io.quarkus.amazon.dynamodb.runtime;
import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient;
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClientBuilder;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.DynamoDbClientBuilder;
@ApplicationScoped
public class DynamodbClientProducer {
private volatile DynamoDbClientBuilder syncConfiguredBuilder;
private volatile DynamoDbAsyncClientBuilder asyncConfiguredBuilder;
private DynamoDbClient client;
private DynamoDbAsyncClient asyncClient;
@Produces
@ApplicationScoped
public DynamoDbClient client() {
client = syncConfiguredBuilder.build();
return client;
}
@Produces
@ApplicationScoped
public DynamoDbAsyncClient asyncClient() {
asyncClient = asyncConfiguredBuilder.build();
return asyncClient;
}
@PreDestroy
public void destroy() {
if (client != null) {
client.close();
}
if (asyncClient != null) {
asyncClient.close();
}
}
public void setSyncConfiguredBuilder(DynamoDbClientBuilder syncConfiguredBuilder) {
this.syncConfiguredBuilder = syncConfiguredBuilder;
}
public void setAsyncConfiguredBuilder(DynamoDbAsyncClientBuilder asyncConfiguredBuilder) {
this.asyncConfiguredBuilder = asyncConfiguredBuilder;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy