本文整理匯總了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);
}
}