
org.jxls.util.ServiceFactoryDefaultImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jxls Show documentation
Show all versions of jxls Show documentation
Small library for Excel generation based on XLS templates
package org.jxls.util;
import java.util.Iterator;
import java.util.ServiceLoader;
import org.jxls.template.SimpleExporter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* SPI creator factory
*/
public class ServiceFactoryDefaultImpl implements ServiceFactory {
private static final Logger LOGGER = LoggerFactory.getLogger(SimpleExporter.class);
@Override
public T createService(Class interfaceClass, T defaultImpl) {
final T service;
final Iterator iterator = ServiceLoader.load(interfaceClass).iterator();
if (iterator.hasNext()) {
service = iterator.next();
} else {
service = defaultImpl;
}
LOGGER.debug("SPI {} => {}", interfaceClass.getName(), service);
LOGGER.info("you may change the SPI on file: META-INF/services/{}", interfaceClass.getName());
return service;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy