Search in sources :

Example 1 with ResultHandle

use of io.quarkus.gizmo.ResultHandle in project camel-quarkus by apache.

the class GrpcProcessor method createBindableServiceBeans.

@BuildStep
void createBindableServiceBeans(BuildProducer<GeneratedBeanBuildItem> generatedBean, BuildProducer<ReflectiveClassBuildItem> reflectiveClass, CombinedIndexBuildItem combinedIndexBuildItem) {
    IndexView index = combinedIndexBuildItem.getIndex();
    Collection<ClassInfo> bindableServiceImpls = index.getAllKnownImplementors(BINDABLE_SERVICE_DOT_NAME);
    // This mimics similar logic in DefaultBindableServiceFactory that uses Javassist ProxyFactory & MethodHandler
    for (ClassInfo service : bindableServiceImpls) {
        if (!Modifier.isAbstract(service.flags())) {
            continue;
        }
        if (service.name().withoutPackagePrefix().startsWith("Mutiny")) {
            /* The generate-code goal of quarkus-maven-plugin generates also Mutiny service that we do not use
                 * Not skipping it here results in randomly registering the Mutiny one or the right one.
                 * In case the Mutiny service one is registered, the client throws something like
                 * io.grpc.StatusRuntimeException: UNIMPLEMENTED */
            continue;
        }
        String superClassName = service.name().toString();
        String generatedClassName = superClassName + "QuarkusMethodHandler";
        // Register the service classes for reflection
        reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, service.name().toString()));
        reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, service.enclosingClass().toString()));
        reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, generatedClassName));
        try (ClassCreator classCreator = ClassCreator.builder().classOutput(new GeneratedBeanGizmoAdaptor(generatedBean)).className(generatedClassName).superClass(superClassName).interfaces(CamelQuarkusBindableService.class).build()) {
            classCreator.addAnnotation(Dependent.class);
            FieldCreator serverMethodHandler = classCreator.getFieldCreator("methodHandler", GrpcMethodHandler.class.getName()).setModifiers(Modifier.PRIVATE);
            // Create constructor
            try (MethodCreator initMethod = classCreator.getMethodCreator("<init>", void.class)) {
                initMethod.setModifiers(Modifier.PUBLIC);
                initMethod.invokeSpecialMethod(MethodDescriptor.ofMethod(superClassName, "<init>", void.class), initMethod.getThis());
                initMethod.returnValue(null);
            }
            // Create setMethodHandler override
            try (MethodCreator setMethodHandlerMethod = classCreator.getMethodCreator("setMethodHandler", void.class, GrpcMethodHandler.class)) {
                setMethodHandlerMethod.setModifiers(Modifier.PUBLIC);
                ResultHandle self = setMethodHandlerMethod.getThis();
                ResultHandle methodHandlerInstance = setMethodHandlerMethod.getMethodParam(0);
                setMethodHandlerMethod.writeInstanceField(serverMethodHandler.getFieldDescriptor(), self, methodHandlerInstance);
                setMethodHandlerMethod.returnValue(null);
            }
            // Override service methods that the gRPC component is interested in
            // E.g methods with one or two parameters where one is of type StreamObserver
            List<MethodInfo> methods = service.methods();
            for (MethodInfo method : methods) {
                if (isCandidateServiceMethod(method)) {
                    String[] params = method.parameters().stream().map(type -> type.name().toString()).toArray(String[]::new);
                    ClassInfo classInfo = index.getClassByName(DotName.createSimple(GrpcMethodHandler.class.getName()));
                    String returnType = method.returnType().name().toString();
                    try (MethodCreator methodCreator = classCreator.getMethodCreator(method.name(), returnType, params)) {
                        method.exceptions().stream().map(type -> type.name().toString()).forEach(methodCreator::addException);
                        if (method.parameters().size() == 1) {
                            ResultHandle returnValue = generateGrpcDelegateMethod(classInfo, serverMethodHandler, methodCreator, method, "handleForConsumerStrategy");
                            methodCreator.returnValue(returnValue);
                        } else if (method.parameters().size() == 2) {
                            generateGrpcDelegateMethod(classInfo, serverMethodHandler, methodCreator, method, "handle");
                            methodCreator.returnValue(null);
                        }
                    }
                }
            }
        }
    }
}
Also used : BindableService(io.grpc.BindableService) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) AbstractFutureStub(io.grpc.stub.AbstractFutureStub) AbstractBlockingStub(io.grpc.stub.AbstractBlockingStub) MethodCreator(io.quarkus.gizmo.MethodCreator) DotName(org.jboss.jandex.DotName) Type(org.jboss.jandex.Type) ClassCreator(io.quarkus.gizmo.ClassCreator) ClassInfo(org.jboss.jandex.ClassInfo) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) GeneratedBeanBuildItem(io.quarkus.arc.deployment.GeneratedBeanBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep) MethodInfo(org.jboss.jandex.MethodInfo) StreamObserver(io.grpc.stub.StreamObserver) AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) AbstractAsyncStub(io.grpc.stub.AbstractAsyncStub) IndexView(org.jboss.jandex.IndexView) MethodDescriptor(io.quarkus.gizmo.MethodDescriptor) Collection(java.util.Collection) CamelQuarkusBindableService(org.apache.camel.quarkus.grpc.runtime.CamelQuarkusBindableService) List(java.util.List) GeneratedBeanGizmoAdaptor(io.quarkus.arc.deployment.GeneratedBeanGizmoAdaptor) Dependent(javax.enterprise.context.Dependent) FieldCreator(io.quarkus.gizmo.FieldCreator) AbstractStub(io.grpc.stub.AbstractStub) Modifier(java.lang.reflect.Modifier) GrpcMethodHandler(org.apache.camel.component.grpc.server.GrpcMethodHandler) ResultHandle(io.quarkus.gizmo.ResultHandle) QuarkusBindableServiceFactory(org.apache.camel.quarkus.grpc.runtime.QuarkusBindableServiceFactory) IndexView(org.jboss.jandex.IndexView) FieldCreator(io.quarkus.gizmo.FieldCreator) CamelQuarkusBindableService(org.apache.camel.quarkus.grpc.runtime.CamelQuarkusBindableService) GeneratedBeanGizmoAdaptor(io.quarkus.arc.deployment.GeneratedBeanGizmoAdaptor) ClassCreator(io.quarkus.gizmo.ClassCreator) MethodCreator(io.quarkus.gizmo.MethodCreator) ResultHandle(io.quarkus.gizmo.ResultHandle) MethodInfo(org.jboss.jandex.MethodInfo) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) ClassInfo(org.jboss.jandex.ClassInfo) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Example 2 with ResultHandle

use of io.quarkus.gizmo.ResultHandle in project camel-quarkus by apache.

the class GrpcProcessor method generateGrpcDelegateMethod.

