io.quarkus.resteasy.reactive.common.deployment.FactoryUtils Maven / Gradle / Ivy
package io.quarkus.resteasy.reactive.common.deployment;
import java.util.Objects;
import java.util.Set;
import org.jboss.jandex.ClassInfo;
import org.jboss.resteasy.reactive.common.core.SingletonBeanFactory;
import org.jboss.resteasy.reactive.spi.BeanFactory;
import io.quarkus.arc.deployment.BeanContainerBuildItem;
import io.quarkus.resteasy.reactive.common.runtime.ResteasyReactiveCommonRecorder;
public class FactoryUtils {
public static BeanFactory factory(ClassInfo providerClass, Set singletons,
ResteasyReactiveCommonRecorder recorder,
BeanContainerBuildItem beanContainerBuildItem) {
return factory(providerClass.name().toString(), singletons, recorder, beanContainerBuildItem);
}
public static BeanFactory factory(String providerClass, Set singletons,
ResteasyReactiveCommonRecorder recorder,
BeanContainerBuildItem beanContainerBuildItem) {
Objects.requireNonNull(providerClass, "providerClass cannot be null");
if (singletons.contains(providerClass)) {
return new SingletonBeanFactory<>(providerClass);
} else {
return recorder.factory(providerClass,
beanContainerBuildItem.getValue());
}
}
}