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

com.eshore.uas.extensions.Extend Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
package com.eshore.uas.extensions;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;

/**
 * 扩展注入口
 * @author eshore
 *
 */
public class Extend {
	private static HashMap extensionmap=new HashMap();
	
	/**
	 * 扩展注入口
	 * @param o 扩展点实例,实现了扩展点接口的实例,由系统自动注入到对应原扩展点
	 */
	public static void addExtension(Object o) {
		Class[] clazz = o.getClass().getInterfaces();
		if(clazz!=null&&clazz.length>0)for(Class c:clazz) {
			Collection col = extensionmap.get(c);
			if(col==null) {
				col=new ArrayList();
				extensionmap.put(c, col);
			}
			col.add(o);
		}
	}
	
	public static Collection getExtensions(Class clazz) {
		return extensionmap.get(clazz);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy