Search in sources :

Example 1 with JdbcDataSourceBuildItem

use of io.quarkus.agroal.spi.JdbcDataSourceBuildItem in project keycloak by keycloak.

the class LiquibaseProcessor method configure.

@Record(ExecutionTime.STATIC_INIT)
@BuildStep
void configure(KeycloakRecorder recorder, List<JdbcDataSourceBuildItem> jdbcDataSources, CombinedIndexBuildItem indexBuildItem) {
    DotName liquibaseServiceName = DotName.createSimple(LiquibaseService.class.getName());
    Map<String, List<String>> services = new HashMap<>();
    IndexView index = indexBuildItem.getIndex();
    JdbcDataSourceBuildItem dataSourceBuildItem = jdbcDataSources.get(0);
    String dbKind = dataSourceBuildItem.getDbKind();
    for (Class<?> c : Arrays.asList(liquibase.diff.compare.DatabaseObjectComparator.class, liquibase.parser.NamespaceDetails.class, liquibase.precondition.Precondition.class, Database.class, liquibase.change.Change.class, liquibase.snapshot.SnapshotGenerator.class, liquibase.changelog.ChangeLogHistoryService.class, liquibase.datatype.LiquibaseDataType.class, liquibase.executor.Executor.class, SqlGenerator.class)) {
        List<String> impls = new ArrayList<>();
        services.put(c.getName(), impls);
        Set<ClassInfo> classes = new HashSet<>();
        if (c.isInterface()) {
            classes.addAll(index.getAllKnownImplementors(DotName.createSimple(c.getName())));
        } else {
            classes.addAll(index.getAllKnownSubclasses(DotName.createSimple(c.getName())));
        }
        filterImplementations(c, dbKind, classes);
        for (ClassInfo found : classes) {
            if (Modifier.isAbstract(found.flags()) || Modifier.isInterface(found.flags()) || !found.hasNoArgsConstructor() || !Modifier.isPublic(found.flags())) {
                continue;
            }
            AnnotationInstance annotationInstance = found.classAnnotation(liquibaseServiceName);
            if (annotationInstance == null || !annotationInstance.value("skip").asBoolean()) {
                impls.add(found.name().toString());
            }
        }
    }
    services.put(LockService.class.getName(), Arrays.asList(DummyLockService.class.getName()));
    services.put(ChangeLogParser.class.getName(), Arrays.asList(XMLChangeLogSAXParser.class.getName()));
    recorder.configureLiquibase(services);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DotName(org.jboss.jandex.DotName) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet) DummyLockService(org.keycloak.connections.jpa.updater.liquibase.lock.DummyLockService) LockService(liquibase.lockservice.LockService) IndexView(org.jboss.jandex.IndexView) ChangeLogParser(liquibase.parser.ChangeLogParser) LiquibaseService(liquibase.servicelocator.LiquibaseService) JdbcDataSourceBuildItem(io.quarkus.agroal.spi.JdbcDataSourceBuildItem) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ClassInfo(org.jboss.jandex.ClassInfo) Record(io.quarkus.deployment.annotations.Record) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Aggregations

JdbcDataSourceBuildItem (io.quarkus.agroal.spi.JdbcDataSourceBuildItem)1 BuildStep (io.quarkus.deployment.annotations.BuildStep)1 Record (io.quarkus.deployment.annotations.Record)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 LockService (liquibase.lockservice.LockService)1 ChangeLogParser (liquibase.parser.ChangeLogParser)1 LiquibaseService (liquibase.servicelocator.LiquibaseService)1 AnnotationInstance (org.jboss.jandex.AnnotationInstance)1 ClassInfo (org.jboss.jandex.ClassInfo)1 DotName (org.jboss.jandex.DotName)1 IndexView (org.jboss.jandex.IndexView)1 DummyLockService (org.keycloak.connections.jpa.updater.liquibase.lock.DummyLockService)1