Search in sources :

Example 11 with RuntimeValue

use of io.quarkus.runtime.RuntimeValue in project camel-quarkus by apache.

the class CamelDozerRecorder method createDozerBeanMapperConfiguration.

public RuntimeValue<DozerBeanMapperConfiguration> createDozerBeanMapperConfiguration(List<String> mappingFiles) {
    DozerBeanMapperConfiguration dozerBeanMapperConfiguration = new DozerBeanMapperConfiguration();
    dozerBeanMapperConfiguration.setMappingFiles(mappingFiles);
    return new RuntimeValue<>(dozerBeanMapperConfiguration);
}
Also used : DozerBeanMapperConfiguration(org.apache.camel.converter.dozer.DozerBeanMapperConfiguration) RuntimeValue(io.quarkus.runtime.RuntimeValue)

Example 12 with RuntimeValue

use of io.quarkus.runtime.RuntimeValue in project camel-quarkus by apache.

the class FhirContextRecorder method createDstu2FhirContext.

public RuntimeValue<FhirContext> createDstu2FhirContext(Collection<String> resourceDefinitions) {
    FhirContext fhirContext = FhirContext.forDstu2();
    initContext(resourceDefinitions, fhirContext);
    return new RuntimeValue<>(fhirContext);
}
Also used : FhirContext(ca.uhn.fhir.context.FhirContext) RuntimeValue(io.quarkus.runtime.RuntimeValue)

Example 13 with RuntimeValue

use of io.quarkus.runtime.RuntimeValue in project camel-quarkus by apache.

the class CamelProcessor method typeConverterRegistry.

/*
     * Discover {@link TypeConverterLoader}.
     */
@SuppressWarnings("unchecked")
@Record(ExecutionTime.STATIC_INIT)
@BuildStep
CamelTypeConverterRegistryBuildItem typeConverterRegistry(CamelRecorder recorder, ApplicationArchivesBuildItem applicationArchives, List<CamelTypeConverterLoaderBuildItem> additionalLoaders, CombinedIndexBuildItem combinedIndex, BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {
    IndexView index = combinedIndex.getIndex();
    RuntimeValue<TypeConverterRegistry> typeConverterRegistry = recorder.createTypeConverterRegistry();
    // 
    // This should be simplified by searching for classes implementing TypeConverterLoader but that
    // would lead to have org.apache.camel.impl.converter.AnnotationTypeConverterLoader taken into
    // account even if it should not.
    // 
    final ClassLoader TCCL = Thread.currentThread().getContextClassLoader();
    for (ApplicationArchive archive : applicationArchives.getAllApplicationArchives()) {
        for (Path root : archive.getRootDirs()) {
            Path path = root.resolve(BaseTypeConverterRegistry.META_INF_SERVICES_TYPE_CONVERTER_LOADER);
            if (!Files.isRegularFile(path)) {
                continue;
            }
            try {
                Files.readAllLines(path, StandardCharsets.UTF_8).stream().map(String::trim).filter(l -> !l.isEmpty()).filter(l -> !l.startsWith("#")).map(l -> (Class<? extends TypeConverterLoader>) CamelSupport.loadClass(l, TCCL)).forEach(loader -> recorder.addTypeConverterLoader(typeConverterRegistry, loader));
            } catch (IOException e) {
                throw new RuntimeException("Error discovering TypeConverterLoader", e);
            }
        }
    }
    Set<String> internalConverters = new HashSet<>();
    // ignore all @converters from org.apache.camel:camel-* dependencies
    for (ApplicationArchive archive : applicationArchives.getAllApplicationArchives()) {
        ArtifactKey artifactKey = archive.getKey();
        if (artifactKey != null && "org.apache.camel".equals(artifactKey.getGroupId()) && artifactKey.getArtifactId().startsWith("camel-")) {
            internalConverters.addAll(archive.getIndex().getAnnotations(DotName.createSimple(Converter.class.getName())).stream().filter(a -> a.target().kind() == AnnotationTarget.Kind.CLASS).map(a -> a.target().asClass().name().toString()).collect(Collectors.toSet()));
        }
    }
    Set<Class> convertersClasses = index.getAnnotations(DotName.createSimple(Converter.class.getName())).stream().filter(a -> a.target().kind() == AnnotationTarget.Kind.CLASS && (a.value("generateBulkLoader") == null || !a.value("generateBulkLoader").asBoolean()) && (a.value("generateLoader") == null || !a.value("generateLoader").asBoolean())).map(a -> a.target().asClass().name().toString()).filter(s -> !internalConverters.contains(s)).map(s -> CamelSupport.loadClass(s, TCCL)).collect(Collectors.toSet());
    recorder.loadAnnotatedConverters(typeConverterRegistry, convertersClasses);
    // 
    for (CamelTypeConverterLoaderBuildItem item : additionalLoaders) {
        recorder.addTypeConverterLoader(typeConverterRegistry, item.getValue());
    }
    return new CamelTypeConverterRegistryBuildItem(typeConverterRegistry);
}
Also used : Path(java.nio.file.Path) UnremovableBeanBuildItem(io.quarkus.arc.deployment.UnremovableBeanBuildItem) CamelComponentNameResolverBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelComponentNameResolverBuildItem) LoggerFactory(org.slf4j.LoggerFactory) Overridable(io.quarkus.deployment.annotations.Overridable) CamelTypeConverterRegistryBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelTypeConverterRegistryBuildItem) CamelServicePatternBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem) ClassInfo(org.jboss.jandex.ClassInfo) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) Capabilities(io.quarkus.deployment.Capabilities) AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) BaseTypeConverterRegistry(org.apache.camel.impl.converter.BaseTypeConverterRegistry) CamelModelJAXBContextFactoryBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelModelJAXBContextFactoryBuildItem) CamelRecorder(org.apache.camel.quarkus.core.CamelRecorder) CamelServiceDestination(org.apache.camel.quarkus.core.deployment.spi.CamelServiceDestination) AnnotationTarget(org.jboss.jandex.AnnotationTarget) Path(java.nio.file.Path) TypeConverterLoader(org.apache.camel.spi.TypeConverterLoader) Builder(org.apache.camel.quarkus.core.FastFactoryFinderResolver.Builder) BeanRegistrationPhaseBuildItem(io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem) Predicate(java.util.function.Predicate) CamelModelToXMLDumperBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelModelToXMLDumperBuildItem) ExecutionTime(io.quarkus.deployment.annotations.ExecutionTime) Set(java.util.Set) NativeImageResourceBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) List(java.util.List) RoutesBuilderClassExcludeBuildItem(org.apache.camel.quarkus.core.deployment.spi.RoutesBuilderClassExcludeBuildItem) Modifier(java.lang.reflect.Modifier) CamelProducers(org.apache.camel.quarkus.core.CamelProducers) CamelRoutesBuilderClassBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelRoutesBuilderClassBuildItem) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) Record(io.quarkus.deployment.annotations.Record) CamelSupport(org.apache.camel.quarkus.core.deployment.util.CamelSupport) DotName(org.jboss.jandex.DotName) Type(org.jboss.jandex.Type) ContainerBeansBuildItem(org.apache.camel.quarkus.core.deployment.spi.ContainerBeansBuildItem) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) BuildStep(io.quarkus.deployment.annotations.BuildStep) ArtifactKey(io.quarkus.maven.dependency.ArtifactKey) RuntimeValue(io.quarkus.runtime.RuntimeValue) TypeConverterRegistry(org.apache.camel.spi.TypeConverterRegistry) IndexView(org.jboss.jandex.IndexView) CamelCapabilities(org.apache.camel.quarkus.core.CamelCapabilities) SchemaResource(org.apache.camel.quarkus.core.deployment.catalog.SchemaResource) CamelFactoryFinderResolverBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelFactoryFinderResolverBuildItem) Logger(org.slf4j.Logger) ApplicationArchivesBuildItem(io.quarkus.deployment.builditem.ApplicationArchivesBuildItem) FileUtils(org.apache.camel.quarkus.core.util.FileUtils) Files(java.nio.file.Files) PathFilter(org.apache.camel.quarkus.core.deployment.util.PathFilter) CamelTypeConverterLoaderBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelTypeConverterLoaderBuildItem) IOException(java.io.IOException) CamelServiceFilterBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelServiceFilterBuildItem) BuildTimeCamelCatalog(org.apache.camel.quarkus.core.deployment.catalog.BuildTimeCamelCatalog) Converter(org.apache.camel.Converter) ApplicationArchive(io.quarkus.deployment.ApplicationArchive) CamelConfig(org.apache.camel.quarkus.core.CamelConfig) BuildTimeCamelCatalogBuildItem(org.apache.camel.quarkus.core.deployment.spi.BuildTimeCamelCatalogBuildItem) CamelServiceBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelServiceBuildItem) BuildTimeJsonSchemaResolver(org.apache.camel.quarkus.core.deployment.catalog.BuildTimeJsonSchemaResolver) BuildExtension(io.quarkus.arc.processor.BuildExtension) CamelConfigFlags(org.apache.camel.quarkus.core.CamelConfigFlags) CamelServiceFilter(org.apache.camel.quarkus.core.deployment.spi.CamelServiceFilter) ArtifactKey(io.quarkus.maven.dependency.ArtifactKey) CamelTypeConverterLoaderBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelTypeConverterLoaderBuildItem) IndexView(org.jboss.jandex.IndexView) CamelTypeConverterRegistryBuildItem(org.apache.camel.quarkus.core.deployment.spi.CamelTypeConverterRegistryBuildItem) IOException(java.io.IOException) ApplicationArchive(io.quarkus.deployment.ApplicationArchive) TypeConverterLoader(org.apache.camel.spi.TypeConverterLoader) BaseTypeConverterRegistry(org.apache.camel.impl.converter.BaseTypeConverterRegistry) TypeConverterRegistry(org.apache.camel.spi.TypeConverterRegistry) Converter(org.apache.camel.Converter) HashSet(java.util.HashSet) Record(io.quarkus.deployment.annotations.Record) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 14 with RuntimeValue

use of io.quarkus.runtime.RuntimeValue in project camel-quarkus by apache.

the class ConsumeRecorder method getEndpointUri.

public RuntimeValue<Object> getEndpointUri(RuntimeValue<CamelContext> camelContext, String beanName, String endpointMethodName) {
    /* Possible improvement: Instead of using reflection, we could generate this method at build time
         * to call the bean method directly */
    Object bean = camelContext.getValue().getRegistry().lookupByName(beanName);
    Method method = null;
    try {
        Class<?> cl = bean.getClass();
        do {
            method = Stream.of(cl.getDeclaredMethods()).filter(m -> m.getName().equals(endpointMethodName) && m.getParameterCount() == 0).findFirst().orElse(null);
            cl = cl.getSuperclass();
        } while (method == null && cl != Object.class);
        Object result = method.invoke(bean);
        return new RuntimeValue<>(result);
    } catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        throw new RuntimeException(e);
    }
}
Also used : RoutesDefinition(org.apache.camel.model.RoutesDefinition) CamelContext(org.apache.camel.CamelContext) TypeConversionException(org.apache.camel.TypeConversionException) Stream(java.util.stream.Stream) Model(org.apache.camel.model.Model) NoTypeConversionAvailableException(org.apache.camel.NoTypeConversionAvailableException) RuntimeValue(io.quarkus.runtime.RuntimeValue) Consume(org.apache.camel.Consume) Recorder(io.quarkus.runtime.annotations.Recorder) Endpoint(org.apache.camel.Endpoint) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) RuntimeValue(io.quarkus.runtime.RuntimeValue) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 15 with RuntimeValue

use of io.quarkus.runtime.RuntimeValue in project camel-quarkus by apache.

the class CamelMainRecorder method createRuntime.

public RuntimeValue<CamelRuntime> createRuntime(BeanContainer beanContainer, RuntimeValue<CamelMain> main, long shutdownTimeoutMs) {
    final CamelRuntime runtime = new CamelMainRuntime(main.getValue(), shutdownTimeoutMs);
    // register to the container
    beanContainer.instance(CamelProducers.class).setRuntime(runtime);
    return new RuntimeValue<>(runtime);
}
Also used : CamelProducers(org.apache.camel.quarkus.core.CamelProducers) CamelRuntime(org.apache.camel.quarkus.core.CamelRuntime) RuntimeValue(io.quarkus.runtime.RuntimeValue)

Aggregations

RuntimeValue (io.quarkus.runtime.RuntimeValue)31 FhirContext (ca.uhn.fhir.context.FhirContext)4 BuildStep (io.quarkus.deployment.annotations.BuildStep)2 Record (io.quarkus.deployment.annotations.Record)2 CamelContext (org.apache.camel.CamelContext)2 Component (org.apache.camel.Component)2 KnativeComponent (org.apache.camel.component.knative.KnativeComponent)2 CamelProducers (org.apache.camel.quarkus.core.CamelProducers)2 ComponentCustomizer (org.apache.camel.spi.ComponentCustomizer)2 Logger (ch.qos.logback.classic.Logger)1 AWSLogs (com.amazonaws.services.logs.AWSLogs)1 AWSLogsClientBuilder (com.amazonaws.services.logs.AWSLogsClientBuilder)1 Configuration (freemarker.template.Configuration)1 Tracer (io.opentracing.Tracer)1 CloudWatchCredentialsProvider (io.quarkiverse.logging.cloudwatch.auth.CloudWatchCredentialsProvider)1 AdditionalBeanBuildItem (io.quarkus.arc.deployment.AdditionalBeanBuildItem)1 BeanRegistrationPhaseBuildItem (io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem)1 UnremovableBeanBuildItem (io.quarkus.arc.deployment.UnremovableBeanBuildItem)1 BuildExtension (io.quarkus.arc.processor.BuildExtension)1 ApplicationArchive (io.quarkus.deployment.ApplicationArchive)1