configplugincomponent.java

来自「pojo的mvc框架」· Java 代码 · 共 62 行

JAVA
62
字号
package xyz.frame.config;import xyz.frame.component.ComponentInstantiationException;import xyz.frame.plugin.XyzPlugin;import xyz.frame.util.ReflectionUtil;import xyz.frame.webapp.DefaultWebApplication;/** * Models the xml portion to deal with factory classes *  * @author Guilherme Silveira */public class ConfigPluginComponent implements ConfigItem {	private Class<?> pluginClazz;	public <T> ConfigPluginComponent(Class<T> clazz) {		super();		this.pluginClazz = clazz;	}	public Class<?> getPluginClass() {		return pluginClazz;	}	/**	 * Registers itself	 * 	 * @see xyz.frame.config.ConfigItem#register(xyz.frame.webapp.DefaultWebApplication)	 */	@SuppressWarnings("unchecked")	public void register(DefaultWebApplication application)			throws ConfigException {		try {			application.getPluginManager().register(					(XyzPlugin) (ReflectionUtil							.instantiate(this.pluginClazz)));		} catch (ComponentInstantiationException e) {			throw new ConfigException(e.getMessage(), e);		} catch (ClassCastException e) {			throw new ConfigException(					"Did you forget to implement the plugin interface?", e);		}	}	/**	 * 	 * @see xyz.frame.config.ConfigItem#isComponent()	 */	public boolean isComponent() {		return true;	}	/**	 * 	 * @see xyz.frame.config.ConfigItem#isManager()	 */	public boolean isManager() {		return false;	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?