use of org.projectnessie.versioned.TracingVersionStore in project nessie by projectnessie.
the class DatabaseAdapterExtension method resolve.
private Object resolve(NessieDbAdapter nessieDbAdapter, AnnotatedElement annotatedElement, Class<?> type, ExtensionContext context, ParameterContext parameterContext, boolean canReinit, Consumer<DatabaseAdapter> newAdapter) {
StoreWorker<?, ?, ?> storeWorker = createStoreWorker(nessieDbAdapter);
DatabaseAdapter databaseAdapter = createAdapterResource(nessieDbAdapter, context, parameterContext, storeWorker);
if (nessieDbAdapter.withTracing()) {
databaseAdapter = new TracingDatabaseAdapter(databaseAdapter);
}
if (canReinit && nessieDbAdapter.initializeRepo()) {
reinit(databaseAdapter);
}
Object assign;
if (type.isAssignableFrom(DatabaseAdapter.class)) {
assign = databaseAdapter;
} else if (type.isAssignableFrom(VersionStore.class)) {
VersionStore<?, ?, ?> store = createStore(databaseAdapter, storeWorker);
if (nessieDbAdapter.withTracing()) {
store = new TracingVersionStore<>(store);
}
assign = store;
} else {
throw new IllegalStateException("Cannot assign to " + annotatedElement);
}
newAdapter.accept(databaseAdapter);
return assign;
}
Aggregations