use of io.quarkus.deployment.annotations.Overridable in project quarkus-mybatis by quarkiverse.
the class MyBatisProcessor method addMyBatisMappers.
@BuildStep
@Overridable
void addMyBatisMappers(BuildProducer<MyBatisMapperBuildItem> mappers, BuildProducer<ReflectiveClassBuildItem> reflective, BuildProducer<NativeImageProxyDefinitionBuildItem> proxy, CombinedIndexBuildItem indexBuildItem) {
for (AnnotationInstance i : indexBuildItem.getIndex().getAnnotations(MYBATIS_MAPPER)) {
if (i.target().kind() == AnnotationTarget.Kind.CLASS) {
DotName dotName = i.target().asClass().name();
reflective.produce(new ReflectiveClassBuildItem(true, false, dotName.toString()));
proxy.produce(new NativeImageProxyDefinitionBuildItem(dotName.toString()));
Optional<AnnotationInstance> mapperDatasource = i.target().asClass().annotations().entrySet().stream().filter(entry -> entry.getKey().equals(MYBATIS_MAPPER_DATA_SOURCE)).map(Map.Entry::getValue).map(annotationList -> annotationList.get(0)).findFirst();
if (mapperDatasource.isPresent()) {
String dataSourceName = mapperDatasource.get().value().asString();
mappers.produce(new MyBatisMapperBuildItem(dotName, dataSourceName));
} else {
mappers.produce(new MyBatisMapperBuildItem(dotName, "<default>"));
}
}
}
}
Aggregations