package com.elink.util;
/*
* <p>Company: 凌科软件 www.elingke.com </p>
* @author liubaojun
* @version 1.0
* Created on 2004-11-29
* 来源于 elinkBSP 部分源代码
*/
import Java.lang.reflect.*;
import java.net.*;
public class ClassUtil
{
/**
@param strClassName
@param argsType
@param args
@return Object
@throws java.lang.NoSUChMethodException
@throws java.lang.SecurityException
@throws java.lang.ClassNotFoundException
@throws java.lang.InstantiationException
@throws java.lang.IllegalAccessException
@throws java.lang.IllegalArgumentException
@throws java.lang.reflect.InvocationTargetException
*/
public static Object loadClass(String strClassName, Class[] argsType,
Object[] args)
throws NoSuchMethodException, SecurityException, ClassNotFoundException,
InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException
{
Object returnObj = null;
Class className = null;
Constructor constructor = null;
className = Class.forName(strClassName);
constructor = className.getConstructor(argsType);
returnObj = constructor.newInstance(args);
return returnObj;
}
/**
@param strClassName
@return Object
@throws java.lang.NoSuchMethodException
@throws java.lang.SecurityException
@throws java.lang.ClassNotFoundException
@throws java.lang.InstantiationException
@throws java.lang.IllegalAccessException
@throws java.lang.IllegalArgumentException
@throws java.lang.reflect.InvocationTargetException
*/
public static Object loadClass(String strClassName)
throws NoSuchMethodException, SecurityException, ClassNotFoundException,
InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException
{
return loadClass(strClassName, null, null);
}
public static Object loadClass(String strClassName, Object defObj)
{
try
{
return loadClass(strClassName, null, null);
}
catch( Throwable ex )
{
LogUtil.logException( ex );
}
return defObj;
}
/**
@param classObject
@param strMethodName