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

com.github.charlemaznable.bunny.rabbit.spring.loader.BunnyHandlerLoaderImpl Maven / Gradle / Ivy

Go to download

Bunny rabbits will skip hand-in-hand with baby lambs across sunny green meadows.

There is a newer version: 2023.0.4
Show newest version
package com.github.charlemaznable.bunny.rabbit.spring.loader;

import com.github.charlemaznable.bunny.plugin.BunnyHandler;
import com.github.charlemaznable.bunny.rabbit.core.common.BunnyHandlerLoader;
import com.github.charlemaznable.core.spring.SpringContext;
import lombok.val;

import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

import static com.github.charlemaznable.core.lang.Listt.newArrayList;
import static java.util.Objects.isNull;

@SuppressWarnings("rawtypes")
public final class BunnyHandlerLoaderImpl implements BunnyHandlerLoader {

    private List handlers;

    @Override
    public synchronized List loadHandlers() {
        if (isNull(handlers)) {
            val handlerNames = newArrayList(SpringContext
                    .getBeanNamesForType(BunnyHandler.class));
            Function handlerBuilder = SpringContext::getBean;
            handlers = handlerNames.stream().map(handlerBuilder).collect(Collectors.toList());
        }
        return handlers;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy