use of io.quarkus.arc.deployment.SyntheticBeanBuildItem 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);
}
}
Aggregations