本文整理汇总了Java中org.databene.commons.BeanUtil.forName方法的典型用法代码示例。如果您正苦于以下问题:Java BeanUtil.forName方法的具体用法?Java BeanUtil.forName怎么用?Java BeanUtil.forName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.databene.commons.BeanUtil
的用法示例。
在下文中一共展示了BeanUtil.forName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
@Override
public void configure(Preferences preferences) {
entries = new ArrayList<AutoRetryEntry>();
for (String nodeName : preferences.getChildNodeNames()) {
if (nodeName.matches("retry[0-9]+")) {
AutoRetryEntry entry = new AutoRetryEntry();
ValidatingPreferencesWrapper values = new ValidatingPreferencesWrapper(preferences.getChildNode(nodeName));
entry.maxCount = values.getRequiredIntValue("maxCount");
entry.methodName = values.getRequiredStringValue("method");
entry.exceptionClass = BeanUtil.forName(values.getRequiredStringValue("exception"));
entry.interfaceClass = BeanUtil.forName(values.getRequiredStringValue("interface"));
entries.add(entry);
}
}
}
示例2: connect
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
public static Connection connect(String url, String driverClassName, String user, String password, boolean readOnly) throws ConnectFailedException {
try {
if (driverClassName == null)
throw new ConfigurationError("No JDBC driver class name provided");
// Instantiate driver
Class<Driver> driverClass = BeanUtil.forName(driverClassName);
Driver driver = driverClass.newInstance();
// Wrap connection properties
java.util.Properties info = new java.util.Properties();
if (user != null)
info.put("user", user);
if (password != null)
info.put("password", password);
// connect
JDBC_LOGGER.debug("opening connection to " + url);
Connection connection = driver.connect(url, info);
if (connection == null)
throw new ConnectFailedException("Connecting the database failed silently - " +
"probably due to wrong driver (" + driverClassName + ") or wrong URL format (" + url + ")");
connection = wrapWithPooledConnection(connection, readOnly);
return connection;
} catch (Exception e) {
throw new ConnectFailedException("Connecting " + url + " failed: ", e);
}
}
示例3: classForPotentialResourceName
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
public static Class<?> classForPotentialResourceName(String classOrResourceName) {
String resourceName = classOrResourceName.trim();
String className;
if (resourceName.endsWith(".java")) {
className = deriveClassName(resourceName, "java");
className = className.substring(0, className.length() - ".java".length());
}
else {
className = resourceName;
}
return BeanUtil.forName(className);
}
示例4: getTestClass
import org.databene.commons.BeanUtil; //导入方法依赖的package包/类
private static Class<?> getTestClass(String[] args) {
String className = args[0].trim();
if (className.endsWith(".java")) {
className = className.substring(0, className.length() - ".java".length());
}
return BeanUtil.forName(className);
}