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

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

There is a newer version: 5.0.2
Show newest version
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 - 2024 Weber Informatics LLC | Privacy Policy