Search in sources :

Example 1 with Hl7Terser

use of org.apache.camel.component.hl7.Hl7Terser in project camel-quarkus by apache.

the class Hl7Processor method registerForReflection.

@BuildStep
void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, CombinedIndexBuildItem combinedIndex) {
    IndexView index = combinedIndex.getIndex();
    // Register hapi model types for reflection
    String[] hapiStructureClasses = index.getAllKnownImplementors(DotName.createSimple(Structure.class.getName())).stream().map(classInfo -> classInfo.name().toString()).toArray(String[]::new);
    String[] hapiTypeClasses = index.getAllKnownImplementors(DotName.createSimple(Type.class.getName())).stream().map(classInfo -> classInfo.name().toString()).toArray(String[]::new);
    reflectiveClass.produce(new ReflectiveClassBuildItem(false, true, hapiStructureClasses));
    reflectiveClass.produce(new ReflectiveClassBuildItem(false, true, hapiTypeClasses));
    // Beans that have the Hl7Terser annotation require reflective access
    String[] terserBeans = index.getAnnotations(DotName.createSimple(Hl7Terser.class.getName())).stream().map(AnnotationInstance::target).map(annotationTarget -> {
        if (annotationTarget.kind().equals(AnnotationTarget.Kind.FIELD)) {
            return annotationTarget.asType().asClass();
        } else if (annotationTarget.kind().equals(AnnotationTarget.Kind.METHOD)) {
            return annotationTarget.asMethod().declaringClass();
        } else if (annotationTarget.kind().equals(AnnotationTarget.Kind.METHOD_PARAMETER)) {
            return annotationTarget.asMethodParameter().method().declaringClass();
        }
        return null;
    }).filter(CamelSupport::isConcrete).map(classInfo -> classInfo.name().toString()).toArray(String[]::new);
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, terserBeans));
}
Also used : IndexView(org.jboss.jandex.IndexView) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) CamelSupport(org.apache.camel.quarkus.core.deployment.util.CamelSupport) Hl7Terser(org.apache.camel.component.hl7.Hl7Terser) DotName(org.jboss.jandex.DotName) Structure(ca.uhn.hl7v2.model.Structure) CurateOutcomeBuildItem(io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) IndexDependencyBuildItem(io.quarkus.deployment.builditem.IndexDependencyBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) AnnotationInstance(org.jboss.jandex.AnnotationInstance) AnnotationTarget(org.jboss.jandex.AnnotationTarget) Type(ca.uhn.hl7v2.model.Type) Type(ca.uhn.hl7v2.model.Type) IndexView(org.jboss.jandex.IndexView) Structure(ca.uhn.hl7v2.model.Structure) CamelSupport(org.apache.camel.quarkus.core.deployment.util.CamelSupport) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) AnnotationInstance(org.jboss.jandex.AnnotationInstance) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Aggregations

Structure (ca.uhn.hl7v2.model.Structure)1 Type (ca.uhn.hl7v2.model.Type)1 BuildProducer (io.quarkus.deployment.annotations.BuildProducer)1 BuildStep (io.quarkus.deployment.annotations.BuildStep)1 CombinedIndexBuildItem (io.quarkus.deployment.builditem.CombinedIndexBuildItem)1 FeatureBuildItem (io.quarkus.deployment.builditem.FeatureBuildItem)1 IndexDependencyBuildItem (io.quarkus.deployment.builditem.IndexDependencyBuildItem)1 ReflectiveClassBuildItem (io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem)1 CurateOutcomeBuildItem (io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem)1 Hl7Terser (org.apache.camel.component.hl7.Hl7Terser)1 CamelSupport (org.apache.camel.quarkus.core.deployment.util.CamelSupport)1 AnnotationInstance (org.jboss.jandex.AnnotationInstance)1 AnnotationTarget (org.jboss.jandex.AnnotationTarget)1 DotName (org.jboss.jandex.DotName)1 IndexView (org.jboss.jandex.IndexView)1