Java Class 映射及实用工具类完整源代码

王朝java/jsp·作者佚名  2008-05-31
宽屏版  字体: |||超大  

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有