com.github.charlemaznable.bunny.rabbit.spring.loader.BunnyHandlerLoaderImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bunny-rabbit Show documentation
Show all versions of bunny-rabbit Show documentation
Bunny rabbits will skip hand-in-hand with baby lambs across sunny green meadows.
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