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

com.fireflysource.common.service.ServiceUtils Maven / Gradle / Ivy

package com.fireflysource.common.service;

import java.util.ServiceLoader;

/**
 * @author Pengtao Qiu
 */
abstract public class ServiceUtils {

    public static  T loadService(Class clazz, T defaultService) {
        T service = null;
        ServiceLoader serviceLoader = ServiceLoader.load(clazz);
        for (T t : serviceLoader) {
            service = t;
        }
        if (service == null) {
            service = defaultService;
        }
        return service;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy