Search in sources :

Example 1 with NativeImageProxyDefinitionBuildItem

use of io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem in project camel-quarkus by apache.

the class PubnubProcessor method registerProxyInterfaces.

@BuildStep
void registerProxyInterfaces(BuildProducer<NativeImageProxyDefinitionBuildItem> proxyDefinitions, CombinedIndexBuildItem combinedIndex) {
    IndexView index = combinedIndex.getIndex();
    index.getKnownClasses().stream().map(classInfo -> classInfo.name().toString()).filter(name -> name.startsWith("com.pubnub.api.services")).map(NativeImageProxyDefinitionBuildItem::new).forEach(proxyDefinitions::produce);
}
Also used : IndexDependencyBuildItem(io.quarkus.deployment.builditem.IndexDependencyBuildItem) IndexView(org.jboss.jandex.IndexView) BuildStep(io.quarkus.deployment.annotations.BuildStep) ExtensionSslNativeSupportBuildItem(io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) NativeImageProxyDefinitionBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) IndexView(org.jboss.jandex.IndexView) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 2 with NativeImageProxyDefinitionBuildItem

use of io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem in project camel-quarkus by apache.

the class InjectionPointsProcessor method produceBeans.

void produceBeans(CamelRecorder recorder, List<CapabilityBuildItem> capabilities, BuildProducer<SyntheticBeanBuildItem> syntheticBeans, BuildProducer<NativeImageProxyDefinitionBuildItem> proxyDefinitions, AtomicReference<Boolean> beanCapabilityAvailable, AnnotationInstance annot, final DotName fieldType, String annotationTarget, DotName declaringClass) {
    try {
        Class<?> clazz = Class.forName(fieldType.toString(), false, Thread.currentThread().getContextClassLoader());
        if (ProducerTemplate.class.isAssignableFrom(clazz)) {
            syntheticBeans.produce(SyntheticBeanBuildItem.configure(fieldType).setRuntimeInit().scope(Singleton.class).supplier(recorder.createProducerTemplate(annot.value().asString())).addQualifier(annot).done());
        /*
                 * Note that ProducerTemplate injection points not having @EndpointInject are produced via
                 * CamelProducers.camelProducerTemplate()
                 */
        } else if (FluentProducerTemplate.class.isAssignableFrom(clazz)) {
            syntheticBeans.produce(SyntheticBeanBuildItem.configure(fieldType).setRuntimeInit().scope(Singleton.class).supplier(recorder.createFluentProducerTemplate(annot.value().asString())).addQualifier(annot).done());
        /*
                 * Note that FluentProducerTemplate injection points not having @EndpointInject are produced via
                 * CamelProducers.camelFluentProducerTemplate()
                 */
        } else if (clazz.isInterface()) {
            if (beanCapabilityAvailable.get() == null) {
                beanCapabilityAvailable.set(capabilities.stream().map(CapabilityBuildItem::getName).anyMatch(feature -> CamelCapabilities.BEAN.equals(feature)));
            }
            if (!beanCapabilityAvailable.get()) {
                throw new IllegalStateException("Add camel-quarkus-bean dependency to be able to use @org.apache.camel.Produce on fields with interface type: " + fieldType.toString() + " " + annotationTarget + " in " + declaringClass.toString());
            }
            proxyDefinitions.produce(new NativeImageProxyDefinitionBuildItem(fieldType.toString()));
            syntheticBeans.produce(SyntheticBeanBuildItem.configure(fieldType).setRuntimeInit().scope(Singleton.class).supplier(recorder.produceProxy(clazz, annot.value().asString())).addQualifier(annot).done());
        }
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}
Also used : CamelRuntimeTaskBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelRuntimeTaskBuildItem) SyntheticBeanBuildItem(io.quarkus.arc.deployment.SyntheticBeanBuildItem) Record(io.quarkus.deployment.annotations.Record) EndpointInject(org.apache.camel.EndpointInject) Logger(org.jboss.logging.Logger) DotName(org.jboss.jandex.DotName) Type(org.jboss.jandex.Type) Component(org.apache.camel.Component) Endpoint(org.apache.camel.Endpoint) ClassInfo(org.jboss.jandex.ClassInfo) FieldInfo(org.jboss.jandex.FieldInfo) Singleton(javax.inject.Singleton) AtomicReference(java.util.concurrent.atomic.AtomicReference) Supplier(java.util.function.Supplier) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) Produce(org.apache.camel.Produce) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) Inject(javax.inject.Inject) BuildStep(io.quarkus.deployment.annotations.BuildStep) MethodInfo(org.jboss.jandex.MethodInfo) FluentProducerTemplate(org.apache.camel.FluentProducerTemplate) CamelRecorder(org.apache.camel.quarkus.core.CamelRecorder) Map(java.util.Map) Kind(org.jboss.jandex.AnnotationTarget.Kind) ProducerTemplate(org.apache.camel.ProducerTemplate) NativeImageProxyDefinitionBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem) AnnotationTarget(org.jboss.jandex.AnnotationTarget) Named(javax.inject.Named) CapabilityBuildItem(io.quarkus.deployment.builditem.CapabilityBuildItem) AnnotationsTransformerBuildItem(io.quarkus.arc.deployment.AnnotationsTransformerBuildItem) CamelCapabilities(org.apache.camel.quarkus.core.CamelCapabilities) BeanRegistrationPhaseBuildItem(io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem) Collection(java.util.Collection) ExecutionTime(io.quarkus.deployment.annotations.ExecutionTime) InjectionPointsRecorder(org.apache.camel.quarkus.core.InjectionPointsRecorder) Set(java.util.Set) InjectionPointInfo(io.quarkus.arc.processor.InjectionPointInfo) Objects(java.util.Objects) QualifierRegistrarBuildItem(io.quarkus.arc.deployment.QualifierRegistrarBuildItem) AnnotationsTransformer(io.quarkus.arc.processor.AnnotationsTransformer) QualifierRegistrar(io.quarkus.arc.processor.QualifierRegistrar) List(java.util.List) AnnotationInstance(org.jboss.jandex.AnnotationInstance) Collections(java.util.Collections) BuildExtension(io.quarkus.arc.processor.BuildExtension) FluentProducerTemplate(org.apache.camel.FluentProducerTemplate) Singleton(javax.inject.Singleton) CapabilityBuildItem(io.quarkus.deployment.builditem.CapabilityBuildItem) NativeImageProxyDefinitionBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem)

