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

io.leopard.web.servlet.BeanLoader Maven / Gradle / Ivy

package io.leopard.web.servlet;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.ListableBeanFactory;

public class BeanLoader {

	public static  List load(BeanFactory beanFactory, Class clazz) {
		List list = new ArrayList();
		{
			ListableBeanFactory factory = (ListableBeanFactory) beanFactory;
			Map map = factory.getBeansOfType(clazz);
			for (T bean : map.values()) {
				list.add(bean);
			}
		}

		{
			Iterator iterator = ServiceLoader.load(clazz).iterator();
			while (iterator.hasNext()) {
				list.add(iterator.next());
			}
		}

		return list;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy