当前位置: 首页>>代码示例>>Java>>正文


Java MethodUtils.invokeStaticMethod方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:ligoj,项目名称:plugin-prov,代码行数:19,代码来源:TerraformUtilsTest.java

示例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);
	}
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:10,代码来源:JdbcProtobufTemplate.java

示例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;
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:21,代码来源:JdbcProtobufTemplate.java

示例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;
}
 
开发者ID:alibaba,项目名称:jvm-sandbox,代码行数:13,代码来源:ControlModule.java

示例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);
    }
}
 
开发者ID:alfio-event,项目名称:alf.io,代码行数:10,代码来源:SpringBootLauncher.java


注:本文中的org.apache.commons.lang3.reflect.MethodUtils.invokeStaticMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。