Example 3 with NativeImageProxyDefinitionBuildItem

use of io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem in project camel-quarkus by apache.

the class XchangeProcessor method registerProxyClasses.

@BuildStep
void registerProxyClasses(BuildProducer<NativeImageProxyDefinitionBuildItem> nativeImageProxy, CombinedIndexBuildItem combinedIndexBuildItem) {
    // Some xchange libraries use JAX-RS proxies to interact with the exchange APIs so we need to register them
    IndexView index = combinedIndexBuildItem.getIndex();
    index.getAnnotations(DotName.createSimple("javax.ws.rs.Path")).stream().map(AnnotationInstance::target).filter(target -> target.kind().equals(AnnotationTarget.Kind.CLASS)).map(AnnotationTarget::asClass).filter(classInfo -> Modifier.isInterface(classInfo.flags())).map(classInfo -> classInfo.name().toString()).filter(className -> className.startsWith("org.knowm.xchange")).map(NativeImageProxyDefinitionBuildItem::new).forEach(nativeImageProxy::produce);
}
Also used : IndexView(org.jboss.jandex.IndexView) ExtensionSslNativeSupportBuildItem(io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) NativeImageResourceBundleBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem) RuntimeInitializedClassBuildItem(io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem) DotName(org.jboss.jandex.DotName) NativeImageResourceBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem) CurateOutcomeBuildItem(io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem) ClassInfo(org.jboss.jandex.ClassInfo) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) IndexDependencyBuildItem(io.quarkus.deployment.builditem.IndexDependencyBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep) Order(org.knowm.xchange.dto.Order) Stream(java.util.stream.Stream) ApplicationModel(io.quarkus.bootstrap.model.ApplicationModel) BaseExchange(org.knowm.xchange.BaseExchange) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) AnnotationInstance(org.jboss.jandex.AnnotationInstance) Modifier(java.lang.reflect.Modifier) ResolvedDependency(io.quarkus.maven.dependency.ResolvedDependency) NativeImageProxyDefinitionBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem) AnnotationTarget(org.jboss.jandex.AnnotationTarget) IndexView(org.jboss.jandex.IndexView) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 4 with NativeImageProxyDefinitionBuildItem

use of io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem in project camel-quarkus by apache.

the class SpringRabbitmqProcessor method initProxies.

@BuildStep
void initProxies(BuildProducer<NativeImageProxyDefinitionBuildItem> proxies) {
    proxies.produce(new NativeImageProxyDefinitionBuildItem(ChannelProxy.class.getCanonicalName()));
    proxies.produce(new NativeImageProxyDefinitionBuildItem("org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer$ContainerDelegate", SpringProxy.class.getCanonicalName(), Advised.class.getCanonicalName(), DecoratingProxy.class.getCanonicalName()));
}
Also used : NativeImageProxyDefinitionBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 5 with NativeImageProxyDefinitionBuildItem

use of io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem 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

BuildStep (io.quarkus.deployment.annotations.BuildStep)6 NativeImageProxyDefinitionBuildItem (io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem)6 BuildProducer (io.quarkus.deployment.annotations.BuildProducer)4 CombinedIndexBuildItem (io.quarkus.deployment.builditem.CombinedIndexBuildItem)4 ReflectiveClassBuildItem (io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem)4 AnnotationInstance (org.jboss.jandex.AnnotationInstance)4 DotName (org.jboss.jandex.DotName)4 FeatureBuildItem (io.quarkus.deployment.builditem.FeatureBuildItem)3 SyntheticBeanBuildItem (io.quarkus.arc.deployment.SyntheticBeanBuildItem)2 ExecutionTime (io.quarkus.deployment.annotations.ExecutionTime)2 Record (io.quarkus.deployment.annotations.Record)2 ExtensionSslNativeSupportBuildItem (io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem)2 IndexDependencyBuildItem (io.quarkus.deployment.builditem.IndexDependencyBuildItem)2 NativeImageResourceBuildItem (io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem)2 RuntimeInitializedClassBuildItem (io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem)2 List (java.util.List)2 Map (java.util.Map)2 AnnotationTarget (org.jboss.jandex.AnnotationTarget)2 ClassInfo (org.jboss.jandex.ClassInfo)2 IndexView (org.jboss.jandex.IndexView)2