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

gu.sql2java.utils.SPIUtils Maven / Gradle / Ivy

There is a newer version: 5.2.0
Show newest version
package gu.sql2java.utils;

import java.util.ServiceLoader;

/**
 * @author guyadong
 * @since 3.26.2
 *
 */
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 - 2024 Weber Informatics LLC | Privacy Policy