From 2e06344635b52bcc166846ff4dce2e0746d17ae1 Mon Sep 17 00:00:00 2001 From: ndr_brt Date: Wed, 7 Aug 2024 11:07:25 +0200 Subject: [PATCH] refactor: separate sql stores from datasources --- DEPENDENCIES | 4 ++-- .../sql/credentials/SqlCredentialStoreExtension.java | 8 +++++++- .../did/store/sql/SqlDidResourceStoreExtension.java | 8 ++++++-- .../sql/keypair/SqlKeyPairResourceStoreExtension.java | 6 +++++- .../SqlParticipantContextStoreExtension.java | 8 ++++++-- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index d9df8202a..072de09e3 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -51,8 +51,8 @@ maven/mavencentral/com.github.java-json-tools/uri-template/0.10, , approved, #15 maven/mavencentral/com.google.code.findbugs/jsr305/2.0.1, BSD-3-Clause AND CC-BY-2.5 AND LGPL-2.1+, approved, CQ13390 maven/mavencentral/com.google.code.findbugs/jsr305/3.0.2, CC-BY-2.5, approved, #15220 maven/mavencentral/com.google.code.gson/gson/2.10.1, Apache-2.0, approved, #6159 -maven/mavencentral/com.google.crypto.tink/tink/1.13.0, Apache-2.0, approved, #14502 maven/mavencentral/com.google.crypto.tink/tink/1.14.0, Apache-2.0, approved, clearlydefined +maven/mavencentral/com.google.crypto.tink/tink/1.14.1, Apache-2.0, approved, clearlydefined maven/mavencentral/com.google.errorprone/error_prone_annotations/2.11.0, Apache-2.0, approved, clearlydefined maven/mavencentral/com.google.errorprone/error_prone_annotations/2.22.0, Apache-2.0, approved, #10661 maven/mavencentral/com.google.errorprone/error_prone_annotations/2.26.1, Apache-2.0, approved, #13657 @@ -65,7 +65,7 @@ maven/mavencentral/com.google.guava/guava/31.1-jre, Apache-2.0, approved, clearl maven/mavencentral/com.google.guava/guava/33.2.0-jre, Apache-2.0 AND CC0-1.0 AND (Apache-2.0 AND CC-PDDC), approved, #14607 maven/mavencentral/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava, Apache-2.0, approved, CQ22657 maven/mavencentral/com.google.j2objc/j2objc-annotations/1.3, Apache-2.0, approved, CQ21195 -maven/mavencentral/com.google.protobuf/protobuf-java/3.25.1, BSD-3-Clause, approved, clearlydefined +maven/mavencentral/com.google.protobuf/protobuf-java/3.25.3, BSD-3-Clause, approved, clearlydefined maven/mavencentral/com.google.protobuf/protobuf-java/4.27.0, BSD-3-Clause, approved, clearlydefined maven/mavencentral/com.googlecode.libphonenumber/libphonenumber/8.11.1, Apache-2.0, approved, clearlydefined maven/mavencentral/com.jayway.jsonpath/json-path/2.7.0, Apache-2.0, approved, clearlydefined diff --git a/extensions/store/sql/identity-hub-credentials-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/credentials/SqlCredentialStoreExtension.java b/extensions/store/sql/identity-hub-credentials-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/credentials/SqlCredentialStoreExtension.java index e680f3246..6dcefc11e 100644 --- a/extensions/store/sql/identity-hub-credentials-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/credentials/SqlCredentialStoreExtension.java +++ b/extensions/store/sql/identity-hub-credentials-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/credentials/SqlCredentialStoreExtension.java @@ -25,6 +25,7 @@ import org.eclipse.edc.spi.types.TypeManager; import org.eclipse.edc.sql.QueryExecutor; import org.eclipse.edc.sql.bootstrapper.SqlSchemaBootstrapper; +import org.eclipse.edc.sql.configuration.DataSourceName; import org.eclipse.edc.transaction.datasource.spi.DataSourceRegistry; import org.eclipse.edc.transaction.spi.TransactionContext; @@ -34,8 +35,12 @@ public class SqlCredentialStoreExtension implements ServiceExtension { public static final String NAME = "CredentialResource SQL Store Extension"; + @Deprecated(since = "0.8.1") @Setting(value = "Datasource name for the DidResource database", defaultValue = DataSourceRegistry.DEFAULT_DATASOURCE) public static final String DATASOURCE_SETTING_NAME = "edc.datasource.credentials.name"; + @Setting(value = "The datasource to be used", defaultValue = DataSourceRegistry.DEFAULT_DATASOURCE) + public static final String DATASOURCE_NAME = "edc.sql.store.credentials.datasource"; + @Inject private DataSourceRegistry dataSourceRegistry; @Inject @@ -66,6 +71,7 @@ private CredentialStoreStatements getStatementImpl() { } private String getDataSourceName(ServiceExtensionContext context) { - return context.getConfig().getString(DATASOURCE_SETTING_NAME, DataSourceRegistry.DEFAULT_DATASOURCE); + return DataSourceName.getDataSourceName(DATASOURCE_NAME, DATASOURCE_SETTING_NAME, context.getConfig(), context.getMonitor()); } + } diff --git a/extensions/store/sql/identity-hub-did-store-sql/src/main/java/org/eclipse/edc/identityhub/did/store/sql/SqlDidResourceStoreExtension.java b/extensions/store/sql/identity-hub-did-store-sql/src/main/java/org/eclipse/edc/identityhub/did/store/sql/SqlDidResourceStoreExtension.java index 2f76c553f..6a59e39d9 100644 --- a/extensions/store/sql/identity-hub-did-store-sql/src/main/java/org/eclipse/edc/identityhub/did/store/sql/SqlDidResourceStoreExtension.java +++ b/extensions/store/sql/identity-hub-did-store-sql/src/main/java/org/eclipse/edc/identityhub/did/store/sql/SqlDidResourceStoreExtension.java @@ -25,6 +25,7 @@ import org.eclipse.edc.spi.types.TypeManager; import org.eclipse.edc.sql.QueryExecutor; import org.eclipse.edc.sql.bootstrapper.SqlSchemaBootstrapper; +import org.eclipse.edc.sql.configuration.DataSourceName; import org.eclipse.edc.transaction.datasource.spi.DataSourceRegistry; import org.eclipse.edc.transaction.spi.TransactionContext; @@ -34,8 +35,12 @@ public class SqlDidResourceStoreExtension implements ServiceExtension { public static final String NAME = "DID Resource SQL Store Extension"; + @Deprecated(since = "0.8.1") @Setting(value = "Datasource name for the DidResource database", defaultValue = DataSourceRegistry.DEFAULT_DATASOURCE) public static final String DATASOURCE_SETTING_NAME = "edc.datasource.didresource.name"; + @Setting(value = "The datasource to be used", defaultValue = DataSourceRegistry.DEFAULT_DATASOURCE) + public static final String DATASOURCE_NAME = "edc.sql.store.didresource.datasource"; + @Inject private DataSourceRegistry dataSourceRegistry; @Inject @@ -46,7 +51,6 @@ public class SqlDidResourceStoreExtension implements ServiceExtension { private QueryExecutor queryExecutor; @Inject(required = false) private DidResourceStatements statements; - @Inject private SqlSchemaBootstrapper sqlSchemaBootstrapper; @@ -66,6 +70,6 @@ private DidResourceStatements getStatementImpl() { } private String getDataSourceName(ServiceExtensionContext context) { - return context.getConfig().getString(DATASOURCE_SETTING_NAME, DataSourceRegistry.DEFAULT_DATASOURCE); + return DataSourceName.getDataSourceName(DATASOURCE_NAME, DATASOURCE_SETTING_NAME, context.getConfig(), context.getMonitor()); } } diff --git a/extensions/store/sql/identity-hub-keypair-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/keypair/SqlKeyPairResourceStoreExtension.java b/extensions/store/sql/identity-hub-keypair-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/keypair/SqlKeyPairResourceStoreExtension.java index 376629e9a..5b1485db4 100644 --- a/extensions/store/sql/identity-hub-keypair-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/keypair/SqlKeyPairResourceStoreExtension.java +++ b/extensions/store/sql/identity-hub-keypair-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/keypair/SqlKeyPairResourceStoreExtension.java @@ -25,6 +25,7 @@ import org.eclipse.edc.spi.types.TypeManager; import org.eclipse.edc.sql.QueryExecutor; import org.eclipse.edc.sql.bootstrapper.SqlSchemaBootstrapper; +import org.eclipse.edc.sql.configuration.DataSourceName; import org.eclipse.edc.transaction.datasource.spi.DataSourceRegistry; import org.eclipse.edc.transaction.spi.TransactionContext; @@ -34,8 +35,11 @@ public class SqlKeyPairResourceStoreExtension implements ServiceExtension { public static final String NAME = "KeyPair Resource SQL Store Extension"; + @Deprecated(since = "0.8.1") @Setting(value = "Datasource name for the KeyPairResource database", defaultValue = DataSourceRegistry.DEFAULT_DATASOURCE) public static final String DATASOURCE_SETTING_NAME = "edc.datasource.keypair.name"; + @Setting(value = "The datasource to be used", defaultValue = DataSourceRegistry.DEFAULT_DATASOURCE) + public static final String DATASOURCE_NAME = "edc.sql.store.keypair.datasource"; @Inject private DataSourceRegistry dataSourceRegistry; @@ -76,6 +80,6 @@ private KeyPairResourceStoreStatements getStatementImpl() { } private String getDataSourceName(ServiceExtensionContext context) { - return context.getConfig().getString(DATASOURCE_SETTING_NAME, DataSourceRegistry.DEFAULT_DATASOURCE); + return DataSourceName.getDataSourceName(DATASOURCE_NAME, DATASOURCE_SETTING_NAME, context.getConfig(), context.getMonitor()); } } diff --git a/extensions/store/sql/identity-hub-participantcontext-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/participantcontext/SqlParticipantContextStoreExtension.java b/extensions/store/sql/identity-hub-participantcontext-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/participantcontext/SqlParticipantContextStoreExtension.java index 414ab22e1..a467185b9 100644 --- a/extensions/store/sql/identity-hub-participantcontext-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/participantcontext/SqlParticipantContextStoreExtension.java +++ b/extensions/store/sql/identity-hub-participantcontext-store-sql/src/main/java/org/eclipse/edc/identityhub/store/sql/participantcontext/SqlParticipantContextStoreExtension.java @@ -25,6 +25,7 @@ import org.eclipse.edc.spi.types.TypeManager; import org.eclipse.edc.sql.QueryExecutor; import org.eclipse.edc.sql.bootstrapper.SqlSchemaBootstrapper; +import org.eclipse.edc.sql.configuration.DataSourceName; import org.eclipse.edc.transaction.datasource.spi.DataSourceRegistry; import org.eclipse.edc.transaction.spi.TransactionContext; @@ -34,8 +35,12 @@ public class SqlParticipantContextStoreExtension implements ServiceExtension { public static final String NAME = "ParticipantContext SQL Store Extension"; + @Deprecated(since = "0.8.1") @Setting(value = "Datasource name for the ParticipantContext database", defaultValue = DataSourceRegistry.DEFAULT_DATASOURCE) public static final String DATASOURCE_SETTING_NAME = "edc.datasource.participantcontext.name"; + @Setting(value = "The datasource to be used", defaultValue = DataSourceRegistry.DEFAULT_DATASOURCE) + public static final String DATASOURCE_NAME = "edc.sql.store.participantcontext.datasource"; + @Inject private DataSourceRegistry dataSourceRegistry; @Inject @@ -46,7 +51,6 @@ public class SqlParticipantContextStoreExtension implements ServiceExtension { private QueryExecutor queryExecutor; @Inject(required = false) private ParticipantContextStoreStatements statements; - @Inject private SqlSchemaBootstrapper sqlSchemaBootstrapper; @@ -66,6 +70,6 @@ private ParticipantContextStoreStatements getStatementImpl() { } private String getDataSourceName(ServiceExtensionContext context) { - return context.getConfig().getString(DATASOURCE_SETTING_NAME, DataSourceRegistry.DEFAULT_DATASOURCE); + return DataSourceName.getDataSourceName(DATASOURCE_NAME, DATASOURCE_SETTING_NAME, context.getConfig(), context.getMonitor()); } }