Package cn.com.byd.utils

Source Code of cn.com.byd.utils.InvokeMethodUtil

package cn.com.byd.utils;


import cn.com.byd.exceptions.AppExceptin;
import cn.com.byd.exceptions.NoModuleException;
import cn.com.byd.factory.builder.FactoryBuilder;
import cn.com.byd.support.ILogger;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class InvokeMethodUtil {
    private final static ILogger log =
        FactoryBuilder.getLoggerFactory().getLogger(InvokeMethodUtil.class);

    public InvokeMethodUtil() {
        super();
    }

    public static Object invoke(Object obj, String methodName,
                                Object... args) throws NoModuleException,
                                                       AppExceptin {
        Method method = null;
        try {
            method =
                    ObjectPropertyUtil.findMethod(obj.getClass(), methodName, args);
            return method.invoke(obj, args);
        } catch (NoSuchMethodException e) {
            log.error(e);
            throw new NoModuleException(e);
        } catch (IllegalAccessException e) {
            log.error(e);
            throw new AppExceptin(e);
        } catch (InvocationTargetException e) {
            log.error(e);
            throw new AppExceptin(e);
        }
    }
}
TOP

Related Classes of cn.com.byd.utils.InvokeMethodUtil

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.