private ResultHandle generateGrpcDelegateMethod(ClassInfo classInfo, FieldCreator fieldCreator, MethodCreator methodCreator, MethodInfo sourceMethod, String targetMethod) {
    MethodInfo method = classInfo.methods().stream().filter(methodInfo -> methodInfo.name().equals(targetMethod)).findFirst().orElseThrow(() -> new RuntimeException("Unable to find target method " + targetMethod + " on GrpcServerMethodHandler"));
    ResultHandle methodNameParam = methodCreator.load(sourceMethod.name());
    ResultHandle[] methodParams;
    if (sourceMethod.parameters().size() == 1) {
        methodParams = new ResultHandle[] { methodCreator.getMethodParam(0), methodNameParam };
    } else {
        methodParams = new ResultHandle[] { methodCreator.getMethodParam(0), methodCreator.getMethodParam(1), methodNameParam };
    }
    ResultHandle resultHandle = methodCreator.readInstanceField(fieldCreator.getFieldDescriptor(), methodCreator.getThis());
    return methodCreator.invokeVirtualMethod(method, resultHandle, methodParams);
}
Also used : MethodInfo(org.jboss.jandex.MethodInfo) ResultHandle(io.quarkus.gizmo.ResultHandle)

Example 3 with ResultHandle

use of io.quarkus.gizmo.ResultHandle in project quarkus-github-action by quarkiverse.

the class GitHubActionProcessor method generatePayloadTypeResolver.

private static void generatePayloadTypeResolver(ClassOutput beanClassOutput, BuildProducer<ReflectiveClassBuildItem> reflectiveClasses, Collection<EventDefinition> eventDefinitions) {
    String payloadTypeResolverClassName = GitHubEvent.class.getPackageName() + ".PayloadTypeResolverImpl";
    reflectiveClasses.produce(new ReflectiveClassBuildItem(true, true, payloadTypeResolverClassName));
    ClassCreator payloadTypeResolverClassCreator = ClassCreator.builder().classOutput(beanClassOutput).className(payloadTypeResolverClassName).interfaces(PayloadTypeResolver.class).build();
    payloadTypeResolverClassCreator.addAnnotation(Singleton.class);
    Map<String, DotName> payloadTypeMapping = eventDefinitions.stream().collect(Collectors.toMap(ed -> ed.getEvent(), ed -> ed.getPayloadType(), (ed1, ed2) -> ed1));
    MethodCreator getPayloadTypeMethodCreator = payloadTypeResolverClassCreator.getMethodCreator("getPayloadType", Class.class, String.class);
    ResultHandle eventRh = getPayloadTypeMethodCreator.getMethodParam(0);
    for (Entry<String, DotName> payloadTypeMappingEntry : payloadTypeMapping.entrySet()) {
        BytecodeCreator matches = getPayloadTypeMethodCreator.ifTrue(getPayloadTypeMethodCreator.invokeVirtualMethod(MethodDescriptors.OBJECT_EQUALS, getPayloadTypeMethodCreator.load(payloadTypeMappingEntry.getKey()), eventRh)).trueBranch();
        matches.returnValue(matches.loadClass(payloadTypeMappingEntry.getValue().toString()));
    }
    getPayloadTypeMethodCreator.returnValue(getPayloadTypeMethodCreator.loadNull());
    payloadTypeResolverClassCreator.close();
}
Also used : DotNames(io.quarkus.arc.processor.DotNames) GeneratedClassGizmoAdaptor(io.quarkus.deployment.GeneratedClassGizmoAdaptor) Arrays(java.util.Arrays) MethodVisitor(org.objectweb.asm.MethodVisitor) PayloadTypeResolver(io.quarkiverse.githubaction.runtime.PayloadTypeResolver) ClassOutput(io.quarkus.gizmo.ClassOutput) RunTimeConfigurationDefaultBuildItem(io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem) ClassInfo(org.jboss.jandex.ClassInfo) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) GeneratedBeanBuildItem(io.quarkus.arc.deployment.GeneratedBeanBuildItem) MethodInfo(org.jboss.jandex.MethodInfo) Context(io.quarkiverse.githubaction.Context) AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) AnnotationLiteral(javax.enterprise.util.AnnotationLiteral) Map(java.util.Map) BytecodeCreator(io.quarkus.gizmo.BytecodeCreator) GHEventPayload(org.kohsuke.github.GHEventPayload) ConfigFileReader(io.quarkiverse.githubaction.runtime.ConfigFileReader) MethodParameterInfo(org.jboss.jandex.MethodParameterInfo) ClassVisitor(org.objectweb.asm.ClassVisitor) GitHub(org.kohsuke.github.GitHub) AnnotationsTransformerBuildItem(io.quarkus.arc.deployment.AnnotationsTransformerBuildItem) ActionDispatchingConfiguration(io.quarkiverse.githubaction.deployment.DispatchingConfiguration.ActionDispatchingConfiguration) AnnotationValue(org.jboss.jandex.AnnotationValue) ReflectiveHierarchyBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem) EventAnnotationLiteral(io.quarkiverse.githubaction.deployment.DispatchingConfiguration.EventAnnotationLiteral) Collection(java.util.Collection) Set(java.util.Set) ActionLiteral(io.quarkiverse.githubaction.Action.ActionLiteral) BuiltinScope(io.quarkus.arc.processor.BuiltinScope) Collectors(java.util.stream.Collectors) MethodDescriptors(io.quarkus.arc.processor.MethodDescriptors) List(java.util.List) GitHubEvent(io.quarkiverse.githubaction.runtime.GitHubEvent) GitHubApiClassWithBridgeMethodsBuildItem(io.quarkiverse.githubapi.deployment.GitHubApiClassWithBridgeMethodsBuildItem) ActionDispatchingMethod(io.quarkiverse.githubaction.deployment.DispatchingConfiguration.ActionDispatchingMethod) Actions(io.quarkiverse.githubapp.event.Actions) AnnotationInstance(org.jboss.jandex.AnnotationInstance) Modifier(java.lang.reflect.Modifier) Annotation(java.lang.annotation.Annotation) Entry(java.util.Map.Entry) Optional(java.util.Optional) Multiplexer(io.quarkiverse.githubaction.runtime.Multiplexer) HashUtil(io.quarkus.runtime.util.HashUtil) ResultHandle(io.quarkus.gizmo.ResultHandle) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) Logger(org.jboss.logging.Logger) MethodCreator(io.quarkus.gizmo.MethodCreator) DotName(org.jboss.jandex.DotName) Type(org.jboss.jandex.Type) AnnotatedElement(io.quarkus.gizmo.AnnotatedElement) HashMap(java.util.HashMap) ClassCreator(io.quarkus.gizmo.ClassCreator) Singleton(javax.inject.Singleton) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) EVENT(io.quarkiverse.githubaction.deployment.GitHubActionDotNames.EVENT) Inject(javax.inject.Inject) BuildStep(io.quarkus.deployment.annotations.BuildStep) INJECTABLE_TYPES(io.quarkiverse.githubaction.deployment.GitHubActionDotNames.INJECTABLE_TYPES) Kind(org.jboss.jandex.AnnotationTarget.Kind) EventAnnotation(io.quarkiverse.githubaction.deployment.DispatchingConfiguration.EventAnnotation) Gizmo(io.quarkus.gizmo.Gizmo) PrintStream(java.io.PrintStream) Event(javax.enterprise.event.Event) IndexView(org.jboss.jandex.IndexView) Opcodes(org.objectweb.asm.Opcodes) MethodDescriptor(io.quarkus.gizmo.MethodDescriptor) CONFIG_FILE(io.quarkiverse.githubaction.deployment.GitHubActionDotNames.CONFIG_FILE) GitHubEventHandler(io.quarkiverse.githubaction.runtime.GitHubEventHandler) FieldDescriptor(io.quarkus.gizmo.FieldDescriptor) Action(io.quarkiverse.githubaction.Action) GeneratedBeanGizmoAdaptor(io.quarkus.arc.deployment.GeneratedBeanGizmoAdaptor) ACTION(io.quarkiverse.githubaction.deployment.GitHubActionDotNames.ACTION) GeneratedClassBuildItem(io.quarkus.deployment.builditem.GeneratedClassBuildItem) LaunchModeBuildItem(io.quarkus.deployment.builditem.LaunchModeBuildItem) FieldCreator(io.quarkus.gizmo.FieldCreator) BytecodeTransformerBuildItem(io.quarkus.deployment.builditem.BytecodeTransformerBuildItem) Collections(java.util.Collections) MethodCreator(io.quarkus.gizmo.MethodCreator) PayloadTypeResolver(io.quarkiverse.githubaction.runtime.PayloadTypeResolver) ResultHandle(io.quarkus.gizmo.ResultHandle) BytecodeCreator(io.quarkus.gizmo.BytecodeCreator) GitHubEvent(io.quarkiverse.githubaction.runtime.GitHubEvent) ClassCreator(io.quarkus.gizmo.ClassCreator) DotName(org.jboss.jandex.DotName) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem)

Example 4 with ResultHandle

use of io.quarkus.gizmo.ResultHandle in project quarkus-github-action by quarkiverse.

the class GitHubActionProcessor method generateMultiplexers.

/**
 * Multiplexers listen to the sync events emitted by the main class.
 * <p>
 * They are subclasses of the application classes registering actions or listening to GitHub events through our annotations.
 * <p>
 * They are useful for several purposes:
 * <ul>
 * <li>A single application method can listen to multiple event types: the event types are qualifiers and CDI wouldn't allow
 * that (only events matching all the qualifiers would be received by the application method). That's why this class is
 * called a multiplexer: it will generate one method per event type and each generated method will delegate to the original
 * method.</li>
 * <li>The multiplexer also handles the resolution of payloads, config files...</li>
 * <li>We can inject a properly configured instance of GitHub or DynamicGraphQLClient into the method.</li>
 * </ul>
 */
private static void generateMultiplexers(ClassOutput beanClassOutput, DispatchingConfiguration dispatchingConfiguration, BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {
    for (Entry<DotName, TreeSet<ActionDispatchingMethod>> actionDispatchingMethodsEntry : dispatchingConfiguration.getMethods().entrySet()) {
        DotName declaringClassName = actionDispatchingMethodsEntry.getKey();
        TreeSet<ActionDispatchingMethod> actionDispatchingMethods = actionDispatchingMethodsEntry.getValue();
        ClassInfo declaringClass = actionDispatchingMethods.iterator().next().getMethod().declaringClass();
        reflectiveClasses.produce(new ReflectiveClassBuildItem(true, true, declaringClassName.toString()));
        String multiplexerClassName = declaringClassName + "_Multiplexer";
        reflectiveClasses.produce(new ReflectiveClassBuildItem(true, true, multiplexerClassName));
        ClassCreator multiplexerClassCreator = ClassCreator.builder().classOutput(beanClassOutput).className(multiplexerClassName).superClass(declaringClassName.toString()).build();
        multiplexerClassCreator.addAnnotation(Multiplexer.class);
        if (!BuiltinScope.isDeclaredOn(declaringClass)) {
            multiplexerClassCreator.addAnnotation(Singleton.class);
        }
        for (AnnotationInstance classAnnotation : declaringClass.classAnnotations()) {
            multiplexerClassCreator.addAnnotation(classAnnotation);
        }
        // Copy the constructors
        for (MethodInfo originalConstructor : declaringClass.constructors()) {
            MethodCreator constructorCreator = multiplexerClassCreator.getMethodCreator(MethodDescriptor.ofConstructor(multiplexerClassName, originalConstructor.parameters().stream().map(t -> t.name().toString()).toArray(String[]::new)));
            List<AnnotationInstance> originalMethodAnnotations = originalConstructor.annotations().stream().filter(ai -> ai.target().kind() == Kind.METHOD).collect(Collectors.toList());
            for (AnnotationInstance originalMethodAnnotation : originalMethodAnnotations) {
                constructorCreator.addAnnotation(originalMethodAnnotation);
            }
            Map<Short, List<AnnotationInstance>> originalConstructorParameterAnnotationMapping = originalConstructor.annotations().stream().filter(ai -> ai.target().kind() == Kind.METHOD_PARAMETER).collect(Collectors.groupingBy(ai -> ai.target().asMethodParameter().position()));
            List<ResultHandle> parametersRh = new ArrayList<>();
            for (short i = 0; i < originalConstructor.parameters().size(); i++) {
                parametersRh.add(constructorCreator.getMethodParam(i));
                AnnotatedElement parameterAnnotations = constructorCreator.getParameterAnnotations(i);
                List<AnnotationInstance> originalConstructorParameterAnnotations = originalConstructorParameterAnnotationMapping.getOrDefault(i, Collections.emptyList());
                for (AnnotationInstance originalConstructorParameterAnnotation : originalConstructorParameterAnnotations) {
                    parameterAnnotations.addAnnotation(originalConstructorParameterAnnotation);
                }
            }
            constructorCreator.invokeSpecialMethod(MethodDescriptor.of(originalConstructor), constructorCreator.getThis(), parametersRh.toArray(ResultHandle[]::new));
            constructorCreator.returnValue(null);
        }
        // Generate the multiplexed event dispatching methods
        for (ActionDispatchingMethod actionDispatchingMethod : actionDispatchingMethods) {
            String name = actionDispatchingMethod.getName();
            AnnotationInstance eventSubscriberInstance = actionDispatchingMethod.getEventSubscriberInstance();
            MethodInfo originalMethod = actionDispatchingMethod.getMethod();
            Map<Short, List<AnnotationInstance>> originalMethodParameterAnnotationMapping = originalMethod.annotations().stream().filter(ai -> ai.target().kind() == Kind.METHOD_PARAMETER).collect(Collectors.groupingBy(ai -> ai.target().asMethodParameter().position()));
            // if the method already has an @Observes or @ObservesAsync annotation
            if (originalMethod.hasAnnotation(DotNames.OBSERVES) || originalMethod.hasAnnotation(DotNames.OBSERVES_ASYNC)) {
                LOG.warn("Methods listening to GitHub actions may not be annotated with @Observes or @ObservesAsync. Offending method: " + originalMethod.declaringClass().name() + "#" + originalMethod);
            }
            List<String> parameterTypes = new ArrayList<>();
            List<Type> originalMethodParameterTypes = originalMethod.parameters();
            // detect the parameter that is a payload
            short payloadParameterPosition = -1;
            if (eventSubscriberInstance != null) {
                for (short i = 0; i < originalMethodParameterTypes.size(); i++) {
                    List<AnnotationInstance> parameterAnnotations = originalMethodParameterAnnotationMapping.getOrDefault(i, Collections.emptyList());
                    if (parameterAnnotations.stream().anyMatch(ai -> ai.name().equals(eventSubscriberInstance.name()))) {
                        payloadParameterPosition = i;
                        break;
                    }
                }
            }
            short j = 0;
            Map<Short, Short> parameterMapping = new HashMap<>();
            for (short i = 0; i < originalMethodParameterTypes.size(); i++) {
                List<AnnotationInstance> originalMethodAnnotations = originalMethodParameterAnnotationMapping.getOrDefault(i, Collections.emptyList());
                if (originalMethodAnnotations.stream().anyMatch(ai -> CONFIG_FILE.equals(ai.name())) || INJECTABLE_TYPES.contains(originalMethodParameterTypes.get(i).name()) || i == payloadParameterPosition) {
                    // if the parameter is annotated with @ConfigFile, is of an injectable type or is the payload, we skip it
                    continue;
                }
                parameterTypes.add(originalMethodParameterTypes.get(i).name().toString());
                parameterMapping.put(i, j);
                j++;
            }
            int configFileReaderParameterPosition = -1;
            if (originalMethod.hasAnnotation(CONFIG_FILE)) {
                parameterTypes.add(ConfigFileReader.class.getName());
                configFileReaderParameterPosition = j;
                j++;
            }
            parameterTypes.add(GitHubEvent.class.getName());
            int gitHubEventParameterPosition = j;
            MethodCreator methodCreator = multiplexerClassCreator.getMethodCreator(originalMethod.name() + "_" + HashUtil.sha1(originalMethod.toString() + "_" + (eventSubscriberInstance != null ? eventSubscriberInstance.toString() : EventDefinition.ALL)), originalMethod.returnType().name().toString(), parameterTypes.toArray());
            for (Type exceptionType : originalMethod.exceptions()) {
                methodCreator.addException(exceptionType.name().toString());
            }
            ResultHandle[] parameterValues = new ResultHandle[originalMethod.parameters().size()];
            // copy annotations except for @ConfigFile
            for (short i = 0; i < originalMethodParameterTypes.size(); i++) {
                List<AnnotationInstance> parameterAnnotations = originalMethodParameterAnnotationMapping.getOrDefault(i, Collections.emptyList());
                if (parameterAnnotations.isEmpty()) {
                    continue;
                }
                // Elements that are not in the mapping are ignored
                Short generatedParameterIndex = parameterMapping.get(i);
                if (generatedParameterIndex == null) {
                    continue;
                }
                AnnotatedElement generatedParameterAnnotations = methodCreator.getParameterAnnotations(generatedParameterIndex);
                for (AnnotationInstance annotationInstance : parameterAnnotations) {
                    generatedParameterAnnotations.addAnnotation(annotationInstance);
                }
            }
            // add annotations to the GitHubEvent parameter
            AnnotatedElement gitHubEventParameterAnnotations = methodCreator.getParameterAnnotations(gitHubEventParameterPosition);
            gitHubEventParameterAnnotations.addAnnotation(DotNames.OBSERVES.toString());
            gitHubEventParameterAnnotations.addAnnotation(Action.class).addValue("value", name);
            if (eventSubscriberInstance != null) {
                gitHubEventParameterAnnotations.addAnnotation(eventSubscriberInstance);
            }
            ResultHandle gitHubEventRh = methodCreator.getMethodParam(gitHubEventParameterPosition);
            // generate the code of the method
            for (short originalMethodParameterIndex = 0; originalMethodParameterIndex < originalMethodParameterTypes.size(); originalMethodParameterIndex++) {
                List<AnnotationInstance> parameterAnnotations = originalMethodParameterAnnotationMapping.getOrDefault(originalMethodParameterIndex, Collections.emptyList());
                Short multiplexerMethodParameterIndex = parameterMapping.get(originalMethodParameterIndex);
                if (originalMethodParameterIndex == payloadParameterPosition) {
                    parameterValues[originalMethodParameterIndex] = methodCreator.invokeVirtualMethod(MethodDescriptor.ofMethod(GitHubEvent.class, "getPayload", GHEventPayload.class), gitHubEventRh);
                } else if (INJECTABLE_TYPES.contains(originalMethodParameterTypes.get(originalMethodParameterIndex).name())) {
                    DotName injectableType = originalMethodParameterTypes.get(originalMethodParameterIndex).name();
                    parameterValues[originalMethodParameterIndex] = methodCreator.invokeVirtualMethod(MethodDescriptor.ofMethod(GitHubEvent.class, "get" + injectableType.withoutPackagePrefix(), injectableType.toString()), gitHubEventRh);
                } else if (parameterAnnotations.stream().anyMatch(ai -> ai.name().equals(CONFIG_FILE))) {
                    AnnotationInstance configFileAnnotationInstance = parameterAnnotations.stream().filter(ai -> ai.name().equals(CONFIG_FILE)).findFirst().get();
                    String configObjectType = originalMethodParameterTypes.get(originalMethodParameterIndex).name().toString();
                    boolean isOptional = false;
                    if (Optional.class.getName().equals(configObjectType)) {
                        if (originalMethodParameterTypes.get(originalMethodParameterIndex).kind() != Type.Kind.PARAMETERIZED_TYPE) {
                            throw new IllegalStateException("Optional is used but not parameterized for method " + originalMethod.declaringClass().name() + "#" + originalMethod);
                        }
                        isOptional = true;
                        configObjectType = originalMethodParameterTypes.get(originalMethodParameterIndex).asParameterizedType().arguments().get(0).name().toString();
                    }
                    ResultHandle gitHubRh = methodCreator.invokeVirtualMethod(MethodDescriptor.ofMethod(GitHubEvent.class, "getGitHub", GitHub.class), gitHubEventRh);
                    ResultHandle contextRh = methodCreator.invokeVirtualMethod(MethodDescriptor.ofMethod(GitHubEvent.class, "getContext", Context.class), gitHubEventRh);
                    ResultHandle repositoryRh = methodCreator.invokeInterfaceMethod(MethodDescriptor.ofMethod(Context.class, "getGitHubRepository", String.class), contextRh);
                    ResultHandle configFileReaderRh = methodCreator.getMethodParam(configFileReaderParameterPosition);
                    ResultHandle configObject = methodCreator.invokeVirtualMethod(MethodDescriptor.ofMethod(ConfigFileReader.class, "getConfigObject", Object.class, GitHub.class, String.class, String.class, Class.class), configFileReaderRh, gitHubRh, repositoryRh, methodCreator.load(configFileAnnotationInstance.value().asString()), methodCreator.loadClass(configObjectType));
                    configObject = methodCreator.checkCast(configObject, configObjectType);
                    if (isOptional) {
                        configObject = methodCreator.invokeStaticMethod(MethodDescriptor.ofMethod(Optional.class, "ofNullable", Optional.class, Object.class), configObject);
                    }
                    parameterValues[originalMethodParameterIndex] = configObject;
                } else {
                    parameterValues[originalMethodParameterIndex] = methodCreator.getMethodParam(multiplexerMethodParameterIndex);
                }
            }
            ResultHandle returnValue = methodCreator.invokeVirtualMethod(originalMethod, methodCreator.getThis(), parameterValues);
            methodCreator.returnValue(returnValue);
        }
        multiplexerClassCreator.close();
    }
}
Also used : DotNames(io.quarkus.arc.processor.DotNames) GeneratedClassGizmoAdaptor(io.quarkus.deployment.GeneratedClassGizmoAdaptor) Arrays(java.util.Arrays) MethodVisitor(org.objectweb.asm.MethodVisitor) PayloadTypeResolver(io.quarkiverse.githubaction.runtime.PayloadTypeResolver) ClassOutput(io.quarkus.gizmo.ClassOutput) RunTimeConfigurationDefaultBuildItem(io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem) ClassInfo(org.jboss.jandex.ClassInfo) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) GeneratedBeanBuildItem(io.quarkus.arc.deployment.GeneratedBeanBuildItem) MethodInfo(org.jboss.jandex.MethodInfo) Context(io.quarkiverse.githubaction.Context) AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) AnnotationLiteral(javax.enterprise.util.AnnotationLiteral) Map(java.util.Map) BytecodeCreator(io.quarkus.gizmo.BytecodeCreator) GHEventPayload(org.kohsuke.github.GHEventPayload) ConfigFileReader(io.quarkiverse.githubaction.runtime.ConfigFileReader) MethodParameterInfo(org.jboss.jandex.MethodParameterInfo) ClassVisitor(org.objectweb.asm.ClassVisitor) GitHub(org.kohsuke.github.GitHub) AnnotationsTransformerBuildItem(io.quarkus.arc.deployment.AnnotationsTransformerBuildItem) ActionDispatchingConfiguration(io.quarkiverse.githubaction.deployment.DispatchingConfiguration.ActionDispatchingConfiguration) AnnotationValue(org.jboss.jandex.AnnotationValue) ReflectiveHierarchyBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem) EventAnnotationLiteral(io.quarkiverse.githubaction.deployment.DispatchingConfiguration.EventAnnotationLiteral) Collection(java.util.Collection) Set(java.util.Set) ActionLiteral(io.quarkiverse.githubaction.Action.ActionLiteral) BuiltinScope(io.quarkus.arc.processor.BuiltinScope) Collectors(java.util.stream.Collectors) MethodDescriptors(io.quarkus.arc.processor.MethodDescriptors) List(java.util.List) GitHubEvent(io.quarkiverse.githubaction.runtime.GitHubEvent) GitHubApiClassWithBridgeMethodsBuildItem(io.quarkiverse.githubapi.deployment.GitHubApiClassWithBridgeMethodsBuildItem) ActionDispatchingMethod(io.quarkiverse.githubaction.deployment.DispatchingConfiguration.ActionDispatchingMethod) Actions(io.quarkiverse.githubapp.event.Actions) AnnotationInstance(org.jboss.jandex.AnnotationInstance) Modifier(java.lang.reflect.Modifier) Annotation(java.lang.annotation.Annotation) Entry(java.util.Map.Entry) Optional(java.util.Optional) Multiplexer(io.quarkiverse.githubaction.runtime.Multiplexer) HashUtil(io.quarkus.runtime.util.HashUtil) ResultHandle(io.quarkus.gizmo.ResultHandle) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) Logger(org.jboss.logging.Logger) MethodCreator(io.quarkus.gizmo.MethodCreator) DotName(org.jboss.jandex.DotName) Type(org.jboss.jandex.Type) AnnotatedElement(io.quarkus.gizmo.AnnotatedElement) HashMap(java.util.HashMap) ClassCreator(io.quarkus.gizmo.ClassCreator) Singleton(javax.inject.Singleton) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) EVENT(io.quarkiverse.githubaction.deployment.GitHubActionDotNames.EVENT) Inject(javax.inject.Inject) BuildStep(io.quarkus.deployment.annotations.BuildStep) INJECTABLE_TYPES(io.quarkiverse.githubaction.deployment.GitHubActionDotNames.INJECTABLE_TYPES) Kind(org.jboss.jandex.AnnotationTarget.Kind) EventAnnotation(io.quarkiverse.githubaction.deployment.DispatchingConfiguration.EventAnnotation) Gizmo(io.quarkus.gizmo.Gizmo) PrintStream(java.io.PrintStream) Event(javax.enterprise.event.Event) IndexView(org.jboss.jandex.IndexView) Opcodes(org.objectweb.asm.Opcodes) MethodDescriptor(io.quarkus.gizmo.MethodDescriptor) CONFIG_FILE(io.quarkiverse.githubaction.deployment.GitHubActionDotNames.CONFIG_FILE) GitHubEventHandler(io.quarkiverse.githubaction.runtime.GitHubEventHandler) FieldDescriptor(io.quarkus.gizmo.FieldDescriptor) Action(io.quarkiverse.githubaction.Action) GeneratedBeanGizmoAdaptor(io.quarkus.arc.deployment.GeneratedBeanGizmoAdaptor) ACTION(io.quarkiverse.githubaction.deployment.GitHubActionDotNames.ACTION) GeneratedClassBuildItem(io.quarkus.deployment.builditem.GeneratedClassBuildItem) LaunchModeBuildItem(io.quarkus.deployment.builditem.LaunchModeBuildItem) FieldCreator(io.quarkus.gizmo.FieldCreator) BytecodeTransformerBuildItem(io.quarkus.deployment.builditem.BytecodeTransformerBuildItem) Collections(java.util.Collections) Action(io.quarkiverse.githubaction.Action) HashMap(java.util.HashMap) GitHub(org.kohsuke.github.GitHub) ArrayList(java.util.ArrayList) AnnotatedElement(io.quarkus.gizmo.AnnotatedElement) DotName(org.jboss.jandex.DotName) ClassCreator(io.quarkus.gizmo.ClassCreator) TreeSet(java.util.TreeSet) ActionDispatchingMethod(io.quarkiverse.githubaction.deployment.DispatchingConfiguration.ActionDispatchingMethod) List(java.util.List) ArrayList(java.util.ArrayList) ResultHandle(io.quarkus.gizmo.ResultHandle) Context(io.quarkiverse.githubaction.Context) Optional(java.util.Optional) GitHubEvent(io.quarkiverse.githubaction.runtime.GitHubEvent) Type(org.jboss.jandex.Type) MethodCreator(io.quarkus.gizmo.MethodCreator) ConfigFileReader(io.quarkiverse.githubaction.runtime.ConfigFileReader) MethodInfo(org.jboss.jandex.MethodInfo) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ClassInfo(org.jboss.jandex.ClassInfo)

Example 5 with ResultHandle

use of io.quarkus.gizmo.ResultHandle in project quarkus-github-app by quarkiverse.

the class GitHubAppProcessor method generateMultiplexers.

/**
 * Multiplexers listen to the async events emitted by the dispatcher.
 * <p>
 * They are subclasses of the application classes listening to GitHub events through our annotations.
 * <p>
 * They are useful for several purposes:
 * <ul>
 * <li>A single application method can listen to multiple event types: the event types are qualifiers and CDI wouldn't allow
 * that (only events matching all the qualifiers would be received by the application method). That's why this class is
 * called a multiplexer: it will generate one method per event type and each generated method will delegate to the original
 * method.</li>
 * <li>The multiplexer also handles the resolution of config files.</li>
 * <li>We can inject a properly configured instance of GitHub or DynamicGraphQLClient into the method.</li>
 * </ul>
 */
private static void generateMultiplexers(ClassOutput beanClassOutput, DispatchingConfiguration dispatchingConfiguration, BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) {
    for (Entry<DotName, TreeSet<EventDispatchingMethod>> eventDispatchingMethodsEntry : dispatchingConfiguration.getMethods().entrySet()) {
        DotName declaringClassName = eventDispatchingMethodsEntry.getKey();
        TreeSet<EventDispatchingMethod> eventDispatchingMethods = eventDispatchingMethodsEntry.getValue();
        ClassInfo declaringClass = eventDispatchingMethods.iterator().next().getMethod().declaringClass();
        reflectiveClasses.produce(new ReflectiveClassBuildItem(true, true, declaringClassName.toString()));
        String multiplexerClassName = declaringClassName + "_Multiplexer";
        reflectiveClasses.produce(new ReflectiveClassBuildItem(true, true, multiplexerClassName));
        ClassCreator multiplexerClassCreator = ClassCreator.builder().classOutput(beanClassOutput).className(multiplexerClassName).superClass(declaringClassName.toString()).build();
        multiplexerClassCreator.addAnnotation(Multiplexer.class);
        if (!BuiltinScope.isDeclaredOn(declaringClass)) {
            multiplexerClassCreator.addAnnotation(Singleton.class);
        }
        for (AnnotationInstance classAnnotation : declaringClass.classAnnotations()) {
            multiplexerClassCreator.addAnnotation(classAnnotation);
        }
        // Copy the constructors
        for (MethodInfo originalConstructor : declaringClass.constructors()) {
            MethodCreator constructorCreator = multiplexerClassCreator.getMethodCreator(MethodDescriptor.ofConstructor(multiplexerClassName, originalConstructor.parameters().stream().map(t -> t.name().toString()).toArray(String[]::new)));
            List<AnnotationInstance> originalMethodAnnotations = originalConstructor.annotations().stream().filter(ai -> ai.target().kind() == Kind.METHOD).collect(Collectors.toList());
            for (AnnotationInstance originalMethodAnnotation : originalMethodAnnotations) {
                constructorCreator.addAnnotation(originalMethodAnnotation);
            }
            Map<Short, List<AnnotationInstance>> originalConstructorParameterAnnotationMapping = originalConstructor.annotations().stream().filter(ai -> ai.target().kind() == Kind.METHOD_PARAMETER).collect(Collectors.groupingBy(ai -> ai.target().asMethodParameter().position()));
            List<ResultHandle> parametersRh = new ArrayList<>();
            for (short i = 0; i < originalConstructor.parameters().size(); i++) {
                parametersRh.add(constructorCreator.getMethodParam(i));
                AnnotatedElement parameterAnnotations = constructorCreator.getParameterAnnotations(i);
                List<AnnotationInstance> originalConstructorParameterAnnotations = originalConstructorParameterAnnotationMapping.getOrDefault(i, Collections.emptyList());
                for (AnnotationInstance originalConstructorParameterAnnotation : originalConstructorParameterAnnotations) {
                    parameterAnnotations.addAnnotation(originalConstructorParameterAnnotation);
                }
            }
            constructorCreator.invokeSpecialMethod(MethodDescriptor.of(originalConstructor), constructorCreator.getThis(), parametersRh.toArray(ResultHandle[]::new));
            constructorCreator.returnValue(null);
        }
        // Generate the multiplexed event dispatching methods
        for (EventDispatchingMethod eventDispatchingMethod : eventDispatchingMethods) {
            AnnotationInstance eventSubscriberInstance = eventDispatchingMethod.getEventSubscriberInstance();
            MethodInfo originalMethod = eventDispatchingMethod.getMethod();
            Map<Short, List<AnnotationInstance>> originalMethodParameterAnnotationMapping = originalMethod.annotations().stream().filter(ai -> ai.target().kind() == Kind.METHOD_PARAMETER).collect(Collectors.groupingBy(ai -> ai.target().asMethodParameter().position()));
            // if the method already has an @Observes or @ObservesAsync annotation
            if (originalMethod.hasAnnotation(DotNames.OBSERVES) || originalMethod.hasAnnotation(DotNames.OBSERVES_ASYNC)) {
                LOG.warn("Methods listening to GitHub events may not be annotated with @Observes or @ObservesAsync. Offending method: " + originalMethod.declaringClass().name() + "#" + originalMethod);
            }
            List<String> parameterTypes = new ArrayList<>();
            List<Type> originalMethodParameterTypes = originalMethod.parameters();
            // detect the parameter that is a payload
            short payloadParameterPosition = 0;
            for (short i = 0; i < originalMethodParameterTypes.size(); i++) {
                List<AnnotationInstance> parameterAnnotations = originalMethodParameterAnnotationMapping.getOrDefault(i, Collections.emptyList());
                if (parameterAnnotations.stream().anyMatch(ai -> ai.name().equals(eventSubscriberInstance.name()))) {
                    payloadParameterPosition = i;
                    break;
                }
            }
            short j = 0;
            Map<Short, Short> parameterMapping = new HashMap<>();
            for (short i = 0; i < originalMethodParameterTypes.size(); i++) {
                List<AnnotationInstance> originalMethodAnnotations = originalMethodParameterAnnotationMapping.getOrDefault(i, Collections.emptyList());
                if (originalMethodAnnotations.stream().anyMatch(ai -> CONFIG_FILE.equals(ai.name())) || GITHUB.equals(originalMethodParameterTypes.get(i).name()) || DYNAMIC_GRAPHQL_CLIENT.equals(originalMethodParameterTypes.get(i).name())) {
                    // if the parameter is annotated with @ConfigFile or is of type GitHub or DynamicGraphQLClient, we skip it
                    continue;
                }
                String parameterType;
                if (i == payloadParameterPosition) {
                    parameterType = MultiplexedEvent.class.getName();
                } else {
                    parameterType = originalMethodParameterTypes.get(i).name().toString();
                }
                parameterTypes.add(parameterType);
                parameterMapping.put(i, j);
                j++;
            }
            if (originalMethod.hasAnnotation(CONFIG_FILE)) {
                parameterTypes.add(ConfigFileReader.class.getName());
            }
            MethodCreator methodCreator = multiplexerClassCreator.getMethodCreator(originalMethod.name() + "_" + HashUtil.sha1(eventSubscriberInstance.toString()), originalMethod.returnType().name().toString(), parameterTypes.toArray());
            for (Type exceptionType : originalMethod.exceptions()) {
                methodCreator.addException(exceptionType.name().toString());
            }
            ResultHandle[] parameterValues = new ResultHandle[originalMethod.parameters().size()];
            // copy annotations except for @ConfigFile
            for (short i = 0; i < originalMethodParameterTypes.size(); i++) {
                List<AnnotationInstance> parameterAnnotations = originalMethodParameterAnnotationMapping.getOrDefault(i, Collections.emptyList());
                if (parameterAnnotations.isEmpty()) {
                    continue;
                }
                // @ConfigFile elements are not in the mapping
                Short generatedParameterIndex = parameterMapping.get(i);
                if (generatedParameterIndex == null) {
                    continue;
                }
                AnnotatedElement generatedParameterAnnotations = methodCreator.getParameterAnnotations(generatedParameterIndex);
                if (parameterAnnotations.stream().anyMatch(ai -> ai.name().equals(eventSubscriberInstance.name()))) {
                    generatedParameterAnnotations.addAnnotation(DotNames.OBSERVES_ASYNC.toString());
                    generatedParameterAnnotations.addAnnotation(eventSubscriberInstance);
                } else {
                    for (AnnotationInstance annotationInstance : parameterAnnotations) {
                        generatedParameterAnnotations.addAnnotation(annotationInstance);
                    }
                }
            }
            ResultHandle payloadRh = methodCreator.invokeVirtualMethod(MethodDescriptor.ofMethod(MultiplexedEvent.class, "getPayload", GHEventPayload.class), methodCreator.getMethodParam(parameterMapping.get(payloadParameterPosition)));
            // generate the code of the method
            for (short originalMethodParameterIndex = 0; originalMethodParameterIndex < originalMethodParameterTypes.size(); originalMethodParameterIndex++) {
                List<AnnotationInstance> parameterAnnotations = originalMethodParameterAnnotationMapping.getOrDefault(originalMethodParameterIndex, Collections.emptyList());
                Short multiplexerMethodParameterIndex = parameterMapping.get(originalMethodParameterIndex);
                if (originalMethodParameterIndex == payloadParameterPosition) {
                    parameterValues[originalMethodParameterIndex] = payloadRh;
                } else if (GITHUB.equals(originalMethodParameterTypes.get(originalMethodParameterIndex).name())) {
                    parameterValues[originalMethodParameterIndex] = methodCreator.invokeVirtualMethod(MethodDescriptor.ofMethod(MultiplexedEvent.class, "getGitHub", GitHub.class), methodCreator.getMethodParam(parameterMapping.get(payloadParameterPosition)));
                } else if (DYNAMIC_GRAPHQL_CLIENT.equals(originalMethodParameterTypes.get(originalMethodParameterIndex).name())) {
                    parameterValues[originalMethodParameterIndex] = methodCreator.invokeVirtualMethod(MethodDescriptor.ofMethod(MultiplexedEvent.class, "getGitHubGraphQLClient", DynamicGraphQLClient.class), methodCreator.getMethodParam(parameterMapping.get(payloadParameterPosition)));
                } else if (parameterAnnotations.stream().anyMatch(ai -> ai.name().equals(CONFIG_FILE))) {
                    AnnotationInstance configFileAnnotationInstance = parameterAnnotations.stream().filter(ai -> ai.name().equals(CONFIG_FILE)).findFirst().get();
                    String configObjectType = originalMethodParameterTypes.get(originalMethodParameterIndex).name().toString();
                    boolean isOptional = false;
                    if (Optional.class.getName().equals(configObjectType)) {
                        if (originalMethodParameterTypes.get(originalMethodParameterIndex).kind() != Type.Kind.PARAMETERIZED_TYPE) {
                            throw new IllegalStateException("Optional is used but not parameterized for method " + originalMethod.declaringClass().name() + "#" + originalMethod);
                        }
                        isOptional = true;
                        configObjectType = originalMethodParameterTypes.get(originalMethodParameterIndex).asParameterizedType().arguments().get(0).name().toString();
                    }
                    // it's a config file, we will use the ConfigFileReader (last parameter of the method) and inject the result
                    ResultHandle configFileReaderRh = methodCreator.getMethodParam(parameterTypes.size() - 1);
                    ResultHandle ghRepositoryRh = methodCreator.invokeStaticMethod(MethodDescriptor.ofMethod(PayloadHelper.class, "getRepository", GHRepository.class, GHEventPayload.class), payloadRh);
                    ResultHandle configObject = methodCreator.invokeVirtualMethod(MethodDescriptor.ofMethod(ConfigFileReader.class, "getConfigObject", Object.class, GHRepository.class, String.class, Class.class), configFileReaderRh, ghRepositoryRh, methodCreator.load(configFileAnnotationInstance.value().asString()), methodCreator.loadClass(configObjectType));
                    configObject = methodCreator.checkCast(configObject, configObjectType);
                    if (isOptional) {
                        configObject = methodCreator.invokeStaticMethod(MethodDescriptor.ofMethod(Optional.class, "ofNullable", Optional.class, Object.class), configObject);
                    }
                    parameterValues[originalMethodParameterIndex] = configObject;
                } else {
                    parameterValues[originalMethodParameterIndex] = methodCreator.getMethodParam(multiplexerMethodParameterIndex);
                }
            }
            ResultHandle returnValue = methodCreator.invokeVirtualMethod(originalMethod, methodCreator.getThis(), parameterValues);
            methodCreator.returnValue(returnValue);
        }
        multiplexerClassCreator.close();
    }
}
Also used : GitHubService(io.quarkiverse.githubapp.runtime.github.GitHubService) DotNames(io.quarkus.arc.processor.DotNames) GeneratedClassGizmoAdaptor(io.quarkus.deployment.GeneratedClassGizmoAdaptor) Arrays(java.util.Arrays) GHRepository(org.kohsuke.github.GHRepository) ClassOutput(io.quarkus.gizmo.ClassOutput) ShutdownContextBuildItem(io.quarkus.deployment.builditem.ShutdownContextBuildItem) AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) AnnotationLiteral(javax.enterprise.util.AnnotationLiteral) Map(java.util.Map) BytecodeCreator(io.quarkus.gizmo.BytecodeCreator) GHEventPayload(org.kohsuke.github.GHEventPayload) PayloadHelper(io.quarkiverse.githubapp.runtime.github.PayloadHelper) EVENT(io.quarkiverse.githubapp.deployment.GitHubAppDotNames.EVENT) MethodParameterInfo(org.jboss.jandex.MethodParameterInfo) AnnotationsTransformerBuildItem(io.quarkus.arc.deployment.AnnotationsTransformerBuildItem) AnnotationValue(org.jboss.jandex.AnnotationValue) ReflectiveHierarchyBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem) EventDispatchingMethod(io.quarkiverse.githubapp.deployment.DispatchingConfiguration.EventDispatchingMethod) Set(java.util.Set) EventAnnotationLiteral(io.quarkiverse.githubapp.deployment.DispatchingConfiguration.EventAnnotationLiteral) Reader(java.io.Reader) BuiltinScope(io.quarkus.arc.processor.BuiltinScope) CompletionStage(java.util.concurrent.CompletionStage) AnnotationInstance(org.jboss.jandex.AnnotationInstance) HashUtil(io.quarkus.runtime.util.HashUtil) ResultHandle(io.quarkus.gizmo.ResultHandle) TryBlock(io.quarkus.gizmo.TryBlock) Record(io.quarkus.deployment.annotations.Record) CatchBlockCreator(io.quarkus.gizmo.CatchBlockCreator) DotName(org.jboss.jandex.DotName) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) MultiplexedEvent(io.quarkiverse.githubapp.runtime.MultiplexedEvent) ConfigFileReader(io.quarkiverse.githubapp.runtime.ConfigFileReader) CONFIG_FILE(io.quarkiverse.githubapp.deployment.GitHubAppDotNames.CONFIG_FILE) Gizmo(io.quarkus.gizmo.Gizmo) Opcodes(org.objectweb.asm.Opcodes) GitHubAppRecorder(io.quarkiverse.githubapp.runtime.GitHubAppRecorder) IOException(java.io.IOException) FieldDescriptor(io.quarkus.gizmo.FieldDescriptor) GeneratedBeanGizmoAdaptor(io.quarkus.arc.deployment.GeneratedBeanGizmoAdaptor) StringReader(java.io.StringReader) GeneratedClassBuildItem(io.quarkus.deployment.builditem.GeneratedClassBuildItem) LaunchModeBuildItem(io.quarkus.deployment.builditem.LaunchModeBuildItem) FieldCreator(io.quarkus.gizmo.FieldCreator) BytecodeTransformerBuildItem(io.quarkus.deployment.builditem.BytecodeTransformerBuildItem) GitHubEvent(io.quarkiverse.githubapp.GitHubEvent) WebJarResultsBuildItem(io.quarkus.vertx.http.deployment.webjar.WebJarResultsBuildItem) MethodVisitor(org.objectweb.asm.MethodVisitor) DefaultErrorHandler(io.quarkiverse.githubapp.runtime.error.DefaultErrorHandler) ClassInfo(org.jboss.jandex.ClassInfo) RoutingContext(io.vertx.ext.web.RoutingContext) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) Multiplexer(io.quarkiverse.githubapp.runtime.Multiplexer) GeneratedBeanBuildItem(io.quarkus.arc.deployment.GeneratedBeanBuildItem) MethodInfo(org.jboss.jandex.MethodInfo) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) NotFoundPageDisplayableEndpointBuildItem(io.quarkus.vertx.http.deployment.devmode.NotFoundPageDisplayableEndpointBuildItem) ClassVisitor(org.objectweb.asm.ClassVisitor) GitHub(org.kohsuke.github.GitHub) Collection(java.util.Collection) ExecutionTime(io.quarkus.deployment.annotations.ExecutionTime) Collectors(java.util.stream.Collectors) MethodDescriptors(io.quarkus.arc.processor.MethodDescriptors) List(java.util.List) GitHubApiClassWithBridgeMethodsBuildItem(io.quarkiverse.githubapi.deployment.GitHubApiClassWithBridgeMethodsBuildItem) Actions(io.quarkiverse.githubapp.event.Actions) GACT(io.quarkus.maven.dependency.GACT) WebJarBuildItem(io.quarkus.vertx.http.deployment.webjar.WebJarBuildItem) Modifier(java.lang.reflect.Modifier) Annotation(java.lang.annotation.Annotation) Entry(java.util.Map.Entry) EventAnnotation(io.quarkiverse.githubapp.deployment.DispatchingConfiguration.EventAnnotation) Optional(java.util.Optional) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) RouteBuildItem(io.quarkus.vertx.http.deployment.RouteBuildItem) Logger(org.jboss.logging.Logger) MethodCreator(io.quarkus.gizmo.MethodCreator) Type(org.jboss.jandex.Type) AnnotatedElement(io.quarkus.gizmo.AnnotatedElement) LaunchMode(io.quarkus.runtime.LaunchMode) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) ClassCreator(io.quarkus.gizmo.ClassCreator) Singleton(javax.inject.Singleton) ErrorHandlerBridgeFunction(io.quarkiverse.githubapp.runtime.error.ErrorHandlerBridgeFunction) Function(java.util.function.Function) HttpRootPathBuildItem(io.quarkus.vertx.http.deployment.HttpRootPathBuildItem) Inject(javax.inject.Inject) BuildStep(io.quarkus.deployment.annotations.BuildStep) Kind(org.jboss.jandex.AnnotationTarget.Kind) PrintStream(java.io.PrintStream) Event(javax.enterprise.event.Event) IndexView(org.jboss.jandex.IndexView) MethodDescriptor(io.quarkus.gizmo.MethodDescriptor) DynamicGraphQLClient(io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient) EventDispatchingConfiguration(io.quarkiverse.githubapp.deployment.DispatchingConfiguration.EventDispatchingConfiguration) GITHUB(io.quarkiverse.githubapp.deployment.GitHubAppDotNames.GITHUB) DYNAMIC_GRAPHQL_CLIENT(io.quarkiverse.githubapp.deployment.GitHubAppDotNames.DYNAMIC_GRAPHQL_CLIENT) Handler(io.vertx.core.Handler) Collections(java.util.Collections) EventDispatchingMethod(io.quarkiverse.githubapp.deployment.DispatchingConfiguration.EventDispatchingMethod) HashMap(java.util.HashMap) GitHub(org.kohsuke.github.GitHub) ArrayList(java.util.ArrayList) AnnotatedElement(io.quarkus.gizmo.AnnotatedElement) DotName(org.jboss.jandex.DotName) ClassCreator(io.quarkus.gizmo.ClassCreator) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) List(java.util.List) ResultHandle(io.quarkus.gizmo.ResultHandle) Optional(java.util.Optional) Type(org.jboss.jandex.Type) GHEventPayload(org.kohsuke.github.GHEventPayload) MethodCreator(io.quarkus.gizmo.MethodCreator) ConfigFileReader(io.quarkiverse.githubapp.runtime.ConfigFileReader) MethodInfo(org.jboss.jandex.MethodInfo) MultiplexedEvent(io.quarkiverse.githubapp.runtime.MultiplexedEvent) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ClassInfo(org.jboss.jandex.ClassInfo)

