本文整理汇总了Java中org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod方法的典型用法代码示例。如果您正苦于以下问题:Java MethodUtils.invokeStaticMethod方法的具体用法?Java MethodUtils.invokeStaticMethod怎么用?Java MethodUtils.invokeStaticMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.reflect.MethodUtils
的用法示例。
在下文中一共展示了MethodUtils.invokeStaticMethod方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkCommands
import org.apache.commons.lang3.reflect.MethodUtils; //导入方法依赖的package包/类
private void checkCommands(final String os, final String... command) throws ReflectiveOperationException {
final URL[] urLs = ((URLClassLoader) Main.class.getClassLoader()).getURLs();
ThreadClassLoaderScope scope = null;
try {
System.setProperty("os.name", os);
final URLClassLoader urlClassLoader = new URLClassLoader(urLs, null);
scope = new ThreadClassLoaderScope(urlClassLoader);
final Object terra = urlClassLoader.loadClass("org.ligoj.app.plugin.prov.terraform.TerraformUtils").newInstance();
final Object mock = MethodUtils.invokeStaticMethod(urlClassLoader.loadClass("org.mockito.Mockito"), "mock",
urlClassLoader.loadClass("org.ligoj.bootstrap.resource.system.configuration.ConfigurationResource"));
FieldUtils.writeField(terra, "configuration", mock, true);
Assert.assertEquals(Arrays.asList(command),
((ProcessBuilder) MethodUtils.invokeMethod(terra, true, "newBuilder", new Object[] { new String[] { "terraform" } }))
.command());
} finally {
IOUtils.closeQuietly(scope);
}
}
示例2: getDescriptor
import org.apache.commons.lang3.reflect.MethodUtils; //导入方法依赖的package包/类
private Descriptors.Descriptor getDescriptor(Class<M> messageClass) {
try {
return (Descriptors.Descriptor) MethodUtils.invokeStaticMethod(
messageClass, "getDescriptor");
} catch (NoSuchMethodException | IllegalAccessException
| InvocationTargetException ex) {
throw new RuntimeException(ex);
}
}
示例3: newBuilder
import org.apache.commons.lang3.reflect.MethodUtils; //导入方法依赖的package包/类
/**
* get Builder from messageClass
*
* @param messageClass
* @return
* @throws InvocationTargetException
* @throws IllegalAccessException
* @throws NoSuchMethodException
*/
public static <T extends Message> T.Builder newBuilder(Class<T> messageClass) {
T.Builder builder = null;
try {
builder = (T.Builder) MethodUtils.invokeStaticMethod(messageClass,
"newBuilder");
} catch (NoSuchMethodException | IllegalAccessException
| InvocationTargetException e) {
throw new RuntimeException(e);
}
return builder;
}
示例4: cleanSandboxClassLoader
import org.apache.commons.lang3.reflect.MethodUtils; //导入方法依赖的package包/类
private ClassLoader cleanSandboxClassLoader(final Class<?> classOfAgentLauncher)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
// 清理AgentLauncher.sandboxClassLoaderMap
final ClassLoader sandboxClassLoader = (ClassLoader) MethodUtils.invokeStaticMethod(
classOfAgentLauncher,
"cleanClassLoader",
configInfo.getNamespace()
);
logger.info("clean jvm-sandbox ClassLoader[namespace={}] success, for jvm-sandbox shutdown.",
configInfo.getNamespace());
return sandboxClassLoader;
}
示例5: launchHsqlGUI
import org.apache.commons.lang3.reflect.MethodUtils; //导入方法依赖的package包/类
private static void launchHsqlGUI() {
Class<?> cls;
try {
cls = ClassUtils.getClass("org.hsqldb.util.DatabaseManagerSwing");
MethodUtils.invokeStaticMethod(cls, "main", new Object[]{new String[]{"--url", "jdbc:hsqldb:mem:alfio", "--noexit"}});
} catch (ReflectiveOperationException e) {
log.warn("error starting db manager", e);
}
}