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

org.simpleflatmapper.util.ProducerServiceLoader Maven / Gradle / Ivy

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

There is a newer version: 9.0.2
Show newest version
package org.simpleflatmapper.util;


import java.util.Iterator;
import java.util.ServiceLoader;


public class ProducerServiceLoader {

    @Deprecated
    public static > void produceFromServiceLoader(Class

producer, Consumer consumer) { produceFromServiceLoader(ServiceLoader.load(producer), consumer); } public static > void produceFromServiceLoader(ServiceLoader

serviceLoader, Consumer consumer) { Iterator

iterator = serviceLoader.iterator(); while(iterator.hasNext()) { try { iterator.next().produce(consumer); } catch (Throwable e) { System.err.println("Unexpected error on listing " + serviceLoader + " : " + e); e.printStackTrace(); } } } public interface Producer { void produce(Consumer consumer); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy