本文整理汇总了C#中biz.ritter.javapi.loadClass方法的典型用法代码示例。如果您正苦于以下问题:C# biz.ritter.javapi.loadClass方法的具体用法?C# biz.ritter.javapi.loadClass怎么用?C# biz.ritter.javapi.loadClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类biz.ritter.javapi
的用法示例。
在下文中一共展示了biz.ritter.javapi.loadClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: newInstance
//throws ClassNotFoundException, IllegalAccessException,
// InstantiationException
/**
* Creates a new instance of the specified class name
*
* Package private so this code is not exposed at the API level.
*/
internal static Object newInstance(java.lang.ClassLoader classLoader, String className)
{
java.lang.Class driverClass;
if (classLoader == null) {
driverClass = java.lang.Class.forName(className);
} else {
driverClass = classLoader.loadClass(className);
}
return driverClass.newInstance();
}
示例2: newInstance
//throws ConfigurationError
/**
* Create an instance of a class using the specified ClassLoader and
* optionally fall back to the current ClassLoader if not found.
*
* @param className Name of the concrete class corresponding to the
* service provider
*
* @param cl ClassLoader to use to load the class, null means to use
* the bootstrap ClassLoader
*
* @param doFallback true if the current ClassLoader should be tried as
* a fallback if the class is not found using cl
*/
internal static Object newInstance(String className, java.lang.ClassLoader cl,
bool doFallback)
{
// assert(className != null);
try {
java.lang.Class providerClass;
if (cl == null) {
// If classloader is null Use the bootstrap ClassLoader.
// Thus Class.forName(String) will use the current
// ClassLoader which will be the bootstrap ClassLoader.
providerClass = java.lang.Class.forName (className);
} else {
try {
providerClass = cl.loadClass (className);
} catch (java.lang.ClassNotFoundException x) {
if (doFallback) {
// Fall back to current classloader
cl = typeof(FactoryFinder).getClass ().getClassLoader ();
if (cl != null) {
providerClass = cl.loadClass (className);
} else {
providerClass = java.lang.Class.forName (className);
}
} else {
throw x;
}
}
}
Object instance = providerClass.newInstance ();
if (debug)
dPrint ("created new instance of " + providerClass +
" using ClassLoader: " + cl);
return instance;
} catch (java.lang.ClassNotFoundException x) {
throw new ConfigurationError (
"Provider " + className + " not found", x);
} catch (java.lang.Exception x) {
throw new ConfigurationError (
"Provider " + className + " could not be instantiated: " + x,
x);
}
}