Search in sources :

Example 1 with Overridable

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>"));
            }
        }
    }
}
Also used : Overridable(io.quarkus.deployment.annotations.Overridable) SelectProvider(org.apache.ibatis.annotations.SelectProvider) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) SqlSessionFactoryBuilder(org.apache.ibatis.session.SqlSessionFactoryBuilder) Pair(org.apache.commons.lang3.tuple.Pair) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) MappedJdbcTypes(org.apache.ibatis.type.MappedJdbcTypes) Map(java.util.Map) AnnotationTarget(org.jboss.jandex.AnnotationTarget) NativeImageProxyDefinitionBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem) Result(org.apache.ibatis.annotations.Result) ExecutionTime(io.quarkus.deployment.annotations.ExecutionTime) MyBatisRecorder(io.quarkiverse.mybatis.runtime.MyBatisRecorder) NativeImageResourceBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem) MappedTypes(org.apache.ibatis.type.MappedTypes) Collectors(java.util.stream.Collectors) List(java.util.List) ProxyFactory(org.apache.ibatis.javassist.util.proxy.ProxyFactory) AnnotationInstance(org.jboss.jandex.AnnotationInstance) Mapper(org.apache.ibatis.annotations.Mapper) Optional(java.util.Optional) ConfigurationError(io.quarkus.deployment.configuration.ConfigurationError) DeleteProvider(org.apache.ibatis.annotations.DeleteProvider) MyBatisConfigurationFactory(io.quarkiverse.mybatis.runtime.MyBatisConfigurationFactory) MyBatisDataSourceRuntimeConfig(io.quarkiverse.mybatis.runtime.config.MyBatisDataSourceRuntimeConfig) SyntheticBeanBuildItem(io.quarkus.arc.deployment.SyntheticBeanBuildItem) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) Record(io.quarkus.deployment.annotations.Record) MapperDataSource(io.quarkiverse.mybatis.runtime.meta.MapperDataSource) Logger(org.jboss.logging.Logger) DotName(org.jboss.jandex.DotName) XMLLanguageDriver(org.apache.ibatis.scripting.xmltags.XMLLanguageDriver) UpdateProvider(org.apache.ibatis.annotations.UpdateProvider) Singleton(javax.inject.Singleton) Function(java.util.function.Function) ArrayList(java.util.ArrayList) MyBatisRuntimeConfig(io.quarkiverse.mybatis.runtime.config.MyBatisRuntimeConfig) PerpetualCache(org.apache.ibatis.cache.impl.PerpetualCache) BuildStep(io.quarkus.deployment.annotations.BuildStep) Results(org.apache.ibatis.annotations.Results) SqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory) EnumTypeHandler(org.apache.ibatis.type.EnumTypeHandler) Named(javax.inject.Named) RawLanguageDriver(org.apache.ibatis.scripting.defaults.RawLanguageDriver) ResultMap(org.apache.ibatis.annotations.ResultMap) ResultType(org.apache.ibatis.annotations.ResultType) RuntimeInitializedClassBuildItem(io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem) MyBatisXMLConfigDelegateBuilder(io.quarkiverse.mybatis.runtime.MyBatisXMLConfigDelegateBuilder) LruCache(org.apache.ibatis.cache.decorators.LruCache) JdbcDataSourceBuildItem(io.quarkus.agroal.spi.JdbcDataSourceBuildItem) InsertProvider(org.apache.ibatis.annotations.InsertProvider) Log4jImpl(org.apache.ibatis.logging.log4j.Log4jImpl) DotName(org.jboss.jandex.DotName) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) NativeImageProxyDefinitionBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem) Overridable(io.quarkus.deployment.annotations.Overridable) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Aggregations

MyBatisConfigurationFactory (io.quarkiverse.mybatis.runtime.MyBatisConfigurationFactory)1 MyBatisRecorder (io.quarkiverse.mybatis.runtime.MyBatisRecorder)1 MyBatisXMLConfigDelegateBuilder (io.quarkiverse.mybatis.runtime.MyBatisXMLConfigDelegateBuilder)1 MyBatisDataSourceRuntimeConfig (io.quarkiverse.mybatis.runtime.config.MyBatisDataSourceRuntimeConfig)1 MyBatisRuntimeConfig (io.quarkiverse.mybatis.runtime.config.MyBatisRuntimeConfig)1 MapperDataSource (io.quarkiverse.mybatis.runtime.meta.MapperDataSource)1 JdbcDataSourceBuildItem (io.quarkus.agroal.spi.JdbcDataSourceBuildItem)1 SyntheticBeanBuildItem (io.quarkus.arc.deployment.SyntheticBeanBuildItem)1 BuildProducer (io.quarkus.deployment.annotations.BuildProducer)1 BuildStep (io.quarkus.deployment.annotations.BuildStep)1 ExecutionTime (io.quarkus.deployment.annotations.ExecutionTime)1 Overridable (io.quarkus.deployment.annotations.Overridable)1 Record (io.quarkus.deployment.annotations.Record)1 CombinedIndexBuildItem (io.quarkus.deployment.builditem.CombinedIndexBuildItem)1 FeatureBuildItem (io.quarkus.deployment.builditem.FeatureBuildItem)1 NativeImageProxyDefinitionBuildItem (io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem)1 NativeImageResourceBuildItem (io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem)1 ReflectiveClassBuildItem (io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem)1 RuntimeInitializedClassBuildItem (io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem)1 ConfigurationError (io.quarkus.deployment.configuration.ConfigurationError)1