package com.wecloud.dispatch.general.impl;

import com.wecloud.dispatch.extend.ActionBox;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * @author lixiaozhong
 */
public class GeneralActionBox implements ActionBox, ApplicationContextAware {
	private ApplicationContext applicationContext = null;

	@Override
	public Object getAction(Class<?> type) {

		Object o = null;
		if (null != applicationContext) {
			o = applicationContext.getBean(type);
		}
		return o;
	}

	@Override
	public Object getAction(String className) {
		Object o = null;
		if (null != applicationContext) {
			o = applicationContext.getBean(className);
		}
		return o;
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext;
	}
}
