| | |
| | | package com.lf.server.helper; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | |
| | | /** |
| | | * 类帮助类 |
| | | * @author WWW |
| | | */ |
| | | public class ClassHelper { |
| | | private final static Log log = LogFactory.getLog(ClassHelper.class); |
| | | |
| | | /** |
| | | * 根据类名创建实例 |
| | | * |
| | | * @param className 类名 |
| | | * @return 实体 |
| | | */ |
| | | public static Object createInstance(String className) { |
| | | try { |
| | | Class clazz = Class.forName(className); |
| | |
| | | |
| | | return obj; |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取Bean |
| | | * |
| | | * @param className 类名 |
| | | * @return Bean |
| | | */ |
| | | public static Object getBean(String className) { |
| | | try { |
| | | Object obj = SpringContextHelper.getBean(className); |
| | | |
| | | return obj; |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | return null; |
| | | } |
| | | } |