gu.simplemq.utils.SPIUtils Maven / Gradle / Ivy
The newest version!
package gu.simplemq.utils;
import java.util.ServiceLoader;
/**
* @author guyadong
* @since 2.3.12
*
*/
public class SPIUtils {
private SPIUtils() {
}
/**
* 优先调用{@link ServiceLoader#load(Class)},如果返回为空则调用{@link ServiceLoader#load(Class, ClassLoader)}
* @param
* @param service
*/
public static ServiceLoader serviceLoaderOf(Class service){
ServiceLoader loader = ServiceLoader.load(service);
return loader.iterator().hasNext() ? loader : ServiceLoader.load(service,service.getClassLoader());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy