All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.mailer.runtime.MailerRecorder Maven / Gradle / Ivy

There is a newer version: 3.17.0.CR1
Show newest version
package io.quarkus.mailer.runtime;

import java.util.function.Function;
import java.util.function.Supplier;

import io.quarkus.arc.SyntheticCreationalContext;
import io.quarkus.mailer.Mailer;
import io.quarkus.mailer.MockMailbox;
import io.quarkus.mailer.reactive.ReactiveMailer;
import io.quarkus.runtime.annotations.Recorder;
import io.vertx.ext.mail.MailClient;

@Recorder
public class MailerRecorder {

    public Supplier mailerSupportSupplier(MailerSupport mailerSupport) {
        return new Supplier() {
            @Override
            public MailerSupport get() {
                return mailerSupport;
            }
        };
    }

    public Function, MailClient> mailClientFunction(String name,
            @SuppressWarnings("unused") MailersRuntimeConfig mailersRuntimeConfig) {
        return new Function, MailClient>() {
            @Override
            public MailClient apply(SyntheticCreationalContext context) {
                return context.getInjectedReference(Mailers.class).mailClientFromName(name);
            }
        };
    }

    public Function, io.vertx.mutiny.ext.mail.MailClient> reactiveMailClientFunction(
            String name,
            @SuppressWarnings("unused") MailersRuntimeConfig mailersRuntimeConfig) {
        return new Function, io.vertx.mutiny.ext.mail.MailClient>() {
            @Override
            public io.vertx.mutiny.ext.mail.MailClient apply(
                    SyntheticCreationalContext context) {
                return context.getInjectedReference(Mailers.class).reactiveMailClientFromName(name);
            }
        };
    }

    public Function, Mailer> mailerFunction(String name,
            @SuppressWarnings("unused") MailersRuntimeConfig mailersRuntimeConfig) {
        return new Function, Mailer>() {
            @Override
            public Mailer apply(SyntheticCreationalContext context) {
                return context.getInjectedReference(Mailers.class).mailerFromName(name);
            }
        };
    }

    public Function, ReactiveMailer> reactiveMailerFunction(String name,
            @SuppressWarnings("unused") MailersRuntimeConfig mailersRuntimeConfig) {
        return new Function, ReactiveMailer>() {
            @Override
            public ReactiveMailer apply(SyntheticCreationalContext context) {
                return context.getInjectedReference(Mailers.class).reactiveMailerFromName(name);
            }
        };
    }

    public Function, MockMailbox> mockMailboxFunction(String name,
            @SuppressWarnings("unused") MailersRuntimeConfig mailersRuntimeConfig) {
        return new Function, MockMailbox>() {
            @Override
            public MockMailbox apply(SyntheticCreationalContext context) {
                return context.getInjectedReference(Mailers.class).mockMailboxFromName(name);
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy