com.rt.logic.BaseLogic Maven / Gradle / Ivy
package com.rt.logic;
import com.rt.core.log.Log;
import com.rt.core.util.RTUtil;
import com.rt.core.util.SpringHelper;
/**
* 所有Logic的基类 提供数据库访问和从获得自身实例的通用方式
*
* @author mj
*/
public abstract class BaseLogic implements Logic {
protected Log log = Log.getLog(this.getClass());
/**
* 通过class获取实力,仅适用于自动注入的类
*
* @param clazz class
* @return Logic
*/
public static Logic getInstance(Class clazz) {
return getInstance(clazz.getSimpleName());
}
/**
* 通过class获取实力,仅适用于自动注入的类
*
* @param name name
* @return Logic
*/
public static Logic getInstance(String name) {
Object logic = SpringHelper.getBean(name);
if (logic == null) {
logic = SpringHelper.getBean(RTUtil.toFirstLowerCase(name));
}
return (Logic) logic;
}
@Override
public Object execute(Object context) throws Exception {
return context;
}
}