Aggregations

ResultHandle (io.quarkus.gizmo.ResultHandle)10 ReflectiveClassBuildItem (io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem)6 ClassCreator (io.quarkus.gizmo.ClassCreator)6 FieldCreator (io.quarkus.gizmo.FieldCreator)6 MethodCreator (io.quarkus.gizmo.MethodCreator)6 BuildStep (io.quarkus.deployment.annotations.BuildStep)5 MethodDescriptor (io.quarkus.gizmo.MethodDescriptor)5 MethodInfo (org.jboss.jandex.MethodInfo)4 ActionLiteral (io.quarkiverse.githubaction.Action.ActionLiteral)3 ActionDispatchingConfiguration (io.quarkiverse.githubaction.deployment.DispatchingConfiguration.ActionDispatchingConfiguration)3 EventAnnotation (io.quarkiverse.githubaction.deployment.DispatchingConfiguration.EventAnnotation)3 GitHubEventHandler (io.quarkiverse.githubaction.runtime.GitHubEventHandler)3 GitHubApiClassWithBridgeMethodsBuildItem (io.quarkiverse.githubapi.deployment.GitHubApiClassWithBridgeMethodsBuildItem)3 Actions (io.quarkiverse.githubapp.event.Actions)3 MultiplexedEvent (io.quarkiverse.githubapp.runtime.MultiplexedEvent)3 AdditionalBeanBuildItem (io.quarkus.arc.deployment.AdditionalBeanBuildItem)3 GeneratedBeanBuildItem (io.quarkus.arc.deployment.GeneratedBeanBuildItem)3 GeneratedBeanGizmoAdaptor (io.quarkus.arc.deployment.GeneratedBeanGizmoAdaptor)3 BuildProducer (io.quarkus.deployment.annotations.BuildProducer)3 CombinedIndexBuildItem (io.quarkus.deployment.builditem.CombinedIndexBuildItem)3