Skip to content

Commit

Permalink
refactor: separate sql stores from datasources (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Aug 8, 2024
1 parent d1acfbb commit 9e5da23
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
4 changes: 2 additions & 2 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -46,7 +51,6 @@ public class SqlDidResourceStoreExtension implements ServiceExtension {
private QueryExecutor queryExecutor;
@Inject(required = false)
private DidResourceStatements statements;

@Inject
private SqlSchemaBootstrapper sqlSchemaBootstrapper;

Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -46,7 +51,6 @@ public class SqlParticipantContextStoreExtension implements ServiceExtension {
private QueryExecutor queryExecutor;
@Inject(required = false)
private ParticipantContextStoreStatements statements;

@Inject
private SqlSchemaBootstrapper sqlSchemaBootstrapper;

Expand All @@ -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());
}
}

0 comments on commit 9e5da23

Please sign in to comment.